Bug 1371382 - Update gl_generator to 0.5.3. r=jrmuizel

This also pulls in khronos_api v1.0.1

MozReview-Commit-ID: Gw4GtvD3pOx

--HG--
extra : rebase_source : 95601450e5cf125001e69fdbc104e488e88e926e
This commit is contained in:
Kartikaya Gupta 2017-06-08 17:06:05 -04:00
parent 1be06aea28
commit c1a601a0f4
24 changed files with 826 additions and 531 deletions

View File

@ -1 +1 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"45aea41e3c3f3bf616649f9f826bfe25b3910c6f39906a9fe8803c62dc8e4c8f","README.md":"d1c8edfeedee664271d3b462513477aa098359ede91d24179451705ec99db7b6","generators/debug_struct_gen.rs":"2fdbee9077f560479e06269564bd7d7550600b2687a66273abc08d96afd41cf1","generators/global_gen.rs":"1bcddeb9e2a7cd32ce0fd0b8eb5435c78246165975b2a3ebd799c8f4f7095c58","generators/mod.rs":"62e090f77e146cb4b0f4bb898c4b4754f6733b3fa6f51b73e349cb1b66fbeb31","generators/static_gen.rs":"5758fb47c6f33d24f38248f2b504ce7174414b01b9f25f8c22503f5e9493e549","generators/static_struct_gen.rs":"7c8d6bc8916276b43c5bc84da313a317bf277f13c502e11763587a30add3591b","generators/struct_gen.rs":"2795f531122f794070cdf0bf0d11baf0472d2afd611656bbc44563ac513ec67a","generators/templates/types/egl.rs":"10d4a1b0444960e00bdb37de5eed54588119233177faed86662efe20407df660","generators/templates/types/gl.rs":"eefc1aef9ed4751b4ffa8cbf498347555bc8d4f2650c50e78c2864dad5eb64fc","generators/templates/types/glx.rs":"5bdd0b621d1aac0c8dda8ffa95ce9c7a7614146ff129f18b3a36cf51c3985a61","generators/templates/types/wgl.rs":"f4d21c7c793df4a8256f7f496d2940987bf38a1c3acab06b57dfad2e29d4f713","lib.rs":"4d68840c600a1025025438454d68d70e6da3891f2a5bb33406d4255cb257cda1","registry/mod.rs":"8b901725292a2c4dbb2c882a83b2c05ffd1148af36c7cb9c2c0339e1bb661d7c","registry/parse.rs":"362ce237b7b6e9a71649e597e585281fda7e26e2c0d3694af357438129c7d7ef"},"package":"f1d8edc81c5ae84605a62f5dac661a2313003b26d59839f81d47d46cf0f16a55"}
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"313b48b1cf4f84dafffe0ccfb10e8d98eada41a4b21bc239a25eb90acb57c82c","Cargo.toml.orig":"97cdad3767af6963180d989f333c14b0c2efa0f4715c1a4ecafc415bfc560edb","README.md":"e0ae9e1224f6ce5d6df8e30272a1a23044d2d33b0051bf32ccd74e559f8a9f6c","generators/debug_struct_gen.rs":"8bd1187f346aa927a30781bdf24ca6cb86324b42109bf52a018aae9ae947a46c","generators/global_gen.rs":"2aed997706c797a3b3e60adc91ecad67056ee824fad29e27349f6d37293b5a1e","generators/mod.rs":"58fab4bbfac335de7bd61a01063bea0547d311fec1aaee6946871902adc14072","generators/static_gen.rs":"9fb4ee9f056263611658234539977fb415f93435d290053b84b092e05de16924","generators/static_struct_gen.rs":"23b910c2b14936766036876b9915639058e0cf3bca468c317d4edc7f6498b471","generators/struct_gen.rs":"87d37c9f6f8b457f3de3578b15d552d36843ed62837a0b33cd674103185f43e0","generators/templates/types/egl.rs":"881506faddd220f5ccbd7fc21d74860233f2204ed3dee31d891ae273b1643a74","generators/templates/types/gl.rs":"f71f3a2200c0fa13f09687ef05e51c28c5b11c1bb841acd402c0097d8f9130bd","generators/templates/types/glx.rs":"a2d6a91fc1bf46fab6868b9a01f36fc47e9a9837bc9ed79eba4d08f31117d063","generators/templates/types/wgl.rs":"2270dcf994250a5905b7246ccdbf3770c494cac0642a720ccbb91ac1886490e2","lib.rs":"4d68840c600a1025025438454d68d70e6da3891f2a5bb33406d4255cb257cda1","registry/mod.rs":"7834029699b1bcfa9d395bf03b4b328f38a7d69e4a4c3d3e01e626919b00ed63","registry/parse.rs":"4498677f167fcd6fa5fd34241ae86a6a17b98fe8566fa48f38b3860a7f941f9b"},"package":"0940975a4ca12b088d32b5d5134826c47d2e73de4b0b459b05244c01503eccbb"}

View File

@ -1,26 +1,36 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g. crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
name = "gl_generator"
version = "0.5.2"
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>",
"Corey Richardson",
"Arseny Kapoulkine"
]
version = "0.5.3"
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>", "Corey Richardson", "Arseny Kapoulkine"]
description = "Code generators for creating bindings to the Khronos OpenGL APIs."
license = "Apache-2.0"
homepage = "https://github.com/bjz/gl-rs/gl_generator/"
repository = "https://github.com/bjz/gl-rs/"
homepage = "https://github.com/brendanzab/gl-rs/gl_generator/"
documentation = "https://docs.rs/gl_generator"
readme = "README.md"
license = "Apache-2.0"
repository = "https://github.com/brendanzab/gl-rs/"
[lib]
name = "gl_generator"
path = "lib.rs"
[features]
unstable_generator_utils = []
[dependencies]
khronos_api = { version = "1.0.0", path = "../khronos_api" }
log = "0.3.5"
xml-rs = "0.3.0"
[dependencies.khronos_api]
version = "1.0.1"
[features]
unstable_generator_utils = []

View File

@ -0,0 +1,25 @@
[package]
name = "gl_generator"
version = "0.5.3"
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>",
"Corey Richardson",
"Arseny Kapoulkine"
]
description = "Code generators for creating bindings to the Khronos OpenGL APIs."
license = "Apache-2.0"
documentation = "https://docs.rs/gl_generator"
homepage = "https://github.com/brendanzab/gl-rs/gl_generator/"
repository = "https://github.com/brendanzab/gl-rs/"
readme = "README.md"
[lib]
name = "gl_generator"
path = "lib.rs"
[features]
unstable_generator_utils = []
[dependencies]
khronos_api = { version = "1.0.1", path = "../khronos_api" }
log = "0.3.5"
xml-rs = "0.3.0"

View File

