From b298fe3e91f71ef32a5db6d6e1172d56a482b2b8 Mon Sep 17 00:00:00 2001 From: fschutt Date: Sat, 6 Feb 2021 00:08:45 +0100 Subject: [PATCH 1/3] Add C-types and make generated gl function no_std compatible --- gl_generator/generators/debug_struct_gen.rs | 27 +-- gl_generator/generators/global_gen.rs | 36 ++-- gl_generator/generators/mod.rs | 10 ++ gl_generator/generators/static_gen.rs | 13 +- gl_generator/generators/static_struct_gen.rs | 15 +- gl_generator/generators/struct_gen.rs | 27 +-- .../generators/templates/types/cty.rs | 155 ++++++++++++++++++ .../generators/templates/types/egl.rs | 44 ++--- gl_generator/generators/templates/types/gl.rs | 56 +++---- .../generators/templates/types/glx.rs | 116 ++++++------- .../generators/templates/types/wgl.rs | 42 ++--- gl_generator/registry/parse.rs | 60 +++---- khronos_api/api | 2 +- khronos_api/api_angle | 2 +- khronos_api/api_egl | 2 +- khronos_api/api_webgl | 2 +- 16 files changed, 395 insertions(+), 214 deletions(-) create mode 100644 gl_generator/generators/templates/types/cty.rs diff --git a/gl_generator/generators/debug_struct_gen.rs b/gl_generator/generators/debug_struct_gen.rs index 87e57065..cadd55e4 100644 --- a/gl_generator/generators/debug_struct_gen.rs +++ b/gl_generator/generators/debug_struct_gen.rs @@ -43,13 +43,16 @@ where writeln!( dest, r#" - mod __gl_imports {{ - pub use std::mem; - pub use std::marker::Send; - pub use std::os::raw; - }} + pub mod __gl_imports {{ "# - ) + )?; + + super::write_cty_aliases(dest)?; + + writeln!(dest, r#" + pub use core::mem; + pub use core::marker::Send; + }}"#) } /// Creates a `types` module which contains all the type aliases. @@ -96,17 +99,17 @@ where #[derive(Clone)] pub struct FnPtr {{ /// The function pointer that will be used when calling the function. - f: *const __gl_imports::raw::c_void, + f: *const __gl_imports::c_void, /// True if the pointer points to a real function, false if points to a `panic!` fn. is_loaded: bool, }} impl FnPtr {{ /// Creates a `FnPtr` from a load attempt. - fn new(ptr: *const __gl_imports::raw::c_void) -> FnPtr {{ + fn new(ptr: *const __gl_imports::c_void) -> FnPtr {{ if ptr.is_null() {{ FnPtr {{ - f: missing_fn_panic as *const __gl_imports::raw::c_void, + f: missing_fn_panic as *const __gl_imports::c_void, is_loaded: false }} }} else {{ @@ -185,12 +188,12 @@ where /// let gl = Gl::load_with(|s| glfw.get_proc_address(s)); /// ~~~ #[allow(dead_code, unused_variables)] - pub fn load_with(mut loadfn: F) -> {api} where F: FnMut(&'static str) -> *const __gl_imports::raw::c_void {{ + pub fn load_with(mut loadfn: F) -> {api} where F: FnMut(&'static str) -> *const __gl_imports::c_void {{ #[inline(never)] - fn do_metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::raw::c_void, + fn do_metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::c_void, symbol: &'static str, symbols: &[&'static str]) - -> *const __gl_imports::raw::c_void {{ + -> *const __gl_imports::c_void {{ let mut ptr = loadfn(symbol); if ptr.is_null() {{ for &sym in symbols {{ diff --git a/gl_generator/generators/global_gen.rs b/gl_generator/generators/global_gen.rs index 2ed8a059..4cdea53a 100644 --- a/gl_generator/generators/global_gen.rs +++ b/gl_generator/generators/global_gen.rs @@ -43,15 +43,19 @@ fn write_header(dest: &mut W) -> io::Result<()> where W: io::Write, { + writeln!( dest, r#" - mod __gl_imports {{ - pub use std::mem; - pub use std::os::raw; - }} + pub mod __gl_imports {{ "# - ) + )?; + + super::write_cty_aliases(dest)?; + + writeln!(dest, r#" + pub use core::mem; + }}"#) } /// Creates the metaloadfn function for fallbacks @@ -63,9 +67,9 @@ where dest, r#" #[inline(never)] - fn metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::raw::c_void, + fn metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::c_void, symbol: &'static str, - fallbacks: &[&'static str]) -> *const __gl_imports::raw::c_void {{ + fallbacks: &[&'static str]) -> *const __gl_imports::c_void {{ let mut ptr = loadfn(symbol); if ptr.is_null() {{ for &sym in fallbacks {{ @@ -156,16 +160,16 @@ where #[allow(missing_copy_implementations)] pub struct FnPtr {{ /// The function pointer that will be used when calling the function. - f: *const __gl_imports::raw::c_void, + f: *const __gl_imports::c_void, /// True if the pointer points to a real function, false if points to a `panic!` fn. is_loaded: bool, }} impl FnPtr {{ /// Creates a `FnPtr` from a load attempt. - pub fn new(ptr: *const __gl_imports::raw::c_void) -> FnPtr {{ + pub fn new(ptr: *const __gl_imports::c_void) -> FnPtr {{ if ptr.is_null() {{ - FnPtr {{ f: missing_fn_panic as *const __gl_imports::raw::c_void, is_loaded: false }} + FnPtr {{ f: missing_fn_panic as *const __gl_imports::c_void, is_loaded: false }} }} else {{ FnPtr {{ f: ptr, is_loaded: true }} }} @@ -184,7 +188,7 @@ where "mod storage {{ #![allow(non_snake_case)] #![allow(non_upper_case_globals)] - use super::__gl_imports::raw; + use super::__gl_imports; use super::FnPtr;" )?; @@ -192,7 +196,7 @@ where writeln!( dest, "pub static mut {name}: FnPtr = FnPtr {{ - f: super::missing_fn_panic as *const raw::c_void, + f: super::missing_fn_panic as *const c_void, is_loaded: false }};", name = c.proto.ident @@ -231,7 +235,7 @@ where #[allow(non_snake_case)] pub mod {fnname} {{ use super::{{storage, metaloadfn}}; - use super::__gl_imports::raw; + use super::__gl_imports; use super::FnPtr; #[inline] @@ -241,7 +245,7 @@ where }} #[allow(dead_code)] - pub fn load_with(mut loadfn: F) where F: FnMut(&'static str) -> *const raw::c_void {{ + pub fn load_with(mut loadfn: F) where F: FnMut(&'static str) -> *const c_void {{ unsafe {{ storage::{fnname} = FnPtr::new(metaloadfn(&mut loadfn, "{symbol}", {fallbacks})) }} @@ -290,9 +294,9 @@ where /// gl::load_with(|s| glfw.get_proc_address(s)); /// ~~~ #[allow(dead_code)] - pub fn load_with(mut loadfn: F) where F: FnMut(&'static str) -> *const __gl_imports::raw::c_void {{ + pub fn load_with(mut loadfn: F) where F: FnMut(&'static str) -> *const __gl_imports::c_void {{ #[inline(never)] - fn inner(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::raw::c_void) {{ + fn inner(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::c_void) {{ ")?; for c in ®istry.cmds { diff --git a/gl_generator/generators/mod.rs b/gl_generator/generators/mod.rs index f04c5b05..d12bc239 100644 --- a/gl_generator/generators/mod.rs +++ b/gl_generator/generators/mod.rs @@ -63,6 +63,16 @@ where ) } +/// Generate a "cty" module with C type definitions in order +/// to be no_std compatible +fn write_cty_aliases(dest: &mut W) -> io::Result<()> +where + W: io::Write, +{ + writeln!(dest, "{}", include_str!("templates/types/cty.rs"))?; + Ok(()) +} + /// Generates all the type aliases for a namespace. /// /// Aliases are either `pub type = ...` or `#[repr(C)] pub struct ... { ... }` and contain all the diff --git a/gl_generator/generators/static_gen.rs b/gl_generator/generators/static_gen.rs index a1d2a91a..e449e285 100644 --- a/gl_generator/generators/static_gen.rs +++ b/gl_generator/generators/static_gen.rs @@ -40,12 +40,15 @@ where writeln!( dest, r#" - mod __gl_imports {{ - pub use std::mem; - pub use std::os::raw; - }} + pub mod __gl_imports {{ "# - ) + )?; + + super::write_cty_aliases(dest)?; + + writeln!(dest, r#" + pub use core::mem; + }}"#) } /// Creates a `types` module which contains all the type aliases. diff --git a/gl_generator/generators/static_struct_gen.rs b/gl_generator/generators/static_struct_gen.rs index 0e385cb5..8ced462c 100644 --- a/gl_generator/generators/static_struct_gen.rs +++ b/gl_generator/generators/static_struct_gen.rs @@ -42,12 +42,15 @@ where writeln!( dest, r#" - mod __gl_imports {{ - pub use std::mem; - pub use std::os::raw; - }} + pub mod __gl_imports {{ "# - ) + )?; + + super::write_cty_aliases(dest)?; + + writeln!(dest, r#" + pub use core::mem; + }}"#) } /// Creates a `types` module which contains all the type aliases. @@ -108,7 +111,7 @@ where "impl {api} {{ /// Stub function. #[allow(dead_code)] - pub fn load_with(mut _loadfn: F) -> {api} where F: FnMut(&'static str) -> *const __gl_imports::raw::c_void {{ + pub fn load_with(mut _loadfn: F) -> {api} where F: FnMut(&'static str) -> *const __gl_imports::c_void {{ {api} }}", api = super::gen_struct_name(registry.api), diff --git a/gl_generator/generators/struct_gen.rs b/gl_generator/generators/struct_gen.rs index 55dbd32c..b26968e1 100644 --- a/gl_generator/generators/struct_gen.rs +++ b/gl_generator/generators/struct_gen.rs @@ -43,13 +43,16 @@ where writeln!( dest, r#" - mod __gl_imports {{ - pub use std::mem; - pub use std::marker::Send; - pub use std::os::raw; - }} + pub mod __gl_imports {{ "# - ) + )?; + + super::write_cty_aliases(dest)?; + + writeln!(dest, r#" + pub use core::mem; + pub use core::marker::Send; + }}"#) } /// Creates a `types` module which contains all the type aliases. @@ -96,17 +99,17 @@ where #[derive(Clone)] pub struct FnPtr {{ /// The function pointer that will be used when calling the function. - f: *const __gl_imports::raw::c_void, + f: *const __gl_imports::c_void, /// True if the pointer points to a real function, false if points to a `panic!` fn. is_loaded: bool, }} impl FnPtr {{ /// Creates a `FnPtr` from a load attempt. - fn new(ptr: *const __gl_imports::raw::c_void) -> FnPtr {{ + fn new(ptr: *const __gl_imports::c_void) -> FnPtr {{ if ptr.is_null() {{ FnPtr {{ - f: missing_fn_panic as *const __gl_imports::raw::c_void, + f: missing_fn_panic as *const __gl_imports::c_void, is_loaded: false }} }} else {{ @@ -185,12 +188,12 @@ where /// let gl = Gl::load_with(|s| glfw.get_proc_address(s)); /// ~~~ #[allow(dead_code, unused_variables)] - pub fn load_with(mut loadfn: F) -> {api} where F: FnMut(&'static str) -> *const __gl_imports::raw::c_void {{ + pub fn load_with(mut loadfn: F) -> {api} where F: FnMut(&'static str) -> *const __gl_imports::c_void {{ #[inline(never)] - fn do_metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::raw::c_void, + fn do_metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::c_void, symbol: &'static str, symbols: &[&'static str]) - -> *const __gl_imports::raw::c_void {{ + -> *const __gl_imports::c_void {{ let mut ptr = loadfn(symbol); if ptr.is_null() {{ for &sym in symbols {{ diff --git a/gl_generator/generators/templates/types/cty.rs b/gl_generator/generators/templates/types/cty.rs new file mode 100644 index 00000000..c8071ff9 --- /dev/null +++ b/gl_generator/generators/templates/types/cty.rs @@ -0,0 +1,155 @@ +#![allow(non_camel_case_types)] +#![deny(warnings)] +#![no_std] + +// no-std compatible C typedefs, so we don't have to depend +// on std::os - https://crates.io/crates/cty @ 09bc8e384a7f5bd59f305a6f30c087a32633b690 +// +// Copyright (c) 2017 Jorge Aparicio +// +// Permission is hereby granted, free of charge, to any +// person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the +// Software without restriction, including without +// limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software +// is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice +// shall be included in all copies or substantial portions +// of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// Type aliases to C types like c_int for use with bindgen +// +// # MSRV +// +// This crate is guaranteed to compile on stable Rust 1.30.0 and up. It *might* compile with older +// versions but that may change in any new patch release. + +// AD = Architecture dependent +pub use self::ad::*; +// OD = OS dependent +pub use self::od::*; +// PWD = Pointer Width Dependent +pub use self::pwd::*; + +#[cfg(any(target_arch = "aarch64", + target_arch = "arm", + target_arch = "asmjs", + target_arch = "wasm32", + target_arch = "wasm64", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "s390x", + target_arch = "riscv32", + target_arch = "riscv64"))] +mod ad { + pub type c_char = super::c_uchar; + + pub type c_int = i32; + pub type c_uint = u32; +} + +#[cfg(any(target_arch = "mips", + target_arch = "mips64", + target_arch = "sparc64", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "nvptx", + target_arch = "nvptx64", + target_arch = "xtensa"))] +mod ad { + pub type c_char = super::c_schar; + + pub type c_int = i32; + pub type c_uint = u32; +} + +#[cfg(target_arch = "msp430")] +mod ad { + pub type c_char = super::c_uchar; + + pub type c_int = i16; + pub type c_uint = u16; +} + +// NOTE c_{,u}long definitions come from libc v0.2.3 +#[cfg(not(any(windows, + target_os = "redox", + target_os = "solaris")))] +mod od { + #[cfg(any(target_pointer_width = "16", + target_pointer_width = "32"))] + pub type c_long = i32; + #[cfg(any(target_pointer_width = "16", + target_pointer_width = "32"))] + pub type c_ulong = u32; + + #[cfg(target_pointer_width = "64")] + pub type c_long = i64; + #[cfg(target_pointer_width = "64")] + pub type c_ulong = u64; +} + +#[cfg(windows)] +mod od { + pub type c_long = i32; + pub type c_ulong = u32; +} + +#[cfg(any(target_os = "redox", + target_os = "solaris"))] +mod od { + pub type c_long = i64; + pub type c_ulong = u64; +} + +#[cfg(target_pointer_width = "32")] +mod pwd {} + +#[cfg(target_pointer_width = "64")] +mod pwd {} + +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; + +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_short = i16; +pub type c_longlong = i64; + +pub type c_uchar = u8; +pub type c_ushort = u16; +pub type c_ulonglong = u64; + +pub type c_float = f32; +pub type c_double = f64; + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type c_void = core::ffi::c_void; diff --git a/gl_generator/generators/templates/types/egl.rs b/gl_generator/generators/templates/types/egl.rs index 877638ab..2e9ad825 100644 --- a/gl_generator/generators/templates/types/egl.rs +++ b/gl_generator/generators/templates/types/egl.rs @@ -22,48 +22,48 @@ pub type NativeWindowType = super::NativeWindowType; // EGL alises pub type Bool = EGLBoolean; // TODO: not sure -pub type EGLBoolean = super::__gl_imports::raw::c_uint; -pub type EGLenum = super::__gl_imports::raw::c_uint; +pub type EGLBoolean = super::__gl_imports::c_uint; +pub type EGLenum = super::__gl_imports::c_uint; pub type EGLAttribKHR = isize; pub type EGLAttrib = isize; -pub type EGLConfig = *const super::__gl_imports::raw::c_void; -pub type EGLContext = *const super::__gl_imports::raw::c_void; -pub type EGLDeviceEXT = *const super::__gl_imports::raw::c_void; -pub type EGLDisplay = *const super::__gl_imports::raw::c_void; -pub type EGLSurface = *const super::__gl_imports::raw::c_void; -pub type EGLClientBuffer = *const super::__gl_imports::raw::c_void; +pub type EGLConfig = *const super::__gl_imports::c_void; +pub type EGLContext = *const super::__gl_imports::c_void; +pub type EGLDeviceEXT = *const super::__gl_imports::c_void; +pub type EGLDisplay = *const super::__gl_imports::c_void; +pub type EGLSurface = *const super::__gl_imports::c_void; +pub type EGLClientBuffer = *const super::__gl_imports::c_void; pub enum __eglMustCastToProperFunctionPointerType_fn {} pub type __eglMustCastToProperFunctionPointerType = *mut __eglMustCastToProperFunctionPointerType_fn; -pub type EGLImageKHR = *const super::__gl_imports::raw::c_void; -pub type EGLImage = *const super::__gl_imports::raw::c_void; -pub type EGLOutputLayerEXT = *const super::__gl_imports::raw::c_void; -pub type EGLOutputPortEXT = *const super::__gl_imports::raw::c_void; -pub type EGLSyncKHR = *const super::__gl_imports::raw::c_void; -pub type EGLSync = *const super::__gl_imports::raw::c_void; +pub type EGLImageKHR = *const super::__gl_imports::c_void; +pub type EGLImage = *const super::__gl_imports::c_void; +pub type EGLOutputLayerEXT = *const super::__gl_imports::c_void; +pub type EGLOutputPortEXT = *const super::__gl_imports::c_void; +pub type EGLSyncKHR = *const super::__gl_imports::c_void; +pub type EGLSync = *const super::__gl_imports::c_void; pub type EGLTimeKHR = khronos_utime_nanoseconds_t; pub type EGLTime = khronos_utime_nanoseconds_t; -pub type EGLSyncNV = *const super::__gl_imports::raw::c_void; +pub type EGLSyncNV = *const super::__gl_imports::c_void; pub type EGLTimeNV = khronos_utime_nanoseconds_t; pub type EGLuint64NV = khronos_utime_nanoseconds_t; -pub type EGLStreamKHR = *const super::__gl_imports::raw::c_void; +pub type EGLStreamKHR = *const super::__gl_imports::c_void; pub type EGLuint64KHR = khronos_uint64_t; -pub type EGLNativeFileDescriptorKHR = super::__gl_imports::raw::c_int; +pub type EGLNativeFileDescriptorKHR = super::__gl_imports::c_int; pub type EGLsizeiANDROID = khronos_ssize_t; -pub type EGLSetBlobFuncANDROID = extern "system" fn(*const super::__gl_imports::raw::c_void, +pub type EGLSetBlobFuncANDROID = extern "system" fn(*const super::__gl_imports::c_void, EGLsizeiANDROID, - *const super::__gl_imports::raw::c_void, + *const super::__gl_imports::c_void, EGLsizeiANDROID) -> (); -pub type EGLGetBlobFuncANDROID = extern "system" fn(*const super::__gl_imports::raw::c_void, +pub type EGLGetBlobFuncANDROID = extern "system" fn(*const super::__gl_imports::c_void, EGLsizeiANDROID, - *mut super::__gl_imports::raw::c_void, + *mut super::__gl_imports::c_void, EGLsizeiANDROID) -> EGLsizeiANDROID; #[repr(C)] pub struct EGLClientPixmapHI { - pData: *const super::__gl_imports::raw::c_void, + pData: *const super::__gl_imports::c_void, iWidth: EGLint, iHeight: EGLint, iStride: EGLint, diff --git a/gl_generator/generators/templates/types/gl.rs b/gl_generator/generators/templates/types/gl.rs index 90e46201..d9cd1c10 100644 --- a/gl_generator/generators/templates/types/gl.rs +++ b/gl_generator/generators/templates/types/gl.rs @@ -1,31 +1,31 @@ // Common types from OpenGL 1.1 -pub type GLenum = super::__gl_imports::raw::c_uint; -pub type GLboolean = super::__gl_imports::raw::c_uchar; -pub type GLbitfield = super::__gl_imports::raw::c_uint; -pub type GLvoid = super::__gl_imports::raw::c_void; -pub type GLbyte = super::__gl_imports::raw::c_char; -pub type GLshort = super::__gl_imports::raw::c_short; -pub type GLint = super::__gl_imports::raw::c_int; -pub type GLclampx = super::__gl_imports::raw::c_int; -pub type GLubyte = super::__gl_imports::raw::c_uchar; -pub type GLushort = super::__gl_imports::raw::c_ushort; -pub type GLuint = super::__gl_imports::raw::c_uint; -pub type GLsizei = super::__gl_imports::raw::c_int; -pub type GLfloat = super::__gl_imports::raw::c_float; -pub type GLclampf = super::__gl_imports::raw::c_float; -pub type GLdouble = super::__gl_imports::raw::c_double; -pub type GLclampd = super::__gl_imports::raw::c_double; -pub type GLeglImageOES = *const super::__gl_imports::raw::c_void; -pub type GLchar = super::__gl_imports::raw::c_char; -pub type GLcharARB = super::__gl_imports::raw::c_char; +pub type GLenum = super::__gl_imports::c_uint; +pub type GLboolean = super::__gl_imports::c_uchar; +pub type GLbitfield = super::__gl_imports::c_uint; +pub type GLvoid = super::__gl_imports::c_void; +pub type GLbyte = super::__gl_imports::c_char; +pub type GLshort = super::__gl_imports::c_short; +pub type GLint = super::__gl_imports::c_int; +pub type GLclampx = super::__gl_imports::c_int; +pub type GLubyte = super::__gl_imports::c_uchar; +pub type GLushort = super::__gl_imports::c_ushort; +pub type GLuint = super::__gl_imports::c_uint; +pub type GLsizei = super::__gl_imports::c_int; +pub type GLfloat = super::__gl_imports::c_float; +pub type GLclampf = super::__gl_imports::c_float; +pub type GLdouble = super::__gl_imports::c_double; +pub type GLclampd = super::__gl_imports::c_double; +pub type GLeglImageOES = *const super::__gl_imports::c_void; +pub type GLchar = super::__gl_imports::c_char; +pub type GLcharARB = super::__gl_imports::c_char; #[cfg(target_os = "macos")] -pub type GLhandleARB = *const super::__gl_imports::raw::c_void; +pub type GLhandleARB = *const super::__gl_imports::c_void; #[cfg(not(target_os = "macos"))] -pub type GLhandleARB = super::__gl_imports::raw::c_uint; +pub type GLhandleARB = super::__gl_imports::c_uint; -pub type GLhalfARB = super::__gl_imports::raw::c_ushort; -pub type GLhalf = super::__gl_imports::raw::c_ushort; +pub type GLhalfARB = super::__gl_imports::c_ushort; +pub type GLhalf = super::__gl_imports::c_ushort; // Must be 32 bits pub type GLfixed = GLint; @@ -52,21 +52,21 @@ pub type GLDEBUGPROC = Option; + userParam: *mut super::__gl_imports::c_void)>; pub type GLDEBUGPROCARB = Option; + userParam: *mut super::__gl_imports::c_void)>; pub type GLDEBUGPROCKHR = Option; + userParam: *mut super::__gl_imports::c_void)>; // GLES 1 types // "pub type GLclampx = i32;", @@ -103,6 +103,6 @@ pub type GLDEBUGPROCAMD = Option; -pub type GLhalfNV = super::__gl_imports::raw::c_ushort; + userParam: *mut super::__gl_imports::c_void)>; +pub type GLhalfNV = super::__gl_imports::c_ushort; pub type GLvdpauSurfaceNV = GLintptr; diff --git a/gl_generator/generators/templates/types/glx.rs b/gl_generator/generators/templates/types/glx.rs index b0078da0..158d3e02 100644 --- a/gl_generator/generators/templates/types/glx.rs +++ b/gl_generator/generators/templates/types/glx.rs @@ -1,16 +1,16 @@ -pub type XID = super::__gl_imports::raw::c_ulong; -pub type Bool = super::__gl_imports::raw::c_int; // Not sure if this is correct... +pub type XID = super::__gl_imports::c_ulong; +pub type Bool = super::__gl_imports::c_int; // Not sure if this is correct... pub enum Display {} pub type Font = XID; pub type Pixmap = XID; pub enum Visual {} // TODO: not sure -pub type VisualID = super::__gl_imports::raw::c_ulong; // TODO: not sure +pub type VisualID = super::__gl_imports::c_ulong; // TODO: not sure pub type Window = XID; pub type GLXFBConfigID = XID; -pub type GLXFBConfig = *const super::__gl_imports::raw::c_void; +pub type GLXFBConfig = *const super::__gl_imports::c_void; pub type GLXContextID = XID; -pub type GLXContext = *const super::__gl_imports::raw::c_void; +pub type GLXContext = *const super::__gl_imports::c_void; pub type GLXPixmap = XID; pub type GLXDrawable = XID; pub type GLXWindow = XID; @@ -18,51 +18,51 @@ pub type GLXPbuffer = XID; pub enum __GLXextFuncPtr_fn {} pub type __GLXextFuncPtr = *mut __GLXextFuncPtr_fn; pub type GLXVideoCaptureDeviceNV = XID; -pub type GLXVideoDeviceNV = super::__gl_imports::raw::c_int; +pub type GLXVideoDeviceNV = super::__gl_imports::c_int; pub type GLXVideoSourceSGIX = XID; pub type GLXFBConfigIDSGIX = XID; -pub type GLXFBConfigSGIX = *const super::__gl_imports::raw::c_void; +pub type GLXFBConfigSGIX = *const super::__gl_imports::c_void; pub type GLXPbufferSGIX = XID; #[repr(C)] pub struct XVisualInfo { pub visual: *mut Visual, pub visualid: VisualID, - pub screen: super::__gl_imports::raw::c_int, - pub depth: super::__gl_imports::raw::c_int, - pub class: super::__gl_imports::raw::c_int, - pub red_mask: super::__gl_imports::raw::c_ulong, - pub green_mask: super::__gl_imports::raw::c_ulong, - pub blue_mask: super::__gl_imports::raw::c_ulong, - pub colormap_size: super::__gl_imports::raw::c_int, - pub bits_per_rgb: super::__gl_imports::raw::c_int, + pub screen: super::__gl_imports::c_int, + pub depth: super::__gl_imports::c_int, + pub class: super::__gl_imports::c_int, + pub red_mask: super::__gl_imports::c_ulong, + pub green_mask: super::__gl_imports::c_ulong, + pub blue_mask: super::__gl_imports::c_ulong, + pub colormap_size: super::__gl_imports::c_int, + pub bits_per_rgb: super::__gl_imports::c_int, } #[repr(C)] pub struct GLXPbufferClobberEvent { - pub event_type: super::__gl_imports::raw::c_int, // GLX_DAMAGED or GLX_SAVED - pub draw_type: super::__gl_imports::raw::c_int, // GLX_WINDOW or GLX_PBUFFER - pub serial: super::__gl_imports::raw::c_ulong, // # of last request processed by server + pub event_type: super::__gl_imports::c_int, // GLX_DAMAGED or GLX_SAVED + pub draw_type: super::__gl_imports::c_int, // GLX_WINDOW or GLX_PBUFFER + pub serial: super::__gl_imports::c_ulong, // # of last request processed by server pub send_event: Bool, // true if this came for SendEvent request pub display: *const Display, // display the event was read from pub drawable: GLXDrawable, // XID of Drawable - pub buffer_mask: super::__gl_imports::raw::c_uint, // mask indicating which buffers are affected - pub aux_buffer: super::__gl_imports::raw::c_uint, // which aux buffer was affected - pub x: super::__gl_imports::raw::c_int, - pub y: super::__gl_imports::raw::c_int, - pub width: super::__gl_imports::raw::c_int, - pub height: super::__gl_imports::raw::c_int, - pub count: super::__gl_imports::raw::c_int, // if nonzero, at least this many more + pub buffer_mask: super::__gl_imports::c_uint, // mask indicating which buffers are affected + pub aux_buffer: super::__gl_imports::c_uint, // which aux buffer was affected + pub x: super::__gl_imports::c_int, + pub y: super::__gl_imports::c_int, + pub width: super::__gl_imports::c_int, + pub height: super::__gl_imports::c_int, + pub count: super::__gl_imports::c_int, // if nonzero, at least this many more } #[repr(C)] pub struct GLXBufferSwapComplete { - pub type_: super::__gl_imports::raw::c_int, - pub serial: super::__gl_imports::raw::c_ulong, // # of last request processed by server + pub type_: super::__gl_imports::c_int, + pub serial: super::__gl_imports::c_ulong, // # of last request processed by server pub send_event: Bool, // true if this came from a SendEvent request pub display: *const Display, // Display the event was read from pub drawable: GLXDrawable, // drawable on which event was requested in event mask - pub event_type: super::__gl_imports::raw::c_int, + pub event_type: super::__gl_imports::c_int, pub ust: i64, pub msc: i64, pub sbc: i64, @@ -76,53 +76,53 @@ pub struct GLXBufferSwapComplete { #[repr(C)] pub struct GLXBufferClobberEventSGIX { - pub type_: super::__gl_imports::raw::c_int, - pub serial: super::__gl_imports::raw::c_ulong, // # of last request processed by server + pub type_: super::__gl_imports::c_int, + pub serial: super::__gl_imports::c_ulong, // # of last request processed by server pub send_event: Bool, // true if this came for SendEvent request pub display: *const Display, // display the event was read from pub drawable: GLXDrawable, // i.d. of Drawable - pub event_type: super::__gl_imports::raw::c_int, // GLX_DAMAGED_SGIX or GLX_SAVED_SGIX - pub draw_type: super::__gl_imports::raw::c_int, // GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX - pub mask: super::__gl_imports::raw::c_uint, // mask indicating which buffers are affected - pub x: super::__gl_imports::raw::c_int, - pub y: super::__gl_imports::raw::c_int, - pub width: super::__gl_imports::raw::c_int, - pub height: super::__gl_imports::raw::c_int, - pub count: super::__gl_imports::raw::c_int, // if nonzero, at least this many more + pub event_type: super::__gl_imports::c_int, // GLX_DAMAGED_SGIX or GLX_SAVED_SGIX + pub draw_type: super::__gl_imports::c_int, // GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX + pub mask: super::__gl_imports::c_uint, // mask indicating which buffers are affected + pub x: super::__gl_imports::c_int, + pub y: super::__gl_imports::c_int, + pub width: super::__gl_imports::c_int, + pub height: super::__gl_imports::c_int, + pub count: super::__gl_imports::c_int, // if nonzero, at least this many more } #[repr(C)] pub struct GLXHyperpipeNetworkSGIX { - pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] - pub networkId: super::__gl_imports::raw::c_int, + pub pipeName: [super::__gl_imports::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] + pub networkId: super::__gl_imports::c_int, } #[repr(C)] pub struct GLXHyperpipeConfigSGIX { - pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] - pub channel: super::__gl_imports::raw::c_int, - pub participationType: super::__gl_imports::raw::c_uint, - pub timeSlice: super::__gl_imports::raw::c_int, + pub pipeName: [super::__gl_imports::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] + pub channel: super::__gl_imports::c_int, + pub participationType: super::__gl_imports::c_uint, + pub timeSlice: super::__gl_imports::c_int, } #[repr(C)] pub struct GLXPipeRect { - pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] - pub srcXOrigin: super::__gl_imports::raw::c_int, - pub srcYOrigin: super::__gl_imports::raw::c_int, - pub srcWidth: super::__gl_imports::raw::c_int, - pub srcHeight: super::__gl_imports::raw::c_int, - pub destXOrigin: super::__gl_imports::raw::c_int, - pub destYOrigin: super::__gl_imports::raw::c_int, - pub destWidth: super::__gl_imports::raw::c_int, - pub destHeight: super::__gl_imports::raw::c_int, + pub pipeName: [super::__gl_imports::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] + pub srcXOrigin: super::__gl_imports::c_int, + pub srcYOrigin: super::__gl_imports::c_int, + pub srcWidth: super::__gl_imports::c_int, + pub srcHeight: super::__gl_imports::c_int, + pub destXOrigin: super::__gl_imports::c_int, + pub destYOrigin: super::__gl_imports::c_int, + pub destWidth: super::__gl_imports::c_int, + pub destHeight: super::__gl_imports::c_int, } #[repr(C)] pub struct GLXPipeRectLimits { - pub pipeName: [super::__gl_imports::raw::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] - pub XOrigin: super::__gl_imports::raw::c_int, - pub YOrigin: super::__gl_imports::raw::c_int, - pub maxHeight: super::__gl_imports::raw::c_int, - pub maxWidth: super::__gl_imports::raw::c_int, + pub pipeName: [super::__gl_imports::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] + pub XOrigin: super::__gl_imports::c_int, + pub YOrigin: super::__gl_imports::c_int, + pub maxHeight: super::__gl_imports::c_int, + pub maxWidth: super::__gl_imports::c_int, } diff --git a/gl_generator/generators/templates/types/wgl.rs b/gl_generator/generators/templates/types/wgl.rs index a376d4fa..3f196d25 100644 --- a/gl_generator/generators/templates/types/wgl.rs +++ b/gl_generator/generators/templates/types/wgl.rs @@ -1,31 +1,31 @@ // From WinNT.h -pub type CHAR = super::__gl_imports::raw::c_char; +pub type CHAR = super::__gl_imports::c_char; pub type HANDLE = PVOID; -pub type LONG = super::__gl_imports::raw::c_long; -pub type LPCSTR = *const super::__gl_imports::raw::c_char; +pub type LONG = super::__gl_imports::c_long; +pub type LPCSTR = *const super::__gl_imports::c_char; pub type VOID = (); // #define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name -pub type HPBUFFERARB = *const super::__gl_imports::raw::c_void; -pub type HPBUFFEREXT = *const super::__gl_imports::raw::c_void; -pub type HVIDEOOUTPUTDEVICENV = *const super::__gl_imports::raw::c_void; -pub type HPVIDEODEV = *const super::__gl_imports::raw::c_void; -pub type HPGPUNV = *const super::__gl_imports::raw::c_void; -pub type HGPUNV = *const super::__gl_imports::raw::c_void; -pub type HVIDEOINPUTDEVICENV = *const super::__gl_imports::raw::c_void; +pub type HPBUFFERARB = *const super::__gl_imports::c_void; +pub type HPBUFFEREXT = *const super::__gl_imports::c_void; +pub type HVIDEOOUTPUTDEVICENV = *const super::__gl_imports::c_void; +pub type HPVIDEODEV = *const super::__gl_imports::c_void; +pub type HPGPUNV = *const super::__gl_imports::c_void; +pub type HGPUNV = *const super::__gl_imports::c_void; +pub type HVIDEOINPUTDEVICENV = *const super::__gl_imports::c_void; // From Windef.h -pub type BOOL = super::__gl_imports::raw::c_int; -pub type BYTE = super::__gl_imports::raw::c_uchar; +pub type BOOL = super::__gl_imports::c_int; +pub type BYTE = super::__gl_imports::c_uchar; pub type COLORREF = DWORD; -pub type FLOAT = super::__gl_imports::raw::c_float; +pub type FLOAT = super::__gl_imports::c_float; pub type HDC = HANDLE; pub type HENHMETAFILE = HANDLE; -pub type HGLRC = *const super::__gl_imports::raw::c_void; -pub type INT = super::__gl_imports::raw::c_int; -pub type PVOID = *const super::__gl_imports::raw::c_void; -pub type LPVOID = *const super::__gl_imports::raw::c_void; +pub type HGLRC = *const super::__gl_imports::c_void; +pub type INT = super::__gl_imports::c_int; +pub type PVOID = *const super::__gl_imports::c_void; +pub type LPVOID = *const super::__gl_imports::c_void; pub enum __PROC_fn {} pub type PROC = *mut __PROC_fn; @@ -37,9 +37,9 @@ pub struct RECT { bottom: LONG, } -pub type UINT = super::__gl_imports::raw::c_uint; -pub type USHORT = super::__gl_imports::raw::c_ushort; -pub type WORD = super::__gl_imports::raw::c_ushort; +pub type UINT = super::__gl_imports::c_uint; +pub type USHORT = super::__gl_imports::c_ushort; +pub type WORD = super::__gl_imports::c_ushort; // From BaseTsd.h @@ -48,7 +48,7 @@ pub type INT64 = i64; // From IntSafe.h -pub type DWORD = super::__gl_imports::raw::c_ulong; +pub type DWORD = super::__gl_imports::c_ulong; // From Wingdi.h diff --git a/gl_generator/registry/parse.rs b/gl_generator/registry/parse.rs index cf5755d0..7080bbed 100644 --- a/gl_generator/registry/parse.rs +++ b/gl_generator/registry/parse.rs @@ -852,8 +852,8 @@ pub fn to_rust_ty>(ty: T) -> Cow<'static, str> { "GLushort *" => "*mut types::GLushort", "GLvoid *" => "*mut types::GLvoid", "GLvoid **" => "*const *mut types::GLvoid", - "void *" => "*mut __gl_imports::raw::c_void", - "void **" => "*const *mut __gl_imports::raw::c_void", + "void *" => "*mut __gl_imports::c_void", + "void **" => "*const *mut __gl_imports::c_void", "const GLboolean *" => "*const types::GLboolean", "const GLbyte *" => "*const types::GLbyte", "const GLchar *" => "*const types::GLchar", @@ -880,9 +880,9 @@ pub fn to_rust_ty>(ty: T) -> Cow<'static, str> { "const GLushort *" => "*const types::GLushort", "const GLvdpauSurfaceNV *" => "*const types::GLvdpauSurfaceNV", "const GLvoid *" => "*const types::GLvoid", - "const void*" | "const void *" => "*const __gl_imports::raw::c_void", - "const void **" => "*const *const __gl_imports::raw::c_void", - "const void *const*" => "*const *const __gl_imports::raw::c_void", + "const void*" | "const void *" => "*const __gl_imports::c_void", + "const void **" => "*const *const __gl_imports::c_void", + "const void *const*" => "*const *const __gl_imports::c_void", "const GLboolean **" => "*const *const types::GLboolean", "const GLchar **" => "*const *const types::GLchar", "const GLcharARB **" => "*const *const types::GLcharARB", @@ -923,11 +923,11 @@ pub fn to_rust_ty>(ty: T) -> Cow<'static, str> { "Window" => "types::Window", "__GLXextFuncPtr" => "types::__GLXextFuncPtr", "const GLXContext" => "const types::GLXContext", - "float" => "__gl_imports::raw::c_float", - "int" => "__gl_imports::raw::c_int", + "float" => "__gl_imports::c_float", + "int" => "__gl_imports::c_int", "int64_t" => "i64", - "unsigned int" => "__gl_imports::raw::c_uint", - "unsigned long" => "__gl_imports::raw::c_ulong", + "unsigned int" => "__gl_imports::c_uint", + "unsigned long" => "__gl_imports::c_ulong", // "void " => "()", "DMparams *" => "*mut types::DMparams", "Display *" => "*mut types::Display", @@ -940,16 +940,16 @@ pub fn to_rust_ty>(ty: T) -> Cow<'static, str> { // "GLuint *" => "*mut types::GLuint", "XVisualInfo *" => "*mut types::XVisualInfo", // "const GLubyte *" => "*GLubyte", - "const char *" => "*const __gl_imports::raw::c_char", - "const int *" => "*const __gl_imports::raw::c_int", - // "const void *" => "*const __gl_imports::raw::c_void", - "int *" => "*mut __gl_imports::raw::c_int", + "const char *" => "*const __gl_imports::c_char", + "const int *" => "*const __gl_imports::c_int", + // "const void *" => "*const __gl_imports::c_void", + "int *" => "*mut __gl_imports::c_int", "int32_t *" => "*mut i32", "int64_t *" => "*mut i64", - "long *" => "*mut __gl_imports::raw::c_long", - "unsigned int *" => "*mut __gl_imports::raw::c_uint", - "unsigned long *" => "*mut __gl_imports::raw::c_ulong", - // "void *" => "*mut __gl_imports::raw::c_void", + "long *" => "*mut __gl_imports::c_long", + "unsigned int *" => "*mut __gl_imports::c_uint", + "unsigned long *" => "*mut __gl_imports::c_ulong", + // "void *" => "*mut __gl_imports::c_void", // wgl.xml types "BOOL" => "types::BOOL", @@ -982,8 +982,8 @@ pub fn to_rust_ty>(ty: T) -> Cow<'static, str> { "PROC" => "types::PROC", "UINT" => "types::UINT", "VOID" => "types::VOID", - // "int " => "__gl_imports::raw::c_int", - // "unsigned int " => "__gl_imports::raw::c_uint", + // "int " => "__gl_imports::c_int", + // "unsigned int " => "__gl_imports::c_uint", // "void " => "()", "BOOL *" => "*mut types::BOOL", "DWORD *" => "*mut types::DWORD", @@ -1008,12 +1008,12 @@ pub fn to_rust_ty>(ty: T) -> Cow<'static, str> { "const LPVOID *" => "*const types::LPVOID", "const PIXELFORMATDESCRIPTOR *" => "*const types::IXELFORMATDESCRIPTOR", "const USHORT *" => "*const types::USHORT", - // "const char *" => "*const __gl_imports::raw::c_char", - // "const int *" => "*const __gl_imports::raw::c_int", - "float *" => "*mut __gl_imports::raw::c_float", - // "int *" => "*mut __gl_imports::raw::c_int", - // "unsigned long *" => "*mut __gl_imports::raw::c_ulong", - // "void *" => "*mut __gl_imports::raw::c_void", + // "const char *" => "*const __gl_imports::c_char", + // "const int *" => "*const __gl_imports::c_int", + "float *" => "*mut __gl_imports::c_float", + // "int *" => "*mut __gl_imports::c_int", + // "unsigned long *" => "*mut __gl_imports::c_ulong", + // "void *" => "*mut __gl_imports::c_void", // elx.xml types "khronos_utime_nanoseconds_t" => "types::khronos_utime_nanoseconds_t", @@ -1076,11 +1076,11 @@ pub fn to_rust_ty>(ty: T) -> Cow<'static, str> { "EGLTimeKHR *" => "*mut types::EGLTimeKHR", "EGLOutputPortEXT *" => "*mut types::EGLOutputPortEXT", "EGLuint64KHR *" => "*mut types::EGLuint64KHR", - "const struct AHardwareBuffer *" => "*const __gl_imports::raw::c_void", // humm - "char *" => "*const __gl_imports::raw::c_char", - "struct wl_buffer *" => "*const __gl_imports::raw::c_void", - "struct wl_display *" => "*const __gl_imports::raw::c_void", - "struct wl_resource *" => "*const __gl_imports::raw::c_void", + "const struct AHardwareBuffer *" => "*const __gl_imports::c_void", // humm + "char *" => "*const __gl_imports::c_char", + "struct wl_buffer *" => "*const __gl_imports::c_void", + "struct wl_display *" => "*const __gl_imports::c_void", + "struct wl_resource *" => "*const __gl_imports::c_void", "GLeglClientBufferEXT" => "types::GLeglClientBufferEXT", "GLVULKANPROCNV" => "types::GLVULKANPROCNV", diff --git a/khronos_api/api b/khronos_api/api index e69bd1f0..2afca877 160000 --- a/khronos_api/api +++ b/khronos_api/api @@ -1 +1 @@ -Subproject commit e69bd1f0db882dac9db3aeafce16210ca1108038 +Subproject commit 2afca877b25ec2c7f19ddcba21a8627b9fa8e026 diff --git a/khronos_api/api_angle b/khronos_api/api_angle index 9f323042..d3c00f95 160000 --- a/khronos_api/api_angle +++ b/khronos_api/api_angle @@ -1 +1 @@ -Subproject commit 9f32304208deb75106cd641e8cb09af93f8df860 +Subproject commit d3c00f959f9d4c071143dbe36ba22f8de68d8c67 diff --git a/khronos_api/api_egl b/khronos_api/api_egl index 90b78b06..d42c684f 160000 --- a/khronos_api/api_egl +++ b/khronos_api/api_egl @@ -1 +1 @@ -Subproject commit 90b78b0662e2f0548cfd1926fb77bf628933541b +Subproject commit d42c684f61828e3ce18533f1c6893b79980e6acc diff --git a/khronos_api/api_webgl b/khronos_api/api_webgl index c987f075..08c57bd4 160000 --- a/khronos_api/api_webgl +++ b/khronos_api/api_webgl @@ -1 +1 @@ -Subproject commit c987f075bfdca44119175c41f547d849c08983a3 +Subproject commit 08c57bd431e7c65a41e4da3f736d04122d4452ee From 12f66ebf18afa358b0e338992edb123647160223 Mon Sep 17 00:00:00 2001 From: fschutt Date: Sat, 6 Feb 2021 11:38:29 +0100 Subject: [PATCH 2/3] Use c_uchar instead of c_char, remove unused typedefs --- .../generators/templates/types/cty.rs | 74 +------------------ gl_generator/generators/templates/types/gl.rs | 6 +- .../generators/templates/types/glx.rs | 8 +- .../generators/templates/types/wgl.rs | 4 +- 4 files changed, 10 insertions(+), 82 deletions(-) diff --git a/gl_generator/generators/templates/types/cty.rs b/gl_generator/generators/templates/types/cty.rs index c8071ff9..18fa8ebb 100644 --- a/gl_generator/generators/templates/types/cty.rs +++ b/gl_generator/generators/templates/types/cty.rs @@ -1,4 +1,4 @@ -#![allow(non_camel_case_types)] +#![allow(non_camel_case_types, unused_attributes)] #![deny(warnings)] #![no_std] @@ -40,10 +40,6 @@ // AD = Architecture dependent pub use self::ad::*; -// OD = OS dependent -pub use self::od::*; -// PWD = Pointer Width Dependent -pub use self::pwd::*; #[cfg(any(target_arch = "aarch64", target_arch = "arm", @@ -56,8 +52,6 @@ pub use self::pwd::*; target_arch = "riscv32", target_arch = "riscv64"))] mod ad { - pub type c_char = super::c_uchar; - pub type c_int = i32; pub type c_uint = u32; } @@ -71,85 +65,19 @@ mod ad { target_arch = "nvptx64", target_arch = "xtensa"))] mod ad { - pub type c_char = super::c_schar; - pub type c_int = i32; pub type c_uint = u32; } #[cfg(target_arch = "msp430")] mod ad { - pub type c_char = super::c_uchar; - pub type c_int = i16; pub type c_uint = u16; } -// NOTE c_{,u}long definitions come from libc v0.2.3 -#[cfg(not(any(windows, - target_os = "redox", - target_os = "solaris")))] -mod od { - #[cfg(any(target_pointer_width = "16", - target_pointer_width = "32"))] - pub type c_long = i32; - #[cfg(any(target_pointer_width = "16", - target_pointer_width = "32"))] - pub type c_ulong = u32; - - #[cfg(target_pointer_width = "64")] - pub type c_long = i64; - #[cfg(target_pointer_width = "64")] - pub type c_ulong = u64; -} - -#[cfg(windows)] -mod od { - pub type c_long = i32; - pub type c_ulong = u32; -} - -#[cfg(any(target_os = "redox", - target_os = "solaris"))] -mod od { - pub type c_long = i64; - pub type c_ulong = u64; -} - -#[cfg(target_pointer_width = "32")] -mod pwd {} - -#[cfg(target_pointer_width = "64")] -mod pwd {} - -pub type int8_t = i8; -pub type int16_t = i16; -pub type int32_t = i32; -pub type int64_t = i64; - -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; - -pub type c_schar = i8; pub type c_short = i16; -pub type c_longlong = i64; - pub type c_uchar = u8; pub type c_ushort = u16; -pub type c_ulonglong = u64; - pub type c_float = f32; pub type c_double = f64; - -pub type intmax_t = i64; -pub type uintmax_t = u64; - -pub type size_t = usize; -pub type ptrdiff_t = isize; -pub type intptr_t = isize; -pub type uintptr_t = usize; -pub type ssize_t = isize; - pub type c_void = core::ffi::c_void; diff --git a/gl_generator/generators/templates/types/gl.rs b/gl_generator/generators/templates/types/gl.rs index d9cd1c10..0adbfd5c 100644 --- a/gl_generator/generators/templates/types/gl.rs +++ b/gl_generator/generators/templates/types/gl.rs @@ -3,7 +3,7 @@ pub type GLenum = super::__gl_imports::c_uint; pub type GLboolean = super::__gl_imports::c_uchar; pub type GLbitfield = super::__gl_imports::c_uint; pub type GLvoid = super::__gl_imports::c_void; -pub type GLbyte = super::__gl_imports::c_char; +pub type GLbyte = super::__gl_imports::c_uchar; pub type GLshort = super::__gl_imports::c_short; pub type GLint = super::__gl_imports::c_int; pub type GLclampx = super::__gl_imports::c_int; @@ -16,8 +16,8 @@ pub type GLclampf = super::__gl_imports::c_float; pub type GLdouble = super::__gl_imports::c_double; pub type GLclampd = super::__gl_imports::c_double; pub type GLeglImageOES = *const super::__gl_imports::c_void; -pub type GLchar = super::__gl_imports::c_char; -pub type GLcharARB = super::__gl_imports::c_char; +pub type GLchar = super::__gl_imports::c_uchar; +pub type GLcharARB = super::__gl_imports::c_uchar; #[cfg(target_os = "macos")] pub type GLhandleARB = *const super::__gl_imports::c_void; diff --git a/gl_generator/generators/templates/types/glx.rs b/gl_generator/generators/templates/types/glx.rs index 158d3e02..1f2205bc 100644 --- a/gl_generator/generators/templates/types/glx.rs +++ b/gl_generator/generators/templates/types/glx.rs @@ -93,13 +93,13 @@ pub struct GLXBufferClobberEventSGIX { #[repr(C)] pub struct GLXHyperpipeNetworkSGIX { - pub pipeName: [super::__gl_imports::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] + pub pipeName: [super::__gl_imports::c_uchar; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] pub networkId: super::__gl_imports::c_int, } #[repr(C)] pub struct GLXHyperpipeConfigSGIX { - pub pipeName: [super::__gl_imports::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] + pub pipeName: [super::__gl_imports::c_uchar; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] pub channel: super::__gl_imports::c_int, pub participationType: super::__gl_imports::c_uint, pub timeSlice: super::__gl_imports::c_int, @@ -107,7 +107,7 @@ pub struct GLXHyperpipeConfigSGIX { #[repr(C)] pub struct GLXPipeRect { - pub pipeName: [super::__gl_imports::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] + pub pipeName: [super::__gl_imports::c_uchar; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] pub srcXOrigin: super::__gl_imports::c_int, pub srcYOrigin: super::__gl_imports::c_int, pub srcWidth: super::__gl_imports::c_int, @@ -120,7 +120,7 @@ pub struct GLXPipeRect { #[repr(C)] pub struct GLXPipeRectLimits { - pub pipeName: [super::__gl_imports::c_char; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] + pub pipeName: [super::__gl_imports::c_uchar; 80], // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] pub XOrigin: super::__gl_imports::c_int, pub YOrigin: super::__gl_imports::c_int, pub maxHeight: super::__gl_imports::c_int, diff --git a/gl_generator/generators/templates/types/wgl.rs b/gl_generator/generators/templates/types/wgl.rs index 3f196d25..bb516698 100644 --- a/gl_generator/generators/templates/types/wgl.rs +++ b/gl_generator/generators/templates/types/wgl.rs @@ -1,9 +1,9 @@ // From WinNT.h -pub type CHAR = super::__gl_imports::c_char; +pub type CHAR = super::__gl_imports::c_uchar; pub type HANDLE = PVOID; pub type LONG = super::__gl_imports::c_long; -pub type LPCSTR = *const super::__gl_imports::c_char; +pub type LPCSTR = *const super::__gl_imports::c_uchar; pub type VOID = (); // #define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name pub type HPBUFFERARB = *const super::__gl_imports::c_void; From 7c1ec1651225fa81541358f5fb5f2669d0f5f378 Mon Sep 17 00:00:00 2001 From: fschutt Date: Sat, 6 Feb 2021 11:52:38 +0100 Subject: [PATCH 3/3] Bump version number to 0.15.0 --- README.md | 4 ++-- gl/Cargo.toml | 4 ++-- gl/README.md | 2 +- gl_generator/Cargo.toml | 2 +- gl_generator/README.md | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 968b7c69..5e6e4e64 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ An OpenGL function pointer loader for the Rust Programming Language. ```toml [dependencies] -gl = "0.14.0" +gl = "0.15.0" ``` ### gl_generator @@ -33,7 +33,7 @@ Code generators for creating bindings to the Khronos OpenGL APIs. ```toml [build-dependencies] -gl_generator = "0.14.0" +gl_generator = "0.15.0" ``` ### khronos_api diff --git a/gl/Cargo.toml b/gl/Cargo.toml index 3d181d4d..c5e74586 100644 --- a/gl/Cargo.toml +++ b/gl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gl" -version = "0.14.0" +version = "0.15.0" authors = [ "Brendan Zabarauskas ", "Corey Richardson", @@ -17,7 +17,7 @@ categories = ["api-bindings", "rendering::graphics-api"] keywords = ["gl", "egl", "opengl", "khronos"] [build-dependencies] -gl_generator = { version = "0.14.0", path = "../gl_generator" } +gl_generator = { version = "0.15.0", path = "../gl_generator" } [dev-dependencies] glutin = "0.24" diff --git a/gl/README.md b/gl/README.md index 8e72e504..672c6a12 100644 --- a/gl/README.md +++ b/gl/README.md @@ -8,7 +8,7 @@ An OpenGL function pointer loader for the Rust Programming Language. ```toml [dependencies] -gl = "0.14.0" +gl = "0.15.0" ``` ## Basic usage diff --git a/gl_generator/Cargo.toml b/gl_generator/Cargo.toml index 98f545d3..0a72881f 100644 --- a/gl_generator/Cargo.toml +++ b/gl_generator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gl_generator" -version = "0.14.1" +version = "0.15.0" authors = [ "Brendan Zabarauskas ", "Corey Richardson", diff --git a/gl_generator/README.md b/gl_generator/README.md index 41146f21..487daf91 100644 --- a/gl_generator/README.md +++ b/gl_generator/README.md @@ -19,7 +19,7 @@ Add this to your `Cargo.toml`: ```toml [build-dependencies] -gl_generator = "0.14.0" +gl_generator = "0.15.0" ``` Under the `[package]` section, add: @@ -71,7 +71,7 @@ The `build.rs` file will generate all the OpenGL functions in a file named, ### Global generator -The global generator is the one used by default by the `gl` crate. See the +The global generator is the one used by default by the `gl` crate. See the [README](https://github.com/brendanzab/gl-rs/tree/master/gl) for more details. ### Struct generator