gdextension_interface.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /**************************************************************************/
  2. /* gdextension_interface.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef GDEXTENSION_INTERFACE_H
  31. #define GDEXTENSION_INTERFACE_H
  32. /* This is a C class header, you can copy it and use it directly in your own binders.
  33. * Together with the JSON file, you should be able to generate any binder.
  34. */
  35. #include <stddef.h>
  36. #include <stdint.h>
  37. #ifndef __cplusplus
  38. typedef uint32_t char32_t;
  39. typedef uint16_t char16_t;
  40. #endif
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /* VARIANT TYPES */
  45. typedef enum {
  46. GDEXTENSION_VARIANT_TYPE_NIL,
  47. /* atomic types */
  48. GDEXTENSION_VARIANT_TYPE_BOOL,
  49. GDEXTENSION_VARIANT_TYPE_INT,
  50. GDEXTENSION_VARIANT_TYPE_FLOAT,
  51. GDEXTENSION_VARIANT_TYPE_STRING,
  52. /* math types */
  53. GDEXTENSION_VARIANT_TYPE_VECTOR2,
  54. GDEXTENSION_VARIANT_TYPE_VECTOR2I,
  55. GDEXTENSION_VARIANT_TYPE_RECT2,
  56. GDEXTENSION_VARIANT_TYPE_RECT2I,
  57. GDEXTENSION_VARIANT_TYPE_VECTOR3,
  58. GDEXTENSION_VARIANT_TYPE_VECTOR3I,
  59. GDEXTENSION_VARIANT_TYPE_TRANSFORM2D,
  60. GDEXTENSION_VARIANT_TYPE_VECTOR4,
  61. GDEXTENSION_VARIANT_TYPE_VECTOR4I,
  62. GDEXTENSION_VARIANT_TYPE_PLANE,
  63. GDEXTENSION_VARIANT_TYPE_QUATERNION,
  64. GDEXTENSION_VARIANT_TYPE_AABB,
  65. GDEXTENSION_VARIANT_TYPE_BASIS,
  66. GDEXTENSION_VARIANT_TYPE_TRANSFORM3D,
  67. GDEXTENSION_VARIANT_TYPE_PROJECTION,
  68. /* misc types */
  69. GDEXTENSION_VARIANT_TYPE_COLOR,
  70. GDEXTENSION_VARIANT_TYPE_STRING_NAME,
  71. GDEXTENSION_VARIANT_TYPE_NODE_PATH,
  72. GDEXTENSION_VARIANT_TYPE_RID,
  73. GDEXTENSION_VARIANT_TYPE_OBJECT,
  74. GDEXTENSION_VARIANT_TYPE_CALLABLE,
  75. GDEXTENSION_VARIANT_TYPE_SIGNAL,
  76. GDEXTENSION_VARIANT_TYPE_DICTIONARY,
  77. GDEXTENSION_VARIANT_TYPE_ARRAY,
  78. /* typed arrays */
  79. GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY,
  80. GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY,
  81. GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY,
  82. GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY,
  83. GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY,
  84. GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY,
  85. GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
  86. GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
  87. GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY,
  88. GDEXTENSION_VARIANT_TYPE_VARIANT_MAX
  89. } GDExtensionVariantType;
  90. typedef enum {
  91. /* comparison */
  92. GDEXTENSION_VARIANT_OP_EQUAL,
  93. GDEXTENSION_VARIANT_OP_NOT_EQUAL,
  94. GDEXTENSION_VARIANT_OP_LESS,
  95. GDEXTENSION_VARIANT_OP_LESS_EQUAL,
  96. GDEXTENSION_VARIANT_OP_GREATER,
  97. GDEXTENSION_VARIANT_OP_GREATER_EQUAL,
  98. /* mathematic */
  99. GDEXTENSION_VARIANT_OP_ADD,
  100. GDEXTENSION_VARIANT_OP_SUBTRACT,
  101. GDEXTENSION_VARIANT_OP_MULTIPLY,
  102. GDEXTENSION_VARIANT_OP_DIVIDE,
  103. GDEXTENSION_VARIANT_OP_NEGATE,
  104. GDEXTENSION_VARIANT_OP_POSITIVE,
  105. GDEXTENSION_VARIANT_OP_MODULE,
  106. GDEXTENSION_VARIANT_OP_POWER,
  107. /* bitwise */
  108. GDEXTENSION_VARIANT_OP_SHIFT_LEFT,
  109. GDEXTENSION_VARIANT_OP_SHIFT_RIGHT,
  110. GDEXTENSION_VARIANT_OP_BIT_AND,
  111. GDEXTENSION_VARIANT_OP_BIT_OR,
  112. GDEXTENSION_VARIANT_OP_BIT_XOR,
  113. GDEXTENSION_VARIANT_OP_BIT_NEGATE,
  114. /* logic */
  115. GDEXTENSION_VARIANT_OP_AND,
  116. GDEXTENSION_VARIANT_OP_OR,
  117. GDEXTENSION_VARIANT_OP_XOR,
  118. GDEXTENSION_VARIANT_OP_NOT,
  119. /* containment */
  120. GDEXTENSION_VARIANT_OP_IN,
  121. GDEXTENSION_VARIANT_OP_MAX
  122. } GDExtensionVariantOperator;
  123. typedef void *GDExtensionVariantPtr;
  124. typedef const void *GDExtensionConstVariantPtr;
  125. typedef void *GDExtensionStringNamePtr;
  126. typedef const void *GDExtensionConstStringNamePtr;
  127. typedef void *GDExtensionStringPtr;
  128. typedef const void *GDExtensionConstStringPtr;
  129. typedef void *GDExtensionObjectPtr;
  130. typedef const void *GDExtensionConstObjectPtr;
  131. typedef void *GDExtensionTypePtr;
  132. typedef const void *GDExtensionConstTypePtr;
  133. typedef const void *GDExtensionMethodBindPtr;
  134. typedef int64_t GDExtensionInt;
  135. typedef uint8_t GDExtensionBool;
  136. typedef uint64_t GDObjectInstanceID;
  137. typedef void *GDExtensionRefPtr;
  138. typedef const void *GDExtensionConstRefPtr;
  139. /* VARIANT DATA I/O */
  140. typedef enum {
  141. GDEXTENSION_CALL_OK,
  142. GDEXTENSION_CALL_ERROR_INVALID_METHOD,
  143. GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT, // Expected a different variant type.
  144. GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS, // Expected lower number of arguments.
  145. GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS, // Expected higher number of arguments.
  146. GDEXTENSION_CALL_ERROR_INSTANCE_IS_NULL,
  147. GDEXTENSION_CALL_ERROR_METHOD_NOT_CONST, // Used for const call.
  148. } GDExtensionCallErrorType;
  149. typedef struct {
  150. GDExtensionCallErrorType error;
  151. int32_t argument;
  152. int32_t expected;
  153. } GDExtensionCallError;
  154. typedef void (*GDExtensionVariantFromTypeConstructorFunc)(GDExtensionVariantPtr, GDExtensionTypePtr);
  155. typedef void (*GDExtensionTypeFromVariantConstructorFunc)(GDExtensionTypePtr, GDExtensionVariantPtr);
  156. typedef void (*GDExtensionPtrOperatorEvaluator)(GDExtensionConstTypePtr p_left, GDExtensionConstTypePtr p_right, GDExtensionTypePtr r_result);
  157. typedef void (*GDExtensionPtrBuiltInMethod)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return, int p_argument_count);
  158. typedef void (*GDExtensionPtrConstructor)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args);
  159. typedef void (*GDExtensionPtrDestructor)(GDExtensionTypePtr p_base);
  160. typedef void (*GDExtensionPtrSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_value);
  161. typedef void (*GDExtensionPtrGetter)(GDExtensionConstTypePtr p_base, GDExtensionTypePtr r_value);
  162. typedef void (*GDExtensionPtrIndexedSetter)(GDExtensionTypePtr p_base, GDExtensionInt p_index, GDExtensionConstTypePtr p_value);
  163. typedef void (*GDExtensionPtrIndexedGetter)(GDExtensionConstTypePtr p_base, GDExtensionInt p_index, GDExtensionTypePtr r_value);
  164. typedef void (*GDExtensionPtrKeyedSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionConstTypePtr p_value);
  165. typedef void (*GDExtensionPtrKeyedGetter)(GDExtensionConstTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionTypePtr r_value);
  166. typedef uint32_t (*GDExtensionPtrKeyedChecker)(GDExtensionConstVariantPtr p_base, GDExtensionConstVariantPtr p_key);
  167. typedef void (*GDExtensionPtrUtilityFunction)(GDExtensionTypePtr r_return, const GDExtensionConstTypePtr *p_args, int p_argument_count);
  168. typedef GDExtensionObjectPtr (*GDExtensionClassConstructor)();
  169. typedef void *(*GDExtensionInstanceBindingCreateCallback)(void *p_token, void *p_instance);
  170. typedef void (*GDExtensionInstanceBindingFreeCallback)(void *p_token, void *p_instance, void *p_binding);
  171. typedef GDExtensionBool (*GDExtensionInstanceBindingReferenceCallback)(void *p_token, void *p_binding, GDExtensionBool p_reference);
  172. typedef struct {
  173. GDExtensionInstanceBindingCreateCallback create_callback;
  174. GDExtensionInstanceBindingFreeCallback free_callback;
  175. GDExtensionInstanceBindingReferenceCallback reference_callback;
  176. } GDExtensionInstanceBindingCallbacks;
  177. /* EXTENSION CLASSES */
  178. typedef void *GDExtensionClassInstancePtr;
  179. typedef GDExtensionBool (*GDExtensionClassSet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
  180. typedef GDExtensionBool (*GDExtensionClassGet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  181. typedef uint64_t (*GDExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance);
  182. typedef struct {
  183. GDExtensionVariantType type;
  184. GDExtensionStringNamePtr name;
  185. GDExtensionStringNamePtr class_name;
  186. uint32_t hint; // Bitfield of `PropertyHint` (defined in `extension_api.json`).
  187. GDExtensionStringPtr hint_string;
  188. uint32_t usage; // Bitfield of `PropertyUsageFlags` (defined in `extension_api.json`).
  189. } GDExtensionPropertyInfo;
  190. typedef struct {
  191. GDExtensionStringNamePtr name;
  192. GDExtensionPropertyInfo return_value;
  193. uint32_t flags; // Bitfield of `GDExtensionClassMethodFlags`.
  194. int32_t id;
  195. /* Arguments: `default_arguments` is an array of size `argument_count`. */
  196. uint32_t argument_count;
  197. GDExtensionPropertyInfo *arguments;
  198. /* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
  199. uint32_t default_argument_count;
  200. GDExtensionVariantPtr *default_arguments;
  201. } GDExtensionMethodInfo;
  202. typedef const GDExtensionPropertyInfo *(*GDExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count);
  203. typedef void (*GDExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list);
  204. typedef GDExtensionBool (*GDExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name);
  205. typedef GDExtensionBool (*GDExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  206. typedef void (*GDExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what);
  207. typedef void (*GDExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr p_out);
  208. typedef void (*GDExtensionClassReference)(GDExtensionClassInstancePtr p_instance);
  209. typedef void (*GDExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance);
  210. typedef void (*GDExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  211. typedef GDExtensionObjectPtr (*GDExtensionClassCreateInstance)(void *p_userdata);
  212. typedef void (*GDExtensionClassFreeInstance)(void *p_userdata, GDExtensionClassInstancePtr p_instance);
  213. typedef GDExtensionClassCallVirtual (*GDExtensionClassGetVirtual)(void *p_userdata, GDExtensionConstStringNamePtr p_name);
  214. typedef struct {
  215. GDExtensionBool is_virtual;
  216. GDExtensionBool is_abstract;
  217. GDExtensionClassSet set_func;
  218. GDExtensionClassGet get_func;
  219. GDExtensionClassGetPropertyList get_property_list_func;
  220. GDExtensionClassFreePropertyList free_property_list_func;
  221. GDExtensionClassPropertyCanRevert property_can_revert_func;
  222. GDExtensionClassPropertyGetRevert property_get_revert_func;
  223. GDExtensionClassNotification notification_func;
  224. GDExtensionClassToString to_string_func;
  225. GDExtensionClassReference reference_func;
  226. GDExtensionClassUnreference unreference_func;
  227. GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
  228. GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
  229. GDExtensionClassGetVirtual get_virtual_func; // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
  230. GDExtensionClassGetRID get_rid_func;
  231. void *class_userdata; // Per-class user data, later accessible in instance bindings.
  232. } GDExtensionClassCreationInfo;
  233. typedef void *GDExtensionClassLibraryPtr;
  234. /* Method */
  235. typedef enum {
  236. GDEXTENSION_METHOD_FLAG_NORMAL = 1,
  237. GDEXTENSION_METHOD_FLAG_EDITOR = 2,
  238. GDEXTENSION_METHOD_FLAG_CONST = 4,
  239. GDEXTENSION_METHOD_FLAG_VIRTUAL = 8,
  240. GDEXTENSION_METHOD_FLAG_VARARG = 16,
  241. GDEXTENSION_METHOD_FLAG_STATIC = 32,
  242. GDEXTENSION_METHOD_FLAGS_DEFAULT = GDEXTENSION_METHOD_FLAG_NORMAL,
  243. } GDExtensionClassMethodFlags;
  244. typedef enum {
  245. GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE,
  246. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8,
  247. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16,
  248. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32,
  249. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64,
  250. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8,
  251. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16,
  252. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32,
  253. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64,
  254. GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT,
  255. GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE
  256. } GDExtensionClassMethodArgumentMetadata;
  257. typedef void (*GDExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  258. typedef void (*GDExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  259. typedef struct {
  260. GDExtensionStringNamePtr name;
  261. void *method_userdata;
  262. GDExtensionClassMethodCall call_func;
  263. GDExtensionClassMethodPtrCall ptrcall_func;
  264. uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
  265. /* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored. */
  266. GDExtensionBool has_return_value;
  267. GDExtensionPropertyInfo *return_value_info;
  268. GDExtensionClassMethodArgumentMetadata return_value_metadata;
  269. /* Arguments: `arguments_info` and `arguments_metadata` are array of size `argument_count`.
  270. * Name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies.
  271. */
  272. uint32_t argument_count;
  273. GDExtensionPropertyInfo *arguments_info;
  274. GDExtensionClassMethodArgumentMetadata *arguments_metadata;
  275. /* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
  276. uint32_t default_argument_count;
  277. GDExtensionVariantPtr *default_arguments;
  278. } GDExtensionClassMethodInfo;
  279. /* SCRIPT INSTANCE EXTENSION */
  280. typedef void *GDExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation.
  281. typedef GDExtensionBool (*GDExtensionScriptInstanceSet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
  282. typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  283. typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
  284. typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list);
  285. typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
  286. typedef GDExtensionBool (*GDExtensionScriptInstancePropertyCanRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
  287. typedef GDExtensionBool (*GDExtensionScriptInstancePropertyGetRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  288. typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetOwner)(GDExtensionScriptInstanceDataPtr p_instance);
  289. typedef void (*GDExtensionScriptInstancePropertyStateAdd)(GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value, void *p_userdata);
  290. typedef void (*GDExtensionScriptInstanceGetPropertyState)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata);
  291. typedef const GDExtensionMethodInfo *(*GDExtensionScriptInstanceGetMethodList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
  292. typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list);
  293. typedef GDExtensionBool (*GDExtensionScriptInstanceHasMethod)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
  294. typedef void (*GDExtensionScriptInstanceCall)(GDExtensionScriptInstanceDataPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  295. typedef void (*GDExtensionScriptInstanceNotification)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what);
  296. typedef void (*GDExtensionScriptInstanceToString)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
  297. typedef void (*GDExtensionScriptInstanceRefCountIncremented)(GDExtensionScriptInstanceDataPtr p_instance);
  298. typedef GDExtensionBool (*GDExtensionScriptInstanceRefCountDecremented)(GDExtensionScriptInstanceDataPtr p_instance);
  299. typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetScript)(GDExtensionScriptInstanceDataPtr p_instance);
  300. typedef GDExtensionBool (*GDExtensionScriptInstanceIsPlaceholder)(GDExtensionScriptInstanceDataPtr p_instance);
  301. typedef void *GDExtensionScriptLanguagePtr;
  302. typedef GDExtensionScriptLanguagePtr (*GDExtensionScriptInstanceGetLanguage)(GDExtensionScriptInstanceDataPtr p_instance);
  303. typedef void (*GDExtensionScriptInstanceFree)(GDExtensionScriptInstanceDataPtr p_instance);
  304. typedef void *GDExtensionScriptInstancePtr; // Pointer to ScriptInstance.
  305. typedef struct {
  306. GDExtensionScriptInstanceSet set_func;
  307. GDExtensionScriptInstanceGet get_func;
  308. GDExtensionScriptInstanceGetPropertyList get_property_list_func;
  309. GDExtensionScriptInstanceFreePropertyList free_property_list_func;
  310. GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
  311. GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
  312. GDExtensionScriptInstanceGetOwner get_owner_func;
  313. GDExtensionScriptInstanceGetPropertyState get_property_state_func;
  314. GDExtensionScriptInstanceGetMethodList get_method_list_func;
  315. GDExtensionScriptInstanceFreeMethodList free_method_list_func;
  316. GDExtensionScriptInstanceGetPropertyType get_property_type_func;
  317. GDExtensionScriptInstanceHasMethod has_method_func;
  318. GDExtensionScriptInstanceCall call_func;
  319. GDExtensionScriptInstanceNotification notification_func;
  320. GDExtensionScriptInstanceToString to_string_func;
  321. GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
  322. GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
  323. GDExtensionScriptInstanceGetScript get_script_func;
  324. GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
  325. GDExtensionScriptInstanceSet set_fallback_func;
  326. GDExtensionScriptInstanceGet get_fallback_func;
  327. GDExtensionScriptInstanceGetLanguage get_language_func;
  328. GDExtensionScriptInstanceFree free_func;
  329. } GDExtensionScriptInstanceInfo;
  330. /* INTERFACE */
  331. typedef struct {
  332. uint32_t version_major;
  333. uint32_t version_minor;
  334. uint32_t version_patch;
  335. const char *version_string;
  336. /* GODOT CORE */
  337. void *(*mem_alloc)(size_t p_bytes);
  338. void *(*mem_realloc)(void *p_ptr, size_t p_bytes);
  339. void (*mem_free)(void *p_ptr);
  340. void (*print_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  341. void (*print_error_with_message)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  342. void (*print_warning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  343. void (*print_warning_with_message)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  344. void (*print_script_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  345. void (*print_script_error_with_message)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  346. uint64_t (*get_native_struct_size)(GDExtensionConstStringNamePtr p_name);
  347. /* GODOT VARIANT */
  348. /* variant general */
  349. void (*variant_new_copy)(GDExtensionVariantPtr r_dest, GDExtensionConstVariantPtr p_src);
  350. void (*variant_new_nil)(GDExtensionVariantPtr r_dest);
  351. void (*variant_destroy)(GDExtensionVariantPtr p_self);
  352. /* variant type */
  353. void (*variant_call)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  354. void (*variant_call_static)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  355. void (*variant_evaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionVariantPtr r_return, GDExtensionBool *r_valid);
  356. void (*variant_set)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  357. void (*variant_set_named)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  358. void (*variant_set_keyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  359. void (*variant_set_indexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  360. void (*variant_get)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
  361. void (*variant_get_named)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
  362. void (*variant_get_keyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
  363. void (*variant_get_indexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  364. GDExtensionBool (*variant_iter_init)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
  365. GDExtensionBool (*variant_iter_next)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
  366. void (*variant_iter_get)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
  367. GDExtensionInt (*variant_hash)(GDExtensionConstVariantPtr p_self);
  368. GDExtensionInt (*variant_recursive_hash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count);
  369. GDExtensionBool (*variant_hash_compare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other);
  370. GDExtensionBool (*variant_booleanize)(GDExtensionConstVariantPtr p_self);
  371. void (*variant_duplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep);
  372. void (*variant_stringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret);
  373. GDExtensionVariantType (*variant_get_type)(GDExtensionConstVariantPtr p_self);
  374. GDExtensionBool (*variant_has_method)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
  375. GDExtensionBool (*variant_has_member)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  376. GDExtensionBool (*variant_has_key)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid);
  377. void (*variant_get_type_name)(GDExtensionVariantType p_type, GDExtensionStringPtr r_name);
  378. GDExtensionBool (*variant_can_convert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  379. GDExtensionBool (*variant_can_convert_strict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  380. /* ptrcalls */
  381. GDExtensionVariantFromTypeConstructorFunc (*get_variant_from_type_constructor)(GDExtensionVariantType p_type);
  382. GDExtensionTypeFromVariantConstructorFunc (*get_variant_to_type_constructor)(GDExtensionVariantType p_type);
  383. GDExtensionPtrOperatorEvaluator (*variant_get_ptr_operator_evaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b);
  384. GDExtensionPtrBuiltInMethod (*variant_get_ptr_builtin_method)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash);
  385. GDExtensionPtrConstructor (*variant_get_ptr_constructor)(GDExtensionVariantType p_type, int32_t p_constructor);
  386. GDExtensionPtrDestructor (*variant_get_ptr_destructor)(GDExtensionVariantType p_type);
  387. void (*variant_construct)(GDExtensionVariantType p_type, GDExtensionVariantPtr p_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error);
  388. GDExtensionPtrSetter (*variant_get_ptr_setter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  389. GDExtensionPtrGetter (*variant_get_ptr_getter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  390. GDExtensionPtrIndexedSetter (*variant_get_ptr_indexed_setter)(GDExtensionVariantType p_type);
  391. GDExtensionPtrIndexedGetter (*variant_get_ptr_indexed_getter)(GDExtensionVariantType p_type);
  392. GDExtensionPtrKeyedSetter (*variant_get_ptr_keyed_setter)(GDExtensionVariantType p_type);
  393. GDExtensionPtrKeyedGetter (*variant_get_ptr_keyed_getter)(GDExtensionVariantType p_type);
  394. GDExtensionPtrKeyedChecker (*variant_get_ptr_keyed_checker)(GDExtensionVariantType p_type);
  395. void (*variant_get_constant_value)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionVariantPtr r_ret);
  396. GDExtensionPtrUtilityFunction (*variant_get_ptr_utility_function)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash);
  397. /* extra utilities */
  398. void (*string_new_with_latin1_chars)(GDExtensionStringPtr r_dest, const char *p_contents);
  399. void (*string_new_with_utf8_chars)(GDExtensionStringPtr r_dest, const char *p_contents);
  400. void (*string_new_with_utf16_chars)(GDExtensionStringPtr r_dest, const char16_t *p_contents);
  401. void (*string_new_with_utf32_chars)(GDExtensionStringPtr r_dest, const char32_t *p_contents);
  402. void (*string_new_with_wide_chars)(GDExtensionStringPtr r_dest, const wchar_t *p_contents);
  403. void (*string_new_with_latin1_chars_and_len)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  404. void (*string_new_with_utf8_chars_and_len)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  405. void (*string_new_with_utf16_chars_and_len)(GDExtensionStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_size);
  406. void (*string_new_with_utf32_chars_and_len)(GDExtensionStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_size);
  407. void (*string_new_with_wide_chars_and_len)(GDExtensionStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_size);
  408. /* Information about the following functions:
  409. * - The return value is the resulting encoded string length.
  410. * - The length returned is in characters, not in bytes. It also does not include a trailing zero.
  411. * - These functions also do not write trailing zero, If you need it, write it yourself at the position indicated by the length (and make sure to allocate it).
  412. * - Passing NULL in r_text means only the length is computed (again, without including trailing zero).
  413. * - p_max_write_length argument is in characters, not bytes. It will be ignored if r_text is NULL.
  414. * - p_max_write_length argument does not affect the return value, it's only to cap write length.
  415. */
  416. GDExtensionInt (*string_to_latin1_chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  417. GDExtensionInt (*string_to_utf8_chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  418. GDExtensionInt (*string_to_utf16_chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length);
  419. GDExtensionInt (*string_to_utf32_chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length);
  420. GDExtensionInt (*string_to_wide_chars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length);
  421. char32_t *(*string_operator_index)(GDExtensionStringPtr p_self, GDExtensionInt p_index);
  422. const char32_t *(*string_operator_index_const)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index);
  423. void (*string_operator_plus_eq_string)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b);
  424. void (*string_operator_plus_eq_char)(GDExtensionStringPtr p_self, char32_t p_b);
  425. void (*string_operator_plus_eq_cstr)(GDExtensionStringPtr p_self, const char *p_b);
  426. void (*string_operator_plus_eq_wcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b);
  427. void (*string_operator_plus_eq_c32str)(GDExtensionStringPtr p_self, const char32_t *p_b);
  428. /* XMLParser extra utilities */
  429. GDExtensionInt (*xml_parser_open_buffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size);
  430. /* FileAccess extra utilities */
  431. void (*file_access_store_buffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length);
  432. uint64_t (*file_access_get_buffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);
  433. /* WorkerThreadPool extra utilities */
  434. int64_t (*worker_thread_pool_add_native_group_task)(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);
  435. int64_t (*worker_thread_pool_add_native_task)(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
  436. /* Packed array functions */
  437. uint8_t *(*packed_byte_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedByteArray
  438. const uint8_t *(*packed_byte_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedByteArray
  439. GDExtensionTypePtr (*packed_color_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedColorArray, returns Color ptr
  440. GDExtensionTypePtr (*packed_color_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedColorArray, returns Color ptr
  441. float *(*packed_float32_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat32Array
  442. const float *(*packed_float32_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat32Array
  443. double *(*packed_float64_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat64Array
  444. const double *(*packed_float64_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat64Array
  445. int32_t *(*packed_int32_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array
  446. const int32_t *(*packed_int32_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array
  447. int64_t *(*packed_int64_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array
  448. const int64_t *(*packed_int64_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array
  449. GDExtensionStringPtr (*packed_string_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedStringArray
  450. GDExtensionStringPtr (*packed_string_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedStringArray
  451. GDExtensionTypePtr (*packed_vector2_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr
  452. GDExtensionTypePtr (*packed_vector2_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr
  453. GDExtensionTypePtr (*packed_vector3_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr
  454. GDExtensionTypePtr (*packed_vector3_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr
  455. GDExtensionVariantPtr (*array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be an Array ptr
  456. GDExtensionVariantPtr (*array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be an Array ptr
  457. void (*array_ref)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from); // p_self should be an Array ptr
  458. void (*array_set_typed)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script); // p_self should be an Array ptr
  459. /* Dictionary functions */
  460. GDExtensionVariantPtr (*dictionary_operator_index)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key); // p_self should be an Dictionary ptr
  461. GDExtensionVariantPtr (*dictionary_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key); // p_self should be an Dictionary ptr
  462. /* OBJECT */
  463. void (*object_method_bind_call)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionVariantPtr r_ret, GDExtensionCallError *r_error);
  464. void (*object_method_bind_ptrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  465. void (*object_destroy)(GDExtensionObjectPtr p_o);
  466. GDExtensionObjectPtr (*global_get_singleton)(GDExtensionConstStringNamePtr p_name);
  467. void *(*object_get_instance_binding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  468. void (*object_set_instance_binding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  469. void (*object_set_instance)(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. */
  470. GDExtensionObjectPtr (*object_cast_to)(GDExtensionConstObjectPtr p_object, void *p_class_tag);
  471. GDExtensionObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id);
  472. GDObjectInstanceID (*object_get_instance_id)(GDExtensionConstObjectPtr p_object);
  473. /* REFERENCE */
  474. GDExtensionObjectPtr (*ref_get_object)(GDExtensionConstRefPtr p_ref);
  475. void (*ref_set_object)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object);
  476. /* SCRIPT INSTANCE */
  477. GDExtensionScriptInstancePtr (*script_instance_create)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
  478. /* CLASSDB */
  479. GDExtensionObjectPtr (*classdb_construct_object)(GDExtensionConstStringNamePtr p_classname); /* The passed class must be a built-in godot class, or an already-registered extension class. In both case, object_set_instance should be called to fully initialize the object. */
  480. GDExtensionMethodBindPtr (*classdb_get_method_bind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash);
  481. void *(*classdb_get_class_tag)(GDExtensionConstStringNamePtr p_classname);
  482. /* CLASSDB EXTENSION */
  483. /* Provided parameters for `classdb_register_extension_*` can be safely freed once the function returns. */
  484. void (*classdb_register_extension_class)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs);
  485. void (*classdb_register_extension_class_method)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info);
  486. void (*classdb_register_extension_class_integer_constant)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_enum_name, GDExtensionConstStringNamePtr p_constant_name, GDExtensionInt p_constant_value, GDExtensionBool p_is_bitfield);
  487. void (*classdb_register_extension_class_property)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter);
  488. void (*classdb_register_extension_class_property_group)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix);
  489. void (*classdb_register_extension_class_property_subgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix);
  490. void (*classdb_register_extension_class_signal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count);
  491. void (*classdb_unregister_extension_class)(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. */
  492. void (*get_library_path)(GDExtensionClassLibraryPtr p_library, GDExtensionStringPtr r_path);
  493. } GDExtensionInterface;
  494. /* INITIALIZATION */
  495. typedef enum {
  496. GDEXTENSION_INITIALIZATION_CORE,
  497. GDEXTENSION_INITIALIZATION_SERVERS,
  498. GDEXTENSION_INITIALIZATION_SCENE,
  499. GDEXTENSION_INITIALIZATION_EDITOR,
  500. GDEXTENSION_MAX_INITIALIZATION_LEVEL,
  501. } GDExtensionInitializationLevel;
  502. typedef struct {
  503. /* Minimum initialization level required.
  504. * If Core or Servers, the extension needs editor or game restart to take effect */
  505. GDExtensionInitializationLevel minimum_initialization_level;
  506. /* Up to the user to supply when initializing */
  507. void *userdata;
  508. /* This function will be called multiple times for each initialization level. */
  509. void (*initialize)(void *userdata, GDExtensionInitializationLevel p_level);
  510. void (*deinitialize)(void *userdata, GDExtensionInitializationLevel p_level);
  511. } GDExtensionInitialization;
  512. /* Define a C function prototype that implements the function below and expose it to dlopen() (or similar).
  513. * This is the entry point of the GDExtension library and will be called on initialization.
  514. * It can be used to set up different init levels, which are called during various stages of initialization/shutdown.
  515. * The function name must be a unique one specified in the .gdextension config file.
  516. */
  517. typedef GDExtensionBool (*GDExtensionInitializationFunction)(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
  518. #ifdef __cplusplus
  519. }
  520. #endif
  521. #endif // GDEXTENSION_INTERFACE_H