@@ -724,6 +724,9 @@ typedef struct {
724
724
725
725
} GDExtensionScriptInstanceInfo3;
726
726
727
+ typedef void (*GDExtensionWorkerThreadPoolGroupTask)(void *, uint32_t );
728
+ typedef void (*GDExtensionWorkerThreadPoolTask)(void *);
729
+
727
730
/* INITIALIZATION */
728
731
729
732
typedef enum {
@@ -734,15 +737,18 @@ typedef enum {
734
737
GDEXTENSION_MAX_INITIALIZATION_LEVEL,
735
738
} GDExtensionInitializationLevel;
736
739
740
+ typedef void (*GDExtensionInitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
741
+ typedef void (*GDExtensionDeinitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
742
+
737
743
typedef struct {
738
744
/* Minimum initialization level required.
739
745
* If Core or Servers, the extension needs editor or game restart to take effect */
740
746
GDExtensionInitializationLevel minimum_initialization_level;
741
747
/* Up to the user to supply when initializing */
742
748
void *userdata;
743
749
/* This function will be called multiple times for each initialization level. */
744
- void (* initialize)( void *userdata, GDExtensionInitializationLevel p_level) ;
745
- void (* deinitialize)( void *userdata, GDExtensionInitializationLevel p_level) ;
750
+ GDExtensionInitializeCallback initialize;
751
+ GDExtensionDeinitializeCallback deinitialize;
746
752
} GDExtensionInitialization;
747
753
748
754
typedef void (*GDExtensionInterfaceFunctionPtr)();
@@ -815,8 +821,12 @@ typedef void (*GDExtensionMainLoopShutdownCallback)();
815
821
typedef void (*GDExtensionMainLoopFrameCallback)();
816
822
817
823
typedef struct {
824
+ // Will be called after Godot is started and is fully initialized.
818
825
GDExtensionMainLoopStartupCallback startup_func;
826
+ // Will be called before Godot is shutdown when it is still fully initialized.
819
827
GDExtensionMainLoopShutdownCallback shutdown_func;
828
+ // Will be called for each process frame. This will run after all `_process()` methods on Node, and before `ScriptServer::frame()`.
829
+ // This is intended to be the equivalent of `ScriptLanguage::frame()` for GDExtension language bindings that don't use the script API.
820
830
GDExtensionMainLoopFrameCallback frame_func;
821
831
} GDExtensionMainLoopCallbacks;
822
832
@@ -1035,7 +1045,7 @@ typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GD
1035
1045
*
1036
1046
* Calls a static method on a Variant.
1037
1047
*
1038
- * @param p_self A pointer to the Variant .
1048
+ * @param p_type The variant type .
1039
1049
* @param p_method A pointer to a StringName identifying the method.
1040
1050
* @param p_args A pointer to a C array of Variant.
1041
1051
* @param p_argument_count The number of arguments.
@@ -1321,7 +1331,7 @@ typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtension
1321
1331
* @param p_self A pointer to the Variant.
1322
1332
* @param p_method A pointer to a StringName with the method name.
1323
1333
*
1324
- * @return
1334
+ * @return true if the variant has the given method; otherwise false.
1325
1335
*/
1326
1336
typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
1327
1337
@@ -1334,7 +1344,7 @@ typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConst
1334
1344
* @param p_type The Variant type.
1335
1345
* @param p_member A pointer to a StringName with the member name.
1336
1346
*
1337
- * @return
1347
+ * @return true if the variant has the given method; otherwise false.
1338
1348
*/
1339
1349
typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
1340
1350
@@ -1505,7 +1515,7 @@ typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(
1505
1515
* Constructs a Variant of the given type, using the first constructor that matches the given arguments.
1506
1516
*
1507
1517
* @param p_type The Variant type.
1508
- * @param p_base A pointer to a Variant to store the constructed value.
1518
+ * @param r_base A pointer to a Variant to store the constructed value.
1509
1519
* @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor.
1510
1520
* @param p_argument_count The number of arguments to pass to the constructor.
1511
1521
* @param r_error A pointer the structure which will be updated with error information.
@@ -1728,7 +1738,7 @@ typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen2)(GDEx
1728
1738
*
1729
1739
* @param r_dest A pointer to a Variant to hold the newly created String.
1730
1740
* @param p_contents A pointer to a UTF-16 encoded C string.
1731
- * @param p_size The number of characters (not bytes).
1741
+ * @param p_char_count The number of characters (not bytes).
1732
1742
*/
1733
1743
typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count);
1734
1744
@@ -1740,7 +1750,7 @@ typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUni
1740
1750
*
1741
1751
* @param r_dest A pointer to a Variant to hold the newly created String.
1742
1752
* @param p_contents A pointer to a UTF-16 encoded C string.
1743
- * @param p_size The number of characters (not bytes).
1753
+ * @param p_char_count The number of characters (not bytes).
1744
1754
* @param p_default_little_endian If true, UTF-16 use little endian.
1745
1755
*
1746
1756
* @return Error code signifying if the operation successful.
@@ -1755,7 +1765,7 @@ typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen2)(GDE
1755
1765
*
1756
1766
* @param r_dest A pointer to a Variant to hold the newly created String.
1757
1767
* @param p_contents A pointer to a UTF-32 encoded C string.
1758
- * @param p_size The number of characters (not bytes).
1768
+ * @param p_char_count The number of characters (not bytes).
1759
1769
*/
1760
1770
typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_char_count);
1761
1771
@@ -1767,7 +1777,7 @@ typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUni
1767
1777
*
1768
1778
* @param r_dest A pointer to a Variant to hold the newly created String.
1769
1779
* @param p_contents A pointer to a wide C string.
1770
- * @param p_size The number of characters (not bytes).
1780
+ * @param p_char_count The number of characters (not bytes).
1771
1781
*/
1772
1782
typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_char_count);
1773
1783
@@ -2084,6 +2094,7 @@ typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_in
2084
2094
* @param p_instance A pointer to a WorkerThreadPool object.
2085
2095
* @param p_func A pointer to a function to run in the thread pool.
2086
2096
* @param p_userdata A pointer to arbitrary data which will be passed to p_func.
2097
+ * @param p_elements The number of element needed in the group.
2087
2098
* @param p_tasks The number of tasks needed in the group.
2088
2099
* @param p_high_priority Whether or not this is a high priority task.
2089
2100
* @param p_description A pointer to a String with the task description.
@@ -2092,7 +2103,7 @@ typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_in
2092
2103
*
2093
2104
* @see WorkerThreadPool::add_group_task()
2094
2105
*/
2095
- typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExtensionObjectPtr p_instance, void (* p_func)( void *, uint32_t ) , void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
2106
+ typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExtensionObjectPtr p_instance, GDExtensionWorkerThreadPoolGroupTask p_func, void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
2096
2107
2097
2108
/* *
2098
2109
* @name worker_thread_pool_add_native_task
@@ -2108,7 +2119,7 @@ typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExte
2108
2119
*
2109
2120
* @return The task ID.
2110
2121
*/
2111
- typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, void (* p_func)( void *) , void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
2122
+ typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, GDExtensionWorkerThreadPoolTask p_func, void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
2112
2123
2113
2124
/* INTERFACE: Packed Array */
2114
2125
@@ -2526,10 +2537,10 @@ typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensi
2526
2537
* Gets a pointer representing an Object's instance binding.
2527
2538
*
2528
2539
* @param p_o A pointer to the Object.
2529
- * @param p_library A token the library received by the GDExtension's entry point function.
2540
+ * @param p_token A token the library received by the GDExtension's entry point function.
2530
2541
* @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
2531
2542
*
2532
- * @return
2543
+ * @return A pointer to the instance binding.
2533
2544
*/
2534
2545
typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
2535
2546
@@ -2540,7 +2551,7 @@ typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectP
2540
2551
* Sets an Object's instance binding.
2541
2552
*
2542
2553
* @param p_o A pointer to the Object.
2543
- * @param p_library A token the library received by the GDExtension's entry point function.
2554
+ * @param p_token A token the library received by the GDExtension's entry point function.
2544
2555
* @param p_binding A pointer to the instance binding.
2545
2556
* @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
2546
2557
*/
@@ -2553,7 +2564,7 @@ typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPt
2553
2564
* Free an Object's instance binding.
2554
2565
*
2555
2566
* @param p_o A pointer to the Object.
2556
- * @param p_library A token the library received by the GDExtension's entry point function.
2567
+ * @param p_token A token the library received by the GDExtension's entry point function.
2557
2568
*/
2558
2569
typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token);
2559
2570
@@ -2563,11 +2574,13 @@ typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectP
2563
2574
*
2564
2575
* Sets an extension class instance on a Object.
2565
2576
*
2577
+ * `p_classname` should be a registered extension class and should extend the `p_o` Object's class.
2578
+ *
2566
2579
* @param p_o A pointer to the Object.
2567
2580
* @param p_classname A pointer to a StringName with the registered extension class's name.
2568
2581
* @param p_instance A pointer to the extension class instance.
2569
2582
*/
2570
- typedef void (*GDExtensionInterfaceObjectSetInstance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */
2583
+ typedef void (*GDExtensionInterfaceObjectSetInstance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance);
2571
2584
2572
2585
/* *
2573
2586
* @name object_get_class_name
@@ -2632,7 +2645,7 @@ typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensio
2632
2645
* @param p_object A pointer to the Object.
2633
2646
* @param p_method A pointer to a StringName identifying the method.
2634
2647
*
2635
- * @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.
2648
+ * @return 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.
2636
2649
*/
2637
2650
typedef GDExtensionBool (*GDExtensionInterfaceObjectHasScriptMethod)(GDExtensionConstObjectPtr p_object, GDExtensionConstStringNamePtr p_method);
2638
2651
@@ -2813,6 +2826,8 @@ typedef void (*GDExtensionInterfaceCallableCustomCreate2)(GDExtensionUninitializ
2813
2826
*
2814
2827
* @param p_callable A pointer to a Callable.
2815
2828
* @param p_token A pointer to an address that uniquely identifies the GDExtension.
2829
+ *
2830
+ * @return The userdata pointer given when creating this custom Callable.
2816
2831
*/
2817
2832
typedef void *(*GDExtensionInterfaceCallableCustomGetUserData)(GDExtensionConstTypePtr p_callable, void *p_token);
2818
2833
@@ -3068,10 +3083,12 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtens
3068
3083
*
3069
3084
* Unregisters an extension class in the ClassDB.
3070
3085
*
3086
+ * Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first.
3087
+ *
3071
3088
* @param p_library A pointer the library received by the GDExtension's entry point function.
3072
3089
* @param p_class_name A pointer to a StringName with the class name.
3073
3090
*/
3074
- typedef void (*GDExtensionInterfaceClassdbUnregisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */
3091
+ typedef void (*GDExtensionInterfaceClassdbUnregisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name);
3075
3092
3076
3093
/* *
3077
3094
* @name get_library_path
@@ -3154,7 +3171,7 @@ typedef void (*GDExtensionInterfaceEditorRegisterGetClassesUsedCallback)(GDExten
3154
3171
* Registers callbacks to be called at different phases of the main loop.
3155
3172
*
3156
3173
* @param p_library A pointer the library received by the GDExtension's entry point function.
3157
- * @param p_callback A pointer to the structure that contains the callbacks.
3174
+ * @param p_callbacks A pointer to the structure that contains the callbacks.
3158
3175
*/
3159
3176
typedef void (*GDExtensionInterfaceRegisterMainLoopCallbacks)(GDExtensionClassLibraryPtr p_library, const GDExtensionMainLoopCallbacks *p_callbacks);
3160
3177
0 commit comments