Repository: brendanzab/gl-rs (language: rust)

Issue:
Support using `gl_generator` as a stand-alone
There are several things that need to be fixed before someone can use `gl_generator` outside of `gl`:
- [x] Move view items from `gl/lib.rs` to the code generated by `gl_generator`.
- [x] Fix the path to `deps/khronos-api/` which is currently relative to `gl/lib.rs`. (edit: https://github.com/bjz/gl-rs/commit/27b127bff2da8d654fedb5cafb7846f738abafeb)
  This is probably the trickiest point. Should `gl_generator` call `include_bin!` on all the `xml` files of `khronos-api` (my favorite solution)? Should it store an absolute path to the `khronos-api` directory during its compilation (I'm not sure that this is reliable)? Should it call `git clone`/`svn clone` during the invocation?
- [x] Define a clear API for `gl_generator`. (edit: https://github.com/bjz/gl-rs/commit/1bd4257484d2ade146506fe4d2f023ab2d9847e1)
  This includes removing the first parameter of `gl_generator` (it should be deduced from the second) and refactoring the last parameter to take an array instead of a string.
- [x] Add tests.

There is also a question here: should `gl_generator` create a module where the symbols are defined, or you should it directly write all functions/constants/etc. in the same module where it is invoked (as it currently does)?



Discussion / hints:
Actually that's a really good idea. We could have a single `khronos-api` crate that just does an `include_bin`. We would never need to worry about it again!

What do you mean? Rename `gl_generator` to `khronos-api`, or add a new `khronos-api` crate?
I don't really see why this should be a separate crate.

If it were a separate crate cargo would know to never rebuild it.

And what about the last question?

I suggest that `gl_generator` generates a module which contains the bindings, and whose name is the first parameter of the macro.

For example calling `gl_generate_bindings("gl", ...);` would generate something like:

``` rust
mod gl {
    pub fn Clear();
    ...
}
```

Otherwise people will probably write `mod gl { generate_gl_bindings!(...) }` anyway.

Generating a module seems fine, but it needs a way to make it pub and specify the name. At which point, you aren't much better than `pub mod gl { generate_gl_bindings!(...) }` in the first place.

That's a good point. I'll stick to the current way for the moment.


Fix patch:
diff --git a/.travis.yml b/.travis.yml
index be83c3de..d35369c0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,7 +16,6 @@ install:
 script:
   - cargo build
   - cargo test
-  - make -C examples
   # the doc directory needs to be in the root for rust-ci
   - cargo doc
   - ln -s target/doc doc
diff --git a/Cargo.toml b/Cargo.toml
index 9e025e60..1f75ccd1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,3 +13,6 @@ path = "src/gl/lib.rs"
 
 [dependencies.gl_generator]
 path = "src/gl_generator"
+
+[dev-dependencies.glfw]
+git = "https://github.com/bjz/glfw-rs"
diff --git a/examples/Makefile b/examples/Makefile
deleted file mode 100644
index 27a46d66..00000000
--- a/examples/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-all: build
-
-build:
-	(cd static_basic && cargo build)
-	(cd static_triangle && cargo build)
-#	error: couldn't open file (no such file or directory (No such file or directory); path=deps/khronos-api/gl.xml; mode=open; access=read)
-#	(cd struct_triangle && cargo build)
-
-update:
-	(cd static_basic && cargo update)
-	(cd static_triangle && cargo update)
-#	(cd struct_triangle && cargo update)
-
-clean:
-	(cd static_basic && cargo clean)
-	(cd static_triangle && cargo clean)
-#	(cd struct_triangle && cargo clean)
diff --git a/examples/static_basic/main.rs b/examples/static_basic.rs
similarity index 100%
rename from examples/static_basic/main.rs
rename to examples/static_basic.rs
diff --git a/examples/static_basic/Cargo.toml b/examples/static_basic/Cargo.toml
deleted file mode 100644
index 729f15bf..00000000
--- a/examples/static_basic/Cargo.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-[package]
-
-name = "static-basic"
-version = "0.1.0"
-authors = [
-]
-
-build = "git submodule update --init --recursive"
-
-[[bin]]
-name = "static-basic"
-path = "main.rs"
-
-[dependencies.gl]
-path = "../../"
-
-[dependencies.glfw]
-git = "https://github.com/bjz/glfw-rs.git"
diff --git a/examples/static_triangle/main.rs b/examples/static_triangle.rs
similarity index 100%
rename from examples/static_triangle/main.rs
rename to examples/static_triangle.rs
diff --git a/examples/static_triangle/Cargo.toml b/examples/static_triangle/Cargo.toml
deleted file mode 100644
index 865e6213..00000000
--- a/examples/static_triangle/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-
-name = "static-triangle"
-version = "0.1.0"
-authors = [
-]
-
-[[bin]]
-name = "static-triangle"
-path = "main.rs"
-
-[dependencies.gl]
-path = "../../"
-
-[dependencies.glfw]
-git = "https://github.com/bjz/glfw-rs.git"
diff --git a/examples/struct_triangle/main.rs b/examples/struct_triangle.rs
similarity index 98%
rename from examples/struct_triangle/main.rs
rename to examples/struct_triangle.rs
index 51903c1d..cf61e18a 100644
--- a/examples/struct_triangle/main.rs
+++ b/examples/struct_triangle.rs
@@ -35,7 +35,7 @@ use self::gl::types::*;
 pub mod gl {
     use std::mem;
     use self::types::*;
-    generate_gl_bindings!("gl", "gl", "core", "3.2", "struct")
+    generate_gl_bindings!("gl", "core", "3.2", "struct")
 }
 
 // Vertex data
diff --git a/examples/struct_triangle/Cargo.toml b/examples/struct_triangle/Cargo.toml
deleted file mode 100644
index 49905943..00000000
--- a/examples/struct_triangle/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-
-name = "struct-triangle"
-version = "0.1.0"
-authors = [
-]
-
-[[bin]]
-name = "struct-triangle"
-path = "main.rs"
-
-[dependencies.gl_generator]
-path = "../../"
-
-[dependencies.glfw]
-git = "https://github.com/bjz/glfw-rs.git"
diff --git a/src/gl/lib.rs b/src/gl/lib.rs
index 15eabd9f..6b6abb2c 100644
--- a/src/gl/lib.rs
+++ b/src/gl/lib.rs
@@ -80,18 +80,9 @@
 #![license = "ASL2"]
 #![crate_type = "lib"]
 
-#![feature(macro_rules)]
-#![feature(globs)]
 #![feature(phase)]
-#![allow(non_camel_case_types)]
-#![allow(non_snake_case_functions)]
-#![allow(unused_variable)]
 
 #[phase(plugin)]
 extern crate gl_generator;
-extern crate libc;
-
-use std::mem;
-use self::types::*;
 
 generate_gl_bindings!("gl", "core", "4.5", "static", [ "GL_EXT_texture_filter_anisotropic" ])
diff --git a/src/gl_generator/lib.rs b/src/gl_generator/lib.rs
index fddea368..361ab48e 100644
--- a/src/gl_generator/lib.rs
+++ b/src/gl_generator/lib.rs
@@ -176,13 +176,13 @@ fn macro_handler(ecx: &mut ExtCtxt, span: Span, token_tree: &[TokenTree]) -> Box
         let result = match generator.as_slice() {
             "static" => task::try(proc() {
                 let mut buffer = MemWriter::new();
-                StaticGenerator::write(&mut buffer, &reg, ns, false);
+                StaticGenerator::write(&mut buffer, &reg, ns);
                 buffer
             }),
 
             "struct" => task::try(proc() {
                 let mut buffer = MemWriter::new();
-                StructGenerator::write(&mut buffer, &reg, ns, false);
+                StructGenerator::write(&mut buffer, &reg, ns);
                 buffer
             }),
 
diff --git a/src/gl_generator/static_gen.rs b/src/gl_generator/static_gen.rs
index 1390afcd..243c85ff 100644
--- a/src/gl_generator/static_gen.rs
+++ b/src/gl_generator/static_gen.rs
@@ -72,10 +72,10 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
         };
 
         let ty = match ident.as_slice() {
-            "TRUE" | "FALSE" => "GLboolean",
+            "TRUE" | "FALSE" => "types::GLboolean",
             _ => match enm.ty {
-                Some(ref s) if s.as_slice() == "ull" => "GLuint64",
-                _ => "GLenum"
+                Some(ref s) if s.as_slice() == "ull" => "types::GLuint64",
+                _ => "types::GLenum"
             }
         };
 
@@ -90,38 +90,10 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
     }
 
     fn write_header(&mut self) {
-        self.write_line("// Copyright 2013 The gl-rs developers. For a full listing of the authors,");
-        self.write_line("// refer to the AUTHORS file at the top-level directory of this distribution.");
-        self.write_line("// ");
-        self.write_line("// Licensed under the Apache License, Version 2.0 (the \"License\");");
-        self.write_line("// you may not use this file except in compliance with the License.");
-        self.write_line("// You may obtain a copy of the License at");
-        self.write_line("// ");
-        self.write_line("//     http://www.apache.org/licenses/LICENSE-2.0");
-        self.write_line("// ");
-        self.write_line("// Unless required by applicable law or agreed to in writing, software");
-        self.write_line("// distributed under the License is distributed on an \"AS IS\" BASIS,");
-        self.write_line("// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
-        self.write_line("// See the License for the specific language governing permissions and");
-        self.write_line("// limitations under the License.");
-        self.write_line("");
-        let ns = self.ns.to_string();
-        self.write_line(format!("#![crate_name = \"{}\"]", ns).as_slice());
-        self.write_line("#![comment = \"An OpenGL function loader.\"]");
-        self.write_line("#![license = \"ASL2\"]");
-        self.write_line("#![crate_type = \"lib\"]");
-        self.write_line("");
-        self.write_line("#![feature(macro_rules)]");
-        self.write_line("#![feature(globs)]");
-        self.write_line("#![allow(non_camel_case_types)]");
-        self.write_line("#![allow(non_snake_case_functions)]");
-        self.write_line("#![allow(unused_variable)]");
-        self.write_line("");
-        self.write_line("extern crate libc;");
-        self.write_line("");
-        self.write_line("use std::mem;");
-        self.write_line("");
-        self.write_line("use self::types::*;");
+        self.write_line("mod __gl_imports {");
+        self.write_line("    extern crate libc;");
+        self.write_line("    pub use std::mem;");
+        self.write_line("}");
     }
 
     fn write_type_aliases(&mut self) {
@@ -131,15 +103,30 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
         self.write_line("");
         match self.ns {
             Gl => {
-                for alias in ty::GL_ALIASES.iter() { self.write_line(*alias) }
+                for alias in ty::GL_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
             }
             Glx => {
-                for alias in ty::X_ALIASES.iter() { self.write_line(*alias) }
-                for alias in ty::GLX_ALIASES.iter() { self.write_line(*alias) }
+                for alias in ty::X_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
+                for alias in ty::GLX_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
             }
             Wgl => {
-                for alias in ty::WIN_ALIASES.iter() { self.write_line(*alias) }
-                for alias in ty::WGL_ALIASES.iter() { self.write_line(*alias) }
+                for alias in ty::WIN_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
+                for alias in ty::WGL_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
             }
         }
         self.decr_indent();
@@ -148,12 +135,12 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
 
     fn write_fnptr_struct_def(&mut self) {
         self.write_line("pub struct FnPtr {");
-        self.write_line("    f: *const libc::c_void,");
+        self.write_line("    f: *const __gl_imports::libc::c_void,");
         self.write_line("    is_loaded: bool,");
         self.write_line("}");
         self.write_line("");
         self.write_line("impl FnPtr {");
-        self.write_line("    pub fn new(ptr: *const libc::c_void, failing_fn: *const libc::c_void) -> FnPtr {");
+        self.write_line("    pub fn new(ptr: *const __gl_imports::libc::c_void, failing_fn: *const __gl_imports::libc::c_void) -> FnPtr {");
         self.write_line("        if ptr.is_null() {");
         self.write_line("            FnPtr { f: failing_fn, is_loaded: false }");
         self.write_line("        } else {");
@@ -166,11 +153,13 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
     fn write_failing_fns(&mut self) {
         self.write_line("mod failing {");
         self.incr_indent();
-        self.write_line("use super::types::*;");
+        self.write_line("use super::types;");
+        self.write_line("use super::__gl_imports;");
         self.write_line("");
         for c in self.registry.cmd_iter() {
             self.write_line(format!(
-                "pub extern \"system\" fn {name}({params}){return_suffix} {{ \
+                "#[allow(non_snake_case_functions)] #[allow(unused_variable)]
+                pub extern \"system\" fn {name}({params}){return_suffix} {{ \
                     fail!(\"`{name}` was not loaded\") \
                 }}",
                 name = c.proto.ident,
@@ -187,9 +176,10 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
             self.write_line(
                 if c.is_safe {
                     format!(
-                        "#[inline] #[unstable] pub fn {name}({params}){return_suffix} {{ \
+                        "#[allow(non_snake_case_functions)] #[allow(unused_variable)]
+                        #[inline] #[unstable] pub fn {name}({params}){return_suffix} {{ \
                             unsafe {{ \
-                                mem::transmute::<_, extern \"system\" fn({types}){return_suffix}>\
+                                __gl_imports::mem::transmute::<_, extern \"system\" fn({types}){return_suffix}>\
                                     (storage::{name}.f)({idents}) \
                             }} \
                         }}",
@@ -201,8 +191,9 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
                     )
                 } else {
                     format!(
-                        "#[inline] #[unstable] pub unsafe fn {name}({typed_params}){return_suffix} {{ \
-                            mem::transmute::<_, extern \"system\" fn({typed_params}) {return_suffix}>\
+                        "#[allow(non_snake_case_functions)] #[allow(unused_variable)]
+                        #[inline] #[unstable] pub unsafe fn {name}({typed_params}){return_suffix} {{ \
+                            __gl_imports::mem::transmute::<_, extern \"system\" fn({typed_params}) {return_suffix}>\
                                 (storage::{name}.f)({idents}) \
                         }}",
                         name = c.proto.ident,
@@ -218,9 +209,9 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
     fn write_ptrs(&mut self) {
         self.write_line("mod storage {");
         self.incr_indent();
-        self.write_line("use libc;");
-        self.write_line("use failing;");
-        self.write_line("use FnPtr;");
+        self.write_line("use super::__gl_imports::libc;");
+        self.write_line("use super::failing;");
+        self.write_line("use super::FnPtr;");
         self.write_line("");
         for c in self.registry.cmd_iter() {
             self.write_line(format!(
@@ -236,27 +227,27 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
     }
 
     fn write_fn_mods(&mut self) {
-        self.write_line("macro_rules! fn_mod {");
-        self.write_line("    ($name:ident, $sym:expr) => {");
-        self.write_line("        #[unstable]");
-        self.write_line("        pub mod $name {");
-        self.write_line("            #[inline]");
-        self.write_line("            pub fn is_loaded() -> bool { unsafe { ::storage::$name.is_loaded } }");
-        self.write_line("            ");
-        self.write_line("            pub fn load_with(loadfn: |symbol: &str| -> *const ::libc::c_void) {");
-        self.write_line("                unsafe { ::storage::$name = ::FnPtr::new(loadfn($sym), ::failing::$name as *const ::libc::c_void) }");
-        self.write_line("            }");
-        self.write_line("        }");
-        self.write_line("    }");
-        self.write_line("}");
-        self.write_line("");
         for c in self.registry.cmd_iter() {
             let ns = self.ns;
             self.write_line(format!(
-                "fn_mod!({name}, \"{symbol}\")",
-                name = c.proto.ident,
-                symbol = common::gen_symbol_name(&ns, c)
-            ).as_slice());
+                "#[unstable]
+                pub mod {0} {{
+                    use super::{{failing, storage}};
+                    use super::FnPtr;
+
+                    #[inline]
+                    pub fn is_loaded() -> bool {{
+                        unsafe {{ storage::{0}.is_loaded }}
+                    }}
+
+                    pub fn load_with(loadfn: |symbol: &str| -> *const super::__gl_imports::libc::c_void) {{
+                        unsafe {{
+                            storage::{0} = FnPtr::new(loadfn(\"{1}\"),
+                                failing::{0} as *const super::__gl_imports::libc::c_void)
+                        }}
+                    }}
+                }}",
+                c.proto.ident, common::gen_symbol_name(&ns, c)).as_slice());
         }
         // for c in self.registry.cmd_iter() {
         //     self.write_line(format!(
@@ -279,7 +270,7 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
         self.write_line("/// gl::load_with(|s| glfw.get_proc_address(s));");
         self.write_line("/// ~~~");
         self.write_line("#[unstable]");
-        self.write_line("pub fn load_with(loadfn: |symbol: &str| -> *const libc::c_void) {");
+        self.write_line("pub fn load_with(loadfn: |symbol: &str| -> *const __gl_imports::libc::c_void) {");
         self.incr_indent();
         for c in self.registry.cmd_iter() {
             self.write_line(format!("{}::load_with(|s| loadfn(s));", c.proto.ident).as_slice());
@@ -288,14 +279,12 @@ impl<'a, W: Writer> StaticGenerator<'a, W> {
         self.write_line("}");
     }
 
-    pub fn write(writer: &mut W, registry: &Registry, ns: Ns, write_header: bool) {
+    pub fn write(writer: &mut W, registry: &Registry, ns: Ns) {
         let mut gen = StaticGenerator::new(writer, registry, ns);
 
-        if write_header {
-            // header with licence, metadata and imports
-            gen.write_header();
-            gen.write_line("");
-        }
+        // header with imports
+        gen.write_header();
+        gen.write_line("");
 
         // type aliases
         gen.write_type_aliases();
diff --git a/src/gl_generator/struct_gen.rs b/src/gl_generator/struct_gen.rs
index b2329a3a..67de946c 100644
--- a/src/gl_generator/struct_gen.rs
+++ b/src/gl_generator/struct_gen.rs
@@ -72,10 +72,10 @@ impl<'a, W: Writer> StructGenerator<'a, W> {
         };
 
         let ty = match ident.as_slice() {
-            "TRUE" | "FALSE" => "GLboolean",
+            "TRUE" | "FALSE" => "types::GLboolean",
             _ => match enm.ty {
-                Some(ref s) if s.as_slice() == "ull" => "GLuint64",
-                _ => "GLenum"
+                Some(ref s) if s.as_slice() == "ull" => "types::GLuint64",
+                _ => "types::GLenum"
             }
         };
 
@@ -90,54 +90,43 @@ impl<'a, W: Writer> StructGenerator<'a, W> {
     }
 
     fn write_header(&mut self) {
-        self.write_line("// Copyright 2013 The gl-rs developers. For a full listing of the authors,");
-        self.write_line("// refer to the AUTHORS file at the top-level directory of this distribution.");
-        self.write_line("// ");
-        self.write_line("// Licensed under the Apache License, Version 2.0 (the \"License\");");
-        self.write_line("// you may not use this file except in compliance with the License.");
-        self.write_line("// You may obtain a copy of the License at");
-        self.write_line("// ");
-        self.write_line("//     http://www.apache.org/licenses/LICENSE-2.0");
-        self.write_line("// ");
-        self.write_line("// Unless required by applicable law or agreed to in writing, software");
-        self.write_line("// distributed under the License is distributed on an \"AS IS\" BASIS,");
-        self.write_line("// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
-        self.write_line("// See the License for the specific language governing permissions and");
-        self.write_line("// limitations under the License.");
-        self.write_line("");
-        let ns = self.ns.to_string();
-        self.write_line(format!("#![crate_name = \"{}\"]", ns).as_slice());
-        self.write_line("#![comment = \"An OpenGL function loader.\"]");
-        self.write_line("#![license = \"ASL2\"]");
-        self.write_line("#![crate_type = \"lib\"]");
-        self.write_line("");
-        self.write_line("#![feature(macro_rules)]");
-        self.write_line("#![feature(globs)]");
-        self.write_line("#![allow(non_camel_case_types)]");
-        self.write_line("#![allow(non_snake_case_functions)]");
-        self.write_line("");
-        self.write_line("extern crate libc;");
-        self.write_line("");
-        self.write_line("use std::mem;");
-        self.write_line("");
-        self.write_line("use self::types::*;");
+        self.write_line("mod __gl_imports {");
+        self.write_line("    extern crate libc;");
+        self.write_line("    pub use std::mem;");
+        self.write_line("}");
     }
 
     fn write_type_aliases(&mut self) {
+        self.write_line("#[stable]");
         self.write_line("pub mod types {");
         self.incr_indent();
         self.write_line("");
         match self.ns {
             Gl => {
-                for alias in ty::GL_ALIASES.iter() { self.write_line(*alias) }
+                for alias in ty::GL_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
             }
             Glx => {
-                for alias in ty::X_ALIASES.iter() { self.write_line(*alias) }
-                for alias in ty::GLX_ALIASES.iter() { self.write_line(*alias) }
+                for alias in ty::X_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
+                for alias in ty::GLX_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
             }
             Wgl => {
-                for alias in ty::WIN_ALIASES.iter() { self.write_line(*alias) }
-                for alias in ty::WGL_ALIASES.iter() { self.write_line(*alias) }
+                for alias in ty::WIN_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
+                for alias in ty::WGL_ALIASES.iter() {
+                    self.write_line("#[allow(non_camel_case_types)]");
+                    self.write_line(*alias)
+                }
             }
         }
         self.decr_indent();
@@ -146,12 +135,12 @@ impl<'a, W: Writer> StructGenerator<'a, W> {
 
     fn write_fnptr_struct_def(&mut self) {
         self.write_line("pub struct FnPtr {");
-        self.write_line("    f: *const ::libc::c_void,");
+        self.write_line("    f: *const __gl_imports::libc::c_void,");
         self.write_line("    is_loaded: bool,");
         self.write_line("}");
         self.write_line("");
         self.write_line("impl FnPtr {");
-        self.write_line("    fn new(ptr: *const ::libc::c_void, failing_fn: *const ::libc::c_void) -> FnPtr {");
+        self.write_line("    fn new(ptr: *const __gl_imports::libc::c_void, failing_fn: *const __gl_imports::libc::c_void) -> FnPtr {");
         self.write_line("        if ptr.is_null() {");
         self.write_line("            FnPtr { f: failing_fn, is_loaded: false }");
         self.write_line("        } else {");
@@ -169,10 +158,11 @@ impl<'a, W: Writer> StructGenerator<'a, W> {
     fn write_failing_fns(&mut self) {
         self.write_line("mod failing {");
         self.incr_indent();
-        self.write_line("use super::types::*;");
+        self.write_line("use super::types;");
+        self.write_line("use super::__gl_imports;");
         self.write_line("");
         for c in self.registry.cmd_iter() {
-            self.write_line("#[allow(unused_variable)]");
+            self.write_line("#[allow(unused_variable)] #[allow(non_snake_case_functions)]");
             self.write_line(format!(
                 "pub extern \"system\" fn {name}({params}){return_suffix} {{ \
                     fail!(\"`{name}` was not loaded\") \
@@ -215,14 +205,14 @@ impl<'a, W: Writer> StructGenerator<'a, W> {
         self.write_line("/// ~~~");
         self.write_line("#[unstable]");
         self.write_line(format!(
-            "pub fn load_with(loadfn: |symbol: &str| -> *const ::libc::c_void) -> {:c} {{", ns
+            "pub fn load_with(loadfn: |symbol: &str| -> *const __gl_imports::libc::c_void) -> {:c} {{", ns
         ).as_slice());
         self.incr_indent();
         self.write_line(format!("{:c} {{", ns).as_slice());
         self.incr_indent();
         for c in self.registry.cmd_iter() {
             self.write_line(format!(
-                "{name}: FnPtr::new(loadfn(\"{symbol}\"), failing::{name} as *const ::libc::c_void),",
+                "{name}: FnPtr::new(loadfn(\"{symbol}\"), failing::{name} as *const __gl_imports::libc::c_void),",
                 name = c.proto.ident,
                 symbol = common::gen_symbol_name(&ns, c)
             ).as_slice());
@@ -236,9 +226,10 @@ impl<'a, W: Writer> StructGenerator<'a, W> {
             self.write_line(
                 if c.is_safe {
                     format!(
-                        "#[inline] #[unstable] pub fn {name}(&self, {params}){return_suffix} {{ \
+                        "#[allow(non_snake_case_functions)] #[allow(unused_variable)]
+                        #[inline] #[unstable] pub fn {name}(&self, {params}){return_suffix} {{ \
                             unsafe {{ \
-                                mem::transmute::<_, extern \"system\" fn({types}){return_suffix}>\
+                                __gl_imports::mem::transmute::<_, extern \"system\" fn({types}){return_suffix}>\
                                     (self.{name}.f)({idents}) \
                             }} \
                         }}",
@@ -250,8 +241,9 @@ impl<'a, W: Writer> StructGenerator<'a, W> {
                     )
                 } else {
                     format!(
-                        "#[inline] #[unstable] pub unsafe fn {name}(&self, {typed_params}){return_suffix} {{ \
-                            mem::transmute::<_, extern \"system\" fn({typed_params}) {return_suffix}>\
+                        "#[allow(non_snake_case_functions)] #[allow(unused_variable)]
+                        #[inline] #[unstable] pub unsafe fn {name}(&self, {typed_params}){return_suffix} {{ \
+                            __gl_imports::mem::transmute::<_, extern \"system\" fn({typed_params}) {return_suffix}>\
                                 (self.{name}.f)({idents}) \
                         }}",
                         name = c.proto.ident,
@@ -266,14 +258,12 @@ impl<'a, W: Writer> StructGenerator<'a, W> {
         self.write_line("}");
     }
 
-    pub fn write(writer: &mut W, registry: &Registry, ns: Ns, write_header: bool) {
+    pub fn write(writer: &mut W, registry: &Registry, ns: Ns) {
         let mut gen = StructGenerator::new(writer, registry, ns);
 
-        if write_header {
-            // header with licence, metadata and imports
-            gen.write_header();
-            gen.write_line("");
-        }
+        // header with imports
+        gen.write_header();
+        gen.write_line("");
 
         // type aliases
         gen.write_type_aliases();
diff --git a/src/gl_generator/ty.rs b/src/gl_generator/ty.rs
index a762941b..8647e33f 100644
--- a/src/gl_generator/ty.rs
+++ b/src/gl_generator/ty.rs
@@ -17,7 +17,7 @@
 
 pub fn to_return_suffix(ty: &str) -> String {
     match ty {
-        "::libc::c_void" | "c_void" | "VOID" | "GLvoid" => "".to_string(),
+        "__gl_imports::libc::c_void" | "c_void" | "VOID" | "GLvoid" => "".to_string(),
         ty_str => format!(" -> {}", ty_str.replace("*mut ", "*const ")),
     }
 }
@@ -26,218 +26,218 @@ pub fn to_return_suffix(ty: &str) -> String {
 pub fn to_rust_ty(ty: &str) -> &'static str {
     match ty {
         // gl.xml types
-        "GLDEBUGPROC"               => "GLDEBUGPROC",
-        "GLDEBUGPROCAMD"            => "GLDEBUGPROCAMD",
-        "GLDEBUGPROCARB"            => "GLDEBUGPROCARB",
-        "GLDEBUGPROCKHR"            => "GLDEBUGPROCKHR",
-        "GLbitfield"                => "GLbitfield",
-        "GLboolean"                 => "GLboolean",
-        "GLbyte"                    => "GLbyte",
-        "GLclampd"                  => "GLclampd",
-        "GLclampf"                  => "GLclampf",
-        "GLclampx"                  => "GLclampx",
-        "GLdouble"                  => "GLdouble",
-        "GLeglImageOES"             => "GLeglImageOES",
-        "GLenum"                    => "GLenum",
-        "GLfixed"                   => "GLfixed",
-        "GLfloat"                   => "GLfloat",
-        "GLhalfNV"                  => "GLhalfNV",
-        "GLhandleARB"               => "GLhandleARB",
-        "GLint"                     => "GLint",
-        "GLint64EXT"                => "GLint64EXT",
-        "GLintptr"                  => "GLintptr",
-        "GLintptrARB"               => "GLintptrARB",
-        "GLshort"                   => "GLshort",
-        "GLsizei"                   => "GLsizei",
-        "GLsizeiptr"                => "GLsizeiptr",
-        "GLsizeiptrARB"             => "GLsizeiptrARB",
-        "GLsync"                    => "GLsync",
-        "GLubyte"                   => "GLubyte",
-        "GLuint"                    => "GLuint",
-        "GLuint64"                  => "GLuint64",
-        "GLuint64EXT"               => "GLuint64EXT",
-        "GLushort"                  => "GLushort",
-        "GLvdpauSurfaceNV"          => "GLvdpauSurfaceNV",
-        "void "                     => "::libc::c_void",
-        "GLboolean *"               => "*mut GLboolean",
-        "GLchar *"                  => "*mut GLchar",
-        "GLcharARB *"               => "*mut GLcharARB",
-        "GLdouble *"                => "*mut GLdouble",
-        "GLenum *"                  => "*mut GLenum",
-        "GLfixed *"                 => "*mut GLfixed",
-        "GLfloat *"                 => "*mut GLfloat",
-        "GLhandleARB *"             => "*mut GLhandleARB",
-        "GLint *"                   => "*mut GLint",
-        "GLint64 *"                 => "*mut GLint64",
-        "GLint64EXT *"              => "*mut GLint64EXT",
-        "GLsizei *"                 => "*mut GLsizei",
-        "GLubyte *"                 => "*mut GLubyte",
-        "GLuint *"                  => "*mut GLuint",
-        "GLuint [2]"                => "*mut [GLuint, ..2]",
-        "GLuint64 *"                => "*mut GLuint64",
-        "GLuint64EXT *"             => "*mut GLuint64EXT",
-        "GLushort *"                => "*mut GLushort",
-        "GLvoid *"                  => "*mut GLvoid",
-        "GLvoid **"                 => "*const *mut GLvoid",
-        "void *"                    => "*mut ::libc::c_void",
-        "void **"                   => "*const *mut ::libc::c_void",
-        "const GLboolean *"         => "*const GLboolean",
-        "const GLbyte *"            => "*const GLbyte",
-        "const GLchar *"            => "*const GLchar",
-        "const GLcharARB *"         => "*const GLcharARB",
-        "const GLclampf *"          => "*const GLclampf",
-        "const GLdouble *"          => "*const GLdouble",
-        "const GLenum *"            => "*const GLenum",
-        "const GLfixed *"           => "*const GLfixed",
-        "const GLfloat"             => "GLfloat",
-        "const GLfloat *"           => "*const GLfloat",
-        "const GLhalfNV *"          => "*const GLhalfNV",
-        "const GLint *"             => "*const GLint",
-        "const GLint64EXT *"        => "*const GLint64EXT",
-        "const GLintptr *"          => "*const GLintptr",
-        "const GLshort *"           => "*const GLshort",
-        "const GLsizei *"           => "*const GLsizei",
-        "const GLsizeiptr *"        => "*const GLsizeiptr",
-        "const GLubyte *"           => "*const GLubyte",
-        "const GLuint *"            => "*const GLuint",
-        "const GLuint64 *"          => "*const GLuint64",
-        "const GLuint64EXT *"       => "*const GLuint64EXT",
-        "const GLushort *"          => "*const GLushort",
-        "const GLvdpauSurfaceNV *"  => "*const GLvdpauSurfaceNV",
-        "const GLvoid *"            => "*const GLvoid",
-        "const void *"              => "*const ::libc::c_void",
-        "const void **"             => "*const *const ::libc::c_void",
-        "const void *const*"        => "*const *const ::libc::c_void",
-        "const GLboolean **"        => "*const *const GLboolean",
-        "const GLchar **"           => "*const *const GLchar",
-        "const GLcharARB **"        => "*const *const GLcharARB",
-        "const GLvoid **"           => "*const *const GLvoid",
-        "const GLchar *const*"      => "*const *const GLchar",
-        "const GLvoid *const*"      => "*const *const GLvoid",
-        "struct _cl_context *"      => "*const _cl_context",
-        "struct _cl_event *"        => "*const _cl_event",
+        "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",
+        "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 "                     => "__gl_imports::libc::c_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::libc::c_void",
+        "void **"                   => "*const *mut __gl_imports::libc::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 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::libc::c_void",
+        "const void **"             => "*const *const __gl_imports::libc::c_void",
+        "const void *const*"        => "*const *const __gl_imports::libc::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",
 
         // glx.xml types
-        "Bool"                      => "Bool",
-        "Colormap"                  => "Colormap",
-        "DMbuffer"                  => "DMbuffer",
-        "Font"                      => "Font",
-        "GLXContext"                => "GLXContext",
-        "GLXContextID"              => "GLXContextID",
-        "GLXDrawable"               => "GLXDrawable",
-        "GLXFBConfig"               => "GLXFBConfig",
-        "GLXFBConfigSGIX"           => "GLXFBConfigSGIX",
-        "GLXPbuffer"                => "GLXPbuffer",
-        "GLXPbufferSGIX"            => "GLXPbufferSGIX",
-        "GLXPixmap"                 => "GLXPixmap",
-        "GLXVideoCaptureDeviceNV"   => "GLXVideoCaptureDeviceNV",
-        "GLXVideoDeviceNV"          => "GLXVideoDeviceNV",
-        "GLXVideoSourceSGIX"        => "GLXVideoSourceSGIX",
-        "GLXWindow"                 => "GLXWindow",
-        // "GLboolean"                 => "GLboolean",
-        // "GLenum"                    => "GLenum",
-        // "GLint"                     => "GLint",
-        // "GLsizei"                   => "GLsizei",
-        // "GLuint"                    => "GLuint",
-        "Pixmap"                    => "Pixmap",
-        "Status"                    => "Status",
-        "VLNode"                    => "VLNode",
-        "VLPath"                    => "VLPath",
-        "VLServer"                  => "VLServer",
-        "Window"                    => "Window",
-        "__GLXextFuncPtr"           => "__GLXextFuncPtr",
-        "const GLXContext"          => "const GLXContext",
-        "float "                    => "::libc::c_float",
-        "int "                      => "::libc::c_int",
+        "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::libc::c_float",
+        "int "                      => "__gl_imports::libc::c_int",
         "int64_t"                   => "i64",
-        "unsigned int "             => "::libc::c_uint",
-        "unsigned long "            => "::libc::c_ulong",
-        // "void "                     => "::libc::c_void",
-        "DMparams *"                => "*mut DMparams",
-        "Display *"                 => "*mut Display",
-        "GLXFBConfig *"             => "*mut GLXFBConfig",
-        "GLXFBConfigSGIX *"         => "*mut GLXFBConfigSGIX",
-        "GLXHyperpipeConfigSGIX *"  => "*mut GLXHyperpipeConfigSGIX",
-        "GLXHyperpipeNetworkSGIX *" => "*mut GLXHyperpipeNetworkSGIX",
-        "GLXVideoCaptureDeviceNV *" => "*mut GLXVideoCaptureDeviceNV",
-        "GLXVideoDeviceNV *"        => "*mut GLXVideoDeviceNV",
-        // "GLuint *"                  => "*mut GLuint",
-        "XVisualInfo *"             => "*mut XVisualInfo",
+        "unsigned int "             => "__gl_imports::libc::c_uint",
+        "unsigned long "            => "__gl_imports::libc::c_ulong",
+        // "void "                     => "__gl_imports::libc::c_void",
+        "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",
+        // "GLuint *"                  => "*mut types::GLuint",
+        "XVisualInfo *"             => "*mut types::XVisualInfo",
         // "const GLubyte *"           => "*GLubyte",
-        "const char *"              => "*const ::libc::c_char",
-        "const int *"               => "*const ::libc::c_int",
-        // "const void *"              => "*const ::libc::c_void",
-        "int *"                     => "*mut ::libc::c_int",
+        "const char *"              => "*const __gl_imports::libc::c_char",
+        "const int *"               => "*const __gl_imports::libc::c_int",
+        // "const void *"              => "*const __gl_imports::libc::c_void",
+        "int *"                     => "*mut __gl_imports::libc::c_int",
         "int32_t *"                 => "*mut i32",
         "int64_t *"                 => "*mut i64",
-        "long *"                    => "*mut ::libc::c_long",
-        "unsigned int *"            => "*mut ::libc::c_uint",
-        "unsigned long *"           => "*mut ::libc::c_ulong",
-        // "void *"                    => "*mut ::libc::c_void",
+        "long *"                    => "*mut __gl_imports::libc::c_long",
+        "unsigned int *"            => "*mut __gl_imports::libc::c_uint",
+        "unsigned long *"           => "*mut __gl_imports::libc::c_ulong",
+        // "void *"                    => "*mut __gl_imports::libc::c_void",
 
         // wgl.xml types
-        "BOOL"                      => "BOOL",
-        "DWORD"                     => "DWORD",
-        "FLOAT"                     => "FLOAT",
-        // "GLbitfield"                => "GLbitfield",
-        // "GLboolean"                 => "GLboolean",
-        // "GLenum"                    => "GLenum",
-        // "GLfloat"                   => "GLfloat",
-        // "GLint"                     => "GLint",
-        // "GLsizei"                   => "GLsizei",
-        // "GLuint"                    => "GLuint",
-        // "GLushort"                  => "GLushort",
-        "HANDLE"                    => "HANDLE",
-        "HDC"                       => "HDC",
-        "HENHMETAFILE"              => "HENHMETAFILE",
-        "HGLRC"                     => "HGLRC",
-        "HGPUNV"                    => "HGPUNV",
-        "HPBUFFERARB"               => "HPBUFFERARB",
-        "HPBUFFEREXT"               => "HPBUFFEREXT",
-        "HPVIDEODEV"                => "HPVIDEODEV",
-        "HVIDEOINPUTDEVICENV"       => "HVIDEOINPUTDEVICENV",
-        "HVIDEOOUTPUTDEVICENV"      => "HVIDEOOUTPUTDEVICENV",
-        "INT"                       => "INT",
-        "INT64"                     => "INT64",
-        "LPCSTR"                    => "LPCSTR",
-        "LPGLYPHMETRICSFLOAT"       => "LPGLYPHMETRICSFLOAT",
-        "LPVOID"                    => "LPVOID",
-        "PGPU_DEVICE"               => "PGPU_DEVICE",
-        "PROC"                      => "PROC",
-        "UINT"                      => "UINT",
-        "VOID"                      => "VOID",
-        // "int "                      => "::libc::c_int",
-        // "unsigned int "             => "::libc::c_uint",
-        // "void "                     => "::libc::c_void",
-        "BOOL *"                    => "*mut BOOL",
-        "DWORD *"                   => "*mut DWORD",
-        "FLOAT *"                   => "*mut FLOAT",
-        // "GLuint *"                  => "*mut GLuint",
-        "HANDLE *"                  => "*mut HANDLE",
-        "HGPUNV *"                  => "*mut HGPUNV",
-        "HPVIDEODEV *"              => "*mut HPVIDEODEV",
-        "HVIDEOINPUTDEVICENV *"     => "*mut HVIDEOINPUTDEVICENV",
-        "HVIDEOOUTPUTDEVICENV *"    => "*mut HVIDEOOUTPUTDEVICENV",
-        "INT32 *"                   => "*mut INT32",
-        "INT64 *"                   => "*mut INT64",
-        "UINT *"                    => "*mut UINT",
-        "USHORT *"                  => "*mut USHORT",
-        "const COLORREF *"          => "*const COLORREF",
-        "const DWORD *"             => "*const DWORD",
-        "const FLOAT *"             => "*const FLOAT",
-        // "const GLushort *"          => "*const GLushort",
-        "const HANDLE *"            => "*const HANDLE",
-        "const HGPUNV *"            => "*const HGPUNV",
-        "const LAYERPLANEDESCRIPTOR *"  => "*const LAYERPLANEDESCRIPTOR",
-        "const LPVOID *"            => "*const LPVOID",
-        "const PIXELFORMATDESCRIPTOR *" => "*const PIXELFORMATDESCRIPTOR",
-        "const USHORT *"            => "*const USHORT",
-        // "const char *"              => "*const ::libc::c_char",
-        // "const int *"               => "*const ::libc::c_int",
-        "float *"                   => "*mut ::libc::c_float",
-        // "int *"                     => "*mut ::libc::c_int",
-        // "unsigned long *"           => "*mut ::libc::c_ulong",
-        // "void *"                    => "*mut ::libc::c_void",
+        "BOOL"                      => "types::BOOL",
+        "DWORD"                     => "types::DWORD",
+        "FLOAT"                     => "types::FLOAT",
+        // "GLbitfield"                => "types::GLbitfield",
+        // "GLboolean"                 => "types::GLboolean",
+        // "GLenum"                    => "types::GLenum",
+        // "GLfloat"                   => "types::GLfloat",
+        // "GLint"                     => "types::GLint",
+        // "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",
+        // "int "                      => "__gl_imports::libc::c_int",
+        // "unsigned int "             => "__gl_imports::libc::c_uint",
+        // "void "                     => "__gl_imports::libc::c_void",
+        "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",
+        // "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 PIXELFORMATDESCRIPTOR *" => "*const types::IXELFORMATDESCRIPTOR",
+        "const USHORT *"            => "*const types::USHORT",
+        // "const char *"              => "*const __gl_imports::libc::c_char",
+        // "const int *"               => "*const __gl_imports::libc::c_int",
+        "float *"                   => "*mut __gl_imports::libc::c_float",
+        // "int *"                     => "*mut __gl_imports::libc::c_int",
+        // "unsigned long *"           => "*mut __gl_imports::libc::c_ulong",
+        // "void *"                    => "*mut __gl_imports::libc::c_void",
 
         // failure
         _ => fail!("Type conversion not implemented for `{}`", ty),
@@ -248,43 +248,43 @@ pub type Src = &'static [&'static str];
 
 pub static GL_ALIASES: Src = &[
     "// Common types from OpenGL 1.1",
-    "pub type GLenum = ::libc::c_uint;",
-    "pub type GLboolean = ::libc::c_uchar;",
-    "pub type GLbitfield = ::libc::c_uint;",
-    "pub type GLvoid = ::libc::c_void;",
-    "pub type GLbyte = ::libc::c_char;",
-    "pub type GLshort = ::libc::c_short;",
-    "pub type GLint = ::libc::c_int;",
-    "pub type GLclampx = ::libc::c_int;",
-    "pub type GLubyte = ::libc::c_uchar;",
-    "pub type GLushort = ::libc::c_ushort;",
-    "pub type GLuint = ::libc::c_uint;",
-    "pub type GLsizei = ::libc::c_int;",
-    "pub type GLfloat = ::libc::c_float;",
-    "pub type GLclampf = ::libc::c_float;",
-    "pub type GLdouble = ::libc::c_double;",
-    "pub type GLclampd = ::libc::c_double;",
-    "pub type GLeglImageOES = *const ::libc::c_void;",
-    "pub type GLchar = ::libc::c_char;",
-    "pub type GLcharARB = ::libc::c_char;",
+    "pub type GLenum = super::__gl_imports::libc::c_uint;",
+    "pub type GLboolean = super::__gl_imports::libc::c_uchar;",
+    "pub type GLbitfield = super::__gl_imports::libc::c_uint;",
+    "pub type GLvoid = super::__gl_imports::libc::c_void;",
+    "pub type GLbyte = super::__gl_imports::libc::c_char;",
+    "pub type GLshort = super::__gl_imports::libc::c_short;",
+    "pub type GLint = super::__gl_imports::libc::c_int;",
+    "pub type GLclampx = super::__gl_imports::libc::c_int;",
+    "pub type GLubyte = super::__gl_imports::libc::c_uchar;",
+    "pub type GLushort = super::__gl_imports::libc::c_ushort;",
+    "pub type GLuint = super::__gl_imports::libc::c_uint;",
+    "pub type GLsizei = super::__gl_imports::libc::c_int;",
+    "pub type GLfloat = super::__gl_imports::libc::c_float;",
+    "pub type GLclampf = super::__gl_imports::libc::c_float;",
+    "pub type GLdouble = super::__gl_imports::libc::c_double;",
+    "pub type GLclampd = super::__gl_imports::libc::c_double;",
+    "pub type GLeglImageOES = *const super::__gl_imports::libc::c_void;",
+    "pub type GLchar = super::__gl_imports::libc::c_char;",
+    "pub type GLcharARB = super::__gl_imports::libc::c_char;",
     "",
     "#[cfg(target_os = \"macos\")]",
-    "pub type GLhandleARB = *const ::libc::c_void;",
+    "pub type GLhandleARB = *const super::__gl_imports::libc::c_void;",
     "#[cfg(not(target_os = \"macos\"))]",
-    "pub type GLhandleARB = ::libc::c_uint;",
+    "pub type GLhandleARB = super::__gl_imports::libc::c_uint;",
     "",
-    "pub type GLhalfARB = ::libc::c_ushort;",
-    "pub type GLhalf = ::libc::c_ushort;",
+    "pub type GLhalfARB = super::__gl_imports::libc::c_ushort;",
+    "pub type GLhalf = super::__gl_imports::libc::c_ushort;",
     "",
     "// Must be 32 bits",
     "pub type GLfixed = GLint;",
     "",
-    "pub type GLintptr = ::libc::ptrdiff_t;",
-    "pub type GLsizeiptr = ::libc::ptrdiff_t;",
+    "pub type GLintptr = super::__gl_imports::libc::ptrdiff_t;",
+    "pub type GLsizeiptr = super::__gl_imports::libc::ptrdiff_t;",
     "pub type GLint64 = i64;",
     "pub type GLuint64 = u64;",
-    "pub type GLintptrARB = ::libc::ptrdiff_t;",
-    "pub type GLsizeiptrARB = ::libc::ptrdiff_t;",
+    "pub type GLintptrARB = super::__gl_imports::libc::ptrdiff_t;",
+    "pub type GLsizeiptrARB = super::__gl_imports::libc::ptrdiff_t;",
     "pub type GLint64EXT = i64;",
     "pub type GLuint64EXT = u64;",
     "",
@@ -295,9 +295,9 @@ pub static GL_ALIASES: Src = &[
     "pub struct _cl_context;",
     "pub struct _cl_event;",
     "",
-    "pub type GLDEBUGPROC = extern \"system\" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut ::libc::c_void);",
-    "pub type GLDEBUGPROCARB = extern \"system\" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut ::libc::c_void);",
-    "pub type GLDEBUGPROCKHR = extern \"system\" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut ::libc::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::libc::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::libc::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::libc::c_void);",
     "",
     // "// GLES 1 types",
     // "pub type GLclampx = i32;",
@@ -329,57 +329,57 @@ pub static GL_ALIASES: Src = &[
     // "// 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 ::libc::c_void);",
-    "pub type GLhalfNV = ::libc::c_ushort;",
+    "pub type GLDEBUGPROCAMD = extern \"system\" fn(id: GLuint, category: GLenum, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut super::__gl_imports::libc::c_void);",
+    "pub type GLhalfNV = super::__gl_imports::libc::c_ushort;",
     "pub type GLvdpauSurfaceNV = GLintptr;",
 ];
 
 pub static X_ALIASES: Src = &[
-    "pub type XID = ::libc::c_ulong;",
-    "pub type Bool = ::libc::c_int;         // Not sure if this is correct...",
+    "pub type XID = super::__gl_imports::libc::c_ulong;",
+    "pub type Bool = super::__gl_imports::libc::c_int;         // Not sure if this is correct...",
     "pub struct Display;",
 ];
 
 pub static GLX_ALIASES: Src = &[
     "pub type GLXFBConfigID = XID;",
-    "pub type GLXFBConfig = *const ::libc::c_void;",
+    "pub type GLXFBConfig = *const super::__gl_imports::libc::c_void;",
     "pub type GLXContextID = XID;",
-    "pub type GLXContext = *const ::libc::c_void;",
+    "pub type GLXContext = *const super::__gl_imports::libc::c_void;",
     "pub type GLXPixmap = XID;",
     "pub type GLXDrawable = XID;",
     "pub type GLXWindow = XID;",
     "pub type GLXPbuffer = XID;",
     "pub type __GLXextFuncPtr = extern \"system\" fn();",
     "pub type GLXVideoCaptureDeviceNV = XID;",
-    "pub type GLXVideoDeviceNV = ::libc::c_int;",
+    "pub type GLXVideoDeviceNV = super::__gl_imports::libc::c_int;",
     "pub type GLXVideoSourceSGIX = XID;",
     "pub type GLXFBConfigIDSGIX = XID;",
-    "pub type GLXFBConfigSGIX = *const ::libc::c_void;",
+    "pub type GLXFBConfigSGIX = *const super::__gl_imports::libc::c_void;",
     "pub type GLXPbufferSGIX = XID;",
     "",
     "pub struct GLXPbufferClobberEvent {",
-    "    event_type: ::libc::c_int,          // GLX_DAMAGED or GLX_SAVED",
-    "    draw_type: ::libc::c_int,           // GLX_WINDOW or GLX_PBUFFER",
-    "    serial: ::libc::c_ulong,            // # of last request processed by server",
+    "    event_type: super::__gl_imports::libc::c_int,          // GLX_DAMAGED or GLX_SAVED",
+    "    draw_type: super::__gl_imports::libc::c_int,           // GLX_WINDOW or GLX_PBUFFER",
+    "    serial: super::__gl_imports::libc::c_ulong,            // # of last request processed by server",
     "    send_event: Bool,           // true if this came for SendEvent request",
     "    display: *const Display,          // display the event was read from",
     "    drawable: GLXDrawable,      // XID of Drawable",
-    "    buffer_mask: ::libc::c_uint,        // mask indicating which buffers are affected",
-    "    aux_buffer: ::libc::c_uint,         // which aux buffer was affected",
-    "    x: ::libc::c_int,",
-    "    y: ::libc::c_int,",
-    "    width: ::libc::c_int,",
-    "    height: ::libc::c_int,",
-    "    count: ::libc::c_int,               // if nonzero, at least this many more",
+    "    buffer_mask: super::__gl_imports::libc::c_uint,        // mask indicating which buffers are affected",
+    "    aux_buffer: super::__gl_imports::libc::c_uint,         // which aux buffer was affected",
+    "    x: super::__gl_imports::libc::c_int,",
+    "    y: super::__gl_imports::libc::c_int,",
+    "    width: super::__gl_imports::libc::c_int,",
+    "    height: super::__gl_imports::libc::c_int,",
+    "    count: super::__gl_imports::libc::c_int,               // if nonzero, at least this many more",
     "}",
     "",
     "pub struct GLXBufferSwapComplete {",
-    "    type: ::libc::c_int,",
-    "    serial: ::libc::c_ulong,            // # of last request processed by server",
+    "    type: super::__gl_imports::libc::c_int,",
+    "    serial: super::__gl_imports::libc::c_ulong,            // # of last request processed by server",
     "    send_event: Bool,           // true if this came from a SendEvent request",
     "    display: *const Display,          // Display the event was read from",
     "    drawable: GLXDrawable,      // drawable on which event was requested in event mask",
-    "    event_type: ::libc::c_int,",
+    "    event_type: super::__gl_imports::libc::c_int,",
     "    ust: i64,",
     "    msc: i64,",
     "    sbc: i64,",
@@ -392,72 +392,72 @@ pub static GLX_ALIASES: Src = &[
     "// } GLXEvent;",
     "",
     "pub struct GLXBufferClobberEventSGIX {",
-    "    type: ::libc::c_int,",
-    "    serial: ::libc::c_ulong,            // # of last request processed by server",
+    "    type: super::__gl_imports::libc::c_int,",
+    "    serial: super::__gl_imports::libc::c_ulong,            // # of last request processed by server",
     "    send_event: Bool,           // true if this came for SendEvent request",
     "    display: *const Display,          // display the event was read from",
     "    drawable: GLXDrawable,      // i.d. of Drawable",
-    "    event_type: ::libc::c_int,          // GLX_DAMAGED_SGIX or GLX_SAVED_SGIX",
-    "    draw_type: ::libc::c_int,           // GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX",
-    "    mask: ::libc::c_uint,               // mask indicating which buffers are affected",
-    "    x: ::libc::c_int,",
-    "    y: ::libc::c_int,",
-    "    width: ::libc::c_int,",
-    "    height: ::libc::c_int,",
-    "    count: ::libc::c_int,               // if nonzero, at least this many more",
+    "    event_type: super::__gl_imports::libc::c_int,          // GLX_DAMAGED_SGIX or GLX_SAVED_SGIX",
+    "    draw_type: super::__gl_imports::libc::c_int,           // GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX",
+    "    mask: super::__gl_imports::libc::c_uint,               // mask indicating which buffers are affected",
+    "    x: super::__gl_imports::libc::c_int,",
+    "    y: super::__gl_imports::libc::c_int,",
+    "    width: super::__gl_imports::libc::c_int,",
+    "    height: super::__gl_imports::libc::c_int,",
+    "    count: super::__gl_imports::libc::c_int,               // if nonzero, at least this many more",
     "}",
     "",
     "pub struct GLXHyperpipeNetworkSGIX {",
-    "    pipeName: [::libc::c_char, ..80],   // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]",
-    "    networkId: ::libc::c_int,",
+    "    pipeName: [super::__gl_imports::libc::c_char, ..80],   // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]",
+    "    networkId: super::__gl_imports::libc::c_int,",
     "}",
     "",
     "pub struct GLXHyperpipeConfigSGIX {",
-    "    pipeName: [::libc::c_char, ..80],   // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]",
-    "    channel: ::libc::c_int,",
-    "    participationType: ::libc::c_uint,",
-    "    timeSlice: ::libc::c_int,",
+    "    pipeName: [super::__gl_imports::libc::c_char, ..80],   // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]",
+    "    channel: super::__gl_imports::libc::c_int,",
+    "    participationType: super::__gl_imports::libc::c_uint,",
+    "    timeSlice: super::__gl_imports::libc::c_int,",
     "}",
     "",
     "pub struct GLXPipeRect {",
-    "    pipeName: [::libc::c_char, ..80],   // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]",
-    "    srcXOrigin: ::libc::c_int,",
-    "    srcYOrigin: ::libc::c_int,",
-    "    srcWidth: ::libc::c_int,",
-    "    srcHeight: ::libc::c_int,",
-    "    destXOrigin: ::libc::c_int,",
-    "    destYOrigin: ::libc::c_int,",
-    "    destWidth: ::libc::c_int,",
-    "    destHeight: ::libc::c_int,",
+    "    pipeName: [super::__gl_imports::libc::c_char, ..80],   // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]",
+    "    srcXOrigin: super::__gl_imports::libc::c_int,",
+    "    srcYOrigin: super::__gl_imports::libc::c_int,",
+    "    srcWidth: super::__gl_imports::libc::c_int,",
+    "    srcHeight: super::__gl_imports::libc::c_int,",
+    "    destXOrigin: super::__gl_imports::libc::c_int,",
+    "    destYOrigin: super::__gl_imports::libc::c_int,",
+    "    destWidth: super::__gl_imports::libc::c_int,",
+    "    destHeight: super::__gl_imports::libc::c_int,",
     "}",
     "",
     "pub struct GLXPipeRectLimits {",
-    "    pipeName: [::libc::c_char, ..80],   // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]",
-    "    XOrigin: ::libc::c_int,",
-    "    YOrigin: ::libc::c_int,",
-    "    maxHeight: ::libc::c_int,",
-    "    maxWidth: ::libc::c_int,",
+    "    pipeName: [super::__gl_imports::libc::c_char, ..80],   // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]",
+    "    XOrigin: super::__gl_imports::libc::c_int,",
+    "    YOrigin: super::__gl_imports::libc::c_int,",
+    "    maxHeight: super::__gl_imports::libc::c_int,",
+    "    maxWidth: super::__gl_imports::libc::c_int,",
     "}",
 ];
 
 pub static WIN_ALIASES: Src = &[
     "// From WinNT.h",
-    "pub type CHAR = ::libc::c_char;",
+    "pub type CHAR = super::__gl_imports::libc::c_char;",
     "pub type HANDLE = PVOID;",
-    "pub type LONG = ::libc::c_long;",
-    "pub type LPCSTR = *const ::libc::c_char;",
-    "pub type VOID = ::libc::c_void;",
+    "pub type LONG = super::__gl_imports::libc::c_long;",
+    "pub type LPCSTR = *const super::__gl_imports::libc::c_char;",
+    "pub type VOID = super::__gl_imports::libc::c_void;",
     "",
     "// From Windef.h",
-    "pub type BOOL = ::libc::c_int;",
-    "pub type BYTE = ::libc::c_uchar;",
+    "pub type BOOL = super::__gl_imports::libc::c_int;",
+    "pub type BYTE = super::__gl_imports::libc::c_uchar;",
     "pub type COLORREF = DWORD;",
-    "pub type FLOAT = ::libc::c_float;",
+    "pub type FLOAT = super::__gl_imports::libc::c_float;",
     "pub type HDC = HANDLE;",
     "pub type HENHMETAFILE = HANDLE;",
-    "pub type HGLRC = *const ::libc::c_void;",
-    "pub type INT = ::libc::c_int;",
-    "pub type LPVOID = *const ::libc::c_void;",
+    "pub type HGLRC = *const super::__gl_imports::libc::c_void;",
+    "pub type INT = super::__gl_imports::libc::c_int;",
+    "pub type LPVOID = *const super::__gl_imports::libc::c_void;",
     "pub type PROC = extern \"system\" fn();     // Not sure about this one :/",
     "pub struct RECT {",
     "    left: LONG,",
@@ -465,16 +465,16 @@ pub static WIN_ALIASES: Src = &[
     "    right: LONG,",
     "    bottom: LONG,",
     "}",
-    "pub type UINT = ::libc::c_uint;",
-    "pub type USHORT = ::libc::c_ushort;",
-    "pub type WORD = ::libc::c_ushort;",
+    "pub type UINT = super::__gl_imports::libc::c_uint;",
+    "pub type USHORT = super::__gl_imports::libc::c_ushort;",
+    "pub type WORD = super::__gl_imports::libc::c_ushort;",
     "",
     "// From BaseTsd.h",
     "pub type INT32 = i32;",
     "pub type INT64 = i64;",
     "",
     "// From IntSafe.h",
-    "pub type DWORD = ::libc::c_ulong;",
+    "pub type DWORD = super::__gl_imports::libc::c_ulong;",
     "",
     "// From Wingdi.h",
     "pub struct POINTFLOAT {",
@@ -488,7 +488,7 @@ pub static WIN_ALIASES: Src = &[
     "    gmfCellIncX: FLOAT,",
     "    gmfCellIncY: FLOAT,",
     "}",
-    "pub type LPGLYPHMETRICSFLOAT = *const GLYPHMETRICSFLOAT;",
+    "pub type LPGLYPHMETRICSFLOAT = *const types::GLYPHMETRICSFLOAT;",
     "pub struct LAYERPLANEDESCRIPTOR {",
     "    nSize: WORD,",
     "    nVersion: WORD,",
@@ -548,11 +548,13 @@ pub static WIN_ALIASES: Src = &[
 pub static WGL_ALIASES: Src = &[
     "// From WinNT.h",
     "// #define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name",
-    "macro_rules! DECLARE_HANDLE(",
-    "    ($name:ident) => (",
-    "        pub type $name = *const ::libc::c_void;",
-    "    )",
-    ")",
+    "pub type HPBUFFERARB = *const super::__gl_imports::libc::c_void;",
+    "pub type HPBUFFEREXT = *const super::__gl_imports::libc::c_void;",
+    "pub type HVIDEOOUTPUTDEVICENV = *const super::__gl_imports::libc::c_void;",
+    "pub type HPVIDEODEV = *const super::__gl_imports::libc::c_void;",
+    "pub type HPGPUNV = *const super::__gl_imports::libc::c_void;",
+    "pub type HGPUNV = *const super::__gl_imports::libc::c_void;",
+    "pub type HVIDEOINPUTDEVICENV = *const super::__gl_imports::libc::c_void;",
     "",
     "pub struct _GPU_DEVICE {",
     "    cb: DWORD,",
@@ -561,13 +563,7 @@ pub static WGL_ALIASES: Src = &[
     "    Flags: DWORD,",
     "    rcVirtualScreen: RECT,",
     "}",
-    "DECLARE_HANDLE!(HPBUFFERARB)",
-    "DECLARE_HANDLE!(HPBUFFEREXT)",
-    "DECLARE_HANDLE!(HVIDEOOUTPUTDEVICENV)",
-    "DECLARE_HANDLE!(HPVIDEODEV)",
-    "DECLARE_HANDLE!(HPGPUNV)",
-    "DECLARE_HANDLE!(HGPUNV)",
-    "DECLARE_HANDLE!(HVIDEOINPUTDEVICENV)",
+
     "pub struct GPU_DEVICE(_GPU_DEVICE);",
     "pub struct PGPU_DEVICE(*const _GPU_DEVICE);",
 ];


Test patch:
diff --git a/tests/struct_generator.rs b/tests/struct_generator.rs
new file mode 100644
index 00000000..e0859900
--- /dev/null
+++ b/tests/struct_generator.rs
@@ -0,0 +1,6 @@
+#![feature(phase)]
+
+#[phase(plugin)]
+extern crate gl_generator;
+
+generate_gl_bindings!("gl", "core", "4.5", "struct")