@@ -59,6 +59,8 @@ class CallableCustomExtension : public CallableCustom {
5959
6060 GDExtensionCallableCustomToString to_string_func;
6161
62+ GDExtensionCallableCustomGetArgumentCount get_argument_count_func;
63+
6264 uint32_t _hash;
6365
6466 static bool default_compare_equal (const CallableCustom *p_a, const CallableCustom *p_b) {
@@ -143,6 +145,21 @@ class CallableCustomExtension : public CallableCustom {
143145 return object;
144146 }
145147
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+
146163 void *get_userdata (void *p_token) const {
147164 return (p_token == token) ? userdata : nullptr ;
148165 }
@@ -157,6 +174,7 @@ class CallableCustomExtension : public CallableCustom {
157174 r_call_error.expected = error.expected ;
158175 }
159176
177+ #ifndef DISABLE_DEPRECATED
160178 CallableCustomExtension (GDExtensionCallableCustomInfo *p_info) {
161179 userdata = p_info->callable_userdata ;
162180 token = p_info->token ;
@@ -172,6 +190,35 @@ class CallableCustomExtension : public CallableCustom {
172190
173191 to_string_func = p_info->to_string_func ;
174192
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+
175222 // Pre-calculate the hash.
176223 if (p_info->hash_func != nullptr ) {
177224 _hash = p_info->hash_func (userdata);
@@ -1378,9 +1425,15 @@ static GDExtensionScriptInstancePtr gdextension_object_get_script_instance(GDExt
13781425 return script_instance_extension->instance ;
13791426}
13801427
1428+ #ifndef DISABLE_DEPRECATED
13811429static void gdextension_callable_custom_create (GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo *p_custom_callable_info) {
13821430 memnew_placement (r_callable, Callable (memnew (CallableCustomExtension (p_custom_callable_info))));
13831431}
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+ }
13841437
13851438static void *gdextension_callable_custom_get_userdata (GDExtensionTypePtr p_callable, void *p_token) {
13861439 const Callable &callable = *reinterpret_cast <const Callable *>(p_callable);
@@ -1595,7 +1648,10 @@ void gdextension_setup_interface() {
15951648 REGISTER_INTERFACE_FUNC (placeholder_script_instance_create);
15961649 REGISTER_INTERFACE_FUNC (placeholder_script_instance_update);
15971650 REGISTER_INTERFACE_FUNC (object_get_script_instance);
1651+ #ifndef DISABLE_DEPRECATED
15981652 REGISTER_INTERFACE_FUNC (callable_custom_create);
1653+ #endif // DISABLE_DEPRECATED
1654+ REGISTER_INTERFACE_FUNC (callable_custom_create2);
15991655 REGISTER_INTERFACE_FUNC (callable_custom_get_userdata);
16001656 REGISTER_INTERFACE_FUNC (classdb_construct_object);
16011657 REGISTER_INTERFACE_FUNC (classdb_get_method_bind);
0 commit comments