@@ -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