diff --git a/README.md b/README.md index 1ac78352..c267ee8b 100644 --- a/README.md +++ b/README.md @@ -160,3 +160,12 @@ implementations for these APIs. You will need to manually provide the linkage. For example to use WGL or OpenGL 1.1 on Windows, you will need to add `#[link="OpenGL32.lib"] extern {}` somewhere in your code. + +### Custom Generators + +The `gl_generator` crate is extensible. This is a niche feature useful only in +very rare cases. To create a custom generator, [create a new plugin +crate](http://doc.rust-lang.org/guide-plugin.html#syntax-extensions) which +depends on `gl_generator`. Then, implement the `gl_generator::Generator` trait +and in your plugin registrar, register a function which calls +`gl_generator::generate_bindings` with your custom generator and its name. diff --git a/src/gl_generator/lib.rs b/src/gl_generator/lib.rs index 9f948430..1cc3927f 100644 --- a/src/gl_generator/lib.rs +++ b/src/gl_generator/lib.rs @@ -141,14 +141,14 @@ fn macro_handler(ecx: &mut ExtCtxt, span: Span, tts: &[TokenTree]) -> Box)>) -> Box { + generators: Vec<(&str, Box)>) -> Box { // Generator options let mut api = None::<(Ns, &'static [u8])>; let mut profile = None::; let mut version = None::; let mut generator = None::>; let mut extensions = None::>; - let mut custom_generators = Some(custom_generators); + let mut generators = Some(generators); let tts = drop_trailing_comma(tts); @@ -255,8 +255,8 @@ pub fn generate_bindings(ecx: &mut ExtCtxt, span: Span, tts: &[TokenTree], } match tts { [&TtToken(span, token::LitStr(gen))] => { - if custom_generators.is_none() { continue; } - for (name, generator_) in custom_generators.take().unwrap().into_iter() { + if generators.is_none() { continue; } + for (name, generator_) in generators.take().unwrap().into_iter() { if name == gen.as_str() { generator = Some(generator_); break;