fix bindgen

This commit is contained in:
Cobrand
2024-06-13 15:24:49 +02:00
parent 22a8c3114f
commit 0ab402a616
8 changed files with 3830 additions and 13085 deletions

View File

@@ -31,9 +31,9 @@ optional = true
[dev-dependencies]
rand = "0.7"
wgpu = { version = "0.19", features = ["spirv"] }
wgpu = { version = "0.20", features = ["spirv"] }
pollster = "0.2.4"
env_logger = "0.9.0"
env_logger = "0.11.0"
[dependencies.raw-window-handle]
version = "0.6.0"

View File

@@ -20,7 +20,7 @@ path = "src/lib.rs"
libc = "^0.2"
[build-dependencies.bindgen]
version = "^0.53"
version = "^0.69"
optional = true
[build-dependencies.pkg-config]

View File

@@ -756,11 +756,11 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) {
let bindings = bindings
.header("wrapper.h")
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
.blocklist_item("FP_NAN")
.blocklist_item("FP_INFINITE")
.blocklist_item("FP_ZERO")
.blocklist_item("FP_SUBNORMAL")
.blocklist_item("FP_NORMAL")
.derive_debug(false)
.generate()
.expect("Unable to generate bindings!");
@@ -774,16 +774,16 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) {
if cfg!(feature = "image") {
let image_bindings = image_bindings
.header("wrapper_image.h")
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
.whitelist_type("IMG.*")
.whitelist_function("IMG.*")
.whitelist_var("IMG.*")
.blacklist_type("SDL_.*")
.blacklist_type("_IO.*|FILE")
.blocklist_item("FP_NAN")
.blocklist_item("FP_INFINITE")
.blocklist_item("FP_ZERO")
.blocklist_item("FP_SUBNORMAL")
.blocklist_item("FP_NORMAL")
.allowlist_type("IMG.*")
.allowlist_function("IMG.*")
.allowlist_var("IMG.*")
.blocklist_type("SDL_.*")
.blocklist_type("_IO.*|FILE")
.generate()
.expect("Unable to generate image_bindings!");
@@ -797,16 +797,16 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) {
if cfg!(feature = "ttf") {
let ttf_bindings = ttf_bindings
.header("wrapper_ttf.h")
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
.whitelist_type("TTF.*")
.whitelist_function("TTF.*")
.whitelist_var("TTF.*")
.blacklist_type("SDL_.*")
.blacklist_type("_IO.*|FILE")
.blocklist_item("FP_NAN")
.blocklist_item("FP_INFINITE")
.blocklist_item("FP_ZERO")
.blocklist_item("FP_SUBNORMAL")
.blocklist_item("FP_NORMAL")
.allowlist_type("TTF.*")
.allowlist_function("TTF.*")
.allowlist_var("TTF.*")
.blocklist_type("SDL_.*")
.blocklist_type("_IO.*|FILE")
.generate()
.expect("Unable to generate ttf_bindings!");
@@ -820,19 +820,19 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) {
if cfg!(feature = "mixer") {
let mixer_bindings = mixer_bindings
.header("wrapper_mixer.h")
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
.whitelist_type("MIX.*")
.whitelist_type("Mix.*")
.whitelist_type("MUS.*")
.whitelist_function("Mix.*")
.whitelist_var("MIX.*")
.whitelist_var("MUS.*")
.blacklist_type("SDL_.*")
.blacklist_type("_IO.*|FILE")
.blocklist_item("FP_NAN")
.blocklist_item("FP_INFINITE")
.blocklist_item("FP_ZERO")
.blocklist_item("FP_SUBNORMAL")
.blocklist_item("FP_NORMAL")
.allowlist_type("MIX.*")
.allowlist_type("Mix.*")
.allowlist_type("MUS.*")
.allowlist_function("Mix.*")
.allowlist_var("MIX.*")
.allowlist_var("MUS.*")
.blocklist_type("SDL_.*")
.blocklist_type("_IO.*|FILE")
.generate()
.expect("Unable to generate mixer_bindings!");
@@ -846,15 +846,15 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) {
if cfg!(feature = "gfx") {
let gfx_framerate_bindings = gfx_framerate_bindings
.header("wrapper_gfx_framerate.h")
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
.whitelist_type("FPS.*")
.whitelist_function("SDL_.*rame.*")
.whitelist_var("FPS.*")
.blacklist_type("_IO.*|FILE")
.blocklist_item("FP_NAN")
.blocklist_item("FP_INFINITE")
.blocklist_item("FP_ZERO")
.blocklist_item("FP_SUBNORMAL")
.blocklist_item("FP_NORMAL")
.allowlist_type("FPS.*")
.allowlist_function("SDL_.*rame.*")
.allowlist_var("FPS.*")
.blocklist_type("_IO.*|FILE")
.generate()
.expect("Unable to generate gfx_framerate_bindings!");
@@ -866,31 +866,31 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) {
let gfx_primitives_bindings = gfx_primitives_bindings
.header("wrapper_gfx_primitives.h")
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
.blacklist_type("SDL_.*")
.whitelist_function("pixel.*")
.whitelist_function("rectangle.*")
.whitelist_function("rounded.*")
.whitelist_function("box.*")
.whitelist_function(".*line(Color|RGBA).*")
.whitelist_function("thick.*")
.whitelist_function(".*circle.*")
.whitelist_function("arc.*")
.whitelist_function("filled.*")
.whitelist_function(".*ellipse.*")
.whitelist_function("pie.*")
.whitelist_function(".*trigon.*")
.whitelist_function(".*polygon.*")
.whitelist_function("textured.*")
.whitelist_function("bezier.*")
.whitelist_function("character.*")
.whitelist_function("string.*")
.whitelist_function("gfx.*")
.blacklist_type("_IO.*|FILE")
.blocklist_item("FP_NAN")
.blocklist_item("FP_INFINITE")
.blocklist_item("FP_ZERO")
.blocklist_item("FP_SUBNORMAL")
.blocklist_item("FP_NORMAL")
.blocklist_type("SDL_.*")
.allowlist_function("pixel.*")
.allowlist_function("rectangle.*")
.allowlist_function("rounded.*")
.allowlist_function("box.*")
.allowlist_function(".*line(Color|RGBA).*")
.allowlist_function("thick.*")
.allowlist_function(".*circle.*")
.allowlist_function("arc.*")
.allowlist_function("filled.*")
.allowlist_function(".*ellipse.*")
.allowlist_function("pie.*")
.allowlist_function(".*trigon.*")
.allowlist_function(".*polygon.*")
.allowlist_function("textured.*")
.allowlist_function("bezier.*")
.allowlist_function("character.*")
.allowlist_function("string.*")
.allowlist_function("gfx.*")
.blocklist_type("_IO.*|FILE")
.generate()
.expect("Unable to generate gfx_primitives_bindings!");
@@ -902,13 +902,13 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) {
let gfx_imagefilter_bindings = gfx_imagefilter_bindings
.header("wrapper_gfx_imagefilter.h")
.whitelist_function("SDL_image.*")
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
.blacklist_type("_IO.*|FILE")
.allowlist_function("SDL_image.*")
.blocklist_item("FP_NAN")
.blocklist_item("FP_INFINITE")
.blocklist_item("FP_ZERO")
.blocklist_item("FP_SUBNORMAL")
.blocklist_item("FP_NORMAL")
.blocklist_type("_IO.*|FILE")
.generate()
.expect("Unable to generate gfx_imagefilter_bindings!");
@@ -920,17 +920,17 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) {
let gfx_rotozoom_bindings = gfx_rotozoom_bindings
.header("wrapper_gfx_rotozoom.h")
.blacklist_type("SDL_.*")
.whitelist_function("rotozoom.*")
.whitelist_function("zoom.*")
.whitelist_function("shrink.*")
.whitelist_function("rotate.*")
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
.blacklist_type("_IO.*|FILE")
.blocklist_type("SDL_.*")
.allowlist_function("rotozoom.*")
.allowlist_function("zoom.*")
.allowlist_function("shrink.*")
.allowlist_function("rotate.*")
.blocklist_item("FP_NAN")
.blocklist_item("FP_INFINITE")
.blocklist_item("FP_ZERO")
.blocklist_item("FP_SUBNORMAL")
.blocklist_item("FP_NORMAL")
.blocklist_type("_IO.*|FILE")
.generate()
.expect("Unable to generate gfx_rotozoom_bindings!");

File diff suppressed because one or more lines are too long

View File

@@ -669,11 +669,19 @@ pub enum Event {
timestamp: u32,
window_id: u32,
which: u32,
/// How much did we scroll in X, with integer precision
x: i32,
/// How much did we scroll in Y, with integer precision
y: i32,
direction: MouseWheelDirection,
/// How much did we scroll in X, with floating precision (added in 2.0.18)
precise_x: f32,
/// How much did we scroll in Y, with floating precision (added in 2.0.18)
precise_y: f32,
/// The X position of the mouse from the window's origin
mouse_x: i32,
/// The X position of the mouse from the window's origin
mouse_y: i32
},
JoyAxisMotion {
@@ -1205,6 +1213,8 @@ impl Event {
direction,
precise_x,
precise_y,
mouse_x,
mouse_y
} => {
let event = sys::SDL_MouseWheelEvent {
type_: SDL_EventType::SDL_MOUSEWHEEL as u32,
@@ -1216,6 +1226,8 @@ impl Event {
direction: direction.to_ll(),
preciseX: precise_x,
preciseY: precise_y,
mouseX: mouse_x,
mouseY: mouse_y,
};
unsafe {
ptr::copy(&event, ret.as_mut_ptr() as *mut sys::SDL_MouseWheelEvent, 1);
@@ -1680,6 +1692,8 @@ impl Event {
direction: mouse::MouseWheelDirection::from_ll(event.direction),
precise_x: event.preciseX,
precise_y: event.preciseY,
mouse_x: event.mouseX,
mouse_y: event.mouseY,
}
}
@@ -2356,6 +2370,8 @@ impl Event {
/// precise_y: 0.0,
/// x: 0,
/// y: 0,
/// mouse_x: 0,
/// mouse_y: 0,
/// direction: MouseWheelDirection::Normal,
/// };
/// assert!(ev.is_mouse());
@@ -2925,6 +2941,8 @@ mod test {
direction: MouseWheelDirection::Flipped,
precise_x: 1.6,
precise_y: 2.7,
mouse_x: 0,
mouse_y: 5,
};
let e2 = Event::from_ll(e.clone().to_ll().unwrap());
assert_eq!(e, e2);

View File

@@ -118,7 +118,7 @@ impl PowerLevel {
SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_MEDIUM => PowerLevel::Medium,
SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_FULL => PowerLevel::Full,
SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_WIRED => PowerLevel::Wired,
_ => panic!("Unexpected power level: {:?}", raw),
_ => panic!("Unexpected power level: {}", raw as i32),
}
}

View File

@@ -145,7 +145,7 @@ impl<'a> io::Read for RWops<'a> {
self.raw,
buf.as_ptr() as *mut c_void,
1,
out_len as sys::size_t,
out_len as libc::size_t,
)
};
Ok(ret as usize)
@@ -160,7 +160,7 @@ impl<'a> io::Write for RWops<'a> {
self.raw,
buf.as_ptr() as *const c_void,
1,
in_len as sys::size_t,
in_len as libc::size_t,
)
};
Ok(ret as usize)

View File

@@ -1489,7 +1489,7 @@ impl Window {
#[doc(alias = "SDL_GetWindowICCProfile")]
pub fn icc_profile(&self) -> Result<Vec<u8>, String> {
unsafe {
let mut size: sys::size_t = 0;
let mut size: libc::size_t = 0;
let data = sys::SDL_GetWindowICCProfile(self.context.raw, &mut size as *mut _);
if data.is_null() {
return Err(get_error());
@@ -1556,9 +1556,9 @@ impl Window {
#[doc(alias = "SDL_SetWindowResizable")]
pub fn set_resizable(&mut self, resizable: bool) {
let resizable = if resizable {
SDL_bool::SDL_TRUE
sys::SDL_bool::SDL_TRUE
} else {
SDL_bool::SDL_FALSE
sys::SDL_bool::SDL_FALSE
};
unsafe {
sys::SDL_SetWindowResizable(self.context.raw, resizable);