@ -1,7 +1,7 @@
# gl_generator
[![Version](https://img.shields.io/crates/v/gl_generator.svg)](https://crates.io/crates/gl_generator)
[![License](https://img.shields.io/crates/l/gl_generator.svg)](https://github.com/bjz/gl-rs/blob/master/LICENSE)
[![License](https://img.shields.io/crates/l/gl_generator.svg)](https://github.com/brendanzab/gl-rs/blob/master/LICENSE)
[![Downloads](https://img.shields.io/crates/d/gl_generator.svg)](https://crates.io/crates/gl_generator)
Code generators for creating bindings to the Khronos OpenGL APIs.

View File

@ -19,7 +19,9 @@ use std::io;
pub struct DebugStructGenerator;
impl super::Generator for DebugStructGenerator {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(write_header(dest));
try!(write_type_aliases(registry, dest));
try!(write_enums(registry, dest));
@ -33,8 +35,11 @@ impl super::Generator for DebugStructGenerator {
/// Creates a `__gl_imports` module which contains all the external symbols that we need for the
/// bindings.
fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest, r#"
fn write_header<W>(dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
r#"
mod __gl_imports {{
pub use std::mem;
pub use std::marker::Send;
@ -46,8 +51,11 @@ fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
/// Creates a `types` module which contains all the type aliases.
///
/// See also `generators::gen_types`.
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, r#"
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
r#"
pub mod types {{
#![allow(non_camel_case_types, non_snake_case, dead_code, missing_copy_implementations)]
"#));
@ -58,7 +66,9 @@ fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()> wh
}
/// Creates all the `<enum>` elements at the root of the bindings.
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
for enm in &registry.enums {
try!(super::gen_enum_item(enm, "types::", dest));
}
@ -67,8 +77,11 @@ fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W:
}
/// Creates a `FnPtr` structure which contains the store for a single binding.
fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest, "
fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
"
#[allow(dead_code, missing_copy_implementations)]
#[derive(Clone)]
pub struct FnPtr {{
@ -106,26 +119,29 @@ fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()> where W: io::Write
/// Creates a `panicking` module which contains one function per GL command.
///
/// These functions are the mocks that are called if the real function could not be loaded.
fn write_panicking_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_panicking_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
"#[inline(never)]
"#[inline(never)]
fn missing_fn_panic() -> ! {{
panic!(\"{api} function was not loaded\")
}}",
api = registry.api
)
api = registry.api)
}
/// Creates a structure which stores all the `FnPtr` of the bindings.
///
/// The name of the struct corresponds to the namespace.
fn write_struct<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, "
fn write_struct<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
"
#[allow(non_camel_case_types, non_snake_case, dead_code)]
#[derive(Clone)]
pub struct {api} {{",
api = super::gen_struct_name(registry.api)
));
api = super::gen_struct_name(registry.api)));
for cmd in &registry.cmds {
if let Some(v) = registry.aliases.get(&cmd.proto.ident) {
@ -138,9 +154,11 @@ fn write_struct<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W:
}
/// Creates the `impl` of the structure created by `write_struct`.
fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
"impl {api} {{
"impl {api} {{
/// Load each OpenGL symbol using a custom load function. This allows for the
/// use of functions like `glfwGetProcAddress` or `SDL_GL_GetProcAddress`.
///
@ -167,8 +185,7 @@ fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: i
do_metaloadfn(&mut loadfn, symbol, symbols)
}};
{api} {{",
api = super::gen_struct_name(registry.api)
));
api = super::gen_struct_name(registry.api)));
for cmd in &registry.cmds {
try!(writeln!(dest,
@ -187,27 +204,31 @@ fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: i
}
try!(writeln!(dest,
"}}
}}"
));
"}}
}}"));
for cmd in &registry.cmds {
let idents = super::gen_parameters(cmd, true, false);
let typed_params = super::gen_parameters(cmd, false, true);
let println = format!("println!(\"[OpenGL] {}({})\" {});",
cmd.proto.ident,
(0 .. idents.len()).map(|_| "{:?}".to_string()).collect::<Vec<_>>().join(", "),
idents.iter().zip(typed_params.iter())
.map(|(name, ty)| {
if ty.contains("GLDEBUGPROC") {
format!(", \"<callback>\"")
} else {
format!(", {}", name)
}
}).collect::<Vec<_>>().concat());
cmd.proto.ident,
(0..idents.len())
.map(|_| "{:?}".to_string())
.collect::<Vec<_>>()
.join(", "),
idents
.iter()
.zip(typed_params.iter())
.map(|(name, ty)| if ty.contains("GLDEBUGPROC") {
format!(", \"<callback>\"")
} else {
format!(", {}", name)
})
.collect::<Vec<_>>()
.concat());
try!(writeln!(dest,
"#[allow(non_snake_case, unused_variables, dead_code)]
"#[allow(non_snake_case, unused_variables, dead_code)]
#[inline] pub unsafe fn {name}(&self, {params}) -> {return_suffix} {{ \
{println}
let r = __gl_imports::mem::transmute::<_, extern \"system\" fn({typed_params}) -> {return_suffix}>\
@ -215,25 +236,28 @@ fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: i
{print_err}
r
}}",
name = cmd.proto.ident,
params = super::gen_parameters(cmd, true, true).join(", "),
typed_params = typed_params.join(", "),
return_suffix = cmd.proto.ty,
idents = idents.join(", "),
println = println,
print_err = if cmd.proto.ident != "GetError" && registry.cmds.iter().find(|cmd| cmd.proto.ident == "GetError").is_some() {
format!(r#"match __gl_imports::mem::transmute::<_, extern "system" fn() -> u32>
name = cmd.proto.ident,
params = super::gen_parameters(cmd, true, true).join(", "),
typed_params = typed_params.join(", "),
return_suffix = cmd.proto.ty,
idents = idents.join(", "),
println = println,
print_err = if cmd.proto.ident != "GetError" &&
registry
.cmds
.iter()
.find(|cmd| cmd.proto.ident == "GetError")
.is_some() {
format!(r#"match __gl_imports::mem::transmute::<_, extern "system" fn() -> u32>
(self.GetError.f)() {{ 0 => (), r => println!("[OpenGL] ^ GL error triggered: {{}}", r) }}"#)
} else {
format!("")
}
))
} else {
format!("")
}))
}
writeln!(dest,
"}}
"}}
unsafe impl __gl_imports::Send for {api} {{}}",
api = super::gen_struct_name(registry.api)
)
api = super::gen_struct_name(registry.api))
}

View File

@ -19,7 +19,9 @@ use std::io;
pub struct GlobalGenerator;
impl super::Generator for GlobalGenerator {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(write_header(dest));
try!(write_metaloadfn(dest));
try!(write_type_aliases(registry, dest));
@ -36,8 +38,11 @@ impl super::Generator for GlobalGenerator {
/// Creates a `__gl_imports` module which contains all the external symbols that we need for the
/// bindings.
fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest, r#"
fn write_header<W>(dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
r#"
mod __gl_imports {{
pub use std::mem;
pub use std::os::raw;
@ -46,8 +51,11 @@ fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
}
/// Creates the metaloadfn function for fallbacks
fn write_metaloadfn<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest, r#"
fn write_metaloadfn<W>(dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
r#"
#[inline(never)]
fn metaloadfn(mut loadfn: &mut FnMut(&str) -> *const __gl_imports::raw::c_void,
symbol: &str,
@ -67,21 +75,27 @@ fn write_metaloadfn<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
/// Creates a `types` module which contains all the type aliases.
///
/// See also `generators::gen_types`.
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, r#"
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
r#"
pub mod types {{
#![allow(non_camel_case_types, non_snake_case, dead_code, missing_copy_implementations)]
"#));
try!(super::gen_types(registry.api, dest));
writeln!(dest, "
writeln!(dest,
"
}}
")
}
/// Creates all the `<enum>` elements at the root of the bindings.
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
for enm in &registry.enums {
try!(super::gen_enum_item(enm, "types::", dest));
}
@ -93,7 +107,9 @@ fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W:
///
/// The function calls the corresponding function pointer stored in the `storage` module created
/// by `write_ptrs`.
fn write_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
for cmd in &registry.cmds {
if let Some(v) = registry.aliases.get(&cmd.proto.ident) {
try!(writeln!(dest, "/// Fallbacks: {}", v.join(", ")));
@ -117,8 +133,11 @@ fn write_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io
}
/// Creates a `FnPtr` structure which contains the store for a single binding.
fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest, "
fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
"
#[allow(missing_copy_implementations)]
pub struct FnPtr {{
/// The function pointer that will be used when calling the function.
@ -141,22 +160,24 @@ fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()> where W: io::Write
}
/// Creates a `storage` module which contains a static `FnPtr` per GL command in the registry.
fn write_ptrs<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_ptrs<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
"mod storage {{
"mod storage {{
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
use super::__gl_imports::raw;
use super::FnPtr;"));
for c in &registry.cmds {
try!(writeln!(dest,
"pub static mut {name}: FnPtr = FnPtr {{
"pub static mut {name}: FnPtr = FnPtr {{
f: super::missing_fn_panic as *const raw::c_void,
is_loaded: false
}};",
name = c.proto.ident
));
name = c.proto.ident));
}
writeln!(dest, "}}")
@ -166,13 +187,18 @@ fn write_ptrs<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: i
///
/// Each module contains `is_loaded` and `load_with` which interact with the `storage` module
/// created by `write_ptrs`.
fn write_fn_mods<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_fn_mods<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
for c in &registry.cmds {
let fallbacks = match registry.aliases.get(&c.proto.ident) {
Some(v) => {
let names = v.iter().map(|name| format!("\"{}\"", super::gen_symbol_name(registry.api, &name[..]))).collect::<Vec<_>>();
let names = v.iter()
.map(|name| format!("\"{}\"", super::gen_symbol_name(registry.api, &name[..])))
.collect::<Vec<_>>();
format!("&[{}]", names.join(", "))
}, None => "&[]".to_string(),
}
None => "&[]".to_string(),
};
let fnname = &c.proto.ident[..];
let symbol = super::gen_symbol_name(registry.api, &c.proto.ident[..]);
@ -207,20 +233,26 @@ fn write_fn_mods<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W
/// Creates a `missing_fn_panic` function.
///
/// This function is the mock that is called if the real function could not be called.
fn write_panicking_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_panicking_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
"#[inline(never)]
"#[inline(never)]
fn missing_fn_panic() -> ! {{
panic!(\"{api} function was not loaded\")
}}
", api = registry.api)
",
api = registry.api)
}
/// Creates the `load_with` function.
///
/// The function calls `load_with` in each module created by `write_fn_mods`.
fn write_load_fn<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, "
fn write_load_fn<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
"
/// Load each OpenGL symbol using a custom load function. This allows for the
/// use of functions like `glfwGetProcAddress` or `SDL_GL_GetProcAddress`.
/// ~~~ignore
@ -231,11 +263,13 @@ fn write_load_fn<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W
"));
for c in &registry.cmds {
try!(writeln!(dest, "{cmd_name}::load_with(|s| loadfn(s));",
try!(writeln!(dest,
"{cmd_name}::load_with(|s| loadfn(s));",
cmd_name = &c.proto.ident[..]));
}
writeln!(dest, "
writeln!(dest,
"
}}
")
}

View File

@ -30,7 +30,7 @@ pub trait Generator {
pub fn gen_struct_name(api: Api) -> &'static str {
match api {
Api::Gl => "Gl",
Api::Gl => "Gl",
Api::Glx => "Glx",
Api::Wgl => "Wgl",
Api::Egl => "Egl",
@ -41,7 +41,9 @@ pub fn gen_struct_name(api: Api) -> &'static str {
}
/// This function generates a `const name: type = value;` item.
pub fn gen_enum_item<W>(enm: &Enum, types_prefix: &str, dest: &mut W) -> io::Result<()> where W: io::Write {
pub fn gen_enum_item<W>(enm: &Enum, types_prefix: &str, dest: &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,
@ -59,14 +61,16 @@ pub fn gen_enum_item<W>(enm: &Enum, types_prefix: &str, dest: &mut W) -> io::Res
///
/// Aliases are either `pub type = ...` or `#[repr(C)] pub struct ... { ... }` and contain all the
/// things that we can't obtain from the XML files.
pub fn gen_types<W>(api: Api, dest: &mut W) -> io::Result<()> where W: io::Write {
pub fn gen_types<W>(api: Api, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest, "{}", include_str!("templates/types/gl.rs")));
match api {
Api::Glx => try!(writeln!(dest, "{}", include_str!("templates/types/glx.rs"))),
Api::Wgl => try!(writeln!(dest, "{}", include_str!("templates/types/wgl.rs"))),
Api::Egl => try!(writeln!(dest, "{}", include_str!("templates/types/egl.rs"))),
_ => {},
_ => {}
}
Ok(())
@ -74,7 +78,8 @@ pub fn gen_types<W>(api: Api, dest: &mut W) -> io::Result<()> where W: io::Write
/// Generates the list of Rust `Arg`s that a `Cmd` requires.
pub fn gen_parameters(cmd: &Cmd, with_idents: bool, with_types: bool) -> Vec<String> {
cmd.params.iter()
cmd.params
.iter()
.map(|binding| {
// returning
if with_idents && with_types {

View File

@ -19,7 +19,9 @@ use std::io;
pub struct StaticGenerator;
impl super::Generator for StaticGenerator {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(write_header(dest));
try!(write_type_aliases(registry, dest));
try!(write_enums(registry, dest));
@ -30,8 +32,11 @@ impl super::Generator for StaticGenerator {
/// Creates a `__gl_imports` module which contains all the external symbols that we need for the
/// bindings.
fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest, r#"
fn write_header<W>(dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
r#"
mod __gl_imports {{
pub use std::mem;
pub use std::os::raw;
@ -42,21 +47,27 @@ fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
/// Creates a `types` module which contains all the type aliases.
///
/// See also `generators::gen_types`.
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, r#"
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
r#"
pub mod types {{
#![allow(non_camel_case_types, non_snake_case, dead_code, missing_copy_implementations)]
"#));
try!(super::gen_types(registry.api, dest));
writeln!(dest, "
writeln!(dest,
"
}}
")
}
/// Creates all the `<enum>` elements at the root of the bindings.
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
for enm in &registry.enums {
try!(super::gen_enum_item(enm, "types::", dest));
}
@ -67,8 +78,11 @@ fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W:
/// io::Writes all functions corresponding to the GL bindings.
///
/// These are foreign functions, they don't have any content.
fn write_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, "
fn write_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
"
#[allow(non_snake_case, unused_variables, dead_code)]
extern \"system\" {{"));

View File

@ -19,7 +19,9 @@ use std::io;
pub struct StaticStructGenerator;
impl super::Generator for StaticStructGenerator {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(write_header(dest));
try!(write_type_aliases(registry, dest));
try!(write_enums(registry, dest));
@ -32,8 +34,11 @@ impl super::Generator for StaticStructGenerator {
/// Creates a `__gl_imports` module which contains all the external symbols that we need for the
/// bindings.
fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest, r#"
fn write_header<W>(dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
r#"
mod __gl_imports {{
pub use std::mem;
pub use std::os::raw;
@ -44,8 +49,11 @@ fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
/// Creates a `types` module which contains all the type aliases.
///
/// See also `generators::gen_types`.
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, r#"
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
r#"
pub mod types {{
#![allow(non_camel_case_types, non_snake_case, dead_code, missing_copy_implementations)]
"#));
@ -56,7 +64,9 @@ fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()> wh
}
/// Creates all the `<enum>` elements at the root of the bindings.
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
for enm in &registry.enums {
try!(super::gen_enum_item(enm, "types::", dest));
}
@ -67,7 +77,9 @@ fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W:
/// Creates a stub structure.
///
/// The name of the struct corresponds to the namespace.
fn write_struct<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_struct<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest, "
#[allow(non_camel_case_types, non_snake_case, dead_code)]
#[derive(Copy, Clone)]
@ -77,7 +89,9 @@ fn write_struct<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W:
}
/// Creates the `impl` of the structure created by `write_struct`.
fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
"impl {api} {{
/// Stub function.
@ -110,9 +124,12 @@ fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: i
/// io::Writes all functions corresponding to the GL bindings.
///
/// These are foreign functions, they don't have any content.
fn write_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest, "
try!(writeln!(dest,
"
#[allow(non_snake_case)]
#[allow(unused_variables)]
#[allow(dead_code)]

View File

@ -19,7 +19,9 @@ use std::io;
pub struct StructGenerator;
impl super::Generator for StructGenerator {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write<W>(&self, registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(write_header(dest));
try!(write_type_aliases(registry, dest));
try!(write_enums(registry, dest));
@ -33,8 +35,11 @@ impl super::Generator for StructGenerator {
/// Creates a `__gl_imports` module which contains all the external symbols that we need for the
/// bindings.
fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest, r#"
fn write_header<W>(dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
r#"
mod __gl_imports {{
pub use std::mem;
pub use std::marker::Send;
@ -46,8 +51,11 @@ fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
/// Creates a `types` module which contains all the type aliases.
///
/// See also `generators::gen_types`.
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, r#"
fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
r#"
pub mod types {{
#![allow(non_camel_case_types, non_snake_case, dead_code, missing_copy_implementations)]
"#));
@ -58,7 +66,9 @@ fn write_type_aliases<W>(registry: &Registry, dest: &mut W) -> io::Result<()> wh
}
/// Creates all the `<enum>` elements at the root of the bindings.
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
for enm in &registry.enums {
try!(super::gen_enum_item(enm, "types::", dest));
}
@ -67,8 +77,11 @@ fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W:
}
/// Creates a `FnPtr` structure which contains the store for a single binding.
fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest, "
fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
"
#[allow(dead_code, missing_copy_implementations)]
#[derive(Clone)]
pub struct FnPtr {{
@ -106,26 +119,29 @@ fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()> where W: io::Write
/// Creates a `panicking` module which contains one function per GL command.
///
/// These functions are the mocks that are called if the real function could not be loaded.
fn write_panicking_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_panicking_fns<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
writeln!(dest,
"#[inline(never)]
"#[inline(never)]
fn missing_fn_panic() -> ! {{
panic!(\"{api} function was not loaded\")
}}",
api = registry.api
)
api = registry.api)
}
/// Creates a structure which stores all the `FnPtr` of the bindings.
///
/// The name of the struct corresponds to the namespace.
fn write_struct<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, "
fn write_struct<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
"
#[allow(non_camel_case_types, non_snake_case, dead_code)]
#[derive(Clone)]
pub struct {api} {{",
api = super::gen_struct_name(registry.api)
));
api = super::gen_struct_name(registry.api)));
for cmd in &registry.cmds {
if let Some(v) = registry.aliases.get(&cmd.proto.ident) {
@ -138,9 +154,11 @@ fn write_struct<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W:
}
/// Creates the `impl` of the structure created by `write_struct`.
fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write {
fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where W: io::Write
{
try!(writeln!(dest,
"impl {api} {{
"impl {api} {{
/// Load each OpenGL symbol using a custom load function. This allows for the
/// use of functions like `glfwGetProcAddress` or `SDL_GL_GetProcAddress`.
///
@ -167,8 +185,7 @@ fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: i
do_metaloadfn(&mut loadfn, symbol, symbols)
}};
{api} {{",
api = super::gen_struct_name(registry.api)
));
api = super::gen_struct_name(registry.api)));
for cmd in &registry.cmds {
try!(writeln!(dest,
@ -187,9 +204,8 @@ fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: i
}
try!(writeln!(dest,
"}}
}}"
));
"}}
}}"));
for cmd in &registry.cmds {
try!(writeln!(dest,
@ -207,9 +223,8 @@ fn write_impl<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: i
}
writeln!(dest,
"}}
"}}
unsafe impl __gl_imports::Send for {api} {{}}",
api = super::gen_struct_name(registry.api)
)
api = super::gen_struct_name(registry.api))
}

View File

@ -1,19 +1,27 @@
// platform-specific aliases are unknown
// IMPORTANT: these are alises to the same level of the bindings
// the values must be defined by the user
#[allow(dead_code)]
pub type khronos_utime_nanoseconds_t = super::khronos_utime_nanoseconds_t;
#[allow(dead_code)]
pub type khronos_uint64_t = super::khronos_uint64_t;
#[allow(dead_code)]
pub type khronos_ssize_t = super::khronos_ssize_t;
pub type EGLNativeDisplayType = super::EGLNativeDisplayType;
#[allow(dead_code)]
pub type EGLNativePixmapType = super::EGLNativePixmapType;
#[allow(dead_code)]
pub type EGLNativeWindowType = super::EGLNativeWindowType;
pub type EGLint = super::EGLint;
#[allow(dead_code)]
pub type NativeDisplayType = super::NativeDisplayType;
#[allow(dead_code)]
pub type NativePixmapType = super::NativePixmapType;
#[allow(dead_code)]
pub type NativeWindowType = super::NativeWindowType;
// EGL alises
pub type Bool = EGLBoolean; // TODO: not sure
pub type Bool = EGLBoolean; // TODO: not sure
pub type EGLBoolean = super::__gl_imports::raw::c_uint;
pub type EGLenum = super::__gl_imports::raw::c_uint;
pub type EGLAttribKHR = isize;
@ -40,8 +48,16 @@ pub type EGLStreamKHR = *const super::__gl_imports::raw::c_void;
pub type EGLuint64KHR = khronos_uint64_t;
pub type EGLNativeFileDescriptorKHR = super::__gl_imports::raw::c_int;
pub type EGLsizeiANDROID = khronos_ssize_t;
pub type EGLSetBlobFuncANDROID = extern "system" fn(*const super::__gl_imports::raw::c_void, EGLsizeiANDROID, *const super::__gl_imports::raw::c_void, EGLsizeiANDROID) -> ();
pub type EGLGetBlobFuncANDROID = extern "system" fn(*const super::__gl_imports::raw::c_void, EGLsizeiANDROID, *mut super::__gl_imports::raw::c_void, EGLsizeiANDROID) -> EGLsizeiANDROID;
pub type EGLSetBlobFuncANDROID = extern "system" fn(*const super::__gl_imports::raw::c_void,
EGLsizeiANDROID,
*const super::__gl_imports::raw::c_void,
EGLsizeiANDROID)
-> ();
pub type EGLGetBlobFuncANDROID = extern "system" fn(*const super::__gl_imports::raw::c_void,
EGLsizeiANDROID,
*mut super::__gl_imports::raw::c_void,
EGLsizeiANDROID)
-> EGLsizeiANDROID;
#[repr(C)]
pub struct EGLClientPixmapHI {

View File

@ -19,8 +19,10 @@ pub type GLeglImageOES = *const super::__gl_imports::raw::c_void;
pub type GLchar = super::__gl_imports::raw::c_char;
pub type GLcharARB = super::__gl_imports::raw::c_char;
#[cfg(target_os = "macos")] pub type GLhandleARB = *const super::__gl_imports::raw::c_void;
#[cfg(not(target_os = "macos"))] pub type GLhandleARB = super::__gl_imports::raw::c_uint;
#[cfg(target_os = "macos")]
pub type GLhandleARB = *const super::__gl_imports::raw::c_void;
#[cfg(not(target_os = "macos"))]
pub type GLhandleARB = super::__gl_imports::raw::c_uint;
pub type GLhalfARB = super::__gl_imports::raw::c_ushort;
pub type GLhalf = super::__gl_imports::raw::c_ushort;
@ -40,13 +42,31 @@ pub type GLuint64EXT = u64;
pub enum __GLsync {}
pub type GLsync = *const __GLsync;
// compatible with OpenCL cl_context
// compatible with OpenCL cl_context
pub enum _cl_context {}
pub enum _cl_event {}
pub type GLDEBUGPROC = extern "system" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROCARB = extern "system" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROCKHR = extern "system" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROC = extern "system" fn(source: GLenum,
gltype: GLenum,
id: GLuint,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROCARB = extern "system" fn(source: GLenum,
gltype: GLenum,
id: GLuint,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROCKHR = extern "system" fn(source: GLenum,
gltype: GLenum,
id: GLuint,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void);
// GLES 1 types
// "pub type GLclampx = i32;",
@ -78,6 +98,11 @@ pub type GLDEBUGPROCKHR = extern "system" fn(source: GLenum, gltype: GLenum, id:
// GLES 2 types (none currently)
// Vendor extension types
pub type GLDEBUGPROCAMD = extern "system" fn(id: GLuint, category: GLenum, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROCAMD = extern "system" fn(id: GLuint,
category: GLenum,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void);
pub type GLhalfNV = super::__gl_imports::raw::c_ushort;
pub type GLvdpauSurfaceNV = GLintptr;

View File

@ -39,28 +39,28 @@ pub struct XVisualInfo {
#[repr(C)]
pub struct GLXPbufferClobberEvent {
pub event_type: super::__gl_imports::raw::c_int, // GLX_DAMAGED or GLX_SAVED
pub draw_type: super::__gl_imports::raw::c_int, // GLX_WINDOW or GLX_PBUFFER
pub serial: super::__gl_imports::raw::c_ulong, // # of last request processed by server
pub send_event: Bool, // true if this came for SendEvent request
pub display: *const Display, // display the event was read from
pub drawable: GLXDrawable, // XID of Drawable
pub buffer_mask: super::__gl_imports::raw::c_uint, // mask indicating which buffers are affected
pub aux_buffer: super::__gl_imports::raw::c_uint, // which aux buffer was affected
pub event_type: super::__gl_imports::raw::c_int, // GLX_DAMAGED or GLX_SAVED
pub draw_type: super::__gl_imports::raw::c_int, // GLX_WINDOW or GLX_PBUFFER
pub serial: super::__gl_imports::raw::c_ulong, // # of last request processed by server
pub send_event: Bool, // true if this came for SendEvent request
pub display: *const Display, // display the event was read from
pub drawable: GLXDrawable, // XID of Drawable
pub buffer_mask: super::__gl_imports::raw::c_uint, // mask indicating which buffers are affected
pub aux_buffer: super::__gl_imports::raw::c_uint, // which aux buffer was affected
pub x: super::__gl_imports::raw::c_int,
pub y: super::__gl_imports::raw::c_int,
pub width: super::__gl_imports::raw::c_int,
pub height: super::__gl_imports::raw::c_int,
pub count: super::__gl_imports::raw::c_int, // if nonzero, at least this many more
pub count: super::__gl_imports::raw::c_int, // if nonzero, at least this many more
}
#[repr(C)]
pub struct GLXBufferSwapComplete {
pub type_: super::__gl_imports::raw::c_int,
pub serial: super::__gl_imports::raw::c_ulong, // # of last request processed by server
pub send_event: Bool, // true if this came from a SendEvent request
pub display: *const Display, // Display the event was read from
pub drawable: GLXDrawable, // drawable on which event was requested in event mask
pub serial: super::__gl_imports::raw::c_ulong, // # of last request processed by server
pub send_event: Bool, // true if this came from a SendEvent request
pub display: *const Display, // Display the event was read from
pub drawable: GLXDrawable, // drawable on which event was requested in event mask
pub event_type: super::__gl_imports::raw::c_int,
pub ust: i64,
pub msc: i64,
@ -76,29 +76,29 @@ pub struct GLXBufferSwapComplete {
#[repr(C)]
pub struct GLXBufferClobberEventSGIX {
pub type_: super::__gl_imports::raw::c_int,
pub serial: super::__gl_imports::raw::c_ulong, // # of last request processed by server
pub send_event: Bool, // true if this came for SendEvent request
pub display: *const Display, // display the event was read from
pub drawable: GLXDrawable, // i.d. of Drawable
pub event_type: super::__gl_imports::raw::c_int, // GLX_DAMAGED_SGIX or GLX_SAVED_SGIX
pub draw_type: super::__gl_imports::raw::c_int, // GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX
pub mask: super::__gl_imports::raw::c_uint, // mask indicating which buffers are affected
pub serial: super::__gl_imports::raw::c_ulong, // # of last request processed by server
pub send_event: Bool, // true if this came for SendEvent request
pub display: *const Display, // display the event was read from
pub drawable: GLXDrawable, // i.d. of Drawable
pub event_type: super::__gl_imports::raw::c_int, // GLX_DAMAGED_SGIX or GLX_SAVED_SGIX
pub draw_type: super::__gl_imports::raw::c_int, // GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX
pub mask: super::__gl_imports::raw::c_uint, // mask indicating which buffers are affected
pub x: super::__gl_imports::raw::c_int,
pub y: super::__gl_imports::raw::c_int,
pub width: super::__gl_imports::raw::c_int,
pub height: super::__gl_imports::raw::c_int,
pub count: super::__gl_imports::raw::c_int, // if nonzero, at least this many more
pub count: super::__gl_imports::raw::c_int, // if nonzero, at least this many more
}
#[repr(C)]
pub struct GLXHyperpipeNetworkSGIX {
pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
pub networkId: super::__gl_imports::raw::c_int,
}
#[repr(C)]
pub struct GLXHyperpipeConfigSGIX {
pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
pub channel: super::__gl_imports::raw::c_int,
pub participationType: super::__gl_imports::raw::c_uint,
pub timeSlice: super::__gl_imports::raw::c_int,
@ -106,7 +106,7 @@ pub struct GLXHyperpipeConfigSGIX {
#[repr(C)]
pub struct GLXPipeRect {
pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
pub srcXOrigin: super::__gl_imports::raw::c_int,
pub srcYOrigin: super::__gl_imports::raw::c_int,
pub srcWidth: super::__gl_imports::raw::c_int,
@ -119,7 +119,7 @@ pub struct GLXPipeRect {
#[repr(C)]
pub struct GLXPipeRectLimits {
pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
pub XOrigin: super::__gl_imports::raw::c_int,
pub YOrigin: super::__gl_imports::raw::c_int,
pub maxHeight: super::__gl_imports::raw::c_int,

View File

@ -26,7 +26,7 @@ pub type HGLRC = *const super::__gl_imports::raw::c_void;
pub type INT = super::__gl_imports::raw::c_int;
pub type PVOID = *const super::__gl_imports::raw::c_void;
pub type LPVOID = *const super::__gl_imports::raw::c_void;
pub type PROC = extern "system" fn(); // Not sure about this one :/
pub type PROC = extern "system" fn(); // Not sure about this one :/
#[repr(C)]
pub struct RECT {

View File

@ -15,7 +15,7 @@
extern crate khronos_api;
use std::borrow::Cow;
use std::collections::{BTreeSet, HashMap, HashSet};
use std::collections::{BTreeMap, BTreeSet};
use std::fmt;
use std::hash::{Hash, Hasher};
use std::io;
@ -26,12 +26,20 @@ use Generator;
mod parse;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Api { Gl, Glx, Wgl, Egl, GlCore, Gles1, Gles2 }
pub enum Api {
Gl,
Glx,
Wgl,
Egl,
GlCore,
Gles1,
Gles2,
}
impl fmt::Display for Api {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
Api::Gl => write!(fmt, "gl"),
Api::Gl => write!(fmt, "gl"),
Api::Glx => write!(fmt, "glx"),
Api::Wgl => write!(fmt, "wgl"),
Api::Egl => write!(fmt, "egl"),
@ -43,12 +51,18 @@ impl fmt::Display for Api {
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Fallbacks { All, None }
pub enum Fallbacks {
All,
None,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Profile { Core, Compatibility }
pub enum Profile {
Core,
Compatibility,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Enum {
pub ident: String,
pub value: String,
@ -63,13 +77,13 @@ impl Hash for Enum {
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Binding {
pub ident: String,
pub ty: Cow<'static, str>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Cmd {
pub proto: Binding,
pub params: Vec<Binding>,
@ -84,7 +98,7 @@ impl Hash for Cmd {
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct GlxOpcode {
pub opcode: String,
pub name: Option<String>,
@ -93,17 +107,24 @@ pub struct GlxOpcode {
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Registry {
pub api: Api,
pub enums: HashSet<Enum>,
pub cmds: HashSet<Cmd>,
pub aliases: HashMap<String, Vec<String>>,
pub enums: BTreeSet<Enum>,
pub cmds: BTreeSet<Cmd>,
pub aliases: BTreeMap<String, Vec<String>>,
}
impl Registry {
pub fn new<'a, Exts>(api: Api, version: (u8, u8), profile: Profile, fallbacks: Fallbacks, extensions: Exts) -> Registry where
Exts: AsRef<[&'a str]>,
pub fn new<'a, Exts>(api: Api,
version: (u8, u8),
profile: Profile,
fallbacks: Fallbacks,
extensions: Exts)
-> Registry
where Exts: AsRef<[&'a str]>
{
let (major, minor) = version;
let extensions = extensions.as_ref().iter()
let extensions = extensions
.as_ref()
.iter()
.map(<&str>::to_string)
.collect();
@ -125,9 +146,9 @@ impl Registry {
parse::from_xml(src, filter)
}
pub fn write_bindings<W, G>(&self, generator: G, output: &mut W) -> io::Result<()> where
G: Generator,
W: io::Write,
pub fn write_bindings<W, G>(&self, generator: G, output: &mut W) -> io::Result<()>
where G: Generator,
W: io::Write
{
generator.write(&self, output)
}

View File

@ -15,10 +15,8 @@
extern crate khronos_api;
use std::borrow::Cow;
use std::collections::hash_map::Entry;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::btree_map::Entry;
use std::collections::{BTreeMap, BTreeSet};
use std::io;
use xml::attribute::OwnedAttribute;
use xml::EventReader as XmlEventReader;
@ -28,7 +26,8 @@ use {Fallbacks, Api, Profile};
use registry::{Binding, Cmd, Enum, GlxOpcode, Registry};
pub fn from_xml<R: io::Read>(src: R, filter: Filter) -> Registry {
XmlEventReader::new(src).into_iter()
XmlEventReader::new(src)
.into_iter()
.map(Result::unwrap)
.filter_map(ParseEvent::from_xml)
.parse(filter)
@ -41,9 +40,9 @@ struct Attribute {
}
impl Attribute {
fn new<Key, Value>(key: Key, value: Value) -> Attribute where
Key: ToString,
Value: ToString,
fn new<Key, Value>(key: Key, value: Value) -> Attribute
where Key: ToString,
Value: ToString
{
Attribute {
key: key.to_string(),
@ -71,11 +70,9 @@ impl ParseEvent {
XmlEvent::StartDocument { .. } => None,
XmlEvent::EndDocument => None,
XmlEvent::StartElement { name, attributes, .. } => {
let attributes = attributes.into_iter()
.map(Attribute::from)
.collect();
let attributes = attributes.into_iter().map(Attribute::from).collect();
Some(ParseEvent::Start(name.local_name, attributes))
},
}
XmlEvent::EndElement { name } => Some(ParseEvent::End(name.local_name)),
XmlEvent::Characters(chars) => Some(ParseEvent::Text(chars)),
XmlEvent::ProcessingInstruction { .. } => None,
@ -95,7 +92,7 @@ fn api_from_str(src: &str) -> Result<Api, ()> {
"glcore" => Ok(Api::GlCore),
"gles1" => Ok(Api::Gles1),
"gles2" => Ok(Api::Gles2),
_ => Err(()),
_ => Err(()),
}
}
@ -124,15 +121,19 @@ fn underscore_keyword(ident: String) -> String {
}
fn trim_str<'a>(s: &'a str, trim: &str) -> &'a str {
if s.starts_with(trim) { &s[trim.len()..] } else { s }
if s.starts_with(trim) {
&s[trim.len()..]
} else {
s
}
}
fn trim_enum_prefix(ident: &str, api: Api) -> String {
let ident = match api {
Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 => trim_str(ident, "GL_"),
Api::Glx => trim_str(ident, "GLX_"),
Api::Wgl => trim_str(ident, "WGL_"),
Api::Egl => trim_str(ident, "EGL_"),
Api::Wgl => trim_str(ident, "WGL_"),
Api::Egl => trim_str(ident, "EGL_"),
};
underscore_numeric_prefix(ident)
}
@ -144,10 +145,10 @@ fn make_enum(ident: String, ty: Option<String>, value: String, alias: Option<Str
// nothing to see here....
// just brute forcing some paren matching... (ノ ◕ ◡ ◕)ノ *:・゚✧
let working = &value[2 .. value.len() - 1];
let working = &value[2..value.len() - 1];
if let Some((i, _)) = working.match_indices(")").next() {
let ty = working[.. i].to_string();
let value = working[i + 1 ..].to_string();
let ty = working[..i].to_string();
let value = working[i + 1..].to_string();
(Cow::Owned(ty), value, true)
} else {
@ -179,16 +180,20 @@ fn trim_cmd_prefix(ident: &str, api: Api) -> &str {
match api {
Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 => trim_str(ident, "gl"),
Api::Glx => trim_str(ident, "glX"),
Api::Wgl => trim_str(ident, "wgl"),
Api::Egl => trim_str(ident, "egl"),
Api::Wgl => trim_str(ident, "wgl"),
Api::Egl => trim_str(ident, "egl"),
}
}
fn merge_map(a: &mut HashMap<String, Vec<String>>, b: HashMap<String, Vec<String>>) {
fn merge_map(a: &mut BTreeMap<String, Vec<String>>, b: BTreeMap<String, Vec<String>>) {
for (k, v) in b {
match a.entry(k) {
Entry::Occupied(mut ent) => { ent.get_mut().extend(v); },
Entry::Vacant(ent) => { ent.insert(v); }
Entry::Occupied(mut ent) => {
ent.get_mut().extend(v);
}
Entry::Vacant(ent) => {
ent.insert(v);
}
}
}
}
@ -244,7 +249,7 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
let mut cmds = Vec::new();
let mut features = Vec::new();
let mut extensions = Vec::new();
let mut aliases = HashMap::new();
let mut aliases = BTreeMap::new();
while let Some(event) = self.next() {
match event {
@ -291,8 +296,8 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
}
}
let mut desired_enums = HashSet::new();
let mut desired_cmds = HashSet::new();
let mut desired_enums = BTreeSet::new();
let mut desired_cmds = BTreeSet::new();
// find the features we want
let mut found_feature = false;
@ -329,7 +334,9 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
for extension in &extensions {
if filter.extensions.contains(&extension.name) {
if !extension.supported.contains(&filter.api) {
panic!("Requested {}, which doesn't support the {} API", extension.name, filter.api);
panic!("Requested {}, which doesn't support the {} API",
extension.name,
filter.api);
}
for require in &extension.requires {
desired_enums.extend(require.enums.iter().map(|x| x.clone()));
@ -356,7 +363,11 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
api: filter.api,
enums: enums.into_iter().filter(is_desired_enum).collect(),
cmds: cmds.into_iter().filter(is_desired_cmd).collect(),
aliases: if filter.fallbacks == Fallbacks::None { HashMap::new() } else { aliases },
aliases: if filter.fallbacks == Fallbacks::None {
BTreeMap::new()
} else {
aliases
},
}
}
@ -370,7 +381,9 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
fn consume_start_element(&mut self, expected_name: &str) -> Vec<Attribute> {
match self.next().unwrap() {
ParseEvent::Start(name, attributes) => {
if expected_name == name { attributes } else {
if expected_name == name {
attributes
} else {
panic!("Expected <{}>, found: <{}>", expected_name, name)
}
}
@ -389,12 +402,16 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
loop {
match self.next().unwrap() {
ParseEvent::End(ref name) if expected_name == name => break,
_ => {},
_ => {}
}
}
}
fn consume_two<'a, T: FromXml, U: FromXml>(&mut self, one: &'a str, two: &'a str, end: &'a str) -> (Vec<T>, Vec<U>) {
fn consume_two<'a, T: FromXml, U: FromXml>(&mut self,
one: &'a str,
two: &'a str,
end: &'a str)
-> (Vec<T>, Vec<U>) {
debug!("consume_two: looking for {} and {} until {}", one, two, end);
let mut ones = Vec::new();
@ -421,7 +438,7 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
} else {
panic!("Unexpected element: <{:?} {:?}>", n, &attributes);
}
},
}
ParseEvent::End(ref name) => {
debug!("Found end element </{:?}>", name);
@ -438,8 +455,9 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
} else {
panic!("Unexpected end element {:?}", name);
}
},
event => panic!("Unexpected message {:?}", event) }
}
event => panic!("Unexpected message {:?}", event),
}
}
}
@ -448,13 +466,13 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
loop {
match self.next().unwrap() {
// ignores
ParseEvent::Text(_) => {},
ParseEvent::Text(_) => {}
ParseEvent::Start(ref name, _) if name == "unused" => self.skip_to_end("unused"),
// add enum definition
ParseEvent::Start(ref name, ref attributes) if name == "enum" => {
enums.push(self.consume_enum(api, attributes));
},
}
// finished building the namespace
ParseEvent::End(ref name) if name == "enums" => break,
@ -475,9 +493,9 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
make_enum(ident, ty, value, alias)
}
fn consume_cmds(&mut self, api: Api) -> (Vec<Cmd>, HashMap<String, Vec<String>>) {
fn consume_cmds(&mut self, api: Api) -> (Vec<Cmd>, BTreeMap<String, Vec<String>>) {
let mut cmds = Vec::new();
let mut aliases: HashMap<String, Vec<String>> = HashMap::new();
let mut aliases: BTreeMap<String, Vec<String>> = BTreeMap::new();
loop {
match self.next().unwrap() {
// add command definition
@ -485,8 +503,12 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
let new = self.consume_cmd(api);
if let Some(ref v) = new.alias {
match aliases.entry(v.clone()) {
Entry::Occupied(mut ent) => { ent.get_mut().push(new.proto.ident.clone()); },
Entry::Vacant(ent) => { ent.insert(vec![new.proto.ident.clone()]); }
Entry::Occupied(mut ent) => {
ent.get_mut().push(new.proto.ident.clone());
}
Entry::Vacant(ent) => {
ent.insert(vec![new.proto.ident.clone()]);
}
}
}
cmds.push(new);
@ -526,9 +548,9 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
}
ParseEvent::Start(ref name, ref attributes) if name == "glx" => {
glx = Some(GlxOpcode {
opcode: get_attribute(&attributes, "opcode").unwrap(),
name: get_attribute(&attributes, "name"),
});
opcode: get_attribute(&attributes, "opcode").unwrap(),
name: get_attribute(&attributes, "name"),
});
self.consume_end_element("glx");
}
ParseEvent::End(ref name) if name == "command" => break,
@ -578,12 +600,11 @@ trait Parse: Sized + Iterator<Item = ParseEvent> {
}
}
impl<T> Parse for T where
T: Sized + Iterator<Item = ParseEvent>,
{}
impl<T> Parse for T where T: Sized + Iterator<Item = ParseEvent> {}
fn get_attribute(attribs: &[Attribute], key: &str) -> Option<String> {
attribs.iter()
attribs
.iter()
.find(|attrib| attrib.key == key)
.map(|attrib| attrib.value.clone())
}
@ -598,7 +619,7 @@ impl FromXml for Require {
let (enums, commands) = parser.consume_two("enum", "command", "require");
Require {
enums: enums,
commands: commands
commands: commands,
}
}
}
@ -613,7 +634,7 @@ impl FromXml for Remove {
Remove {
profile: profile,
enums: enums,
commands: commands
commands: commands,
}
}
}
@ -635,7 +656,7 @@ impl FromXml for Feature {
name: name,
number: number,
requires: require,
removes: remove
removes: remove,
}
}
}
@ -644,7 +665,8 @@ impl FromXml for Extension {
fn convert<P: Parse>(parser: &mut P, a: &[Attribute]) -> Extension {
debug!("Doing a FromXml on Extension");
let name = get_attribute(a, "name").unwrap();
let supported = get_attribute(a, "supported").unwrap()
let supported = get_attribute(a, "supported")
.unwrap()
.split('|')
.map(api_from_str)
.map(Result::unwrap)
@ -656,14 +678,14 @@ impl FromXml for Extension {
require.push(FromXml::convert(parser, &attributes));
}
ParseEvent::End(ref name) if name == "extension" => break,
event => panic!("Unexpected message {:?}", event)
event => panic!("Unexpected message {:?}", event),
}
}
Extension {
name: name,
supported: supported,
requires: require
requires: require,
}
}
}
@ -678,162 +700,162 @@ impl FromXml for String {
pub fn to_rust_ty<T: AsRef<str>>(ty: T) -> Cow<'static, str> {
let ty = match ty.as_ref() {
// gl.xml types
"GLDEBUGPROC" => "types::GLDEBUGPROC",
"GLDEBUGPROCAMD" => "types::GLDEBUGPROCAMD",
"GLDEBUGPROCARB" => "types::GLDEBUGPROCARB",
"GLDEBUGPROCKHR" => "types::GLDEBUGPROCKHR",
"GLbitfield" => "types::GLbitfield",
"GLboolean" => "types::GLboolean",
"GLbyte" => "types::GLbyte",
"GLclampd" => "types::GLclampd",
"GLclampf" => "types::GLclampf",
"GLclampx" => "types::GLclampx",
"GLdouble" => "types::GLdouble",
"GLeglImageOES" => "types::GLeglImageOES",
"GLenum" => "types::GLenum",
"GLfixed" => "types::GLfixed",
"GLfloat" => "types::GLfloat",
"GLhalfNV" => "types::GLhalfNV",
"GLhandleARB" => "types::GLhandleARB",
"GLint" => "types::GLint",
"GLint64" => "types::GLint64",
"GLint64EXT" => "types::GLint64EXT",
"GLintptr" => "types::GLintptr",
"GLintptrARB" => "types::GLintptrARB",
"GLshort" => "types::GLshort",
"GLsizei" => "types::GLsizei",
"GLsizeiptr" => "types::GLsizeiptr",
"GLsizeiptrARB" => "types::GLsizeiptrARB",
"GLsync" => "types::GLsync",
"GLubyte" => "types::GLubyte",
"GLuint" => "types::GLuint",
"GLuint64" => "types::GLuint64",
"GLuint64EXT" => "types::GLuint64EXT",
"GLushort" => "types::GLushort",
"GLvdpauSurfaceNV" => "types::GLvdpauSurfaceNV",
"void " => "()",
"GLboolean *" => "*mut types::GLboolean",
"GLchar *" => "*mut types::GLchar",
"GLcharARB *" => "*mut types::GLcharARB",
"GLdouble *" => "*mut types::GLdouble",
"GLenum *" => "*mut types::GLenum",
"GLfixed *" => "*mut types::GLfixed",
"GLfloat *" => "*mut types::GLfloat",
"GLhandleARB *" => "*mut types::GLhandleARB",
"GLint *" => "*mut types::GLint",
"GLint64 *" => "*mut types::GLint64",
"GLint64EXT *" => "*mut types::GLint64EXT",
"GLsizei *" => "*mut types::GLsizei",
"GLubyte *" => "*mut types::GLubyte",
"GLuint *" => "*mut types::GLuint",
"GLuint [2]" => "*mut [types::GLuint; 2]",
"GLuint64 *" => "*mut types::GLuint64",
"GLuint64EXT *" => "*mut types::GLuint64EXT",
"GLushort *" => "*mut types::GLushort",
"GLvoid *" => "*mut types::GLvoid",
"GLvoid **" => "*const *mut types::GLvoid",
"void *" => "*mut __gl_imports::raw::c_void",
"void **" => "*const *mut __gl_imports::raw::c_void",
"const GLboolean *" => "*const types::GLboolean",
"const GLbyte *" => "*const types::GLbyte",
"const GLchar *" => "*const types::GLchar",
"const GLcharARB *" => "*const types::GLcharARB",
"const GLclampf *" => "*const types::GLclampf",
"const GLdouble *" => "*const types::GLdouble",
"const GLenum *" => "*const types::GLenum",
"const GLfixed *" => "*const types::GLfixed",
"const GLfloat" => "types::GLfloat",
"const GLfloat *" => "*const types::GLfloat",
"const GLhalfNV *" => "*const types::GLhalfNV",
"const GLint *" => "*const types::GLint",
"const GLint64 *" => "*const types::GLint64",
"const GLint64EXT *" => "*const types::GLint64EXT",
"const GLintptr *" => "*const types::GLintptr",
"const GLshort *" => "*const types::GLshort",
"const GLsizei *" => "*const types::GLsizei",
"const GLsizeiptr *" => "*const types::GLsizeiptr",
"const GLubyte *" => "*const types::GLubyte",
"const GLuint *" => "*const types::GLuint",
"const GLuint64 *" => "*const types::GLuint64",
"const GLuint64EXT *" => "*const types::GLuint64EXT",
"const GLushort *" => "*const types::GLushort",
"const GLvdpauSurfaceNV *" => "*const types::GLvdpauSurfaceNV",
"const GLvoid *" => "*const types::GLvoid",
"const void *" => "*const __gl_imports::raw::c_void",
"const void **" => "*const *const __gl_imports::raw::c_void",
"const void *const*" => "*const *const __gl_imports::raw::c_void",
"const GLboolean **" => "*const *const types::GLboolean",
"const GLchar **" => "*const *const types::GLchar",
"const GLcharARB **" => "*const *const types::GLcharARB",
"const GLvoid **" => "*const *const types::GLvoid",
"const GLchar *const*" => "*const *const types::GLchar",
"const GLvoid *const*" => "*const *const types::GLvoid",
"struct _cl_context *" => "*const types::_cl_context",
"struct _cl_event *" => "*const types::_cl_event",
"GLuint[2]" => "[Gluint; 2]",
"GLDEBUGPROC" => "types::GLDEBUGPROC",
"GLDEBUGPROCAMD" => "types::GLDEBUGPROCAMD",
"GLDEBUGPROCARB" => "types::GLDEBUGPROCARB",
"GLDEBUGPROCKHR" => "types::GLDEBUGPROCKHR",
"GLbitfield" => "types::GLbitfield",
"GLboolean" => "types::GLboolean",
"GLbyte" => "types::GLbyte",
"GLclampd" => "types::GLclampd",
"GLclampf" => "types::GLclampf",
"GLclampx" => "types::GLclampx",
"GLdouble" => "types::GLdouble",
"GLeglImageOES" => "types::GLeglImageOES",
"GLenum" => "types::GLenum",
"GLfixed" => "types::GLfixed",
"GLfloat" => "types::GLfloat",
"GLhalfNV" => "types::GLhalfNV",
"GLhandleARB" => "types::GLhandleARB",
"GLint" => "types::GLint",
"GLint64" => "types::GLint64",
"GLint64EXT" => "types::GLint64EXT",
"GLintptr" => "types::GLintptr",
"GLintptrARB" => "types::GLintptrARB",
"GLshort" => "types::GLshort",
"GLsizei" => "types::GLsizei",
"GLsizeiptr" => "types::GLsizeiptr",
"GLsizeiptrARB" => "types::GLsizeiptrARB",
"GLsync" => "types::GLsync",
"GLubyte" => "types::GLubyte",
"GLuint" => "types::GLuint",
"GLuint64" => "types::GLuint64",
"GLuint64EXT" => "types::GLuint64EXT",
"GLushort" => "types::GLushort",
"GLvdpauSurfaceNV" => "types::GLvdpauSurfaceNV",
"void " => "()",
"GLboolean *" => "*mut types::GLboolean",
"GLchar *" => "*mut types::GLchar",
"GLcharARB *" => "*mut types::GLcharARB",
"GLdouble *" => "*mut types::GLdouble",
"GLenum *" => "*mut types::GLenum",
"GLfixed *" => "*mut types::GLfixed",
"GLfloat *" => "*mut types::GLfloat",
"GLhandleARB *" => "*mut types::GLhandleARB",
"GLint *" => "*mut types::GLint",
"GLint64 *" => "*mut types::GLint64",
"GLint64EXT *" => "*mut types::GLint64EXT",
"GLsizei *" => "*mut types::GLsizei",
"GLubyte *" => "*mut types::GLubyte",
"GLuint *" => "*mut types::GLuint",
"GLuint [2]" => "*mut [types::GLuint; 2]",
"GLuint64 *" => "*mut types::GLuint64",
"GLuint64EXT *" => "*mut types::GLuint64EXT",
"GLushort *" => "*mut types::GLushort",
"GLvoid *" => "*mut types::GLvoid",
"GLvoid **" => "*const *mut types::GLvoid",
"void *" => "*mut __gl_imports::raw::c_void",
"void **" => "*const *mut __gl_imports::raw::c_void",
"const GLboolean *" => "*const types::GLboolean",
"const GLbyte *" => "*const types::GLbyte",
"const GLchar *" => "*const types::GLchar",
"const GLcharARB *" => "*const types::GLcharARB",
"const GLclampf *" => "*const types::GLclampf",
"const GLdouble *" => "*const types::GLdouble",
"const GLenum *" => "*const types::GLenum",
"const GLfixed *" => "*const types::GLfixed",
"const GLfloat" => "types::GLfloat",
"const GLfloat *" => "*const types::GLfloat",
"const GLhalfNV *" => "*const types::GLhalfNV",
"const GLint *" => "*const types::GLint",
"const GLint64 *" => "*const types::GLint64",
"const GLint64EXT *" => "*const types::GLint64EXT",
"const GLintptr *" => "*const types::GLintptr",
"const GLshort *" => "*const types::GLshort",
"const GLsizei *" => "*const types::GLsizei",
"const GLsizeiptr *" => "*const types::GLsizeiptr",
"const GLubyte *" => "*const types::GLubyte",
"const GLuint *" => "*const types::GLuint",
"const GLuint64 *" => "*const types::GLuint64",
"const GLuint64EXT *" => "*const types::GLuint64EXT",
"const GLushort *" => "*const types::GLushort",
"const GLvdpauSurfaceNV *" => "*const types::GLvdpauSurfaceNV",
"const GLvoid *" => "*const types::GLvoid",
"const void *" => "*const __gl_imports::raw::c_void",
"const void **" => "*const *const __gl_imports::raw::c_void",
"const void *const*" => "*const *const __gl_imports::raw::c_void",
"const GLboolean **" => "*const *const types::GLboolean",
"const GLchar **" => "*const *const types::GLchar",
"const GLcharARB **" => "*const *const types::GLcharARB",
"const GLvoid **" => "*const *const types::GLvoid",
"const GLchar *const*" => "*const *const types::GLchar",
"const GLvoid *const*" => "*const *const types::GLvoid",
"struct _cl_context *" => "*const types::_cl_context",
"struct _cl_event *" => "*const types::_cl_event",
"GLuint[2]" => "[Gluint; 2]",
// glx.xml types
"Bool" => "types::Bool",
"Colormap" => "types::Colormap",
"DMbuffer" => "types::DMbuffer",
"Font" => "types::Font",
"GLXContext" => "types::GLXContext",
"GLXContextID" => "types::GLXContextID",
"GLXDrawable" => "types::GLXDrawable",
"GLXFBConfig" => "types::GLXFBConfig",
"GLXFBConfigSGIX" => "types::GLXFBConfigSGIX",
"GLXPbuffer" => "types::GLXPbuffer",
"GLXPbufferSGIX" => "types::GLXPbufferSGIX",
"GLXPixmap" => "types::GLXPixmap",
"GLXVideoCaptureDeviceNV" => "types::GLXVideoCaptureDeviceNV",
"GLXVideoDeviceNV" => "types::GLXVideoDeviceNV",
"GLXVideoSourceSGIX" => "types::GLXVideoSourceSGIX",
"GLXWindow" => "types::GLXWindow",
"Bool" => "types::Bool",
"Colormap" => "types::Colormap",
"DMbuffer" => "types::DMbuffer",
"Font" => "types::Font",
"GLXContext" => "types::GLXContext",
"GLXContextID" => "types::GLXContextID",
"GLXDrawable" => "types::GLXDrawable",
"GLXFBConfig" => "types::GLXFBConfig",
"GLXFBConfigSGIX" => "types::GLXFBConfigSGIX",
"GLXPbuffer" => "types::GLXPbuffer",
"GLXPbufferSGIX" => "types::GLXPbufferSGIX",
"GLXPixmap" => "types::GLXPixmap",
"GLXVideoCaptureDeviceNV" => "types::GLXVideoCaptureDeviceNV",
"GLXVideoDeviceNV" => "types::GLXVideoDeviceNV",
"GLXVideoSourceSGIX" => "types::GLXVideoSourceSGIX",
"GLXWindow" => "types::GLXWindow",
// "GLboolean" => "types::GLboolean",
// "GLenum" => "types::GLenum",
// "GLint" => "types::GLint",
// "GLsizei" => "types::GLsizei",
// "GLuint" => "types::GLuint",
"Pixmap" => "types::Pixmap",
"Status" => "types::Status",
"VLNode" => "types::VLNode",
"VLPath" => "types::VLPath",
"VLServer" => "types::VLServer",
"Window" => "types::Window",
"__GLXextFuncPtr" => "types::__GLXextFuncPtr",
"const GLXContext" => "const types::GLXContext",
"float " => "__gl_imports::raw::c_float",
"int " => "__gl_imports::raw::c_int",
"int64_t" => "i64",
"unsigned int " => "__gl_imports::raw::c_uint",
"unsigned long " => "__gl_imports::raw::c_ulong",
"Pixmap" => "types::Pixmap",
"Status" => "types::Status",
"VLNode" => "types::VLNode",
"VLPath" => "types::VLPath",
"VLServer" => "types::VLServer",
"Window" => "types::Window",
"__GLXextFuncPtr" => "types::__GLXextFuncPtr",
"const GLXContext" => "const types::GLXContext",
"float " => "__gl_imports::raw::c_float",
"int " => "__gl_imports::raw::c_int",
"int64_t" => "i64",
"unsigned int " => "__gl_imports::raw::c_uint",
"unsigned long " => "__gl_imports::raw::c_ulong",
// "void " => "()",
"DMparams *" => "*mut types::DMparams",
"Display *" => "*mut types::Display",
"GLXFBConfig *" => "*mut types::GLXFBConfig",
"GLXFBConfigSGIX *" => "*mut types::GLXFBConfigSGIX",
"GLXHyperpipeConfigSGIX *" => "*mut types::GLXHyperpipeConfigSGIX",
"DMparams *" => "*mut types::DMparams",
"Display *" => "*mut types::Display",
"GLXFBConfig *" => "*mut types::GLXFBConfig",
"GLXFBConfigSGIX *" => "*mut types::GLXFBConfigSGIX",
"GLXHyperpipeConfigSGIX *" => "*mut types::GLXHyperpipeConfigSGIX",
"GLXHyperpipeNetworkSGIX *" => "*mut types::GLXHyperpipeNetworkSGIX",
"GLXVideoCaptureDeviceNV *" => "*mut types::GLXVideoCaptureDeviceNV",
"GLXVideoDeviceNV *" => "*mut types::GLXVideoDeviceNV",
"GLXVideoDeviceNV *" => "*mut types::GLXVideoDeviceNV",
// "GLuint *" => "*mut types::GLuint",
"XVisualInfo *" => "*mut types::XVisualInfo",
"XVisualInfo *" => "*mut types::XVisualInfo",
// "const GLubyte *" => "*GLubyte",
"const char *" => "*const __gl_imports::raw::c_char",
"const int *" => "*const __gl_imports::raw::c_int",
"const char *" => "*const __gl_imports::raw::c_char",
"const int *" => "*const __gl_imports::raw::c_int",
// "const void *" => "*const __gl_imports::raw::c_void",
"int *" => "*mut __gl_imports::raw::c_int",
"int32_t *" => "*mut i32",
"int64_t *" => "*mut i64",
"long *" => "*mut __gl_imports::raw::c_long",
"unsigned int *" => "*mut __gl_imports::raw::c_uint",
"unsigned long *" => "*mut __gl_imports::raw::c_ulong",
"int *" => "*mut __gl_imports::raw::c_int",
"int32_t *" => "*mut i32",
"int64_t *" => "*mut i64",
"long *" => "*mut __gl_imports::raw::c_long",
"unsigned int *" => "*mut __gl_imports::raw::c_uint",
"unsigned long *" => "*mut __gl_imports::raw::c_ulong",
// "void *" => "*mut __gl_imports::raw::c_void",
// wgl.xml types
"BOOL" => "types::BOOL",
"DWORD" => "types::DWORD",
"FLOAT" => "types::FLOAT",
"BOOL" => "types::BOOL",
"DWORD" => "types::DWORD",
"FLOAT" => "types::FLOAT",
// "GLbitfield" => "types::GLbitfield",
// "GLboolean" => "types::GLboolean",
// "GLenum" => "types::GLenum",
@ -842,116 +864,116 @@ pub fn to_rust_ty<T: AsRef<str>>(ty: T) -> Cow<'static, str> {
// "GLsizei" => "types::GLsizei",
// "GLuint" => "types::GLuint",
// "GLushort" => "types::GLushort",
"HANDLE" => "types::HANDLE",
"HDC" => "types::HDC",
"HENHMETAFILE" => "types::HENHMETAFILE",
"HGLRC" => "types::HGLRC",
"HGPUNV" => "types::HGPUNV",
"HPBUFFERARB" => "types::HPBUFFERARB",
"HPBUFFEREXT" => "types::HPBUFFEREXT",
"HPVIDEODEV" => "types::HPVIDEODEV",
"HVIDEOINPUTDEVICENV" => "types::HVIDEOINPUTDEVICENV",
"HVIDEOOUTPUTDEVICENV" => "types::HVIDEOOUTPUTDEVICENV",
"INT" => "types::INT",
"INT64" => "types::INT64",
"LPCSTR" => "types::LPCSTR",
"LPGLYPHMETRICSFLOAT" => "types::LPGLYPHMETRICSFLOAT",
"LPVOID" => "types::LPVOID",
"PGPU_DEVICE" => "types::PGPU_DEVICE",
"PROC" => "types::PROC",
"UINT" => "types::UINT",
"VOID" => "types::VOID",
"HANDLE" => "types::HANDLE",
"HDC" => "types::HDC",
"HENHMETAFILE" => "types::HENHMETAFILE",
"HGLRC" => "types::HGLRC",
"HGPUNV" => "types::HGPUNV",
"HPBUFFERARB" => "types::HPBUFFERARB",
"HPBUFFEREXT" => "types::HPBUFFEREXT",
"HPVIDEODEV" => "types::HPVIDEODEV",
"HVIDEOINPUTDEVICENV" => "types::HVIDEOINPUTDEVICENV",
"HVIDEOOUTPUTDEVICENV" => "types::HVIDEOOUTPUTDEVICENV",
"INT" => "types::INT",
"INT64" => "types::INT64",
"LPCSTR" => "types::LPCSTR",
"LPGLYPHMETRICSFLOAT" => "types::LPGLYPHMETRICSFLOAT",
"LPVOID" => "types::LPVOID",
"PGPU_DEVICE" => "types::PGPU_DEVICE",
"PROC" => "types::PROC",
"UINT" => "types::UINT",
"VOID" => "types::VOID",
// "int " => "__gl_imports::raw::c_int",
// "unsigned int " => "__gl_imports::raw::c_uint",
// "void " => "()",
"BOOL *" => "*mut types::BOOL",
"DWORD *" => "*mut types::DWORD",
"FLOAT *" => "*mut types::FLOAT",
"BOOL *" => "*mut types::BOOL",
"DWORD *" => "*mut types::DWORD",
"FLOAT *" => "*mut types::FLOAT",
// "GLuint *" => "*mut types::GLuint",
"HANDLE *" => "*mut types::HANDLE",
"HGPUNV *" => "*mut types::HGPUNV",
"HPVIDEODEV *" => "*mut types::HPVIDEODEV",
"HVIDEOINPUTDEVICENV *" => "*mut types::HVIDEOINPUTDEVICENV",
"HVIDEOOUTPUTDEVICENV *" => "*mut types::HVIDEOOUTPUTDEVICENV",
"INT32 *" => "*mut types::INT32",
"INT64 *" => "*mut types::INT64",
"UINT *" => "*mut types::UINT",
"USHORT *" => "*mut types::USHORT",
"const COLORREF *" => "*const types::COLORREF",
"const DWORD *" => "*const types::DWORD",
"const FLOAT *" => "*const types::FLOAT",
"HANDLE *" => "*mut types::HANDLE",
"HGPUNV *" => "*mut types::HGPUNV",
"HPVIDEODEV *" => "*mut types::HPVIDEODEV",
"HVIDEOINPUTDEVICENV *" => "*mut types::HVIDEOINPUTDEVICENV",
"HVIDEOOUTPUTDEVICENV *" => "*mut types::HVIDEOOUTPUTDEVICENV",
"INT32 *" => "*mut types::INT32",
"INT64 *" => "*mut types::INT64",
"UINT *" => "*mut types::UINT",
"USHORT *" => "*mut types::USHORT",
"const COLORREF *" => "*const types::COLORREF",
"const DWORD *" => "*const types::DWORD",
"const FLOAT *" => "*const types::FLOAT",
// "const GLushort *" => "*const types::GLushort",
"const HANDLE *" => "*const types::HANDLE",
"const HGPUNV *" => "*const types::HGPUNV",
"const LAYERPLANEDESCRIPTOR *" => "*const types::LAYERPLANEDESCRIPTOR",
"const LPVOID *" => "*const types::LPVOID",
"const HANDLE *" => "*const types::HANDLE",
"const HGPUNV *" => "*const types::HGPUNV",
"const LAYERPLANEDESCRIPTOR *" => "*const types::LAYERPLANEDESCRIPTOR",
"const LPVOID *" => "*const types::LPVOID",
"const PIXELFORMATDESCRIPTOR *" => "*const types::IXELFORMATDESCRIPTOR",
"const USHORT *" => "*const types::USHORT",
"const USHORT *" => "*const types::USHORT",
// "const char *" => "*const __gl_imports::raw::c_char",
// "const int *" => "*const __gl_imports::raw::c_int",
"float *" => "*mut __gl_imports::raw::c_float",
"float *" => "*mut __gl_imports::raw::c_float",
// "int *" => "*mut __gl_imports::raw::c_int",
// "unsigned long *" => "*mut __gl_imports::raw::c_ulong",
// "void *" => "*mut __gl_imports::raw::c_void",
// elx.xml types
"khronos_utime_nanoseconds_t" => "types::khronos_utime_nanoseconds_t",
"khronos_uint64_t" => "types::khronos_uint64_t",
"khronos_ssize_t" => "types::khronos_ssize_t",
"EGLNativeDisplayType" => "types::EGLNativeDisplayType",
"EGLNativePixmapType" => "types::EGLNativePixmapType",
"EGLNativeWindowType" => "types::EGLNativeWindowType",
"EGLint" => "types::EGLint",
"EGLint *" => "*mut types::EGLint",
"const EGLint *" => "*const types::EGLint",
"NativeDisplayType" => "types::NativeDisplayType",
"NativePixmapType" => "types::NativePixmapType",
"NativeWindowType" => "types::NativeWindowType",
"khronos_utime_nanoseconds_t" => "types::khronos_utime_nanoseconds_t",
"khronos_uint64_t" => "types::khronos_uint64_t",
"khronos_ssize_t" => "types::khronos_ssize_t",
"EGLNativeDisplayType" => "types::EGLNativeDisplayType",
"EGLNativePixmapType" => "types::EGLNativePixmapType",
"EGLNativeWindowType" => "types::EGLNativeWindowType",
"EGLint" => "types::EGLint",
"EGLint *" => "*mut types::EGLint",
"const EGLint *" => "*const types::EGLint",
"NativeDisplayType" => "types::NativeDisplayType",
"NativePixmapType" => "types::NativePixmapType",
"NativeWindowType" => "types::NativeWindowType",
//"Bool" => "types::Bool",
"EGLBoolean" => "types::EGLBoolean",
"EGLenum" => "types::EGLenum",
"EGLAttribKHR" => "types::EGLAttribKHR",
"EGLAttrib" => "types::EGLAttrib",
"EGLAttrib *" => "*mut types::EGLAttrib",
"const EGLAttrib *" => "*const types::EGLAttrib",
"EGLConfig" => "types::EGLConfig",
"EGLConfig *" => "*mut types::EGLConfig",
"EGLContext" => "types::EGLContext",
"EGLDeviceEXT" => "types::EGLDeviceEXT",
"EGLDisplay" => "types::EGLDisplay",
"EGLSurface" => "types::EGLSurface",
"EGLClientBuffer" => "types::EGLClientBuffer",
"EGLBoolean" => "types::EGLBoolean",
"EGLenum" => "types::EGLenum",
"EGLAttribKHR" => "types::EGLAttribKHR",
"EGLAttrib" => "types::EGLAttrib",
"EGLAttrib *" => "*mut types::EGLAttrib",
"const EGLAttrib *" => "*const types::EGLAttrib",
"EGLConfig" => "types::EGLConfig",
"EGLConfig *" => "*mut types::EGLConfig",
"EGLContext" => "types::EGLContext",
"EGLDeviceEXT" => "types::EGLDeviceEXT",
"EGLDisplay" => "types::EGLDisplay",
"EGLSurface" => "types::EGLSurface",
"EGLClientBuffer" => "types::EGLClientBuffer",
"__eglMustCastToProperFunctionPointerType" => "types::__eglMustCastToProperFunctionPointerType",
"EGLImageKHR" => "types::EGLImageKHR",
"EGLImage" => "types::EGLImage",
"EGLOutputLayerEXT" => "types::EGLOutputLayerEXT",
"EGLOutputPortEXT" => "types::EGLOutputPortEXT",
"EGLSyncKHR" => "types::EGLSyncKHR",
"EGLSync" => "types::EGLSync",
"EGLTimeKHR" => "types::EGLTimeKHR",
"EGLTime" => "types::EGLTime",
"EGLSyncNV" => "types::EGLSyncNV",
"EGLTimeNV" => "types::EGLTimeNV",
"EGLuint64NV" => "types::EGLuint64NV",
"EGLStreamKHR" => "types::EGLStreamKHR",
"EGLuint64KHR" => "types::EGLuint64KHR",
"EGLImageKHR" => "types::EGLImageKHR",
"EGLImage" => "types::EGLImage",
"EGLOutputLayerEXT" => "types::EGLOutputLayerEXT",
"EGLOutputPortEXT" => "types::EGLOutputPortEXT",
"EGLSyncKHR" => "types::EGLSyncKHR",
"EGLSync" => "types::EGLSync",
"EGLTimeKHR" => "types::EGLTimeKHR",
"EGLTime" => "types::EGLTime",
"EGLSyncNV" => "types::EGLSyncNV",
"EGLTimeNV" => "types::EGLTimeNV",
"EGLuint64NV" => "types::EGLuint64NV",
"EGLStreamKHR" => "types::EGLStreamKHR",
"EGLuint64KHR" => "types::EGLuint64KHR",
"EGLNativeFileDescriptorKHR" => "types::EGLNativeFileDescriptorKHR",
"EGLsizeiANDROID" => "types::EGLsizeiANDROID",
"EGLSetBlobFuncANDROID" => "types::EGLSetBlobFuncANDROID",
"EGLGetBlobFuncANDROID" => "types::EGLGetBlobFuncANDROID",
"EGLClientPixmapHI" => "types::EGLClientPixmapHI",
"EGLsizeiANDROID" => "types::EGLsizeiANDROID",
"EGLSetBlobFuncANDROID" => "types::EGLSetBlobFuncANDROID",
"EGLGetBlobFuncANDROID" => "types::EGLGetBlobFuncANDROID",
"EGLClientPixmapHI" => "types::EGLClientPixmapHI",
"struct EGLClientPixmapHI *" => "*const types::EGLClientPixmapHI",
"const EGLAttribKHR *" => "*const types::EGLAttribKHR",
"const EGLuint64KHR *" => "*const types::EGLuint64KHR",
"EGLAttribKHR *" => "*mut types::EGLAttribKHR",
"EGLDeviceEXT *" => "*mut types::EGLDeviceEXT",
"EGLNativeDisplayType *" => "*mut types::EGLNativeDisplayType",
"EGLNativePixmapType *" => "*mut types::EGLNativePixmapType",
"EGLNativeWindowType *" => "*mut types::EGLNativeWindowType",
"EGLOutputLayerEXT *" => "*mut types::EGLOutputLayerEXT",
"EGLTimeKHR *" => "*mut types::EGLTimeKHR",
"EGLOutputPortEXT *" => "*mut types::EGLOutputPortEXT",
"EGLuint64KHR *" => "*mut types::EGLuint64KHR",
"const EGLAttribKHR *" => "*const types::EGLAttribKHR",
"const EGLuint64KHR *" => "*const types::EGLuint64KHR",
"EGLAttribKHR *" => "*mut types::EGLAttribKHR",
"EGLDeviceEXT *" => "*mut types::EGLDeviceEXT",
"EGLNativeDisplayType *" => "*mut types::EGLNativeDisplayType",
"EGLNativePixmapType *" => "*mut types::EGLNativePixmapType",
"EGLNativeWindowType *" => "*mut types::EGLNativeWindowType",
"EGLOutputLayerEXT *" => "*mut types::EGLOutputLayerEXT",
"EGLTimeKHR *" => "*mut types::EGLTimeKHR",
"EGLOutputPortEXT *" => "*mut types::EGLOutputPortEXT",
"EGLuint64KHR *" => "*mut types::EGLuint64KHR",
// failure
_ => panic!("Type conversion not implemented for `{}`", ty.as_ref()),
@ -1000,7 +1022,10 @@ mod tests {
#[test]
fn test_cast_0() {
let e = parse::make_enum("FOO".to_string(), None, "((EGLint)-1)".to_string(), Some("BAR".to_string()));
let e = parse::make_enum("FOO".to_string(),
None,
"((EGLint)-1)".to_string(),
Some("BAR".to_string()));
assert_eq!(e.ident, "FOO");
assert_eq!((&*e.ty, &*e.value), ("EGLint", "-1"));
assert_eq!(e.alias, Some("BAR".to_string()));
@ -1008,7 +1033,10 @@ mod tests {
#[test]
fn test_cast_1() {
let e = parse::make_enum("FOO".to_string(), None, "((EGLint)(-1))".to_string(), Some("BAR".to_string()));
let e = parse::make_enum("FOO".to_string(),
None,
"((EGLint)(-1))".to_string(),
Some("BAR".to_string()));
assert_eq!(e.ident, "FOO");
assert_eq!((&*e.ty, &*e.value), ("EGLint", "(-1)"));
assert_eq!(e.alias, Some("BAR".to_string()));
@ -1016,7 +1044,10 @@ mod tests {
#[test]
fn test_no_type() {
let e = parse::make_enum("FOO".to_string(), None, "value".to_string(), Some("BAR".to_string()));
let e = parse::make_enum("FOO".to_string(),
None,
"value".to_string(),
Some("BAR".to_string()));
assert_eq!(e.ident, "FOO");
assert_eq!(e.value, "value");
assert_eq!(e.alias, Some("BAR".to_string()));
@ -1026,20 +1057,29 @@ mod tests {
#[test]
fn test_u() {
let e = parse::make_enum("FOO".to_string(), Some("u".to_string()), String::new(), None);
let e = parse::make_enum("FOO".to_string(),
Some("u".to_string()),
String::new(),
None);
assert_eq!(e.ty, "GLuint");
}
#[test]
fn test_ull() {
let e = parse::make_enum("FOO".to_string(), Some("ull".to_string()), String::new(), None);
let e = parse::make_enum("FOO".to_string(),
Some("ull".to_string()),
String::new(),
None);
assert_eq!(e.ty, "GLuint64");
}
#[test]
#[should_panic]
fn test_unknown_type() {
parse::make_enum("FOO".to_string(), Some("blargh".to_string()), String::new(), None);
parse::make_enum("FOO".to_string(),
Some("blargh".to_string()),
String::new(),
None);
}
#[test]
@ -1075,27 +1115,19 @@ mod tests {
fn test_start_event() {
let given = XmlEvent::StartElement {
name: OwnedName::local("element"),
attributes: vec![
OwnedAttribute::new(OwnedName::local("attr1"), "val1"),
OwnedAttribute::new(OwnedName::local("attr2"), "val2"),
],
attributes: vec![OwnedAttribute::new(OwnedName::local("attr1"), "val1"),
OwnedAttribute::new(OwnedName::local("attr2"), "val2")],
namespace: Namespace::empty(),
};
let expected = ParseEvent::Start(
"element".to_string(),
vec![
Attribute::new("attr1", "val1"),
Attribute::new("attr2", "val2"),
],
);
let expected = ParseEvent::Start("element".to_string(),
vec![Attribute::new("attr1", "val1"),
Attribute::new("attr2", "val2")]);
assert_eq!(ParseEvent::from_xml(given), Some(expected));
}
#[test]
fn test_end_element() {
let given = XmlEvent::EndElement {
name: OwnedName::local("element"),
};
let given = XmlEvent::EndElement { name: OwnedName::local("element") };
let expected = ParseEvent::End("element".to_string());
assert_eq!(ParseEvent::from_xml(given), Some(expected));
}

View File

@ -1 +1 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"201ece82276abe0662d235dcfe1736ca1306da4e54dba43b07301939c21a03c9","README.md":"4584b28d97d885822adc66e1eae8a329bd5e3b13a5dd887006c08bc5adc0a917","api/GL/glcorearb.h":"d411f59f28484725f6a2927d8f283ef10bf8e14d3b685e76de30c3871ca176e6","api/GL/glext.h":"fd30a350477613fb9a0b3cdaa5b22b18fed56cdbd369c587058c71ea83c8935b","api/GL/glxext.h":"0024c262e896dd3bfcd8c458e809bd2910d8eeae1316998a0654cdb75e5f2019","api/GL/wglext.h":"2fdace6ceefaf6bee7a5d821bcd599774689da354c7670839df4f4a836fd8386","api/Makefile":"fa42b2bf27a450c5be83f3178ca08f9bd24f611786dd503033b84c98ae67d37f","api/README.txt":"8c0b31285b1ce7d661ebdbf2f884264c9a588f7721221a2ad5fba7cafdf5b76f","api/egl.xml":"2590ce135d8b5364f11ae4ca04a0abe1fa781cde99a2b4ade8a2f0fdac09d5e4","api/genheaders.py":"3ddf420a48450c0d74b5c95d956ac09f4aceff2e225b148f0d1415a14f182a11","api/gl.xml":"5cf25ca370fd8c13407192533d5aa6febc4c16b7038882ae75d106f555e8f0e1","api/glx.xml":"9653c70d281fbac1c28292ef6532f41a9aee3c6998260d186b860f7cc2cc7ecd","api/readme.pdf":"26b9a42b4bc0803ee4854d5aa908b76bf08cafb478fd2e772a3b6cf6820daa2f","api/readme.tex":"542e27bcbd975f5c24e19fc2b89d62e8a4af8657f5f0ecebfac1c2640e23a5b6","api/reg.py":"469c294591df494d727bf13333b7080f04ba7c4938baeff14a5ead95b0cbd7c8","api/registry.rnc":"e76be90498a47ab63f9f0eb10b6a63d795a9e4b5a0bde2c89f1709ed8ebf937e","api/wgl.xml":"38b53bc1bc2c16dce1cc627feebcda4fb666c2d23ab0baf09bdecf6cb85bb005","src/lib.rs":"59d07cea8beca750b13ac49d4b1e37e23e753640517ee644bcddf50d431166eb"},"package":"09c9d3760673c427d46f91a0350f0a84a52e6bc5a84adf26dc610b6c52436630"}
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"d5b14cfc2a6504e54c9ceca859378c92d1a4a4cb59d67d3af944d91c2f6bef12","Cargo.toml.orig":"ece4f30db56195f5010330b514af06207e5d32a9d8a909e77baa5f2842133cb5","README.md":"dff09e27dcecc37f1e477d62ea89aa49b4dc743514ea6990c7c83b8b0fc602e4","api/.htaccess":"e600e7ce93361e8de3e32f588f9cc8f472243af676d078a7393acaf142245918","api/GL/glcorearb.h":"d411f59f28484725f6a2927d8f283ef10bf8e14d3b685e76de30c3871ca176e6","api/GL/glext.h":"fd30a350477613fb9a0b3cdaa5b22b18fed56cdbd369c587058c71ea83c8935b","api/GL/glxext.h":"0024c262e896dd3bfcd8c458e809bd2910d8eeae1316998a0654cdb75e5f2019","api/GL/wglext.h":"2fdace6ceefaf6bee7a5d821bcd599774689da354c7670839df4f4a836fd8386","api/Makefile":"fa42b2bf27a450c5be83f3178ca08f9bd24f611786dd503033b84c98ae67d37f","api/README.txt":"8c0b31285b1ce7d661ebdbf2f884264c9a588f7721221a2ad5fba7cafdf5b76f","api/egl.xml":"2590ce135d8b5364f11ae4ca04a0abe1fa781cde99a2b4ade8a2f0fdac09d5e4","api/genheaders.py":"3ddf420a48450c0d74b5c95d956ac09f4aceff2e225b148f0d1415a14f182a11","api/gl.xml":"5cf25ca370fd8c13407192533d5aa6febc4c16b7038882ae75d106f555e8f0e1","api/glx.xml":"9653c70d281fbac1c28292ef6532f41a9aee3c6998260d186b860f7cc2cc7ecd","api/readme.pdf":"26b9a42b4bc0803ee4854d5aa908b76bf08cafb478fd2e772a3b6cf6820daa2f","api/readme.tex":"542e27bcbd975f5c24e19fc2b89d62e8a4af8657f5f0ecebfac1c2640e23a5b6","api/reg.py":"469c294591df494d727bf13333b7080f04ba7c4938baeff14a5ead95b0cbd7c8","api/registry.rnc":"e76be90498a47ab63f9f0eb10b6a63d795a9e4b5a0bde2c89f1709ed8ebf937e","api/wgl.xml":"38b53bc1bc2c16dce1cc627feebcda4fb666c2d23ab0baf09bdecf6cb85bb005","src/lib.rs":"6773dcdb7458a9bebcbefcd28add5f6aa4720bf69c10f348f94615e127f51a2d"},"package":"d5a08e2a31d665af8f1ca437eab6d00a93c9d62a549f73f9ed8fc2e55b5a91a7"}

View File

@ -1,18 +1,23 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g. crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
name = "khronos_api"
version = "1.0.0"
authors = [
"Brendan Zabarauskas <bjzaba@yahoo.com.au>",
"Corey Richardson",
"Arseny Kapoulkine",
"Pierre Krieger <pierre.krieger1708@gmail.com>"
]
version = "1.0.1"
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>", "Corey Richardson", "Arseny Kapoulkine", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "The Khronos XML API Registry, exposed as byte string constants."
license = "Apache-2.0"
homepage = "https://github.com/bjz/gl-rs/khronos_api/"
repository = "https://github.com/bjz/gl-rs/"
homepage = "https://github.com/brendanzab/gl-rs/khronos_api/"
documentation = "https://docs.rs/khronos_api"
readme = "README.md"
keywords = ["opengl", "khronos"]
license = "Apache-2.0"
repository = "https://github.com/brendanzab/gl-rs/"

View File

@ -0,0 +1,17 @@
[package]
name = "khronos_api"
version = "1.0.1"
authors = [
"Brendan Zabarauskas <bjzaba@yahoo.com.au>",
"Corey Richardson",
"Arseny Kapoulkine",
"Pierre Krieger <pierre.krieger1708@gmail.com>"
]
description = "The Khronos XML API Registry, exposed as byte string constants."
license = "Apache-2.0"
documentation = "https://docs.rs/khronos_api"
homepage = "https://github.com/brendanzab/gl-rs/khronos_api/"
repository = "https://github.com/brendanzab/gl-rs/"
readme = "README.md"
keywords = ["opengl", "khronos"]

View File

@ -1,14 +1,26 @@
# khronos_api
[![Version](https://img.shields.io/crates/v/khronos_api.svg)](https://crates.io/crates/khronos_api)
[![License](https://img.shields.io/crates/l/khronos_api.svg)](https://github.com/bjz/gl-rs/blob/master/LICENSE)
[![License](https://img.shields.io/crates/l/khronos_api.svg)](https://github.com/brendanzab/gl-rs/blob/master/LICENSE)
[![Downloads](https://img.shields.io/crates/d/khronos_api.svg)](https://crates.io/crates/khronos_api)
The Khronos XML API Registry, exposed as byte string constants.
```toml
[build-dependencies]
khronos_api = "1.0.0"
```
The following constants are provided:
- `GL_XML`: the contents of [`gl.xml`](https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml)
- `EGL_XML`: the contents of [`egl.xml`](https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/egl.xml)
- `WGL_XML`: the contents of [`wgl.xml`](https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/wgl.xml)
- `GLX_XML`: the contents of [`glx.xml`](https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/glx.xml)
## Changelog
### v1.0.0
- Initial release
- Documentation improvements

View File

@ -0,0 +1,23 @@
# Redirect old .spec file URLs to the cached locations
redirect 301 /registry/api/enum.spec http://www.opengl.org/registry/oldspecs/enum.spec
redirect 301 /registry/api/enumext.spec http://www.opengl.org/registry/oldspecs//enumext.spec
redirect 301 /registry/api/gl.spec http://www.opengl.org/registry/oldspecs//gl.spec
redirect 301 /registry/api/gl.tm http://www.opengl.org/registry/oldspecs//gl.tm
redirect 301 /registry/api/gl3.h http://www.opengl.org/registry/oldspecs//gl3.h
redirect 301 /registry/api/glcorearb.h http://www.opengl.org/registry/oldspecs//glcorearb.h
redirect 301 /registry/api/glcorearbrelease.txt http://www.opengl.org/registry/oldspecs//glcorearbrelease.txt
redirect 301 /registry/api/glext.h http://www.opengl.org/registry/oldspecs//glext.h
redirect 301 /registry/api/glextrelease.txt http://www.opengl.org/registry/oldspecs//glextrelease.txt
redirect 301 /registry/api/glx.spec http://www.opengl.org/registry/oldspecs//glx.spec
redirect 301 /registry/api/glx.tm http://www.opengl.org/registry/oldspecs//glx.tm
redirect 301 /registry/api/glxenum.spec http://www.opengl.org/registry/oldspecs//glxenum.spec
redirect 301 /registry/api/glxenumext.spec http://www.opengl.org/registry/oldspecs//glxenumext.spec
redirect 301 /registry/api/glxext.h http://www.opengl.org/registry/oldspecs//glxext.h
redirect 301 /registry/api/glxext.spec http://www.opengl.org/registry/oldspecs//glxext.spec
redirect 301 /registry/api/wgl.spec http://www.opengl.org/registry/oldspecs//wgl.spec
redirect 301 /registry/api/wgl.tm http://www.opengl.org/registry/oldspecs//wgl.tm
redirect 301 /registry/api/wglenum.spec http://www.opengl.org/registry/oldspecs//wglenum.spec
redirect 301 /registry/api/wglenumext.spec http://www.opengl.org/registry/oldspecs//wglenumext.spec
redirect 301 /registry/api/wglext.h http://www.opengl.org/registry/oldspecs//wglext.h
redirect 301 /registry/api/wglext.spec http://www.opengl.org/registry/oldspecs//wglext.spec

View File

@ -1,4 +1,4 @@
// Copyright 2015 Brendan Zabarauskas
// 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.

View File

@ -365,10 +365,10 @@ dependencies = [
[[package]]
name = "gl_generator"
version = "0.5.2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"khronos_api 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"xml-rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -378,7 +378,7 @@ name = "gleam"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -429,7 +429,7 @@ dependencies = [
[[package]]
name = "khronos_api"
version = "1.0.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -1214,7 +1214,7 @@ dependencies = [
"checksum futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "55f0008e13fc853f79ea8fc86e931486860d4c4c156cdffb59fa5f7fa833660a"
"checksum gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f72af1e933f296b827361eb9e70d0267abf8ad0de9ec7fa667bbe67177b297"
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
"checksum gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1d8edc81c5ae84605a62f5dac661a2313003b26d59839f81d47d46cf0f16a55"
"checksum gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0940975a4ca12b088d32b5d5134826c47d2e73de4b0b459b05244c01503eccbb"
"checksum gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86944a6a4d7f54507f8ee930192d971f18a7b1da526ff529b7a0d4043935380"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5a376f7402b85be6e0ba504243ecbc0709c48019ecc6286d0540c2e359050c88"
@ -1222,7 +1222,7 @@ dependencies = [
"checksum idna 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2233d4940b1f19f0418c158509cd7396b8d70a5db5705ce410914dc8fa603b37"
"checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09c9d3760673c427d46f91a0350f0a84a52e6bc5a84adf26dc610b6c52436630"
"checksum khronos_api 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d5a08e2a31d665af8f1ca437eab6d00a93c9d62a549f73f9ed8fc2e55b5a91a7"
"checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b"
"checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5"
"checksum libloading 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be99f814beb3e9503a786a592c909692bb6d4fc5a695f6ed7987223acfbd5194"

View File

@ -363,10 +363,10 @@ dependencies = [
[[package]]
name = "gl_generator"
version = "0.5.2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"khronos_api 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"xml-rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -376,7 +376,7 @@ name = "gleam"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -427,7 +427,7 @@ dependencies = [
[[package]]
name = "khronos_api"
version = "1.0.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -1201,7 +1201,7 @@ dependencies = [
"checksum futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "55f0008e13fc853f79ea8fc86e931486860d4c4c156cdffb59fa5f7fa833660a"
"checksum gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f72af1e933f296b827361eb9e70d0267abf8ad0de9ec7fa667bbe67177b297"
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
"checksum gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1d8edc81c5ae84605a62f5dac661a2313003b26d59839f81d47d46cf0f16a55"
"checksum gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0940975a4ca12b088d32b5d5134826c47d2e73de4b0b459b05244c01503eccbb"
"checksum gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86944a6a4d7f54507f8ee930192d971f18a7b1da526ff529b7a0d4043935380"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5a376f7402b85be6e0ba504243ecbc0709c48019ecc6286d0540c2e359050c88"
@ -1209,7 +1209,7 @@ dependencies = [
"checksum idna 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2233d4940b1f19f0418c158509cd7396b8d70a5db5705ce410914dc8fa603b37"
"checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09c9d3760673c427d46f91a0350f0a84a52e6bc5a84adf26dc610b6c52436630"
"checksum khronos_api 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d5a08e2a31d665af8f1ca437eab6d00a93c9d62a549f73f9ed8fc2e55b5a91a7"
"checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b"
"checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5"
"checksum libloading 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be99f814beb3e9503a786a592c909692bb6d4fc5a695f6ed7987223acfbd5194"