12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- use registry:: { Registry , Ns } ;
15
+ use registry:: Registry ;
16
16
use std:: io;
17
17
18
18
#[ allow( missing_copy_implementations) ]
19
19
pub struct DebugStructGenerator ;
20
20
21
21
impl super :: Generator for DebugStructGenerator {
22
- fn write < W > ( & self , registry : & Registry , ns : Ns , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
22
+ fn write < W > ( & self , registry : & Registry , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
23
23
try!( write_header ( dest) ) ;
24
- try!( write_type_aliases ( & ns , dest) ) ;
24
+ try!( write_type_aliases ( registry , dest) ) ;
25
25
try!( write_enums ( registry, dest) ) ;
26
26
try!( write_fnptr_struct_def ( dest) ) ;
27
- try!( write_panicking_fns ( & ns , dest) ) ;
28
- try!( write_struct ( registry, & ns , dest) ) ;
29
- try!( write_impl ( registry, & ns , dest) ) ;
27
+ try!( write_panicking_fns ( registry , dest) ) ;
28
+ try!( write_struct ( registry, dest) ) ;
29
+ try!( write_impl ( registry, dest) ) ;
30
30
Ok ( ( ) )
31
31
}
32
32
}
@@ -46,7 +46,7 @@ fn write_header<W>(dest: &mut W) -> io::Result<()> where W: io::Write {
46
46
/// Creates a `types` module which contains all the type aliases.
47
47
///
48
48
/// See also `generators::gen_type_aliases`.
49
- fn write_type_aliases < W > ( ns : & Ns , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
49
+ fn write_type_aliases < W > ( registry : & Registry , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
50
50
try!( writeln ! ( dest, r#"
51
51
pub mod types {{
52
52
#![allow(non_camel_case_types)]
@@ -55,7 +55,7 @@ fn write_type_aliases<W>(ns: &Ns, dest: &mut W) -> io::Result<()> where W: io::W
55
55
#![allow(missing_copy_implementations)]
56
56
"# ) ) ;
57
57
58
- try!( super :: gen_type_aliases ( ns , dest) ) ;
58
+ try!( super :: gen_type_aliases ( registry . api , dest) ) ;
59
59
60
60
writeln ! ( dest, "}}" )
61
61
}
@@ -111,27 +111,27 @@ fn write_fnptr_struct_def<W>(dest: &mut W) -> io::Result<()> where W: io::Write
111
111
/// Creates a `panicking` module which contains one function per GL command.
112
112
///
113
113
/// These functions are the mocks that are called if the real function could not be loaded.
114
- fn write_panicking_fns < W > ( ns : & Ns , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
114
+ fn write_panicking_fns < W > ( registry : & Registry , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
115
115
writeln ! ( dest,
116
116
"#[inline(never)]
117
117
fn missing_fn_panic() -> ! {{
118
- panic!(\" {ns } function was not loaded\" )
118
+ panic!(\" {api } function was not loaded\" )
119
119
}}" ,
120
- ns = ns
120
+ api = registry . api
121
121
)
122
122
}
123
123
124
124
/// Creates a structure which stores all the `FnPtr` of the bindings.
125
125
///
126
126
/// The name of the struct corresponds to the namespace.
127
- fn write_struct < W > ( registry : & Registry , ns : & Ns , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
127
+ fn write_struct < W > ( registry : & Registry , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
128
128
try!( writeln ! ( dest, "
129
129
#[allow(non_camel_case_types)]
130
130
#[allow(non_snake_case)]
131
131
#[allow(dead_code)]
132
132
#[derive(Clone)]
133
- pub struct {ns } {{" ,
134
- ns = ns . fmt_struct_name ( )
133
+ pub struct {api } {{" ,
134
+ api = super :: gen_struct_name ( registry . api )
135
135
) ) ;
136
136
137
137
for c in registry. cmd_iter ( ) {
@@ -145,9 +145,9 @@ fn write_struct<W>(registry: &Registry, ns: &Ns, dest: &mut W) -> io::Result<()>
145
145
}
146
146
147
147
/// Creates the `impl` of the structure created by `write_struct`.
148
- fn write_impl < W > ( registry : & Registry , ns : & Ns , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
148
+ fn write_impl < W > ( registry : & Registry , dest : & mut W ) -> io:: Result < ( ) > where W : io:: Write {
149
149
try!( writeln ! ( dest,
150
- "impl {ns } {{
150
+ "impl {api } {{
151
151
/// Load each OpenGL symbol using a custom load function. This allows for the
152
152
/// use of functions like `glfwGetProcAddress` or `SDL_GL_GetProcAddress`.
153
153
///
@@ -156,7 +156,7 @@ fn write_impl<W>(registry: &Registry, ns: &Ns, dest: &mut W) -> io::Result<()> w
156
156
/// ~~~
157
157
#[allow(dead_code)]
158
158
#[allow(unused_variables)]
159
- pub fn load_with<F>(mut loadfn: F) -> {ns } where F: FnMut(&str) -> *const __gl_imports::raw::c_void {{
159
+ pub fn load_with<F>(mut loadfn: F) -> {api } where F: FnMut(&str) -> *const __gl_imports::raw::c_void {{
160
160
let mut metaloadfn = |symbol: &str, symbols: &[&str]| {{
161
161
let mut ptr = loadfn(symbol);
162
162
if ptr.is_null() {{
@@ -167,19 +167,19 @@ fn write_impl<W>(registry: &Registry, ns: &Ns, dest: &mut W) -> io::Result<()> w
167
167
}}
168
168
ptr
169
169
}};
170
- {ns } {{" ,
171
- ns = ns . fmt_struct_name ( )
170
+ {api } {{" ,
171
+ api = super :: gen_struct_name ( registry . api )
172
172
) ) ;
173
173
174
174
for c in registry. cmd_iter ( ) {
175
175
try!( writeln ! ( dest,
176
176
"{name}: FnPtr::new(metaloadfn(\" {symbol}\" , &[{fallbacks}]))," ,
177
177
name = c. proto. ident,
178
- symbol = super :: gen_symbol_name( ns , & c. proto. ident) ,
178
+ symbol = super :: gen_symbol_name( registry . api , & c. proto. ident) ,
179
179
fallbacks = match registry. aliases. get( & c. proto. ident) {
180
180
Some ( fbs) => {
181
181
fbs. iter( )
182
- . map( |name| format!( "\" {}\" " , super :: gen_symbol_name( ns , & name) ) )
182
+ . map( |name| format!( "\" {}\" " , super :: gen_symbol_name( registry . api , & name) ) )
183
183
. collect:: <Vec <_>>( ) . join( ", " )
184
184
} ,
185
185
None => format!( "" ) ,
@@ -234,7 +234,7 @@ fn write_impl<W>(registry: &Registry, ns: &Ns, dest: &mut W) -> io::Result<()> w
234
234
writeln ! ( dest,
235
235
"}}
236
236
237
- unsafe impl __gl_imports::Send for {ns } {{}}" ,
238
- ns = ns . fmt_struct_name ( )
237
+ unsafe impl __gl_imports::Send for {api } {{}}" ,
238
+ api = super :: gen_struct_name ( registry . api )
239
239
)
240
240
}
0 commit comments