Skip to content

Commit e6debc9

Browse files
authored
Merge pull request #465 from lilizoey/fix/use-latest-preview-build
Fix custom callable no longer working on latest Godot master
2 parents 0028a86 + 79ed1bb commit e6debc9

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

godot-core/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ categories = ["game-engines", "graphics"]
1111
default = []
1212
codegen-fmt = ["godot-ffi/codegen-fmt", "godot-codegen/codegen-fmt"]
1313
codegen-full = ["godot-codegen/codegen-full"]
14-
codegen-lazy-fptrs = ["godot-ffi/codegen-lazy-fptrs", "godot-codegen/codegen-lazy-fptrs"]
14+
codegen-lazy-fptrs = [
15+
"godot-ffi/codegen-lazy-fptrs",
16+
"godot-codegen/codegen-lazy-fptrs",
17+
]
1518
custom-godot = ["godot-ffi/custom-godot", "godot-codegen/custom-godot"]
1619
double-precision = ["godot-codegen/double-precision"]
1720
experimental-godot-api = ["godot-codegen/experimental-godot-api"]

godot-core/src/builtin/callable.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ impl Callable {
5353
}
5454
}
5555

56+
#[cfg(since_api = "4.2")]
57+
fn default_callable_custom_info() -> sys::GDExtensionCallableCustomInfo {
58+
sys::GDExtensionCallableCustomInfo {
59+
callable_userdata: ptr::null_mut(),
60+
token: ptr::null_mut(),
61+
object_id: 0,
62+
call_func: None,
63+
is_valid_func: None, // could be customized, but no real use case yet.
64+
free_func: None,
65+
hash_func: None,
66+
equal_func: None,
67+
// Op < is only used in niche scenarios and default is usually good enough, see https://github.com/godotengine/godot/issues/81901.
68+
less_than_func: None,
69+
to_string_func: None,
70+
}
71+
}
72+
5673
/// Create a callable from a Rust function or closure.
5774
///
5875
/// `name` is used for the string representation of the closure, which helps debugging.
@@ -83,16 +100,10 @@ impl Callable {
83100

84101
let info = sys::GDExtensionCallableCustomInfo {
85102
callable_userdata: Box::into_raw(Box::new(userdata)) as *mut std::ffi::c_void,
86-
token: ptr::null_mut(),
87-
object: ptr::null_mut(),
88103
call_func: Some(rust_callable_call_fn::<F>),
89-
is_valid_func: None, // could be customized, but no real use case yet.
90104
free_func: Some(rust_callable_destroy::<FnWrapper<F>>),
91-
hash_func: None,
92-
equal_func: None,
93-
// Op < is only used in niche scenarios and default is usually good enough, see https://github.com/godotengine/godot/issues/81901.
94-
less_than_func: None,
95105
to_string_func: Some(rust_callable_to_string_named::<F>),
106+
..Self::default_callable_custom_info()
96107
};
97108

98109
Self::from_custom_info(info)
@@ -110,16 +121,12 @@ impl Callable {
110121

111122
let info = sys::GDExtensionCallableCustomInfo {
112123
callable_userdata: Box::into_raw(Box::new(userdata)) as *mut std::ffi::c_void,
113-
token: ptr::null_mut(),
114-
object: ptr::null_mut(),
115124
call_func: Some(rust_callable_call_custom::<C>),
116-
is_valid_func: None, // could be customized, but no real use case yet.
117125
free_func: Some(rust_callable_destroy::<C>),
118126
hash_func: Some(rust_callable_hash::<C>),
119127
equal_func: Some(rust_callable_equal::<C>),
120-
// Op < is only used in niche scenarios and default is usually good enough, see https://github.com/godotengine/godot/issues/81901.
121-
less_than_func: None,
122128
to_string_func: Some(rust_callable_to_string_display::<C>),
129+
..Self::default_callable_custom_info()
123130
};
124131

125132
Self::from_custom_info(info)

0 commit comments

Comments
 (0)