@@ -29,8 +29,8 @@ use self::xml::EventReader as XmlEventReader;
29
29
use self :: xml:: attribute:: OwnedAttribute ;
30
30
use self :: xml:: reader:: XmlEvent ;
31
31
32
- #[ derive( Copy , Clone ) ]
33
- pub enum Api { Gl , Glx , Wgl , Egl , Gles1 , Gles2 }
32
+ #[ derive( Copy , Clone , PartialEq , Eq ) ]
33
+ pub enum Api { Gl , Glx , Wgl , Egl , GlCore , Gles1 , Gles2 }
34
34
35
35
#[ derive( Copy , Clone ) ]
36
36
pub enum Fallbacks { All , None }
@@ -39,10 +39,11 @@ impl FromStr for Api {
39
39
type Err = ( ) ;
40
40
fn from_str ( s : & str ) -> Result < Api , ( ) > {
41
41
match s {
42
- "gl" => Ok ( Api :: Gl ) ,
42
+ "gl" => Ok ( Api :: Gl ) ,
43
43
"glx" => Ok ( Api :: Glx ) ,
44
44
"wgl" => Ok ( Api :: Wgl ) ,
45
45
"egl" => Ok ( Api :: Egl ) ,
46
+ "glcore" => Ok ( Api :: GlCore ) ,
46
47
"gles1" => Ok ( Api :: Gles1 ) ,
47
48
"gles2" => Ok ( Api :: Gles2 ) ,
48
49
_ => Err ( ( ) ) ,
@@ -57,6 +58,7 @@ impl fmt::Display for Api {
57
58
Api :: Glx => write ! ( fmt, "glx" ) ,
58
59
Api :: Wgl => write ! ( fmt, "wgl" ) ,
59
60
Api :: Egl => write ! ( fmt, "egl" ) ,
61
+ Api :: GlCore => write ! ( fmt, "glcore" ) ,
60
62
Api :: Gles1 => write ! ( fmt, "gles1" ) ,
61
63
Api :: Gles2 => write ! ( fmt, "gles2" ) ,
62
64
}
@@ -69,7 +71,7 @@ fn trim_str<'a>(s: &'a str, trim: &str) -> &'a str {
69
71
70
72
fn trim_enum_prefix < ' a > ( ident : & ' a str , api : Api ) -> & ' a str {
71
73
match api {
72
- Api :: Gl | Api :: Gles1 | Api :: Gles2 => trim_str ( ident, "GL_" ) ,
74
+ Api :: Gl | Api :: GlCore | Api :: Gles1 | Api :: Gles2 => trim_str ( ident, "GL_" ) ,
73
75
Api :: Glx => trim_str ( ident, "GLX_" ) ,
74
76
Api :: Wgl => trim_str ( ident, "WGL_" ) ,
75
77
Api :: Egl => trim_str ( ident, "EGL_" ) ,
@@ -78,7 +80,7 @@ fn trim_enum_prefix<'a>(ident: &'a str, api: Api) -> &'a str {
78
80
79
81
fn trim_cmd_prefix < ' a > ( ident : & ' a str , api : Api ) -> & ' a str {
80
82
match api {
81
- Api :: Gl | Api :: Gles1 | Api :: Gles2 => trim_str ( ident, "gl" ) ,
83
+ Api :: Gl | Api :: GlCore | Api :: Gles1 | Api :: Gles2 => trim_str ( ident, "gl" ) ,
82
84
Api :: Glx => trim_str ( ident, "glX" ) ,
83
85
Api :: Wgl => trim_str ( ident, "wgl" ) ,
84
86
Api :: Egl => trim_str ( ident, "egl" ) ,
@@ -219,7 +221,7 @@ pub struct Cmd {
219
221
220
222
#[ derive( Clone ) ]
221
223
pub struct Feature {
222
- pub api : String ,
224
+ pub api : Api ,
223
225
pub name : String ,
224
226
pub number : String ,
225
227
pub requires : Vec < Require > ,
@@ -248,7 +250,7 @@ pub struct Remove {
248
250
pub struct Extension {
249
251
pub name : String ,
250
252
/// which apis this extension is defined for (see Feature.api)
251
- pub supported : Vec < String > ,
253
+ pub supported : Vec < Api > ,
252
254
pub requires : Vec < Require > ,
253
255
}
254
256
@@ -265,11 +267,11 @@ struct RegistryBuilder<R: io::Read> {
265
267
}
266
268
267
269
pub struct Filter {
270
+ pub api : Api ,
268
271
pub fallbacks : Fallbacks ,
269
272
pub extensions : Vec < String > ,
270
273
pub profile : String ,
271
274
pub version : String ,
272
- pub api : String ,
273
275
}
274
276
275
277
/// A big, ugly, imperative impl with methods that accumulates a Registry struct
@@ -679,9 +681,10 @@ impl FromXml for Remove {
679
681
impl FromXml for Feature {
680
682
fn convert < R : io:: Read > ( r : & mut RegistryBuilder < R > , a : & [ OwnedAttribute ] ) -> Feature {
681
683
debug ! ( "Doing a FromXml on Feature" ) ;
682
- let api = get_attribute ( a, "api" ) . unwrap ( ) ;
683
- let name = get_attribute ( a, "name" ) . unwrap ( ) ;
684
- let number = get_attribute ( a, "number" ) . unwrap ( ) ;
684
+ let api = get_attribute ( a, "api" ) . unwrap ( ) ;
685
+ let api = Api :: from_str ( & * api) . unwrap ( ) ;
686
+ let name = get_attribute ( a, "name" ) . unwrap ( ) ;
687
+ let number = get_attribute ( a, "number" ) . unwrap ( ) ;
685
688
686
689
debug ! ( "Found api = {}, name = {}, number = {}" , api, name, number) ;
687
690
@@ -701,7 +704,11 @@ impl FromXml for Extension {
701
704
fn convert < R : io:: Read > ( r : & mut RegistryBuilder < R > , a : & [ OwnedAttribute ] ) -> Extension {
702
705
debug ! ( "Doing a FromXml on Extension" ) ;
703
706
let name = get_attribute ( a, "name" ) . unwrap ( ) ;
704
- let supported = get_attribute ( a, "supported" ) . unwrap ( ) . split ( '|' ) . map ( |x| x. to_string ( ) ) . collect :: < Vec < String > > ( ) ;
707
+ let supported = get_attribute ( a, "supported" ) . unwrap ( )
708
+ . split ( '|' )
709
+ . map ( |x| Api :: from_str ( x) )
710
+ . map ( Result :: unwrap)
711
+ . collect :: < Vec < _ > > ( ) ;
705
712
let mut require = Vec :: new ( ) ;
706
713
loop {
707
714
match r. next ( ) {
0 commit comments