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