// Copyright 2015 Brendan Zabarauskas and the gl-rs developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
use registry::{Cmd, Enum, Registry}; use std::io; use Api;
/// This function generates a `const name: type = value;` item. pubfn gen_enum_item<W>(enm: &Enum, types_prefix: &str, dest: &style='color:red'>mut W) -> io::Result<()> where
W: io::Write,
{
writeln!(dest, "#[allow(dead_code, non_upper_case_globals)] pub const {ident}: {types_prefix}{ty} = {value}{cast_suffix};",
ident = enm.ident,
types_prefix = if enm.ty == "&'static str" { "" } else { types_prefix },
ty = enm.ty,
value = enm.value,
cast_suffix = match enm.cast { true => format!(" as {}{}", types_prefix, enm.ty), false => String::new(),
},
)
}
/// Generates all the type aliases for a namespace. /// /// Aliases are either `pub type = ...` or `#[repr(C)] pub struct ... { ... }` and contain all the /// things that we can't obtain from the XML files. pubfn gen_types<W>(api: Api, dest: &mut W) -> io::Result<()> where
W: io::Write,
{ iflet Api::Egl = api { try!(writeln!(dest, "{}", include_str!("templates/types/egl.rs"))); return Ok(());
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.