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

Issue:
Updated fo Rust 0dfc90a: *const, *mut



Discussion / hints:

Fix patch:
diff --git a/deps/glfw-rs b/deps/glfw-rs
index 61518cbd..dc86d083 160000
--- a/deps/glfw-rs
+++ b/deps/glfw-rs
@@ -1,1 +1,1 @@
-Subproject commit 61518cbd524d33411622c86352e9b4343b4fee90
+Subproject commit dc86d083b4aa3126869c1a458aca412cbe8efb27
diff --git a/deps/sax-rs b/deps/sax-rs
index a5ae75fa..ff9308ab 160000
--- a/deps/sax-rs
+++ b/deps/sax-rs
@@ -1,1 +1,1 @@
-Subproject commit a5ae75fa386534226c8c3082c607b696c2c30382
+Subproject commit ff9308ab77297ca3f6d5c9fd0327ea17d3d6d3df
diff --git a/src/examples/basic.rs b/src/examples/basic.rs
index 3ba597a6..6e952d09 100644
--- a/src/examples/basic.rs
+++ b/src/examples/basic.rs
@@ -20,7 +20,7 @@ extern crate native;
 use glfw::Context;
 
 #[start]
-fn start(argc: int, argv: **u8) -> int {
+fn start(argc: int, argv: *const *const u8) -> int {
     native::start(argc, argv, main)
 }
 
diff --git a/src/examples/triangle.rs b/src/examples/triangle.rs
index 6a5dd0a6..d6e2a22e 100644
--- a/src/examples/triangle.rs
+++ b/src/examples/triangle.rs
@@ -48,7 +48,7 @@ static FS_SRC: &'static str =
     }";
 
 #[start]
