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

Issue:
git submodule object doesn't exist
I can't seem to build the latest version due to "Server doesn't allow request for unadvertised object":

```
$ git clone --recurse-submodules https://github.com/bjz/gl-rs
Cloning into 'gl-rs'...
remote: Counting objects: 3773, done.
remote: Total 3773 (delta 0), reused 0 (delta 0), pack-reused 3773
Receiving objects: 100% (3773/3773), 2.37 MiB | 1.16 MiB/s, done.
Resolving deltas: 100% (2080/2080), done.
Submodule 'khronos_api/api' (https://github.com/capnm/Khronos_XML_API) registered for path 'khronos_api/api'
Cloning into '/Users/engstad/Src/Misc/gl-rs/khronos_api/api'...
remote: Counting objects: 1779, done.
remote: Total 1779 (delta 0), reused 0 (delta 0), pack-reused 1779
Receiving objects: 100% (1779/1779), 2.27 MiB | 808.00 KiB/s, done.
Resolving deltas: 100% (1534/1534), done.
error: Server does not allow request for unadvertised object 035f76ad3fe49cd928f073673f80e8247425b5c7
Fetched in submodule path 'khronos_api/api', but it did not contain 035f76ad3fe49cd928f073673f80e8247425b5c7. Direct fetching of that commit failed.
```


Discussion / hints:
Same here, installing through Cargo:

~~~~
error: failed to load source for a dependency on `gl`

Caused by:
  Unable to update https://github.com/bjz/gl-rs#e4a3bb70

Caused by:
  failed to update submodule `khronos_api/api`

Caused by:
  [9/-3] object not found - no match for id (035f76ad3fe49cd928f073673f80e8247425b5c7)
~~~~
Things do seem to work (at least I can build, but then hit an unrelated issue) if I just clone the repository (without `--recursive`) and then do

~~~~
mv .gitmodules .gitmodules.old
rm -fr khronos_api/api/
git add khronos_api/api
git commit -m "Test"
git submodule add https://github.com/capnm/Khronos_XML_API.git khronos_api/api
~~~~

