@@ -16,6 +16,11 @@ use crate::obj::{Gd, GodotClass, InstanceId};
16
16
use std:: { fmt, ptr} ;
17
17
use sys:: { ffi_methods, GodotFfi } ;
18
18
19
+ #[ cfg( all( since_api = "4.2" , before_api = "4.3" ) ) ]
20
+ type CallableCustomInfo = sys:: GDExtensionCallableCustomInfo ;
21
+ #[ cfg( since_api = "4.3" ) ]
22
+ type CallableCustomInfo = sys:: GDExtensionCallableCustomInfo2 ;
23
+
19
24
/// A `Callable` represents a function in Godot.
20
25
///
21
26
/// Usually a callable is a reference to an `Object` and a method name, this is a standard callable. But can
@@ -61,8 +66,8 @@ impl Callable {
61
66
}
62
67
63
68
#[ cfg( since_api = "4.2" ) ]
64
- fn default_callable_custom_info ( ) -> sys :: GDExtensionCallableCustomInfo {
65
- sys :: GDExtensionCallableCustomInfo {
69
+ fn default_callable_custom_info ( ) -> CallableCustomInfo {
70
+ CallableCustomInfo {
66
71
callable_userdata : ptr:: null_mut ( ) ,
67
72
token : ptr:: null_mut ( ) ,
68
73
object_id : 0 ,
@@ -74,6 +79,8 @@ impl Callable {
74
79
// Op < is only used in niche scenarios and default is usually good enough, see https://github.com/godotengine/godot/issues/81901.
75
80
less_than_func : None ,
76
81
to_string_func : None ,
82
+ #[ cfg( since_api = "4.3" ) ]
83
+ get_argument_count_func : None ,
77
84
}
78
85
}
79
86
@@ -105,7 +112,7 @@ impl Callable {
105
112
} ,
106
113
} ;
107
114
108
- let info = sys :: GDExtensionCallableCustomInfo {
115
+ let info = CallableCustomInfo {
109
116
callable_userdata : Box :: into_raw ( Box :: new ( userdata) ) as * mut std:: ffi:: c_void ,
110
117
call_func : Some ( rust_callable_call_fn :: < F > ) ,
111
118
free_func : Some ( rust_callable_destroy :: < FnWrapper < F > > ) ,
@@ -126,7 +133,7 @@ impl Callable {
126
133
// - a type-erased workaround for PartialEq supertrait (which has a `Self` type parameter and thus is not object-safe)
127
134
let userdata = CallableUserdata { inner : callable } ;
128
135
129
- let info = sys :: GDExtensionCallableCustomInfo {
136
+ let info = CallableCustomInfo {
130
137
callable_userdata : Box :: into_raw ( Box :: new ( userdata) ) as * mut std:: ffi:: c_void ,
131
138
call_func : Some ( rust_callable_call_custom :: < C > ) ,
132
139
free_func : Some ( rust_callable_destroy :: < C > ) ,
@@ -140,11 +147,18 @@ impl Callable {
140
147
}
141
148
142
149
#[ cfg( since_api = "4.2" ) ]
143
- fn from_custom_info ( mut info : sys :: GDExtensionCallableCustomInfo ) -> Callable {
150
+ fn from_custom_info ( mut info : CallableCustomInfo ) -> Callable {
144
151
// SAFETY: callable_custom_create() is a valid way of creating callables.
145
152
unsafe {
146
153
Callable :: new_with_uninit ( |type_ptr| {
147
- sys:: interface_fn!( callable_custom_create) ( type_ptr, ptr:: addr_of_mut!( info) )
154
+ #[ cfg( before_api = "4.3" ) ]
155
+ {
156
+ sys:: interface_fn!( callable_custom_create) ( type_ptr, ptr:: addr_of_mut!( info) )
157
+ }
158
+ #[ cfg( since_api = "4.3" ) ]
159
+ {
160
+ sys:: interface_fn!( callable_custom_create2) ( type_ptr, ptr:: addr_of_mut!( info) )
161
+ }
148
162
} )
149
163
}
150
164
}
0 commit comments