@@ -724,6 +724,9 @@ typedef struct {
724724
725725} GDExtensionScriptInstanceInfo3;
726726
727+ typedef void (*GDExtensionWorkerThreadPoolGroupTask)(void *, uint32_t);
728+ typedef void (*GDExtensionWorkerThreadPoolTask)(void *);
729+
727730/* INITIALIZATION */
728731
729732typedef enum {
@@ -734,15 +737,18 @@ typedef enum {
734737 GDEXTENSION_MAX_INITIALIZATION_LEVEL,
735738} GDExtensionInitializationLevel;
736739
740+ typedef void (*GDExtensionInitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
741+ typedef void (*GDExtensionDeinitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
742+
737743typedef struct {
738744 /* Minimum initialization level required.
739745 * If Core or Servers, the extension needs editor or game restart to take effect */
740746 GDExtensionInitializationLevel minimum_initialization_level;
741747 /* Up to the user to supply when initializing */
742748 void *userdata;
743749 /* 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;
746752} GDExtensionInitialization;
747753
748754typedef void (*GDExtensionInterfaceFunctionPtr)();
@@ -815,8 +821,12 @@ typedef void (*GDExtensionMainLoopShutdownCallback)();
815821typedef void (*GDExtensionMainLoopFrameCallback)();
816822
817823typedef struct {
824+ // Will be called after Godot is started and is fully initialized.
818825 GDExtensionMainLoopStartupCallback startup_func;
826+ // Will be called before Godot is shutdown when it is still fully initialized.
819827 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.
820830 GDExtensionMainLoopFrameCallback frame_func;
821831} GDExtensionMainLoopCallbacks;
822832
@@ -1035,7 +1045,7 @@ typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GD
10351045 *
10361046 * Calls a static method on a Variant.
10371047 *
1038- * @param p_self A pointer to the Variant .
1048+ * @param p_type The variant type .
10391049 * @param p_method A pointer to a StringName identifying the method.
10401050 * @param p_args A pointer to a C array of Variant.
10411051 * @param p_argument_count The number of arguments.
@@ -1321,7 +1331,7 @@ typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtension
13211331 * @param p_self A pointer to the Variant.
13221332 * @param p_method A pointer to a StringName with the method name.
13231333 *
1324- * @return
1334+ * @return true if the variant has the given method; otherwise false.
13251335 */
13261336typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
13271337
@@ -1334,7 +1344,7 @@ typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConst
13341344 * @param p_type The Variant type.
13351345 * @param p_member A pointer to a StringName with the member name.
13361346 *
1337- * @return
1347+ * @return true if the variant has the given method; otherwise false.
13381348 */
13391349typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
13401350
@@ -1505,7 +1515,7 @@ typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(
15051515 * Constructs a Variant of the given type, using the first constructor that matches the given arguments.
15061516 *
15071517 * @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.
15091519 * @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor.
15101520 * @param p_argument_count The number of arguments to pass to the constructor.
15111521 * @param r_error A pointer the structure which will be updated with error information.
@@ -1728,7 +1738,7 @@ typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen2)(GDEx
17281738 *
17291739 * @param r_dest A pointer to a Variant to hold the newly created String.
17301740 * @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).
17321742 */
17331743typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count);
17341744
@@ -1740,7 +1750,7 @@ typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUni
17401750 *
17411751 * @param r_dest A pointer to a Variant to hold the newly created String.
17421752 * @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).
17441754 * @param p_default_little_endian If true, UTF-16 use little endian.
17451755 *
17461756 * @return Error code signifying if the operation successful.
@@ -1755,7 +1765,7 @@ typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen2)(GDE
17551765 *
17561766 * @param r_dest A pointer to a Variant to hold the newly created String.
17571767 * @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).
17591769 */
17601770typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_char_count);
17611771
@@ -1767,7 +1777,7 @@ typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUni
17671777 *
17681778 * @param r_dest A pointer to a Variant to hold the newly created String.
17691779 * @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).
17711781 */
17721782typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_char_count);
17731783
@@ -2084,6 +2094,7 @@ typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_in
20842094 * @param p_instance A pointer to a WorkerThreadPool object.
20852095 * @param p_func A pointer to a function to run in the thread pool.
20862096 * @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.
20872098 * @param p_tasks The number of tasks needed in the group.
20882099 * @param p_high_priority Whether or not this is a high priority task.
20892100 * @param p_description A pointer to a String with the task description.
@@ -2092,7 +2103,7 @@ typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_in
20922103 *
20932104 * @see WorkerThreadPool::add_group_task()
20942105 */
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);
20962107
20972108/**
20982109 * @name worker_thread_pool_add_native_task
@@ -2108,7 +2119,7 @@ typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExte
21082119 *
21092120 * @return The task ID.
21102121 */
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);
21122123
21132124/* INTERFACE: Packed Array */
21142125
@@ -2526,10 +2537,10 @@ typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensi
25262537 * Gets a pointer representing an Object's instance binding.
25272538 *
25282539 * @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.
25302541 * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
25312542 *
2532- * @return
2543+ * @return A pointer to the instance binding.
25332544 */
25342545typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
25352546
@@ -2540,7 +2551,7 @@ typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectP
25402551 * Sets an Object's instance binding.
25412552 *
25422553 * @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.
25442555 * @param p_binding A pointer to the instance binding.
25452556 * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
25462557 */
@@ -2553,7 +2564,7 @@ typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPt
25532564 * Free an Object's instance binding.
25542565 *
25552566 * @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.
25572568 */
25582569typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token);
25592570
@@ -2563,11 +2574,13 @@ typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectP
25632574 *
25642575 * Sets an extension class instance on a Object.
25652576 *
2577+ * `p_classname` should be a registered extension class and should extend the `p_o` Object's class.
2578+ *
25662579 * @param p_o A pointer to the Object.
25672580 * @param p_classname A pointer to a StringName with the registered extension class's name.
25682581 * @param p_instance A pointer to the extension class instance.
25692582 */
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);
25712584
25722585/**
25732586 * @name object_get_class_name
@@ -2632,7 +2645,7 @@ typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensio
26322645 * @param p_object A pointer to the Object.
26332646 * @param p_method A pointer to a StringName identifying the method.
26342647 *
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.
26362649 */
26372650typedef GDExtensionBool (*GDExtensionInterfaceObjectHasScriptMethod)(GDExtensionConstObjectPtr p_object, GDExtensionConstStringNamePtr p_method);
26382651
@@ -2813,6 +2826,8 @@ typedef void (*GDExtensionInterfaceCallableCustomCreate2)(GDExtensionUninitializ
28132826 *
28142827 * @param p_callable A pointer to a Callable.
28152828 * @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.
28162831 */
28172832typedef void *(*GDExtensionInterfaceCallableCustomGetUserData)(GDExtensionConstTypePtr p_callable, void *p_token);
28182833
@@ -3068,10 +3083,12 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtens
30683083 *
30693084 * Unregisters an extension class in the ClassDB.
30703085 *
3086+ * Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first.
3087+ *
30713088 * @param p_library A pointer the library received by the GDExtension's entry point function.
30723089 * @param p_class_name A pointer to a StringName with the class name.
30733090 */
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);
30753092
30763093/**
30773094 * @name get_library_path
@@ -3154,7 +3171,7 @@ typedef void (*GDExtensionInterfaceEditorRegisterGetClassesUsedCallback)(GDExten
31543171 * Registers callbacks to be called at different phases of the main loop.
31553172 *
31563173 * @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.
31583175 */
31593176typedef void (*GDExtensionInterfaceRegisterMainLoopCallbacks)(GDExtensionClassLibraryPtr p_library, const GDExtensionMainLoopCallbacks *p_callbacks);
31603177
0 commit comments