Fix patch:
diff --git a/.gitmodules b/.gitmodules
index 01e0f355..1de003d8 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
-[submodule "khronos_api/api"]
-	path = khronos_api/api
-	url = https://github.com/capnm/Khronos_XML_API
+[submodule "khronos_api/api"]
+	path = khronos_api/api
+	url = https://github.com/KhronosGroup/OpenGL-Registry.git
+[submodule "khronos_api/api_egl"]
+	path = khronos_api/api_egl
+	url = https://github.com/KhronosGroup/EGL-Registry.git
diff --git a/gl_generator/generators/global_gen.rs b/gl_generator/generators/global_gen.rs
index 060d671d..cfc1be95 100644
--- a/gl_generator/generators/global_gen.rs
+++ b/gl_generator/generators/global_gen.rs
@@ -57,7 +57,7 @@ fn write_metaloadfn<W>(dest: &mut W) -> io::Result<()>
     writeln!(dest,
              r#"
         #[inline(never)]
-        fn metaloadfn(mut loadfn: &mut FnMut(&str) -> *const __gl_imports::raw::c_void,
+        fn metaloadfn(loadfn: &mut FnMut(&str) -> *const __gl_imports::raw::c_void,
                       symbol: &str,
                       fallbacks: &[&str]) -> *const __gl_imports::raw::c_void {{
             let mut ptr = loadfn(symbol);
diff --git a/gl_generator/generators/mod.rs b/gl_generator/generators/mod.rs
index 59c5b3ec..6d823447 100644
--- a/gl_generator/generators/mod.rs
+++ b/gl_generator/generators/mod.rs
@@ -37,6 +37,7 @@ pub fn gen_struct_name(api: Api) -> &'static str {
         Api::GlCore => "GlCore",
         Api::Gles1 => "Gles1",
         Api::Gles2 => "Gles2",
+        Api::Glsc2 => "Glsc2",
     }
 }
 
@@ -100,7 +101,7 @@ pub fn gen_parameters(cmd: &Cmd, with_idents: bool, with_types: bool) -> Vec<Str
 /// Example results: `"glClear"`, `"wglCreateContext"`, etc.
 pub fn gen_symbol_name(api: Api, cmd: &str) -> String {
     match api {
-        Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 => format!("gl{}", cmd),
+        Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 | Api::Glsc2 => format!("gl{}", cmd),
         Api::Glx => format!("glX{}", cmd),
         Api::Wgl => format!("wgl{}", cmd),
         Api::Egl => format!("egl{}", cmd),
diff --git a/gl_generator/registry/mod.rs b/gl_generator/registry/mod.rs
index 221cd16e..73642aed 100644
--- a/gl_generator/registry/mod.rs
+++ b/gl_generator/registry/mod.rs
@@ -34,6 +34,7 @@ pub enum Api {
     GlCore,
     Gles1,
     Gles2,
+    Glsc2,
 }
 
 impl fmt::Display for Api {
@@ -46,6 +47,7 @@ impl fmt::Display for Api {
             Api::GlCore => write!(fmt, "glcore"),
             Api::Gles1 => write!(fmt, "gles1"),
             Api::Gles2 => write!(fmt, "gles2"),
+            Api::Glsc2 => write!(fmt, "glsc2"),
         }
     }
 }
@@ -137,7 +139,7 @@ impl Registry {
         };
 
         let src = match api {
-            Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 => khronos_api::GL_XML,
+            Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 | Api::Glsc2 => khronos_api::GL_XML,
             Api::Glx => khronos_api::GLX_XML,
             Api::Wgl => khronos_api::WGL_XML,
             Api::Egl => khronos_api::EGL_XML,
diff --git a/gl_generator/registry/parse.rs b/gl_generator/registry/parse.rs
index dc5b2cdb..32f5c8e3 100644
--- a/gl_generator/registry/parse.rs
+++ b/gl_generator/registry/parse.rs
@@ -92,6 +92,7 @@ fn api_from_str(src: &str) -> Result<Api, ()> {
         "glcore" => Ok(Api::GlCore),
         "gles1" => Ok(Api::Gles1),
         "gles2" => Ok(Api::Gles2),
+        "glsc2" => Ok(Api::Glsc2),
         _ => Err(()),
     }
 }
@@ -130,7 +131,7 @@ fn trim_str<'a>(s: &'a str, trim: &str) -> &'a str {
 
 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::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 | Api::Glsc2 => trim_str(ident, "GL_"),
         Api::Glx => trim_str(ident, "GLX_"),
         Api::Wgl => trim_str(ident, "WGL_"),
         Api::Egl => trim_str(ident, "EGL_"),
@@ -150,6 +151,18 @@ fn make_enum(ident: String, ty: Option<String>, value: String, alias: Option<Str
                 let ty = working[..i].to_string();
                 let value = working[i + 1..].to_string();
 
+                (Cow::Owned(ty), value, true)
+            } else {
+                panic!("Unexpected value format: {}", value)
+            }
+        } else if value.starts_with("EGL_CAST(") && value.ends_with(")") {
+            // Handling "SpecialNumbers" in the egl.xml file
+            // The values for these enums has the form `'EGL_CAST(' type ',' expr ')'`.
+            let working = &value[9..value.len() - 1];
+            if let Some((i, _)) = working.match_indices(",").next() {
+                let ty = working[..i].to_string();
+                let value = working[i + 1..].to_string();
+
                 (Cow::Owned(ty), value, true)
             } else {
                 panic!("Unexpected value format: {}", value)
@@ -178,7 +191,7 @@ fn make_enum(ident: String, ty: Option<String>, value: String, alias: Option<Str
 
 fn trim_cmd_prefix(ident: &str, api: Api) -> &str {
     match api {
-        Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 => trim_str(ident, "gl"),
+        Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 | Api::Glsc2 => trim_str(ident, "gl"),
         Api::Glx => trim_str(ident, "glX"),
         Api::Wgl => trim_str(ident, "wgl"),
         Api::Egl => trim_str(ident, "egl"),
@@ -975,6 +988,15 @@ pub fn to_rust_ty<T: AsRef<str>>(ty: T) -> Cow<'static, str> {
         "EGLOutputPortEXT *" => "*mut types::EGLOutputPortEXT",
         "EGLuint64KHR *" => "*mut types::EGLuint64KHR",
 
+        "GLeglClientBufferEXT" => "types::GLeglClientBufferEXT",
+        "GLint " => "types::GLint",
+        "GLVULKANPROCNV" => "type::GLVULKANPROCNV",
+        "EGLDEBUGPROCKHR" => "type::EGLDEBUGPROCKHR",
+        "EGLObjectKHR" => "type::EGLObjectKHR",
+        "EGLLabelKHR" => "type::EGLLabelKHR",
+        "EGLnsecsANDROID" => "type::EGLnsecsANDROID",
+        "EGLBoolean *" => "*mut type::EGLBoolean",
+
         // failure
         _ => panic!("Type conversion not implemented for `{}`", ty.as_ref()),
     };
@@ -1042,6 +1064,17 @@ mod tests {
             assert_eq!(e.alias, Some("BAR".to_string()));
         }
 
+        #[test]
+        fn test_cast_egl() {
+            let e = parse::make_enum("FOO".to_string(),
+                                     None,
+                                     "EGL_CAST(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()));
+        }
+
         #[test]
         fn test_no_type() {
             let e = parse::make_enum("FOO".to_string(),
diff --git a/khronos_api/api b/khronos_api/api
index 035f76ad..86be6b7d 160000
--- a/khronos_api/api
+++ b/khronos_api/api
@@ -1,1 +1,1 @@
-Subproject commit 035f76ad3fe49cd928f073673f80e8247425b5c7
+Subproject commit 86be6b7d39c53d1bd9d38045f21b8dff53c7c616
diff --git a/khronos_api/api_egl b/khronos_api/api_egl
new file mode 160000
index 00000000..89be4fbc
--- /dev/null
+++ b/khronos_api/api_egl
@@ -0,0 +1,1 @@
+Subproject commit 89be4fbc3ace60f03c0f3b221fff3b6c772bc21e
diff --git a/khronos_api/src/lib.rs b/khronos_api/src/lib.rs
index a391da2e..8651cac3 100644
--- a/khronos_api/src/lib.rs
+++ b/khronos_api/src/lib.rs
@@ -14,14 +14,14 @@
 
 //! This crates contains the sources of the official OpenGL repository.
 
-/// The contents of [`gl.xml`](https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml)
-pub const GL_XML: &'static [u8] = include_bytes!("../api/gl.xml");
+/// The contents of [`gl.xml`](https://github.com/KhronosGroup/OpenGL-Registry/blob/master/xml/gl.xml)
+pub const GL_XML: &'static [u8] = include_bytes!("../api/xml/gl.xml");
 
-/// The contents of [`egl.xml`](https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/egl.xml)
-pub const EGL_XML: &'static [u8] = include_bytes!("../api/egl.xml");
+/// The contents of [`egl.xml`](https://github.com/KhronosGroup/EGL-Registry/blob/master/api/egl.xml)
+pub const EGL_XML: &'static [u8] = include_bytes!("../api_egl/api/egl.xml");
 
-/// The contents of [`wgl.xml`](https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/wgl.xml)
-pub const WGL_XML: &'static [u8] = include_bytes!("../api/wgl.xml");
+/// The contents of [`wgl.xml`](https://github.com/KhronosGroup/OpenGL-Registry/blob/master/xml/wgl.xml)
+pub const WGL_XML: &'static [u8] = include_bytes!("../api/xml/wgl.xml");
 
-/// The contents of [`glx.xml`](https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/glx.xml)
-pub const GLX_XML: &'static [u8] = include_bytes!("../api/glx.xml");
+/// The contents of [`glx.xml`](https://github.com/KhronosGroup/OpenGL-Registry/blob/master/xml/glx.xml)
+pub const GLX_XML: &'static [u8] = include_bytes!("../api/xml/glx.xml");


Test patch: