@@ -442,6 +442,8 @@ typedef GDExtensionBool (*GDExtensionCallableCustomLessThan)(void *callable_user
442
442
443
443
typedef void (* GDExtensionCallableCustomToString )(void * callable_userdata , GDExtensionBool * r_is_valid , GDExtensionStringPtr r_out );
444
444
445
+ typedef GDExtensionInt (* GDExtensionCallableCustomGetArgumentCount )(void * callable_userdata , GDExtensionBool * r_is_valid );
446
+
445
447
typedef struct {
446
448
/* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
447
449
*
@@ -471,7 +473,40 @@ typedef struct {
471
473
GDExtensionCallableCustomLessThan less_than_func ;
472
474
473
475
GDExtensionCallableCustomToString to_string_func ;
474
- } GDExtensionCallableCustomInfo ;
476
+ } GDExtensionCallableCustomInfo ; // Deprecated. Use GDExtensionCallableCustomInfo2 instead.
477
+
478
+ typedef struct {
479
+ /* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
480
+ *
481
+ * `token` should point to an address that uniquely identifies the GDExtension (for example, the
482
+ * `GDExtensionClassLibraryPtr` passed to the entry symbol function.
483
+ *
484
+ * `hash_func`, `equal_func`, and `less_than_func` are optional. If not provided both `call_func` and
485
+ * `callable_userdata` together are used as the identity of the callable for hashing and comparison purposes.
486
+ *
487
+ * The hash returned by `hash_func` is cached, `hash_func` will not be called more than once per callable.
488
+ *
489
+ * `is_valid_func` is necessary if the validity of the callable can change before destruction.
490
+ *
491
+ * `free_func` is necessary if `callable_userdata` needs to be cleaned up when the callable is freed.
492
+ */
493
+ void * callable_userdata ;
494
+ void * token ;
495
+
496
+ GDObjectInstanceID object_id ;
497
+
498
+ GDExtensionCallableCustomCall call_func ;
499
+ GDExtensionCallableCustomIsValid is_valid_func ;
500
+ GDExtensionCallableCustomFree free_func ;
501
+
502
+ GDExtensionCallableCustomHash hash_func ;
503
+ GDExtensionCallableCustomEqual equal_func ;
504
+ GDExtensionCallableCustomLessThan less_than_func ;
505
+
506
+ GDExtensionCallableCustomToString to_string_func ;
507
+
508
+ GDExtensionCallableCustomGetArgumentCount get_argument_count_func ;
509
+ } GDExtensionCallableCustomInfo2 ;
475
510
476
511
/* SCRIPT INSTANCE EXTENSION */
477
512
@@ -2450,6 +2485,7 @@ typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptIn
2450
2485
/**
2451
2486
* @name callable_custom_create
2452
2487
* @since 4.2
2488
+ * @deprecated in Godot 4.3. Use `callable_custom_create2` instead.
2453
2489
*
2454
2490
* Creates a custom Callable object from a function pointer.
2455
2491
*
@@ -2460,6 +2496,19 @@ typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptIn
2460
2496
*/
2461
2497
typedef void (* GDExtensionInterfaceCallableCustomCreate )(GDExtensionUninitializedTypePtr r_callable , GDExtensionCallableCustomInfo * p_callable_custom_info );
2462
2498
2499
+ /**
2500
+ * @name callable_custom_create2
2501
+ * @since 4.3
2502
+ *
2503
+ * Creates a custom Callable object from a function pointer.
2504
+ *
2505
+ * Provided struct can be safely freed once the function returns.
2506
+ *
2507
+ * @param r_callable A pointer that will receive the new Callable.
2508
+ * @param p_callable_custom_info The info required to construct a Callable.
2509
+ */
2510
+ typedef void (* GDExtensionInterfaceCallableCustomCreate2 )(GDExtensionUninitializedTypePtr r_callable , GDExtensionCallableCustomInfo2 * p_callable_custom_info );
2511
+
2463
2512
/**
2464
2513
* @name callable_custom_get_userdata
2465
2514
* @since 4.2
0 commit comments