gdextension_interface.h 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146
  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. /* INITIALIZATION */
  331. typedef enum {
  332. GDEXTENSION_INITIALIZATION_CORE,
  333. GDEXTENSION_INITIALIZATION_SERVERS,
  334. GDEXTENSION_INITIALIZATION_SCENE,
  335. GDEXTENSION_INITIALIZATION_EDITOR,
  336. GDEXTENSION_MAX_INITIALIZATION_LEVEL,
  337. } GDExtensionInitializationLevel;
  338. typedef struct {
  339. /* Minimum initialization level required.
  340. * If Core or Servers, the extension needs editor or game restart to take effect */
  341. GDExtensionInitializationLevel minimum_initialization_level;
  342. /* Up to the user to supply when initializing */
  343. void *userdata;
  344. /* This function will be called multiple times for each initialization level. */
  345. void (*initialize)(void *userdata, GDExtensionInitializationLevel p_level);
  346. void (*deinitialize)(void *userdata, GDExtensionInitializationLevel p_level);
  347. } GDExtensionInitialization;
  348. typedef void (*GDExtensionInterfaceFunctionPtr)();
  349. typedef GDExtensionInterfaceFunctionPtr (*GDExtensionInterfaceGetProcAddress)(const char *p_function_name);
  350. /*
  351. * Each GDExtension should define a C function that matches the signature of GDExtensionInitializationFunction,
  352. * and export it so that it can be loaded via dlopen() or equivalent for the given platform.
  353. *
  354. * For example:
  355. *
  356. * GDExtensionBool my_extension_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
  357. *
  358. * This function's name must be specified as the 'entry_symbol' in the .gdextension file.
  359. *
  360. * This makes it the entry point of the GDExtension and will be called on initialization.
  361. *
  362. * The GDExtension can then modify the r_initialization structure, setting the minimum initialization level,
  363. * and providing pointers to functions that will be called at various stages of initialization/shutdown.
  364. *
  365. * The rest of the GDExtension's interface to Godot consists of function pointers that can be loaded
  366. * by calling p_get_proc_address("...") with the name of the function.
  367. *
  368. * For example:
  369. *
  370. * GDExtensionInterfaceGetGodotVersion *get_godot_version = (GDExtensionInterfaceGetGodotVersion)p_get_proc_address("get_godot_version");
  371. *
  372. * You can then call it like a normal function:
  373. *
  374. * GDExtensionGodotVersion godot_version;
  375. * get_godot_version(&godot_version);
  376. * printf("Godot v%d.%d.%d\n", godot_version.major, godot_version.minor, godot_version.patch);
  377. *
  378. * All of these interface functions are described below, together with the name that's used to load it,
  379. * and the function pointer typedef that shows its signature.
  380. */
  381. typedef GDExtensionBool (*GDExtensionInitializationFunction)(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
  382. /* INTERFACE */
  383. typedef struct {
  384. uint32_t major;
  385. uint32_t minor;
  386. uint32_t patch;
  387. const char *string;
  388. } GDExtensionGodotVersion;
  389. /**
  390. * @name get_godot_version
  391. *
  392. * Gets the Godot version that the GDExtension was loaded into.
  393. *
  394. * @param r_godot_version A pointer to the structure to write the version information into.
  395. */
  396. typedef void (*GDExtensionInterfaceGetGodotVersion)(GDExtensionGodotVersion *r_godot_version);
  397. /* INTERFACE: Memory */
  398. /**
  399. * @name mem_alloc
  400. *
  401. * Allocates memory.
  402. *
  403. * @param p_bytes The amount of memory to allocate in bytes.
  404. *
  405. * @return A pointer to the allocated memory, or NULL if unsuccessful.
  406. */
  407. typedef void *(*GDExtensionInterfaceMemAlloc)(size_t p_bytes);
  408. /**
  409. * @name mem_realloc
  410. *
  411. * Reallocates memory.
  412. *
  413. * @param p_ptr A pointer to the previously allocated memory.
  414. * @param p_bytes The number of bytes to resize the memory block to.
  415. *
  416. * @return A pointer to the allocated memory, or NULL if unsuccessful.
  417. */
  418. typedef void *(*GDExtensionInterfaceMemRealloc)(void *p_ptr, size_t p_bytes);
  419. /**
  420. * @name mem_free
  421. *
  422. * Frees memory.
  423. *
  424. * @param p_ptr A pointer to the previously allocated memory.
  425. */
  426. typedef void (*GDExtensionInterfaceMemFree)(void *p_ptr);
  427. /* INTERFACE: Godot Core */
  428. /**
  429. * @name print_error
  430. *
  431. * Logs an error to Godot's built-in debugger and to the OS terminal.
  432. *
  433. * @param p_description The code trigging the error.
  434. * @param p_function The function name where the error occurred.
  435. * @param p_file The file where the error occurred.
  436. * @param p_line The line where the error occurred.
  437. * @param p_editor_notify Whether or not to notify the editor.
  438. */
  439. typedef void (*GDExtensionInterfacePrintError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  440. /**
  441. * @name print_error_with_message
  442. *
  443. * Logs an error with a message to Godot's built-in debugger and to the OS terminal.
  444. *
  445. * @param p_description The code trigging the error.
  446. * @param p_message The message to show along with the error.
  447. * @param p_function The function name where the error occurred.
  448. * @param p_file The file where the error occurred.
  449. * @param p_line The line where the error occurred.
  450. * @param p_editor_notify Whether or not to notify the editor.
  451. */
  452. typedef void (*GDExtensionInterfacePrintErrorWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  453. /**
  454. * @name print_warning
  455. *
  456. * Logs a warning to Godot's built-in debugger and to the OS terminal.
  457. *
  458. * @param p_description The code trigging the warning.
  459. * @param p_function The function name where the warning occurred.
  460. * @param p_file The file where the warning occurred.
  461. * @param p_line The line where the warning occurred.
  462. * @param p_editor_notify Whether or not to notify the editor.
  463. */
  464. typedef void (*GDExtensionInterfacePrintWarning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  465. /**
  466. * @name print_warning_with_message
  467. *
  468. * Logs a warning with a message to Godot's built-in debugger and to the OS terminal.
  469. *
  470. * @param p_description The code trigging the warning.
  471. * @param p_message The message to show along with the warning.
  472. * @param p_function The function name where the warning occurred.
  473. * @param p_file The file where the warning occurred.
  474. * @param p_line The line where the warning occurred.
  475. * @param p_editor_notify Whether or not to notify the editor.
  476. */
  477. typedef void (*GDExtensionInterfacePrintWarningWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  478. /**
  479. * @name print_script_error
  480. *
  481. * Logs a script error to Godot's built-in debugger and to the OS terminal.
  482. *
  483. * @param p_description The code trigging the error.
  484. * @param p_function The function name where the error occurred.
  485. * @param p_file The file where the error occurred.
  486. * @param p_line The line where the error occurred.
  487. * @param p_editor_notify Whether or not to notify the editor.
  488. */
  489. typedef void (*GDExtensionInterfacePrintScriptError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  490. /**
  491. * @name print_script_error_with_message
  492. *
  493. * Logs a script error with a message to Godot's built-in debugger and to the OS terminal.
  494. *
  495. * @param p_description The code trigging the error.
  496. * @param p_message The message to show along with the error.
  497. * @param p_function The function name where the error occurred.
  498. * @param p_file The file where the error occurred.
  499. * @param p_line The line where the error occurred.
  500. * @param p_editor_notify Whether or not to notify the editor.
  501. */
  502. typedef void (*GDExtensionInterfacePrintScriptErrorWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  503. /**
  504. * @name get_native_struct_size
  505. *
  506. * Gets the size of a native struct (ex. ObjectID) in bytes.
  507. *
  508. * @param p_name A pointer to a StringName identifying the struct name.
  509. *
  510. * @return The size in bytes.
  511. */
  512. typedef uint64_t (*GDExtensionInterfaceGetNativeStructSize)(GDExtensionConstStringNamePtr p_name);
  513. /* INTERFACE: Variant */
  514. /**
  515. * @name variant_new_copy
  516. *
  517. * Copies one Variant into a another.
  518. *
  519. * @param r_dest A pointer to the destination Variant.
  520. * @param p_src A pointer to the source Variant.
  521. */
  522. typedef void (*GDExtensionInterfaceVariantNewCopy)(GDExtensionVariantPtr r_dest, GDExtensionConstVariantPtr p_src);
  523. /**
  524. * @name variant_new_nil
  525. *
  526. * Creates a new Variant containing nil.
  527. *
  528. * @param r_dest A pointer to the destination Variant.
  529. */
  530. typedef void (*GDExtensionInterfaceVariantNewNil)(GDExtensionVariantPtr r_dest);
  531. /**
  532. * @name variant_destroy
  533. *
  534. * Destroys a Variant.
  535. *
  536. * @param p_self A pointer to the Variant to destroy.
  537. */
  538. typedef void (*GDExtensionInterfaceVariantDestroy)(GDExtensionVariantPtr p_self);
  539. /**
  540. * @name variant_call
  541. *
  542. * Calls a method on a Variant.
  543. *
  544. * @param p_self A pointer to the Variant.
  545. * @param p_method A pointer to a StringName identifying the method.
  546. * @param p_args A pointer to a C array of Variant.
  547. * @param p_argument_count The number of arguments.
  548. * @param r_return A pointer a Variant which will be assigned the return value.
  549. * @param r_error A pointer the structure which will hold error information.
  550. *
  551. * @see Variant::callp()
  552. */
  553. typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  554. /**
  555. * @name variant_call_static
  556. *
  557. * Calls a static method on a Variant.
  558. *
  559. * @param p_self A pointer to the Variant.
  560. * @param p_method A pointer to a StringName identifying the method.
  561. * @param p_args A pointer to a C array of Variant.
  562. * @param p_argument_count The number of arguments.
  563. * @param r_return A pointer a Variant which will be assigned the return value.
  564. * @param r_error A pointer the structure which will be updated with error information.
  565. *
  566. * @see Variant::call_static()
  567. */
  568. typedef void (*GDExtensionInterfaceVariantCallStatic)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  569. /**
  570. * @name variant_evaluate
  571. *
  572. * Evaluate an operator on two Variants.
  573. *
  574. * @param p_op The operator to evaluate.
  575. * @param p_a The first Variant.
  576. * @param p_b The second Variant.
  577. * @param r_return A pointer a Variant which will be assigned the return value.
  578. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  579. *
  580. * @see Variant::evaluate()
  581. */
  582. typedef void (*GDExtensionInterfaceVariantEvaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionVariantPtr r_return, GDExtensionBool *r_valid);
  583. /**
  584. * @name variant_set
  585. *
  586. * Sets a key on a Variant to a value.
  587. *
  588. * @param p_self A pointer to the Variant.
  589. * @param p_key A pointer to a Variant representing the key.
  590. * @param p_value A pointer to a Variant representing the value.
  591. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  592. *
  593. * @see Variant::set()
  594. */
  595. typedef void (*GDExtensionInterfaceVariantSet)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  596. /**
  597. * @name variant_set_named
  598. *
  599. * Sets a named key on a Variant to a value.
  600. *
  601. * @param p_self A pointer to the Variant.
  602. * @param p_key A pointer to a StringName representing the key.
  603. * @param p_value A pointer to a Variant representing the value.
  604. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  605. *
  606. * @see Variant::set_named()
  607. */
  608. typedef void (*GDExtensionInterfaceVariantSetNamed)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  609. /**
  610. * @name variant_set_keyed
  611. *
  612. * Sets a keyed property on a Variant to a value.
  613. *
  614. * @param p_self A pointer to the Variant.
  615. * @param p_key A pointer to a Variant representing the key.
  616. * @param p_value A pointer to a Variant representing the value.
  617. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  618. *
  619. * @see Variant::set_keyed()
  620. */
  621. typedef void (*GDExtensionInterfaceVariantSetKeyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  622. /**
  623. * @name variant_set_indexed
  624. *
  625. * Sets an index on a Variant to a value.
  626. *
  627. * @param p_self A pointer to the Variant.
  628. * @param p_index The index.
  629. * @param p_value A pointer to a Variant representing the value.
  630. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  631. * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
  632. */
  633. typedef void (*GDExtensionInterfaceVariantSetIndexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  634. /**
  635. * @name variant_get
  636. *
  637. * Gets the value of a key from a Variant.
  638. *
  639. * @param p_self A pointer to the Variant.
  640. * @param p_key A pointer to a Variant representing the key.
  641. * @param r_ret A pointer to a Variant which will be assigned the value.
  642. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  643. */
  644. typedef void (*GDExtensionInterfaceVariantGet)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
  645. /**
  646. * @name variant_get_named
  647. *
  648. * Gets the value of a named key from a Variant.
  649. *
  650. * @param p_self A pointer to the Variant.
  651. * @param p_key A pointer to a StringName representing the key.
  652. * @param r_ret A pointer to a Variant which will be assigned the value.
  653. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  654. */
  655. typedef void (*GDExtensionInterfaceVariantGetNamed)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
  656. /**
  657. * @name variant_get_keyed
  658. *
  659. * Gets the value of a keyed property from a Variant.
  660. *
  661. * @param p_self A pointer to the Variant.
  662. * @param p_key A pointer to a Variant representing the key.
  663. * @param r_ret A pointer to a Variant which will be assigned the value.
  664. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  665. */
  666. typedef void (*GDExtensionInterfaceVariantGetKeyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
  667. /**
  668. * @name variant_get_indexed
  669. *
  670. * Gets the value of an index from a Variant.
  671. *
  672. * @param p_self A pointer to the Variant.
  673. * @param p_index The index.
  674. * @param r_ret A pointer to a Variant which will be assigned the value.
  675. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  676. * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
  677. */
  678. typedef void (*GDExtensionInterfaceVariantGetIndexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  679. /**
  680. * @name variant_iter_init
  681. *
  682. * Initializes an iterator over a Variant.
  683. *
  684. * @param p_self A pointer to the Variant.
  685. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  686. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  687. *
  688. * @return true if the operation is valid; otherwise false.
  689. *
  690. * @see Variant::iter_init()
  691. */
  692. typedef GDExtensionBool (*GDExtensionInterfaceVariantIterInit)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
  693. /**
  694. * @name variant_iter_next
  695. *
  696. * Gets the next value for an iterator over a Variant.
  697. *
  698. * @param p_self A pointer to the Variant.
  699. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  700. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  701. *
  702. * @return true if the operation is valid; otherwise false.
  703. *
  704. * @see Variant::iter_next()
  705. */
  706. typedef GDExtensionBool (*GDExtensionInterfaceVariantIterNext)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
  707. /**
  708. * @name variant_iter_get
  709. *
  710. * Gets the next value for an iterator over a Variant.
  711. *
  712. * @param p_self A pointer to the Variant.
  713. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  714. * @param r_ret A pointer to a Variant which will be assigned false if the operation is invalid.
  715. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  716. *
  717. * @see Variant::iter_next()
  718. */
  719. typedef void (*GDExtensionInterfaceVariantIterGet)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
  720. /**
  721. * @name variant_hash
  722. *
  723. * Gets the hash of a Variant.
  724. *
  725. * @param p_self A pointer to the Variant.
  726. *
  727. * @return The hash value.
  728. *
  729. * @see Variant::hash()
  730. */
  731. typedef GDExtensionInt (*GDExtensionInterfaceVariantHash)(GDExtensionConstVariantPtr p_self);
  732. /**
  733. * @name variant_recursive_hash
  734. *
  735. * Gets the recursive hash of a Variant.
  736. *
  737. * @param p_self A pointer to the Variant.
  738. * @param p_recursion_count The number of recursive loops so far.
  739. *
  740. * @return The hash value.
  741. *
  742. * @see Variant::recursive_hash()
  743. */
  744. typedef GDExtensionInt (*GDExtensionInterfaceVariantRecursiveHash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count);
  745. /**
  746. * @name variant_hash_compare
  747. *
  748. * Compares two Variants by their hash.
  749. *
  750. * @param p_self A pointer to the Variant.
  751. * @param p_other A pointer to the other Variant to compare it to.
  752. *
  753. * @return The hash value.
  754. *
  755. * @see Variant::hash_compare()
  756. */
  757. typedef GDExtensionBool (*GDExtensionInterfaceVariantHashCompare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other);
  758. /**
  759. * @name variant_booleanize
  760. *
  761. * Converts a Variant to a boolean.
  762. *
  763. * @param p_self A pointer to the Variant.
  764. *
  765. * @return The boolean value of the Variant.
  766. */
  767. typedef GDExtensionBool (*GDExtensionInterfaceVariantBooleanize)(GDExtensionConstVariantPtr p_self);
  768. /**
  769. * @name variant_duplicate
  770. *
  771. * Duplicates a Variant.
  772. *
  773. * @param p_self A pointer to the Variant.
  774. * @param r_ret A pointer to a Variant to store the duplicated value.
  775. * @param p_deep Whether or not to duplicate deeply (when supported by the Variant type).
  776. */
  777. typedef void (*GDExtensionInterfaceVariantDuplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep);
  778. /**
  779. * @name variant_stringify
  780. *
  781. * Converts a Variant to a string.
  782. *
  783. * @param p_self A pointer to the Variant.
  784. * @param r_ret A pointer to a String to store the resulting value.
  785. */
  786. typedef void (*GDExtensionInterfaceVariantStringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret);
  787. /**
  788. * @name variant_get_type
  789. *
  790. * Gets the type of a Variant.
  791. *
  792. * @param p_self A pointer to the Variant.
  793. *
  794. * @return The variant type.
  795. */
  796. typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtensionConstVariantPtr p_self);
  797. /**
  798. * @name variant_has_method
  799. *
  800. * Checks if a Variant has the given method.
  801. *
  802. * @param p_self A pointer to the Variant.
  803. * @param p_method A pointer to a StringName with the method name.
  804. *
  805. * @return
  806. */
  807. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
  808. /**
  809. * @name variant_has_member
  810. *
  811. * Checks if a type of Variant has the given member.
  812. *
  813. * @param p_type The Variant type.
  814. * @param p_member A pointer to a StringName with the member name.
  815. *
  816. * @return
  817. */
  818. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  819. /**
  820. * @name variant_has_key
  821. *
  822. * Checks if a Variant has a key.
  823. *
  824. * @param p_self A pointer to the Variant.
  825. * @param p_key A pointer to a Variant representing the key.
  826. * @param r_valid A pointer to a boolean which will be set to false if the key doesn't exist.
  827. *
  828. * @return true if the key exists; otherwise false.
  829. */
  830. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasKey)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid);
  831. /**
  832. * @name variant_get_type_name
  833. *
  834. * Gets the name of a Variant type.
  835. *
  836. * @param p_type The Variant type.
  837. * @param r_name A pointer to a String to store the Variant type name.
  838. */
  839. typedef void (*GDExtensionInterfaceVariantGetTypeName)(GDExtensionVariantType p_type, GDExtensionStringPtr r_name);
  840. /**
  841. * @name variant_can_convert
  842. *
  843. * Checks if Variants can be converted from one type to another.
  844. *
  845. * @param p_from The Variant type to convert from.
  846. * @param p_to The Variant type to convert to.
  847. *
  848. * @return true if the conversion is possible; otherwise false.
  849. */
  850. typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  851. /**
  852. * @name variant_can_convert_strict
  853. *
  854. * Checks if Variant can be converted from one type to another using stricter rules.
  855. *
  856. * @param p_from The Variant type to convert from.
  857. * @param p_to The Variant type to convert to.
  858. *
  859. * @return true if the conversion is possible; otherwise false.
  860. */
  861. typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvertStrict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  862. /**
  863. * @name get_variant_from_type_constructor
  864. *
  865. * Gets a pointer to a function that can create a Variant of the given type from a raw value.
  866. *
  867. * @param p_type The Variant type.
  868. *
  869. * @return A pointer to a function that can create a Variant of the given type from a raw value.
  870. */
  871. typedef GDExtensionVariantFromTypeConstructorFunc (*GDExtensionInterfaceGetVariantFromTypeConstructor)(GDExtensionVariantType p_type);
  872. /**
  873. * @name get_variant_to_type_constructor
  874. *
  875. * Gets a pointer to a function that can get the raw value from a Variant of the given type.
  876. *
  877. * @param p_type The Variant type.
  878. *
  879. * @return A pointer to a function that can get the raw value from a Variant of the given type.
  880. */
  881. typedef GDExtensionTypeFromVariantConstructorFunc (*GDExtensionInterfaceGetVariantToTypeConstructor)(GDExtensionVariantType p_type);
  882. /**
  883. * @name variant_get_ptr_operator_evaluator
  884. *
  885. * Gets a pointer to a function that can evaluate the given Variant operator on the given Variant types.
  886. *
  887. * @param p_operator The variant operator.
  888. * @param p_type_a The type of the first Variant.
  889. * @param p_type_b The type of the second Variant.
  890. *
  891. * @return A pointer to a function that can evaluate the given Variant operator on the given Variant types.
  892. */
  893. typedef GDExtensionPtrOperatorEvaluator (*GDExtensionInterfaceVariantGetPtrOperatorEvaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b);
  894. /**
  895. * @name variant_get_ptr_builtin_method
  896. *
  897. * Gets a pointer to a function that can call a builtin method on a type of Variant.
  898. *
  899. * @param p_type The Variant type.
  900. * @param p_method A pointer to a StringName with the method name.
  901. * @param p_hash A hash representing the method signature.
  902. *
  903. * @return A pointer to a function that can call a builtin method on a type of Variant.
  904. */
  905. typedef GDExtensionPtrBuiltInMethod (*GDExtensionInterfaceVariantGetPtrBuiltinMethod)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash);
  906. /**
  907. * @name variant_get_ptr_constructor
  908. *
  909. * Gets a pointer to a function that can call one of the constructors for a type of Variant.
  910. *
  911. * @param p_type The Variant type.
  912. * @param p_constructor The index of the constructor.
  913. *
  914. * @return A pointer to a function that can call one of the constructors for a type of Variant.
  915. */
  916. typedef GDExtensionPtrConstructor (*GDExtensionInterfaceVariantGetPtrConstructor)(GDExtensionVariantType p_type, int32_t p_constructor);
  917. /**
  918. * @name variant_get_ptr_destructor
  919. *
  920. * Gets a pointer to a function than can call the destructor for a type of Variant.
  921. *
  922. * @param p_type The Variant type.
  923. *
  924. * @return A pointer to a function than can call the destructor for a type of Variant.
  925. */
  926. typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(GDExtensionVariantType p_type);
  927. /**
  928. * @name variant_construct
  929. *
  930. * Constructs a Variant of the given type, using the first constructor that matches the given arguments.
  931. *
  932. * @param p_type The Variant type.
  933. * @param p_base A pointer to a Variant to store the constructed value.
  934. * @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor.
  935. * @param p_argument_count The number of arguments to pass to the constructor.
  936. * @param r_error A pointer the structure which will be updated with error information.
  937. */
  938. typedef void (*GDExtensionInterfaceVariantConstruct)(GDExtensionVariantType p_type, GDExtensionVariantPtr p_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error);
  939. /**
  940. * @name variant_get_ptr_setter
  941. *
  942. * Gets a pointer to a function that can call a member's setter on the given Variant type.
  943. *
  944. * @param p_type The Variant type.
  945. * @param p_member A pointer to a StringName with the member name.
  946. *
  947. * @return A pointer to a function that can call a member's setter on the given Variant type.
  948. */
  949. typedef GDExtensionPtrSetter (*GDExtensionInterfaceVariantGetPtrSetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  950. /**
  951. * @name variant_get_ptr_getter
  952. *
  953. * Gets a pointer to a function that can call a member's getter on the given Variant type.
  954. *
  955. * @param p_type The Variant type.
  956. * @param p_member A pointer to a StringName with the member name.
  957. *
  958. * @return A pointer to a function that can call a member's getter on the given Variant type.
  959. */
  960. typedef GDExtensionPtrGetter (*GDExtensionInterfaceVariantGetPtrGetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  961. /**
  962. * @name variant_get_ptr_indexed_setter
  963. *
  964. * Gets a pointer to a function that can set an index on the given Variant type.
  965. *
  966. * @param p_type The Variant type.
  967. *
  968. * @return A pointer to a function that can set an index on the given Variant type.
  969. */
  970. typedef GDExtensionPtrIndexedSetter (*GDExtensionInterfaceVariantGetPtrIndexedSetter)(GDExtensionVariantType p_type);
  971. /**
  972. * @name variant_get_ptr_indexed_getter
  973. *
  974. * Gets a pointer to a function that can get an index on the given Variant type.
  975. *
  976. * @param p_type The Variant type.
  977. *
  978. * @return A pointer to a function that can get an index on the given Variant type.
  979. */
  980. typedef GDExtensionPtrIndexedGetter (*GDExtensionInterfaceVariantGetPtrIndexedGetter)(GDExtensionVariantType p_type);
  981. /**
  982. * @name variant_get_ptr_keyed_setter
  983. *
  984. * Gets a pointer to a function that can set a key on the given Variant type.
  985. *
  986. * @param p_type The Variant type.
  987. *
  988. * @return A pointer to a function that can set a key on the given Variant type.
  989. */
  990. typedef GDExtensionPtrKeyedSetter (*GDExtensionInterfaceVariantGetPtrKeyedSetter)(GDExtensionVariantType p_type);
  991. /**
  992. * @name variant_get_ptr_keyed_getter
  993. *
  994. * Gets a pointer to a function that can get a key on the given Variant type.
  995. *
  996. * @param p_type The Variant type.
  997. *
  998. * @return A pointer to a function that can get a key on the given Variant type.
  999. */
  1000. typedef GDExtensionPtrKeyedGetter (*GDExtensionInterfaceVariantGetPtrKeyedGetter)(GDExtensionVariantType p_type);
  1001. /**
  1002. * @name variant_get_ptr_keyed_checker
  1003. *
  1004. * Gets a pointer to a function that can check a key on the given Variant type.
  1005. *
  1006. * @param p_type The Variant type.
  1007. *
  1008. * @return A pointer to a function that can check a key on the given Variant type.
  1009. */
  1010. typedef GDExtensionPtrKeyedChecker (*GDExtensionInterfaceVariantGetPtrKeyedChecker)(GDExtensionVariantType p_type);
  1011. /**
  1012. * @name variant_get_constant_value
  1013. *
  1014. * Gets the value of a constant from the given Variant type.
  1015. *
  1016. * @param p_type The Variant type.
  1017. * @param p_constant A pointer to a StringName with the constant name.
  1018. * @param r_ret A pointer to a Variant to store the value.
  1019. */
  1020. typedef void (*GDExtensionInterfaceVariantGetConstantValue)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionVariantPtr r_ret);
  1021. /**
  1022. * @name variant_get_ptr_utility_function
  1023. *
  1024. * Gets a pointer to a function that can call a Variant utility function.
  1025. *
  1026. * @param p_function A pointer to a StringName with the function name.
  1027. * @param p_hash A hash representing the function signature.
  1028. *
  1029. * @return A pointer to a function that can call a Variant utility function.
  1030. */
  1031. typedef GDExtensionPtrUtilityFunction (*GDExtensionInterfaceVariantGetPtrUtilityFunction)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash);
  1032. /* INTERFACE: String Utilities */
  1033. /**
  1034. * @name string_new_with_latin1_chars
  1035. *
  1036. * Creates a String from a Latin-1 encoded C string.
  1037. *
  1038. * @param r_dest A pointer to a Variant to hold the newly created String.
  1039. * @param p_contents A pointer to a Latin-1 encoded C string (null terminated).
  1040. */
  1041. typedef void (*GDExtensionInterfaceStringNewWithLatin1Chars)(GDExtensionStringPtr r_dest, const char *p_contents);
  1042. /**
  1043. * @name string_new_with_utf8_chars
  1044. *
  1045. * Creates a String from a UTF-8 encoded C string.
  1046. *
  1047. * @param r_dest A pointer to a Variant to hold the newly created String.
  1048. * @param p_contents A pointer to a UTF-8 encoded C string (null terminated).
  1049. */
  1050. typedef void (*GDExtensionInterfaceStringNewWithUtf8Chars)(GDExtensionStringPtr r_dest, const char *p_contents);
  1051. /**
  1052. * @name string_new_with_utf16_chars
  1053. *
  1054. * Creates a String from a UTF-16 encoded C string.
  1055. *
  1056. * @param r_dest A pointer to a Variant to hold the newly created String.
  1057. * @param p_contents A pointer to a UTF-16 encoded C string (null terminated).
  1058. */
  1059. typedef void (*GDExtensionInterfaceStringNewWithUtf16Chars)(GDExtensionStringPtr r_dest, const char16_t *p_contents);
  1060. /**
  1061. * @name string_new_with_utf32_chars
  1062. *
  1063. * Creates a String from a UTF-32 encoded C string.
  1064. *
  1065. * @param r_dest A pointer to a Variant to hold the newly created String.
  1066. * @param p_contents A pointer to a UTF-32 encoded C string (null terminated).
  1067. */
  1068. typedef void (*GDExtensionInterfaceStringNewWithUtf32Chars)(GDExtensionStringPtr r_dest, const char32_t *p_contents);
  1069. /**
  1070. * @name string_new_with_wide_chars
  1071. *
  1072. * Creates a String from a wide C string.
  1073. *
  1074. * @param r_dest A pointer to a Variant to hold the newly created String.
  1075. * @param p_contents A pointer to a wide C string (null terminated).
  1076. */
  1077. typedef void (*GDExtensionInterfaceStringNewWithWideChars)(GDExtensionStringPtr r_dest, const wchar_t *p_contents);
  1078. /**
  1079. * @name string_new_with_latin1_chars_and_len
  1080. *
  1081. * Creates a String from a Latin-1 encoded C string with the given length.
  1082. *
  1083. * @param r_dest A pointer to a Variant to hold the newly created String.
  1084. * @param p_contents A pointer to a Latin-1 encoded C string.
  1085. * @param p_size The number of characters.
  1086. */
  1087. typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1088. /**
  1089. * @name string_new_with_utf8_chars_and_len
  1090. *
  1091. * Creates a String from a UTF-8 encoded C string with the given length.
  1092. *
  1093. * @param r_dest A pointer to a Variant to hold the newly created String.
  1094. * @param p_contents A pointer to a UTF-8 encoded C string.
  1095. * @param p_size The number of characters.
  1096. */
  1097. typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1098. /**
  1099. * @name string_new_with_utf16_chars_and_len
  1100. *
  1101. * Creates a String from a UTF-16 encoded C string with the given length.
  1102. *
  1103. * @param r_dest A pointer to a Variant to hold the newly created String.
  1104. * @param p_contents A pointer to a UTF-16 encoded C string.
  1105. * @param p_size The number of characters.
  1106. */
  1107. typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_size);
  1108. /**
  1109. * @name string_new_with_utf32_chars_and_len
  1110. *
  1111. * Creates a String from a UTF-32 encoded C string with the given length.
  1112. *
  1113. * @param r_dest A pointer to a Variant to hold the newly created String.
  1114. * @param p_contents A pointer to a UTF-32 encoded C string.
  1115. * @param p_size The number of characters.
  1116. */
  1117. typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_size);
  1118. /**
  1119. * @name string_new_with_wide_chars_and_len
  1120. *
  1121. * Creates a String from a wide C string with the given length.
  1122. *
  1123. * @param r_dest A pointer to a Variant to hold the newly created String.
  1124. * @param p_contents A pointer to a wide C string.
  1125. * @param p_size The number of characters.
  1126. */
  1127. typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_size);
  1128. /**
  1129. * @name string_to_latin1_chars
  1130. *
  1131. * Converts a String to a Latin-1 encoded C string.
  1132. *
  1133. * It doesn't write a null terminator.
  1134. *
  1135. * @param p_self A pointer to the String.
  1136. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1137. * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
  1138. *
  1139. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1140. */
  1141. typedef GDExtensionInt (*GDExtensionInterfaceStringToLatin1Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  1142. /**
  1143. * @name string_to_utf8_chars
  1144. *
  1145. * Converts a String to a UTF-8 encoded C string.
  1146. *
  1147. * It doesn't write a null terminator.
  1148. *
  1149. * @param p_self A pointer to the String.
  1150. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1151. * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
  1152. *
  1153. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1154. */
  1155. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf8Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  1156. /**
  1157. * @name string_to_utf16_chars
  1158. *
  1159. * Converts a String to a UTF-16 encoded C string.
  1160. *
  1161. * It doesn't write a null terminator.
  1162. *
  1163. * @param p_self A pointer to the String.
  1164. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1165. * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
  1166. *
  1167. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1168. */
  1169. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf16Chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length);
  1170. /**
  1171. * @name string_to_utf32_chars
  1172. *
  1173. * Converts a String to a UTF-32 encoded C string.
  1174. *
  1175. * It doesn't write a null terminator.
  1176. *
  1177. * @param p_self A pointer to the String.
  1178. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1179. * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
  1180. *
  1181. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1182. */
  1183. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf32Chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length);
  1184. /**
  1185. * @name string_to_wide_chars
  1186. *
  1187. * Converts a String to a wide C string.
  1188. *
  1189. * It doesn't write a null terminator.
  1190. *
  1191. * @param p_self A pointer to the String.
  1192. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1193. * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
  1194. *
  1195. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1196. */
  1197. typedef GDExtensionInt (*GDExtensionInterfaceStringToWideChars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length);
  1198. /**
  1199. * @name string_operator_index
  1200. *
  1201. * Gets a pointer to the character at the given index from a String.
  1202. *
  1203. * @param p_self A pointer to the String.
  1204. * @param p_index The index.
  1205. *
  1206. * @return A pointer to the requested character.
  1207. */
  1208. typedef char32_t *(*GDExtensionInterfaceStringOperatorIndex)(GDExtensionStringPtr p_self, GDExtensionInt p_index);
  1209. /**
  1210. * @name string_operator_index_const
  1211. *
  1212. * Gets a const pointer to the character at the given index from a String.
  1213. *
  1214. * @param p_self A pointer to the String.
  1215. * @param p_index The index.
  1216. *
  1217. * @return A const pointer to the requested character.
  1218. */
  1219. typedef const char32_t *(*GDExtensionInterfaceStringOperatorIndexConst)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index);
  1220. /**
  1221. * @name string_operator_plus_eq_string
  1222. *
  1223. * Appends another String to a String.
  1224. *
  1225. * @param p_self A pointer to the String.
  1226. * @param p_b A pointer to the other String to append.
  1227. */
  1228. typedef void (*GDExtensionInterfaceStringOperatorPlusEqString)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b);
  1229. /**
  1230. * @name string_operator_plus_eq_char
  1231. *
  1232. * Appends a character to a String.
  1233. *
  1234. * @param p_self A pointer to the String.
  1235. * @param p_b A pointer to the character to append.
  1236. */
  1237. typedef void (*GDExtensionInterfaceStringOperatorPlusEqChar)(GDExtensionStringPtr p_self, char32_t p_b);
  1238. /**
  1239. * @name string_operator_plus_eq_cstr
  1240. *
  1241. * Appends a Latin-1 encoded C string to a String.
  1242. *
  1243. * @param p_self A pointer to the String.
  1244. * @param p_b A pointer to a Latin-1 encoded C string (null terminated).
  1245. */
  1246. typedef void (*GDExtensionInterfaceStringOperatorPlusEqCstr)(GDExtensionStringPtr p_self, const char *p_b);
  1247. /**
  1248. * @name string_operator_plus_eq_wcstr
  1249. *
  1250. * Appends a wide C string to a String.
  1251. *
  1252. * @param p_self A pointer to the String.
  1253. * @param p_b A pointer to a wide C string (null terminated).
  1254. */
  1255. typedef void (*GDExtensionInterfaceStringOperatorPlusEqWcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b);
  1256. /**
  1257. * @name string_operator_plus_eq_c32str
  1258. *
  1259. * Appends a UTF-32 encoded C string to a String.
  1260. *
  1261. * @param p_self A pointer to the String.
  1262. * @param p_b A pointer to a UTF-32 encoded C string (null terminated).
  1263. */
  1264. typedef void (*GDExtensionInterfaceStringOperatorPlusEqC32str)(GDExtensionStringPtr p_self, const char32_t *p_b);
  1265. /* INTERFACE: XMLParser Utilities */
  1266. /**
  1267. * @name xml_parser_open_buffer
  1268. *
  1269. * Opens a raw XML buffer on an XMLParser instance.
  1270. *
  1271. * @param p_instance A pointer to an XMLParser object.
  1272. * @param p_buffer A pointer to the buffer.
  1273. * @param p_size The size of the buffer.
  1274. *
  1275. * @return A Godot error code (ex. OK, ERR_INVALID_DATA, etc).
  1276. *
  1277. * @see XMLParser::open_buffer()
  1278. */
  1279. typedef GDExtensionInt (*GDExtensionInterfaceXmlParserOpenBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size);
  1280. /* INTERFACE: FileAccess Utilities */
  1281. /**
  1282. * @name file_access_store_buffer
  1283. *
  1284. * Stores the given buffer using an instance of FileAccess.
  1285. *
  1286. * @param p_instance A pointer to a FileAccess object.
  1287. * @param p_src A pointer to the buffer.
  1288. * @param p_length The size of the buffer.
  1289. *
  1290. * @see FileAccess::store_buffer()
  1291. */
  1292. typedef void (*GDExtensionInterfaceFileAccessStoreBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length);
  1293. /**
  1294. * @name file_access_get_buffer
  1295. *
  1296. * Reads the next p_length bytes into the given buffer using an instance of FileAccess.
  1297. *
  1298. * @param p_instance A pointer to a FileAccess object.
  1299. * @param p_dst A pointer to the buffer to store the data.
  1300. * @param p_length The requested number of bytes to read.
  1301. *
  1302. * @return The actual number of bytes read (may be less than requested).
  1303. */
  1304. typedef uint64_t (*GDExtensionInterfaceFileAccessGetBuffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);
  1305. /* INTERFACE: WorkerThreadPool Utilities */
  1306. /**
  1307. * @name worker_thread_pool_add_native_group_task
  1308. *
  1309. * Adds a group task to an instance of WorkerThreadPool.
  1310. *
  1311. * @param p_instance A pointer to a WorkerThreadPool object.
  1312. * @param p_func A pointer to a function to run in the thread pool.
  1313. * @param p_userdata A pointer to arbitrary data which will be passed to p_func.
  1314. * @param p_tasks The number of tasks needed in the group.
  1315. * @param p_high_priority Whether or not this is a high priority task.
  1316. * @param p_description A pointer to a String with the task description.
  1317. *
  1318. * @return The task group ID.
  1319. *
  1320. * @see WorkerThreadPool::add_group_task()
  1321. */
  1322. 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);
  1323. /**
  1324. * @name worker_thread_pool_add_native_task
  1325. *
  1326. * Adds a task to an instance of WorkerThreadPool.
  1327. *
  1328. * @param p_instance A pointer to a WorkerThreadPool object.
  1329. * @param p_func A pointer to a function to run in the thread pool.
  1330. * @param p_userdata A pointer to arbitrary data which will be passed to p_func.
  1331. * @param p_high_priority Whether or not this is a high priority task.
  1332. * @param p_description A pointer to a String with the task description.
  1333. *
  1334. * @return The task ID.
  1335. */
  1336. typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
  1337. /* INTERFACE: Packed Array */
  1338. /**
  1339. * @name packed_byte_array_operator_index
  1340. *
  1341. * Gets a pointer to a byte in a PackedByteArray.
  1342. *
  1343. * @param p_self A pointer to a PackedByteArray object.
  1344. * @param p_index The index of the byte to get.
  1345. *
  1346. * @return A pointer to the requested byte.
  1347. */
  1348. typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1349. /**
  1350. * @name packed_byte_array_operator_index_const
  1351. *
  1352. * Gets a const pointer to a byte in a PackedByteArray.
  1353. *
  1354. * @param p_self A const pointer to a PackedByteArray object.
  1355. * @param p_index The index of the byte to get.
  1356. *
  1357. * @return A const pointer to the requested byte.
  1358. */
  1359. typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1360. /**
  1361. * @name packed_color_array_operator_index
  1362. *
  1363. * Gets a pointer to a color in a PackedColorArray.
  1364. *
  1365. * @param p_self A pointer to a PackedColorArray object.
  1366. * @param p_index The index of the Color to get.
  1367. *
  1368. * @return A pointer to the requested Color.
  1369. */
  1370. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1371. /**
  1372. * @name packed_color_array_operator_index_const
  1373. *
  1374. * Gets a const pointer to a color in a PackedColorArray.
  1375. *
  1376. * @param p_self A const pointer to a const PackedColorArray object.
  1377. * @param p_index The index of the Color to get.
  1378. *
  1379. * @return A const pointer to the requested Color.
  1380. */
  1381. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1382. /**
  1383. * @name packed_float32_array_operator_index
  1384. *
  1385. * Gets a pointer to a 32-bit float in a PackedFloat32Array.
  1386. *
  1387. * @param p_self A pointer to a PackedFloat32Array object.
  1388. * @param p_index The index of the float to get.
  1389. *
  1390. * @return A pointer to the requested 32-bit float.
  1391. */
  1392. typedef float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1393. /**
  1394. * @name packed_float32_array_operator_index_const
  1395. *
  1396. * Gets a const pointer to a 32-bit float in a PackedFloat32Array.
  1397. *
  1398. * @param p_self A const pointer to a PackedFloat32Array object.
  1399. * @param p_index The index of the float to get.
  1400. *
  1401. * @return A const pointer to the requested 32-bit float.
  1402. */
  1403. typedef const float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1404. /**
  1405. * @name packed_float64_array_operator_index
  1406. *
  1407. * Gets a pointer to a 64-bit float in a PackedFloat64Array.
  1408. *
  1409. * @param p_self A pointer to a PackedFloat64Array object.
  1410. * @param p_index The index of the float to get.
  1411. *
  1412. * @return A pointer to the requested 64-bit float.
  1413. */
  1414. typedef double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1415. /**
  1416. * @name packed_float64_array_operator_index_const
  1417. *
  1418. * Gets a const pointer to a 64-bit float in a PackedFloat64Array.
  1419. *
  1420. * @param p_self A const pointer to a PackedFloat64Array object.
  1421. * @param p_index The index of the float to get.
  1422. *
  1423. * @return A const pointer to the requested 64-bit float.
  1424. */
  1425. typedef const double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1426. /**
  1427. * @name packed_int32_array_operator_index
  1428. *
  1429. * Gets a pointer to a 32-bit integer in a PackedInt32Array.
  1430. *
  1431. * @param p_self A pointer to a PackedInt32Array object.
  1432. * @param p_index The index of the integer to get.
  1433. *
  1434. * @return A pointer to the requested 32-bit integer.
  1435. */
  1436. typedef int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1437. /**
  1438. * @name packed_int32_array_operator_index_const
  1439. *
  1440. * Gets a const pointer to a 32-bit integer in a PackedInt32Array.
  1441. *
  1442. * @param p_self A const pointer to a PackedInt32Array object.
  1443. * @param p_index The index of the integer to get.
  1444. *
  1445. * @return A const pointer to the requested 32-bit integer.
  1446. */
  1447. typedef const int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1448. /**
  1449. * @name packed_int64_array_operator_index
  1450. *
  1451. * Gets a pointer to a 64-bit integer in a PackedInt64Array.
  1452. *
  1453. * @param p_self A pointer to a PackedInt64Array object.
  1454. * @param p_index The index of the integer to get.
  1455. *
  1456. * @return A pointer to the requested 64-bit integer.
  1457. */
  1458. typedef int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1459. /**
  1460. * @name packed_int64_array_operator_index_const
  1461. *
  1462. * Gets a const pointer to a 64-bit integer in a PackedInt64Array.
  1463. *
  1464. * @param p_self A const pointer to a PackedInt64Array object.
  1465. * @param p_index The index of the integer to get.
  1466. *
  1467. * @return A const pointer to the requested 64-bit integer.
  1468. */
  1469. typedef const int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1470. /**
  1471. * @name packed_string_array_operator_index
  1472. *
  1473. * Gets a pointer to a string in a PackedStringArray.
  1474. *
  1475. * @param p_self A pointer to a PackedStringArray object.
  1476. * @param p_index The index of the String to get.
  1477. *
  1478. * @return A pointer to the requested String.
  1479. */
  1480. typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1481. /**
  1482. * @name packed_string_array_operator_index_const
  1483. *
  1484. * Gets a const pointer to a string in a PackedStringArray.
  1485. *
  1486. * @param p_self A const pointer to a PackedStringArray object.
  1487. * @param p_index The index of the String to get.
  1488. *
  1489. * @return A const pointer to the requested String.
  1490. */
  1491. typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1492. /**
  1493. * @name packed_vector2_array_operator_index
  1494. *
  1495. * Gets a pointer to a Vector2 in a PackedVector2Array.
  1496. *
  1497. * @param p_self A pointer to a PackedVector2Array object.
  1498. * @param p_index The index of the Vector2 to get.
  1499. *
  1500. * @return A pointer to the requested Vector2.
  1501. */
  1502. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1503. /**
  1504. * @name packed_vector2_array_operator_index_const
  1505. *
  1506. * Gets a const pointer to a Vector2 in a PackedVector2Array.
  1507. *
  1508. * @param p_self A const pointer to a PackedVector2Array object.
  1509. * @param p_index The index of the Vector2 to get.
  1510. *
  1511. * @return A const pointer to the requested Vector2.
  1512. */
  1513. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1514. /**
  1515. * @name packed_vector3_array_operator_index
  1516. *
  1517. * Gets a pointer to a Vector3 in a PackedVector3Array.
  1518. *
  1519. * @param p_self A pointer to a PackedVector3Array object.
  1520. * @param p_index The index of the Vector3 to get.
  1521. *
  1522. * @return A pointer to the requested Vector3.
  1523. */
  1524. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1525. /**
  1526. * @name packed_vector3_array_operator_index_const
  1527. *
  1528. * Gets a const pointer to a Vector3 in a PackedVector3Array.
  1529. *
  1530. * @param p_self A const pointer to a PackedVector3Array object.
  1531. * @param p_index The index of the Vector3 to get.
  1532. *
  1533. * @return A const pointer to the requested Vector3.
  1534. */
  1535. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1536. /**
  1537. * @name array_operator_index
  1538. *
  1539. * Gets a pointer to a Variant in an Array.
  1540. *
  1541. * @param p_self A pointer to an Array object.
  1542. * @param p_index The index of the Variant to get.
  1543. *
  1544. * @return A pointer to the requested Variant.
  1545. */
  1546. typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1547. /**
  1548. * @name array_operator_index_const
  1549. *
  1550. * Gets a const pointer to a Variant in an Array.
  1551. *
  1552. * @param p_self A const pointer to an Array object.
  1553. * @param p_index The index of the Variant to get.
  1554. *
  1555. * @return A const pointer to the requested Variant.
  1556. */
  1557. typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1558. /**
  1559. * @name array_ref
  1560. *
  1561. * Sets an Array to be a reference to another Array object.
  1562. *
  1563. * @param p_self A pointer to the Array object to update.
  1564. * @param p_from A pointer to the Array object to reference.
  1565. */
  1566. typedef void (*GDExtensionInterfaceArrayRef)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from);
  1567. /**
  1568. * @name array_set_typed
  1569. *
  1570. * Makes an Array into a typed Array.
  1571. *
  1572. * @param p_self A pointer to the Array.
  1573. * @param p_type The type of Variant the Array will store.
  1574. * @param p_class_name A pointer to a StringName with the name of the object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT).
  1575. * @param p_script A pointer to a Script object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT and the base class is extended by a script).
  1576. */
  1577. typedef void (*GDExtensionInterfaceArraySetTyped)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script);
  1578. /* INTERFACE: Dictionary */
  1579. /**
  1580. * @name dictionary_operator_index
  1581. *
  1582. * Gets a pointer to a Variant in a Dictionary with the given key.
  1583. *
  1584. * @param p_self A pointer to a Dictionary object.
  1585. * @param p_key A pointer to a Variant representing the key.
  1586. *
  1587. * @return A pointer to a Variant representing the value at the given key.
  1588. */
  1589. typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key);
  1590. /**
  1591. * @name dictionary_operator_index_const
  1592. *
  1593. * Gets a const pointer to a Variant in a Dictionary with the given key.
  1594. *
  1595. * @param p_self A const pointer to a Dictionary object.
  1596. * @param p_key A pointer to a Variant representing the key.
  1597. *
  1598. * @return A const pointer to a Variant representing the value at the given key.
  1599. */
  1600. typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key);
  1601. /* INTERFACE: Object */
  1602. /**
  1603. * @name object_method_bind_call
  1604. *
  1605. * Calls a method on an Object.
  1606. *
  1607. * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
  1608. * @param p_instance A pointer to the Object.
  1609. * @param p_args A pointer to a C array of Variants representing the arguments.
  1610. * @param p_arg_count The number of arguments.
  1611. * @param r_ret A pointer to Variant which will receive the return value.
  1612. * @param r_error A pointer to a GDExtensionCallError struct that will receive error information.
  1613. */
  1614. typedef void (*GDExtensionInterfaceObjectMethodBindCall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionVariantPtr r_ret, GDExtensionCallError *r_error);
  1615. /**
  1616. * @name object_method_bind_ptrcall
  1617. *
  1618. * Calls a method on an Object (using a "ptrcall").
  1619. *
  1620. * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
  1621. * @param p_instance A pointer to the Object.
  1622. * @param p_args A pointer to a C array representing the arguments.
  1623. * @param r_ret A pointer to the Object that will receive the return value.
  1624. */
  1625. typedef void (*GDExtensionInterfaceObjectMethodBindPtrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  1626. /**
  1627. * @name object_destroy
  1628. *
  1629. * Destroys an Object.
  1630. *
  1631. * @param p_o A pointer to the Object.
  1632. */
  1633. typedef void (*GDExtensionInterfaceObjectDestroy)(GDExtensionObjectPtr p_o);
  1634. /**
  1635. * @name global_get_singleton
  1636. *
  1637. * Gets a global singleton by name.
  1638. *
  1639. * @param p_name A pointer to a StringName with the singleton name.
  1640. *
  1641. * @return A pointer to the singleton Object.
  1642. */
  1643. typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensionConstStringNamePtr p_name);
  1644. /**
  1645. * @name object_get_instance_binding
  1646. *
  1647. * Gets a pointer representing an Object's instance binding.
  1648. *
  1649. * @param p_o A pointer to the Object.
  1650. * @param p_library A token the library received by the GDExtension's entry point function.
  1651. * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
  1652. *
  1653. * @return
  1654. */
  1655. typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  1656. /**
  1657. * @name object_set_instance_binding
  1658. *
  1659. * Sets an Object's instance binding.
  1660. *
  1661. * @param p_o A pointer to the Object.
  1662. * @param p_library A token the library received by the GDExtension's entry point function.
  1663. * @param p_binding A pointer to the instance binding.
  1664. * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
  1665. */
  1666. typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  1667. /**
  1668. * @name object_set_instance
  1669. *
  1670. * Sets an extension class instance on a Object.
  1671. *
  1672. * @param p_o A pointer to the Object.
  1673. * @param p_classname A pointer to a StringName with the registered extension class's name.
  1674. * @param p_instance A pointer to the extension class instance.
  1675. */
  1676. 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. */
  1677. /**
  1678. * @name object_get_class_name
  1679. *
  1680. * Gets the class name of an Object.
  1681. *
  1682. * @param p_object A pointer to the Object.
  1683. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1684. * @param r_class_name A pointer to a String to receive the class name.
  1685. *
  1686. * @return true if successful in getting the class name; otherwise false.
  1687. */
  1688. typedef GDExtensionBool (*GDExtensionInterfaceObjectGetClassName)(GDExtensionConstObjectPtr p_object, GDExtensionClassLibraryPtr p_library, GDExtensionStringNamePtr r_class_name);
  1689. /**
  1690. * @name object_cast_to
  1691. *
  1692. * Casts an Object to a different type.
  1693. *
  1694. * @param p_object A pointer to the Object.
  1695. * @param p_class_tag A pointer uniquely identifying a built-in class in the ClassDB.
  1696. *
  1697. * @return Returns a pointer to the Object, or NULL if it can't be cast to the requested type.
  1698. */
  1699. typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectCastTo)(GDExtensionConstObjectPtr p_object, void *p_class_tag);
  1700. /**
  1701. * @name object_get_instance_from_id
  1702. *
  1703. * Gets an Object by its instance ID.
  1704. *
  1705. * @param p_instance_id The instance ID.
  1706. *
  1707. * @return A pointer to the Object.
  1708. */
  1709. typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectGetInstanceFromId)(GDObjectInstanceID p_instance_id);
  1710. /**
  1711. * @name object_get_instance_id
  1712. *
  1713. * Gets the instance ID from an Object.
  1714. *
  1715. * @param p_object A pointer to the Object.
  1716. *
  1717. * @return The instance ID.
  1718. */
  1719. typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensionConstObjectPtr p_object);
  1720. /* INTERFACE: Reference */
  1721. /**
  1722. * @name ref_get_object
  1723. *
  1724. * Gets the Object from a reference.
  1725. *
  1726. * @param p_ref A pointer to the reference.
  1727. *
  1728. * @return A pointer to the Object from the reference or NULL.
  1729. */
  1730. typedef GDExtensionObjectPtr (*GDExtensionInterfaceRefGetObject)(GDExtensionConstRefPtr p_ref);
  1731. /**
  1732. * @name ref_set_object
  1733. *
  1734. * Sets the Object referred to by a reference.
  1735. *
  1736. * @param p_ref A pointer to the reference.
  1737. * @param p_object A pointer to the Object to refer to.
  1738. */
  1739. typedef void (*GDExtensionInterfaceRefSetObject)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object);
  1740. /* INTERFACE: Script Instance */
  1741. /**
  1742. * @name script_instance_create
  1743. *
  1744. * Creates a script instance that contains the given info and instance data.
  1745. *
  1746. * @param p_info A pointer to a GDExtensionScriptInstanceInfo struct.
  1747. * @param p_instance_data A pointer to a data representing the script instance in the GDExtension. This will be passed to all the function pointers on p_info.
  1748. *
  1749. * @return A pointer to a ScriptInstanceExtension object.
  1750. */
  1751. typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
  1752. /* INTERFACE: ClassDB */
  1753. /**
  1754. * @name classdb_construct_object
  1755. *
  1756. * Constructs an Object of the requested class.
  1757. *
  1758. * The passed class must be a built-in godot class, or an already-registered extension class. In both cases, object_set_instance() should be called to fully initialize the object.
  1759. *
  1760. * @param p_classname A pointer to a StringName with the class name.
  1761. *
  1762. * @return A pointer to the newly created Object.
  1763. */
  1764. typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject)(GDExtensionConstStringNamePtr p_classname);
  1765. /**
  1766. * @name classdb_get_method_bind
  1767. *
  1768. * Gets a pointer to the MethodBind in ClassDB for the given class, method and hash.
  1769. *
  1770. * @param p_classname A pointer to a StringName with the class name.
  1771. * @param p_methodname A pointer to a StringName with the method name.
  1772. * @param p_hash A hash representing the function signature.
  1773. *
  1774. * @return A pointer to the MethodBind from ClassDB.
  1775. */
  1776. typedef GDExtensionMethodBindPtr (*GDExtensionInterfaceClassdbGetMethodBind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash);
  1777. /**
  1778. * @name classdb_get_class_tag
  1779. *
  1780. * Gets a pointer uniquely identifying the given built-in class in the ClassDB.
  1781. *
  1782. * @param p_classname A pointer to a StringName with the class name.
  1783. *
  1784. * @return A pointer uniquely identifying the built-in class in the ClassDB.
  1785. */
  1786. typedef void *(*GDExtensionInterfaceClassdbGetClassTag)(GDExtensionConstStringNamePtr p_classname);
  1787. /* INTERFACE: ClassDB Extension */
  1788. /**
  1789. * @name classdb_register_extension_class
  1790. *
  1791. * Registers an extension class in the ClassDB.
  1792. *
  1793. * Provided struct can be safely freed once the function returns.
  1794. *
  1795. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1796. * @param p_class_name A pointer to a StringName with the class name.
  1797. * @param p_parent_class_name A pointer to a StringName with the parent class name.
  1798. * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo struct.
  1799. */
  1800. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs);
  1801. /**
  1802. * @name classdb_register_extension_class_method
  1803. *
  1804. * Registers a method on an extension class in the ClassDB.
  1805. *
  1806. * Provided struct can be safely freed once the function returns.
  1807. *
  1808. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1809. * @param p_class_name A pointer to a StringName with the class name.
  1810. * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct.
  1811. */
  1812. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info);
  1813. /**
  1814. * @name classdb_register_extension_class_integer_constant
  1815. *
  1816. * Registers an integer constant on an extension class in the ClassDB.
  1817. *
  1818. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1819. * @param p_class_name A pointer to a StringName with the class name.
  1820. * @param p_enum_name A pointer to a StringName with the enum name.
  1821. * @param p_constant_name A pointer to a StringName with the constant name.
  1822. * @param p_constant_value The constant value.
  1823. * @param p_is_bitfield Whether or not this is a bit field.
  1824. */
  1825. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_enum_name, GDExtensionConstStringNamePtr p_constant_name, GDExtensionInt p_constant_value, GDExtensionBool p_is_bitfield);
  1826. /**
  1827. * @name classdb_register_extension_class_property
  1828. *
  1829. * Registers a property on an extension class in the ClassDB.
  1830. *
  1831. * Provided struct can be safely freed once the function returns.
  1832. *
  1833. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1834. * @param p_class_name A pointer to a StringName with the class name.
  1835. * @param p_info A pointer to a GDExtensionPropertyInfo struct.
  1836. * @param p_setter A pointer to a StringName with the name of the setter method.
  1837. * @param p_getter A pointer to a StringName with the name of the getter method.
  1838. */
  1839. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassProperty)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter);
  1840. /**
  1841. * @name classdb_register_extension_class_property_group
  1842. *
  1843. * Registers a property group on an extension class in the ClassDB.
  1844. *
  1845. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1846. * @param p_class_name A pointer to a StringName with the class name.
  1847. * @param p_group_name A pointer to a String with the group name.
  1848. * @param p_prefix A pointer to a String with the prefix used by properties in this group.
  1849. */
  1850. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix);
  1851. /**
  1852. * @name classdb_register_extension_class_property_subgroup
  1853. *
  1854. * Registers a property subgroup on an extension class in the ClassDB.
  1855. *
  1856. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1857. * @param p_class_name A pointer to a StringName with the class name.
  1858. * @param p_subgroup_name A pointer to a String with the subgroup name.
  1859. * @param p_prefix A pointer to a String with the prefix used by properties in this subgroup.
  1860. */
  1861. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix);
  1862. /**
  1863. * @name classdb_register_extension_class_signal
  1864. *
  1865. * Registers a signal on an extension class in the ClassDB.
  1866. *
  1867. * Provided structs can be safely freed once the function returns.
  1868. *
  1869. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1870. * @param p_class_name A pointer to a StringName with the class name.
  1871. * @param p_signal_name A pointer to a StringName with the signal name.
  1872. * @param p_argument_info A pointer to a GDExtensionPropertyInfo struct.
  1873. * @param p_argument_count The number of arguments the signal receives.
  1874. */
  1875. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count);
  1876. /**
  1877. * @name classdb_unregister_extension_class
  1878. *
  1879. * Unregisters an extension class in the ClassDB.
  1880. *
  1881. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1882. * @param p_class_name A pointer to a StringName with the class name.
  1883. */
  1884. 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. */
  1885. /**
  1886. * @name get_library_path
  1887. *
  1888. * Gets the path to the current GDExtension library.
  1889. *
  1890. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1891. * @param r_path A pointer to a String which will receive the path.
  1892. */
  1893. typedef void (*GDExtensionInterfaceGetLibraryPath)(GDExtensionClassLibraryPtr p_library, GDExtensionStringPtr r_path);
  1894. /**
  1895. * @name editor_add_plugin
  1896. *
  1897. * Adds an editor plugin.
  1898. *
  1899. * It's safe to call during initialization.
  1900. *
  1901. * @param p_class_name A pointer to a StringName with the name of a class (descending from EditorPlugin) which is already registered with ClassDB.
  1902. */
  1903. typedef void (*GDExtensionInterfaceEditorAddPlugin)(GDExtensionConstStringNamePtr p_class_name);
  1904. /**
  1905. * @name editor_remove_plugin
  1906. *
  1907. * Removes an editor plugin.
  1908. *
  1909. * @param p_class_name A pointer to a StringName with the name of a class that was previously added as an editor plugin.
  1910. */
  1911. typedef void (*GDExtensionInterfaceEditorRemovePlugin)(GDExtensionConstStringNamePtr p_class_name);
  1912. #ifdef __cplusplus
  1913. }
  1914. #endif
  1915. #endif // GDEXTENSION_INTERFACE_H