From ff1fc49d5f3a06402783152b757fc2c87c9841d8 Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Sat, 15 Feb 2020 12:21:32 +0200 Subject: [PATCH] Upgrade bindgen, fix size_t changes --- imgui-sys-bindgen/Cargo.toml | 2 +- imgui-sys/src/bindings.rs | 29 +++++++++++++++-------------- src/context.rs | 2 +- src/fonts/atlas.rs | 2 +- src/input_widget.rs | 4 ++-- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/imgui-sys-bindgen/Cargo.toml b/imgui-sys-bindgen/Cargo.toml index 1cbfb36..5d6abcc 100644 --- a/imgui-sys-bindgen/Cargo.toml +++ b/imgui-sys-bindgen/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT/Apache-2.0" publish = false [dependencies] -bindgen = "0.52" +bindgen = "0.53" failure = "0.1" serde = "1.0" serde_derive = "1.0" diff --git a/imgui-sys/src/bindings.rs b/imgui-sys/src/bindings.rs index 970c05e..25a0c76 100644 --- a/imgui-sys/src/bindings.rs +++ b/imgui-sys/src/bindings.rs @@ -5,6 +5,7 @@ #![allow(non_snake_case)] #![allow(clippy::all)] +pub type size_t = ::std::os::raw::c_ulong; #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct ImVec2_Simple { @@ -5134,12 +5135,12 @@ extern "C" { extern "C" { pub fn igDebugCheckVersionAndDataLayout( version_str: *const ::std::os::raw::c_char, - sz_io: usize, - sz_style: usize, - sz_vec2: usize, - sz_vec4: usize, - sz_drawvert: usize, - sz_drawidx: usize, + sz_io: size_t, + sz_style: size_t, + sz_vec2: size_t, + sz_vec4: size_t, + sz_drawvert: size_t, + sz_drawidx: size_t, ) -> bool; } extern "C" { @@ -5900,7 +5901,7 @@ extern "C" { pub fn igInputText( label: *const ::std::os::raw::c_char, buf: *mut ::std::os::raw::c_char, - buf_size: usize, + buf_size: size_t, flags: ImGuiInputTextFlags, callback: ImGuiInputTextCallback, user_data: *mut ::std::os::raw::c_void, @@ -5910,7 +5911,7 @@ extern "C" { pub fn igInputTextMultiline( label: *const ::std::os::raw::c_char, buf: *mut ::std::os::raw::c_char, - buf_size: usize, + buf_size: size_t, size: ImVec2, flags: ImGuiInputTextFlags, callback: ImGuiInputTextCallback, @@ -5922,7 +5923,7 @@ extern "C" { label: *const ::std::os::raw::c_char, hint: *const ::std::os::raw::c_char, buf: *mut ::std::os::raw::c_char, - buf_size: usize, + buf_size: size_t, flags: ImGuiInputTextFlags, callback: ImGuiInputTextCallback, user_data: *mut ::std::os::raw::c_void, @@ -6420,7 +6421,7 @@ extern "C" { pub fn igSetDragDropPayload( type_: *const ::std::os::raw::c_char, data: *const ::std::os::raw::c_void, - sz: usize, + sz: size_t, cond: ImGuiCond, ) -> bool; } @@ -6615,19 +6616,19 @@ extern "C" { pub fn igLoadIniSettingsFromDisk(ini_filename: *const ::std::os::raw::c_char); } extern "C" { - pub fn igLoadIniSettingsFromMemory(ini_data: *const ::std::os::raw::c_char, ini_size: usize); + pub fn igLoadIniSettingsFromMemory(ini_data: *const ::std::os::raw::c_char, ini_size: size_t); } extern "C" { pub fn igSaveIniSettingsToDisk(ini_filename: *const ::std::os::raw::c_char); } extern "C" { - pub fn igSaveIniSettingsToMemory(out_ini_size: *mut usize) -> *const ::std::os::raw::c_char; + pub fn igSaveIniSettingsToMemory(out_ini_size: *mut size_t) -> *const ::std::os::raw::c_char; } extern "C" { pub fn igSetAllocatorFunctions( alloc_func: ::std::option::Option< unsafe extern "C" fn( - sz: usize, + sz: size_t, user_data: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void, >, @@ -6641,7 +6642,7 @@ extern "C" { ); } extern "C" { - pub fn igMemAlloc(size: usize) -> *mut ::std::os::raw::c_void; + pub fn igMemAlloc(size: size_t) -> *mut ::std::os::raw::c_void; } extern "C" { pub fn igMemFree(ptr: *mut ::std::os::raw::c_void); diff --git a/src/context.rs b/src/context.rs index 48fb352..8fa39dd 100644 --- a/src/context.rs +++ b/src/context.rs @@ -186,7 +186,7 @@ impl Context { } /// Loads settings from a string slice containing settings in .Ini file format pub fn load_ini_settings(&mut self, data: &str) { - unsafe { sys::igLoadIniSettingsFromMemory(data.as_ptr() as *const _, data.len()) } + unsafe { sys::igLoadIniSettingsFromMemory(data.as_ptr() as *const _, data.len() as u64) } } /// Saves settings to a mutable string buffer in .Ini file format pub fn save_ini_settings(&mut self, buf: &mut String) { diff --git a/src/fonts/atlas.rs b/src/fonts/atlas.rs index 3209171..4324d88 100644 --- a/src/fonts/atlas.rs +++ b/src/fonts/atlas.rs @@ -90,7 +90,7 @@ impl FontAtlas { // We can't guarantee `data` is alive when the font atlas is built, so // make a copy and move ownership of the data to the atlas let data_copy = unsafe { - let ptr = sys::igMemAlloc(data.len()) as *mut u8; + let ptr = sys::igMemAlloc(data.len() as u64) as *mut u8; assert!(!ptr.is_null()); slice::from_raw_parts_mut(ptr, data.len()) }; diff --git a/src/input_widget.rs b/src/input_widget.rs index ea197d5..c9b2573 100644 --- a/src/input_widget.rs +++ b/src/input_widget.rs @@ -190,7 +190,7 @@ impl<'ui, 'p> InputText<'ui, 'p> { let result = sys::igInputText( self.label.as_ptr(), ptr, - capacity, + capacity as u64, self.flags.bits(), callback, data, @@ -240,7 +240,7 @@ impl<'ui, 'p> InputTextMultiline<'ui, 'p> { let result = sys::igInputTextMultiline( self.label.as_ptr(), ptr, - capacity, + capacity as u64, self.size.into(), self.flags.bits(), callback,