Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Oct 4, 2023
1 parent 17568de commit d5a60f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions godot-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ pub fn emit_godot_version_cfg() {
..
} = get_godot_version();

// if std::hint::black_box(true) {
// panic!("Godot version: {}.{}.{}", major, minor, patch);
// }

// Start at 1; checking for "since/before 4.0" makes no sense
let max = 2;
for m in 1..=minor {
Expand Down
15 changes: 14 additions & 1 deletion godot-core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub enum PluginComponent {

generated_recreate_fn: Option<
unsafe extern "C" fn(
p_class_userdata: *mut ::std::os::raw::c_void,
p_class_userdata: *mut std::ffi::c_void,
p_object: sys::GDExtensionObjectPtr,
) -> sys::GDExtensionClassInstancePtr,
>,
Expand Down Expand Up @@ -308,6 +308,7 @@ fn fill_class_info(component: PluginComponent, c: &mut ClassRegistrationInfo) {
free_fn,
} => {
c.parent_class_name = Some(base_class_name);

fill_into(
&mut c.godot_params.create_instance_func,
generated_create_fn,
Expand All @@ -318,10 +319,16 @@ fn fill_class_info(component: PluginComponent, c: &mut ClassRegistrationInfo) {
c.class_name,
)
);

#[cfg(before_api = "4.2")]
assert!(generated_recreate_fn.is_none()); // not used

#[cfg(since_api = "4.2")]
fill_into(
&mut c.godot_params.recreate_instance_func,
generated_recreate_fn,
);

c.godot_params.free_instance_func = Some(free_fn);
}

Expand All @@ -343,7 +350,13 @@ fn fill_class_info(component: PluginComponent, c: &mut ClassRegistrationInfo) {
// this shouldn't panic since rustc will error if there's
// multiple `impl {Class}Virtual for Thing` definitions
fill_into(&mut c.godot_params.create_instance_func, user_create_fn).unwrap();

#[cfg(before_api = "4.2")]
assert!(user_recreate_fn.is_none()); // not used

#[cfg(since_api = "4.2")]
fill_into(&mut c.godot_params.recreate_instance_func, user_recreate_fn);

c.godot_params.to_string_func = user_to_string_fn;
c.godot_params.notification_func = user_on_notification_fn;
c.godot_params.get_virtual_func = Some(get_virtual_fn);
Expand Down

0 comments on commit d5a60f4

Please sign in to comment.