-fn start(argc: int, argv: **u8) -> int {
+fn start(argc: int, argv: *const *const u8) -> int {
     native::start(argc, argv, main)
 }
 
diff --git a/src/gen/main.rs b/src/gen/main.rs
index 5086b0f6..ed5fe24d 100644
--- a/src/gen/main.rs
+++ b/src/gen/main.rs
@@ -283,10 +283,10 @@ impl<'a, W: Writer> Generator<'a, W> {
     }
 
     fn write_fnptr_struct_def(&mut self) {
-        self.write_line("pub struct FnPtr { f: *libc::c_void, is_loaded: bool }");
+        self.write_line("pub struct FnPtr { f: *const libc::c_void, is_loaded: bool }");
         self.write_line("");
         self.write_line("impl FnPtr {");
-        self.write_line("    pub fn new(ptr: *libc::c_void, failing_fn: *libc::c_void) -> FnPtr {");
+        self.write_line("    pub fn new(ptr: *const libc::c_void, failing_fn: *const 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 {");
@@ -359,7 +359,7 @@ impl<'a, W: Writer> Generator<'a, W> {
         for c in self.registry.cmd_iter() {
             self.write_line(format!(
                 "pub static mut {name}: FnPtr = FnPtr {{ \
-                    f: failing::{name} as *libc::c_void, \
+                    f: failing::{name} as *const libc::c_void, \
                     is_loaded: false \
                 }};",
                 name = c.proto.ident,
@@ -376,8 +376,8 @@ impl<'a, W: Writer> Generator<'a, W> {
         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| -> *::libc::c_void) {");
-        self.write_line("                unsafe { ::storage::$name = ::FnPtr::new(loadfn($sym), ::failing::$name as *::libc::c_void) }");
+        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("    }");
@@ -411,7 +411,7 @@ impl<'a, W: Writer> Generator<'a, W> {
         self.write_line("/// ~~~");
         self.write_line("/// let gl = gl::load_with(glfw::get_proc_address);");
         self.write_line("/// ~~~");
-        self.write_line("pub fn load_with(loadfn: |symbol: &str| -> *libc::c_void) {");
+        self.write_line("pub fn load_with(loadfn: |symbol: &str| -> *const 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());
diff --git a/src/gen/ty.rs b/src/gen/ty.rs
index 1a4f6bb3..6fd6fc13 100644
--- a/src/gen/ty.rs
+++ b/src/gen/ty.rs
@@ -16,7 +16,7 @@
 pub fn to_return_suffix(ty: &str) -> String {
     match ty {
         "c_void" | "VOID" | "GLvoid" => "".to_str(),
-        ty_str => format!(" -> {}", ty_str.replace("*mut ", "*")),
+        ty_str => format!(" -> {}", ty_str.replace("*mut ", "*const ")),
     }
 }
 
@@ -75,43 +75,43 @@ pub fn to_rust_ty(ty: &str) -> &'static str {
         "GLuint64EXT *"             => "*mut GLuint64EXT",
         "GLushort *"                => "*mut GLushort",
         "GLvoid *"                  => "*mut GLvoid",
-        "GLvoid **"                 => "**mut GLvoid",
+        "GLvoid **"                 => "*const *mut GLvoid",
         "void *"                    => "*mut c_void",
-        "void **"                   => "**mut c_void",
-        "const GLboolean *"         => "*GLboolean",
-        "const GLbyte *"            => "*GLbyte",
-        "const GLchar *"            => "*GLchar",
-        "const GLcharARB *"         => "*GLcharARB",
-        "const GLclampf *"          => "*GLclampf",
-        "const GLdouble *"          => "*GLdouble",
-        "const GLenum *"            => "*GLenum",
-        "const GLfixed *"           => "*GLfixed",
-        "const GLfloat *"           => "*GLfloat",
-        "const GLhalfNV *"          => "*GLhalfNV",
-        "const GLint *"             => "*GLint",
-        "const GLint64EXT *"        => "*GLint64EXT",
-        "const GLintptr *"          => "*GLintptr",
-        "const GLshort *"           => "*GLshort",
-        "const GLsizei *"           => "*GLsizei",
-        "const GLsizeiptr *"        => "*GLsizeiptr",
-        "const GLubyte *"           => "*GLubyte",
-        "const GLuint *"            => "*GLuint",
-        "const GLuint64 *"          => "*GLuint64",
-        "const GLuint64EXT *"       => "*GLuint64EXT",
-        "const GLushort *"          => "*GLushort",
-        "const GLvdpauSurfaceNV *"  => "*GLvdpauSurfaceNV",
-        "const GLvoid *"            => "*GLvoid",
-        "const void *"              => "*c_void",
-        "const void **"             => "**c_void",
-        "const void *const*"        => "**c_void",
-        "const GLboolean **"        => "**GLboolean",
-        "const GLchar **"           => "**GLchar",
-        "const GLcharARB **"        => "**GLcharARB",
-        "const GLvoid **"           => "**GLvoid",
-        "const GLchar *const*"      => "**GLchar",
-        "const GLvoid *const*"      => "**GLvoid",
-        "struct _cl_context *"      => "*_cl_context",
-        "struct _cl_event *"        => "*_cl_event",
+        "void **"                   => "*const *mut 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 *"           => "*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 c_void",
+        "const void **"             => "*const *const c_void",
+        "const void *const*"        => "*const *const 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",
 
         // glx.xml types
         "Bool"                      => "Bool",
@@ -160,9 +160,9 @@ pub fn to_rust_ty(ty: &str) -> &'static str {
         // "GLuint *"                  => "*mut GLuint",
         "XVisualInfo *"             => "*mut XVisualInfo",
         // "const GLubyte *"           => "*GLubyte",
-        "const char *"              => "*c_char",
-        "const int *"               => "*c_int",
-        // "const void *"              => "*c_void",
+        "const char *"              => "*const c_char",
+        "const int *"               => "*const c_int",
+        // "const void *"              => "*const c_void",
         "int *"                     => "*mut c_int",
         "int32_t *"                 => "*mut i32",
         "int64_t *"                 => "*mut i64",
@@ -218,18 +218,18 @@ pub fn to_rust_ty(ty: &str) -> &'static str {
         "INT64 *"                   => "*mut INT64",
         "UINT *"                    => "*mut UINT",
         "USHORT *"                  => "*mut USHORT",
-        "const COLORREF *"          => "*COLORREF",
-        "const DWORD *"             => "*DWORD",
-        "const FLOAT *"             => "*FLOAT",
-        // "const GLushort *"          => "*GLushort",
-        "const HANDLE *"            => "*HANDLE",
-        "const HGPUNV *"            => "*HGPUNV",
-        "const LAYERPLANEDESCRIPTOR *"  => "*LAYERPLANEDESCRIPTOR",
-        "const LPVOID *"            => "*LPVOID",
-        "const PIXELFORMATDESCRIPTOR *" => "*PIXELFORMATDESCRIPTOR",
-        "const USHORT *"            => "*USHORT",
-        // "const char *"              => "*c_char",
-        // "const int *"               => "*c_int",
+        "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 c_char",
+        // "const int *"               => "*const c_int",
         "float *"                   => "*mut c_float",
         // "int *"                     => "*mut c_int",
         // "unsigned long *"           => "*mut c_ulong",
@@ -260,12 +260,12 @@ pub static GL_ALIASES: Src = &[
     "pub type GLclampf = c_float;",
     "pub type GLdouble = c_double;",
     "pub type GLclampd = c_double;",
-    "pub type GLeglImageOES = *c_void;",
+    "pub type GLeglImageOES = *const c_void;",
     "pub type GLchar = c_char;",
     "pub type GLcharARB = c_char;",
     "",
     "#[cfg(target_os = \"macos\")]",
-    "pub type GLhandleARB = *c_void;",
+    "pub type GLhandleARB = *const c_void;",
     "#[cfg(not(target_os = \"macos\"))]",
     "pub type GLhandleARB = c_uint;",
     "",
@@ -285,15 +285,15 @@ pub static GL_ALIASES: Src = &[
     "pub type GLuint64EXT = u64;",
     "",
     "pub struct __GLsync;",
-    "pub type GLsync = *__GLsync;",
+    "pub type GLsync = *const __GLsync;",
     "",
     "// compatible with OpenCL cl_context",
     "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: *GLchar, userParam: *c_void);",
-    "pub type GLDEBUGPROCARB = extern \"system\" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *GLchar, userParam: *c_void);",
-    "pub type GLDEBUGPROCKHR = extern \"system\" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *GLchar, userParam: *c_void);",
+    "pub type GLDEBUGPROC = extern \"system\" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut c_void);",
+    "pub type GLDEBUGPROCARB = extern \"system\" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut c_void);",
+    "pub type GLDEBUGPROCKHR = extern \"system\" fn(source: GLenum, gltype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut c_void);",
     "",
     // "// GLES 1 types",
     // "pub type GLclampx = i32;",
@@ -325,7 +325,7 @@ 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: *GLchar, userParam: *c_void);",
+    "pub type GLDEBUGPROCAMD = extern \"system\" fn(id: GLuint, category: GLenum, severity: GLenum, length: GLsizei, message: *const GLchar, userParam: *mut c_void);",
     "pub type GLhalfNV = c_ushort;",
     "pub type GLvdpauSurfaceNV = GLintptr;",
 ];
@@ -338,9 +338,9 @@ pub static X_ALIASES: Src = &[
 
 pub static GLX_ALIASES: Src = &[
     "pub type GLXFBConfigID = XID;",
-    "pub type GLXFBConfig = *c_void;",
+    "pub type GLXFBConfig = *const c_void;",
     "pub type GLXContextID = XID;",
-    "pub type GLXContext = *c_void;",
+    "pub type GLXContext = *const c_void;",
     "pub type GLXPixmap = XID;",
     "pub type GLXDrawable = XID;",
     "pub type GLXWindow = XID;",
@@ -350,7 +350,7 @@ pub static GLX_ALIASES: Src = &[
     "pub type GLXVideoDeviceNV = unsigned int;",
     "pub type GLXVideoSourceSGIX = XID;",
     "pub type GLXFBConfigIDSGIX = XID;",
-    "pub type GLXFBConfigSGIX = *c_void;",
+    "pub type GLXFBConfigSGIX = *const c_void;",
     "pub type GLXPbufferSGIX = XID;",
     "",
     "pub struct GLXPbufferClobberEvent {",
@@ -358,7 +358,7 @@ pub static GLX_ALIASES: Src = &[
     "    draw_type: c_int,           // GLX_WINDOW or GLX_PBUFFER",
     "    serial: c_ulong,            // # of last request processed by server",
     "    send_event: Bool,           // true if this came for SendEvent request",
-    "    display: *Display,          // display the event was read from",
+    "    display: *const Display,          // display the event was read from",
     "    drawable: GLXDrawable,      // XID of Drawable",
     "    buffer_mask: c_uint,        // mask indicating which buffers are affected",
     "    aux_buffer: c_uint,         // which aux buffer was affected",
@@ -373,7 +373,7 @@ pub static GLX_ALIASES: Src = &[
     "    type: c_int,",
     "    serial: c_ulong,            // # of last request processed by server",
     "    send_event: Bool,           // true if this came from a SendEvent request",
-    "    display: *Display,          // Display the event was read from",
+    "    display: *const Display,          // Display the event was read from",
     "    drawable: GLXDrawable,      // drawable on which event was requested in event mask",
     "    event_type: c_int,",
     "    ust: i64,",
@@ -391,7 +391,7 @@ pub static GLX_ALIASES: Src = &[
     "    type: c_int,",
     "    serial: c_ulong,            // # of last request processed by server",
     "    send_event: Bool,           // true if this came for SendEvent request",
-    "    display: *Display,          // display the event was read from",
+    "    display: *const Display,          // display the event was read from",
     "    drawable: GLXDrawable,      // i.d. of Drawable",
     "    event_type: c_int,          // GLX_DAMAGED_SGIX or GLX_SAVED_SGIX",
     "    draw_type: c_int,           // GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX",
@@ -441,7 +441,7 @@ pub static WIN_ALIASES: Src = &[
     "pub type CHAR = c_char;",
     "pub type HANDLE = PVOID;",
     "pub type LONG = c_long;",
-    "pub type LPCSTR = *c_char;",
+    "pub type LPCSTR = *const c_char;",
     "pub type VOID = c_void;",
     "",
     "// From Windef.h",
@@ -451,9 +451,9 @@ pub static WIN_ALIASES: Src = &[
     "pub type FLOAT = c_float;",
     "pub type HDC = HANDLE;",
     "pub type HENHMETAFILE = HANDLE;",
-    "pub type HGLRC = *c_void;",
+    "pub type HGLRC = *const c_void;",
     "pub type INT = c_int;",
-    "pub type LPVOID = *c_void;",
+    "pub type LPVOID = *const c_void;",
     "pub type PROC = extern \"system\" fn();     // Not sure about this one :/",
     "pub struct RECT {",
     "    left: LONG,",
@@ -484,7 +484,7 @@ pub static WIN_ALIASES: Src = &[
     "    gmfCellIncX: FLOAT,",
     "    gmfCellIncY: FLOAT,",
     "}",
-    "pub type LPGLYPHMETRICSFLOAT = *GLYPHMETRICSFLOAT;",
+    "pub type LPGLYPHMETRICSFLOAT = *const GLYPHMETRICSFLOAT;",
     "pub struct LAYERPLANEDESCRIPTOR {",
     "    nSize: WORD,",
     "    nVersion: WORD,",
@@ -546,7 +546,7 @@ pub static WGL_ALIASES: Src = &[
     "// #define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name",
     "macro_rules! DECLARE_HANDLE(",
     "    ($name:ident) => (",
-    "        pub type $name = *c_void;",
+    "        pub type $name = *const c_void;",
     "    )",
     ")",
     "",
@@ -565,5 +565,5 @@ pub static WGL_ALIASES: Src = &[
     "DECLARE_HANDLE!(HGPUNV)",
     "DECLARE_HANDLE!(HVIDEOINPUTDEVICENV)",
     "pub struct GPU_DEVICE(_GPU_DEVICE);",
-    "pub struct PGPU_DEVICE(*_GPU_DEVICE);",
+    "pub struct PGPU_DEVICE(*const _GPU_DEVICE);",
 ];


Test patch: