@@ -364,13 +364,18 @@ typedef struct {
364
364
GDExtensionClassMethodPtrCall ptrcall_func ;
365
365
uint32_t method_flags ; // Bitfield of `GDExtensionClassMethodFlags`.
366
366
367
- /* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored. */
367
+ /* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored.
368
+ *
369
+ * @todo Consider dropping `has_return_value` and making the other two properties match `GDExtensionMethodInfo` and `GDExtensionClassVirtualMethod` for consistency in future version of this struct.
370
+ */
368
371
GDExtensionBool has_return_value ;
369
372
GDExtensionPropertyInfo * return_value_info ;
370
373
GDExtensionClassMethodArgumentMetadata return_value_metadata ;
371
374
372
375
/* Arguments: `arguments_info` and `arguments_metadata` are array of size `argument_count`.
373
376
* Name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies.
377
+ *
378
+ * @todo Consider renaming `arguments_info` to `arguments` for consistency in future version of this struct.
374
379
*/
375
380
uint32_t argument_count ;
376
381
GDExtensionPropertyInfo * arguments_info ;
@@ -381,6 +386,18 @@ typedef struct {
381
386
GDExtensionVariantPtr * default_arguments ;
382
387
} GDExtensionClassMethodInfo ;
383
388
389
+ typedef struct {
390
+ GDExtensionStringNamePtr name ;
391
+ uint32_t method_flags ; // Bitfield of `GDExtensionClassMethodFlags`.
392
+
393
+ GDExtensionPropertyInfo return_value ;
394
+ GDExtensionClassMethodArgumentMetadata return_value_metadata ;
395
+
396
+ uint32_t argument_count ;
397
+ GDExtensionPropertyInfo * arguments ;
398
+ GDExtensionClassMethodArgumentMetadata * arguments_metadata ;
399
+ } GDExtensionClassVirtualMethodInfo ;
400
+
384
401
typedef void (* GDExtensionCallableCustomCall )(void * callable_userdata , const GDExtensionConstVariantPtr * p_args , GDExtensionInt p_argument_count , GDExtensionVariantPtr r_return , GDExtensionCallError * r_error );
385
402
typedef GDExtensionBool (* GDExtensionCallableCustomIsValid )(void * callable_userdata );
386
403
typedef void (* GDExtensionCallableCustomFree )(void * callable_userdata );
@@ -2268,6 +2285,34 @@ typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectGetInstanceFromId)(GDOb
2268
2285
*/
2269
2286
typedef GDObjectInstanceID (* GDExtensionInterfaceObjectGetInstanceId )(GDExtensionConstObjectPtr p_object );
2270
2287
2288
+ /**
2289
+ * @name object_has_script_method
2290
+ * @since 4.3
2291
+ *
2292
+ * Checks if this object has a script with the given method.
2293
+ *
2294
+ * @param p_object A pointer to the Object.
2295
+ * @param p_method A pointer to a StringName identifying the method.
2296
+ *
2297
+ * @returns true if the object has a script and that script has a method with the given name. Returns false if the object has no script.
2298
+ */
2299
+ typedef GDExtensionBool (* GDExtensionInterfaceObjectHasScriptMethod )(GDExtensionConstObjectPtr p_object , GDExtensionConstStringNamePtr p_method );
2300
+
2301
+ /**
2302
+ * @name object_call_script_method
2303
+ * @since 4.3
2304
+ *
2305
+ * Call the given script method on this object.
2306
+ *
2307
+ * @param p_object A pointer to the Object.
2308
+ * @param p_method A pointer to a StringName identifying the method.
2309
+ * @param p_args A pointer to a C array of Variant.
2310
+ * @param p_argument_count The number of arguments.
2311
+ * @param r_return A pointer a Variant which will be assigned the return value.
2312
+ * @param r_error A pointer the structure which will hold error information.
2313
+ */
2314
+ typedef void (* GDExtensionInterfaceObjectCallScriptMethod )(GDExtensionObjectPtr p_object , GDExtensionConstStringNamePtr p_method , const GDExtensionConstVariantPtr * p_args , GDExtensionInt p_argument_count , GDExtensionUninitializedVariantPtr r_return , GDExtensionCallError * r_error );
2315
+
2271
2316
/* INTERFACE: Reference */
2272
2317
2273
2318
/**
@@ -2483,6 +2528,20 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass2)(GDExtensionCl
2483
2528
*/
2484
2529
typedef void (* GDExtensionInterfaceClassdbRegisterExtensionClassMethod )(GDExtensionClassLibraryPtr p_library , GDExtensionConstStringNamePtr p_class_name , const GDExtensionClassMethodInfo * p_method_info );
2485
2530
2531
+ /**
2532
+ * @name classdb_register_extension_class_virtual_method
2533
+ * @since 4.3
2534
+ *
2535
+ * Registers a virtual method on an extension class in ClassDB, that can be implemented by scripts or other extensions.
2536
+ *
2537
+ * Provided struct can be safely freed once the function returns.
2538
+ *
2539
+ * @param p_library A pointer the library received by the GDExtension's entry point function.
2540
+ * @param p_class_name A pointer to a StringName with the class name.
2541
+ * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct.
2542
+ */
2543
+ typedef void (* GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod )(GDExtensionClassLibraryPtr p_library , GDExtensionConstStringNamePtr p_class_name , const GDExtensionClassVirtualMethodInfo * p_method_info );
2544
+
2486
2545
/**
2487
2546
* @name classdb_register_extension_class_integer_constant
2488
2547
* @since 4.1
0 commit comments