@@ -59,6 +59,8 @@ class CallableCustomExtension : public CallableCustom {
59
59
60
60
GDExtensionCallableCustomToString to_string_func;
61
61
62
+ GDExtensionCallableCustomGetArgumentCount get_argument_count_func;
63
+
62
64
uint32_t _hash;
63
65
64
66
static bool default_compare_equal (const CallableCustom *p_a, const CallableCustom *p_b) {
@@ -143,6 +145,21 @@ class CallableCustomExtension : public CallableCustom {
143
145
return object;
144
146
}
145
147
148
+ int get_argument_count (bool &r_is_valid) const override {
149
+ if (get_argument_count_func != nullptr ) {
150
+ GDExtensionBool is_valid = false ;
151
+
152
+ GDExtensionInt ret = get_argument_count_func (userdata, &is_valid);
153
+
154
+ if (is_valid) {
155
+ r_is_valid = true ;
156
+ return ret;
157
+ }
158
+ }
159
+ r_is_valid = false ;
160
+ return 0 ;
161
+ }
162
+
146
163
void *get_userdata (void *p_token) const {
147
164
return (p_token == token) ? userdata : nullptr ;
148
165
}
@@ -157,6 +174,7 @@ class CallableCustomExtension : public CallableCustom {
157
174
r_call_error.expected = error.expected ;
158
175
}
159
176
177
+ #ifndef DISABLE_DEPRECATED
160
178
CallableCustomExtension (GDExtensionCallableCustomInfo *p_info) {
161
179
userdata = p_info->callable_userdata ;
162
180
token = p_info->token ;
@@ -172,6 +190,35 @@ class CallableCustomExtension : public CallableCustom {
172
190
173
191
to_string_func = p_info->to_string_func ;
174
192
193
+ get_argument_count_func = nullptr ;
194
+
195
+ // Pre-calculate the hash.
196
+ if (p_info->hash_func != nullptr ) {
197
+ _hash = p_info->hash_func (userdata);
198
+ } else {
199
+ _hash = hash_murmur3_one_64 ((uint64_t )call_func);
200
+ _hash = hash_murmur3_one_64 ((uint64_t )userdata, _hash);
201
+ }
202
+ }
203
+ #endif
204
+
205
+ CallableCustomExtension (GDExtensionCallableCustomInfo2 *p_info) {
206
+ userdata = p_info->callable_userdata ;
207
+ token = p_info->token ;
208
+
209
+ object = p_info->object_id ;
210
+
211
+ call_func = p_info->call_func ;
212
+ is_valid_func = p_info->is_valid_func ;
213
+ free_func = p_info->free_func ;
214
+
215
+ equal_func = p_info->equal_func ;
216
+ less_than_func = p_info->less_than_func ;
217
+
218
+ to_string_func = p_info->to_string_func ;
219
+
220
+ get_argument_count_func = p_info->get_argument_count_func ;
221
+
175
222
// Pre-calculate the hash.
176
223
if (p_info->hash_func != nullptr ) {
177
224
_hash = p_info->hash_func (userdata);
@@ -1378,9 +1425,15 @@ static GDExtensionScriptInstancePtr gdextension_object_get_script_instance(GDExt
1378
1425
return script_instance_extension->instance ;
1379
1426
}
1380
1427
1428
+ #ifndef DISABLE_DEPRECATED
1381
1429
static void gdextension_callable_custom_create (GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo *p_custom_callable_info) {
1382
1430
memnew_placement (r_callable, Callable (memnew (CallableCustomExtension (p_custom_callable_info))));
1383
1431
}
1432
+ #endif
1433
+
1434
+ static void gdextension_callable_custom_create2 (GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo2 *p_custom_callable_info) {
1435
+ memnew_placement (r_callable, Callable (memnew (CallableCustomExtension (p_custom_callable_info))));
1436
+ }
1384
1437
1385
1438
static void *gdextension_callable_custom_get_userdata (GDExtensionTypePtr p_callable, void *p_token) {
1386
1439
const Callable &callable = *reinterpret_cast <const Callable *>(p_callable);
@@ -1595,7 +1648,10 @@ void gdextension_setup_interface() {
1595
1648
REGISTER_INTERFACE_FUNC (placeholder_script_instance_create);
1596
1649
REGISTER_INTERFACE_FUNC (placeholder_script_instance_update);
1597
1650
REGISTER_INTERFACE_FUNC (object_get_script_instance);
1651
+ #ifndef DISABLE_DEPRECATED
1598
1652
REGISTER_INTERFACE_FUNC (callable_custom_create);
1653
+ #endif // DISABLE_DEPRECATED
1654
+ REGISTER_INTERFACE_FUNC (callable_custom_create2);
1599
1655
REGISTER_INTERFACE_FUNC (callable_custom_get_userdata);
1600
1656
REGISTER_INTERFACE_FUNC (classdb_construct_object);
1601
1657
REGISTER_INTERFACE_FUNC (classdb_get_method_bind);
0 commit comments