gdextension_interface.h 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305
  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. // In this API there are multiple functions which expect the caller to pass a pointer
  124. // on return value as parameter.
  125. // In order to make it clear if the caller should initialize the return value or not
  126. // we have two flavor of types:
  127. // - `GDExtensionXXXPtr` for pointer on an initialized value
  128. // - `GDExtensionUninitializedXXXPtr` for pointer on uninitialized value
  129. //
  130. // Notes:
  131. // - Not respecting those requirements can seems harmless, but will lead to unexpected
  132. // segfault or memory leak (for instance with a specific compiler/OS, or when two
  133. // native extensions start doing ptrcall on each other).
  134. // - Initialization must be done with the function pointer returned by `variant_get_ptr_constructor`,
  135. // zero-initializing the variable should not be considered a valid initialization method here !
  136. // - Some types have no destructor (see `extension_api.json`'s `has_destructor` field), for
  137. // them it is always safe to skip the constructor for the return value if you are in a hurry ;-)
  138. typedef void *GDExtensionVariantPtr;
  139. typedef const void *GDExtensionConstVariantPtr;
  140. typedef void *GDExtensionUninitializedVariantPtr;
  141. typedef void *GDExtensionStringNamePtr;
  142. typedef const void *GDExtensionConstStringNamePtr;
  143. typedef void *GDExtensionUninitializedStringNamePtr;
  144. typedef void *GDExtensionStringPtr;
  145. typedef const void *GDExtensionConstStringPtr;
  146. typedef void *GDExtensionUninitializedStringPtr;
  147. typedef void *GDExtensionObjectPtr;
  148. typedef const void *GDExtensionConstObjectPtr;
  149. typedef void *GDExtensionUninitializedObjectPtr;
  150. typedef void *GDExtensionTypePtr;
  151. typedef const void *GDExtensionConstTypePtr;
  152. typedef void *GDExtensionUninitializedTypePtr;
  153. typedef const void *GDExtensionMethodBindPtr;
  154. typedef int64_t GDExtensionInt;
  155. typedef uint8_t GDExtensionBool;
  156. typedef uint64_t GDObjectInstanceID;
  157. typedef void *GDExtensionRefPtr;
  158. typedef const void *GDExtensionConstRefPtr;
  159. /* VARIANT DATA I/O */
  160. typedef enum {
  161. GDEXTENSION_CALL_OK,
  162. GDEXTENSION_CALL_ERROR_INVALID_METHOD,
  163. GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT, // Expected a different variant type.
  164. GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS, // Expected lower number of arguments.
  165. GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS, // Expected higher number of arguments.
  166. GDEXTENSION_CALL_ERROR_INSTANCE_IS_NULL,
  167. GDEXTENSION_CALL_ERROR_METHOD_NOT_CONST, // Used for const call.
  168. } GDExtensionCallErrorType;
  169. typedef struct {
  170. GDExtensionCallErrorType error;
  171. int32_t argument;
  172. int32_t expected;
  173. } GDExtensionCallError;
  174. typedef void (*GDExtensionVariantFromTypeConstructorFunc)(GDExtensionUninitializedVariantPtr, GDExtensionTypePtr);
  175. typedef void (*GDExtensionTypeFromVariantConstructorFunc)(GDExtensionUninitializedTypePtr, GDExtensionVariantPtr);
  176. typedef void (*GDExtensionPtrOperatorEvaluator)(GDExtensionConstTypePtr p_left, GDExtensionConstTypePtr p_right, GDExtensionTypePtr r_result);
  177. typedef void (*GDExtensionPtrBuiltInMethod)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return, int p_argument_count);
  178. typedef void (*GDExtensionPtrConstructor)(GDExtensionUninitializedTypePtr p_base, const GDExtensionConstTypePtr *p_args);
  179. typedef void (*GDExtensionPtrDestructor)(GDExtensionTypePtr p_base);
  180. typedef void (*GDExtensionPtrSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_value);
  181. typedef void (*GDExtensionPtrGetter)(GDExtensionConstTypePtr p_base, GDExtensionTypePtr r_value);
  182. typedef void (*GDExtensionPtrIndexedSetter)(GDExtensionTypePtr p_base, GDExtensionInt p_index, GDExtensionConstTypePtr p_value);
  183. typedef void (*GDExtensionPtrIndexedGetter)(GDExtensionConstTypePtr p_base, GDExtensionInt p_index, GDExtensionTypePtr r_value);
  184. typedef void (*GDExtensionPtrKeyedSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionConstTypePtr p_value);
  185. typedef void (*GDExtensionPtrKeyedGetter)(GDExtensionConstTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionTypePtr r_value);
  186. typedef uint32_t (*GDExtensionPtrKeyedChecker)(GDExtensionConstVariantPtr p_base, GDExtensionConstVariantPtr p_key);
  187. typedef void (*GDExtensionPtrUtilityFunction)(GDExtensionTypePtr r_return, const GDExtensionConstTypePtr *p_args, int p_argument_count);
  188. typedef GDExtensionObjectPtr (*GDExtensionClassConstructor)();
  189. typedef void *(*GDExtensionInstanceBindingCreateCallback)(void *p_token, void *p_instance);
  190. typedef void (*GDExtensionInstanceBindingFreeCallback)(void *p_token, void *p_instance, void *p_binding);
  191. typedef GDExtensionBool (*GDExtensionInstanceBindingReferenceCallback)(void *p_token, void *p_binding, GDExtensionBool p_reference);
  192. typedef struct {
  193. GDExtensionInstanceBindingCreateCallback create_callback;
  194. GDExtensionInstanceBindingFreeCallback free_callback;
  195. GDExtensionInstanceBindingReferenceCallback reference_callback;
  196. } GDExtensionInstanceBindingCallbacks;
  197. /* EXTENSION CLASSES */
  198. typedef void *GDExtensionClassInstancePtr;
  199. typedef GDExtensionBool (*GDExtensionClassSet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
  200. typedef GDExtensionBool (*GDExtensionClassGet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  201. typedef uint64_t (*GDExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance);
  202. typedef struct {
  203. GDExtensionVariantType type;
  204. GDExtensionStringNamePtr name;
  205. GDExtensionStringNamePtr class_name;
  206. uint32_t hint; // Bitfield of `PropertyHint` (defined in `extension_api.json`).
  207. GDExtensionStringPtr hint_string;
  208. uint32_t usage; // Bitfield of `PropertyUsageFlags` (defined in `extension_api.json`).
  209. } GDExtensionPropertyInfo;
  210. typedef struct {
  211. GDExtensionStringNamePtr name;
  212. GDExtensionPropertyInfo return_value;
  213. uint32_t flags; // Bitfield of `GDExtensionClassMethodFlags`.
  214. int32_t id;
  215. /* Arguments: `default_arguments` is an array of size `argument_count`. */
  216. uint32_t argument_count;
  217. GDExtensionPropertyInfo *arguments;
  218. /* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
  219. uint32_t default_argument_count;
  220. GDExtensionVariantPtr *default_arguments;
  221. } GDExtensionMethodInfo;
  222. typedef const GDExtensionPropertyInfo *(*GDExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count);
  223. typedef void (*GDExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list);
  224. typedef GDExtensionBool (*GDExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name);
  225. typedef GDExtensionBool (*GDExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  226. typedef void (*GDExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what);
  227. typedef void (*GDExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr p_out);
  228. typedef void (*GDExtensionClassReference)(GDExtensionClassInstancePtr p_instance);
  229. typedef void (*GDExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance);
  230. typedef void (*GDExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  231. typedef GDExtensionObjectPtr (*GDExtensionClassCreateInstance)(void *p_userdata);
  232. typedef void (*GDExtensionClassFreeInstance)(void *p_userdata, GDExtensionClassInstancePtr p_instance);
  233. typedef GDExtensionClassCallVirtual (*GDExtensionClassGetVirtual)(void *p_userdata, GDExtensionConstStringNamePtr p_name);
  234. typedef struct {
  235. GDExtensionBool is_virtual;
  236. GDExtensionBool is_abstract;
  237. GDExtensionClassSet set_func;
  238. GDExtensionClassGet get_func;
  239. GDExtensionClassGetPropertyList get_property_list_func;
  240. GDExtensionClassFreePropertyList free_property_list_func;
  241. GDExtensionClassPropertyCanRevert property_can_revert_func;
  242. GDExtensionClassPropertyGetRevert property_get_revert_func;
  243. GDExtensionClassNotification notification_func;
  244. GDExtensionClassToString to_string_func;
  245. GDExtensionClassReference reference_func;
  246. GDExtensionClassUnreference unreference_func;
  247. GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
  248. GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
  249. GDExtensionClassGetVirtual get_virtual_func; // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
  250. GDExtensionClassGetRID get_rid_func;
  251. void *class_userdata; // Per-class user data, later accessible in instance bindings.
  252. } GDExtensionClassCreationInfo;
  253. typedef void *GDExtensionClassLibraryPtr;
  254. /* Method */
  255. typedef enum {
  256. GDEXTENSION_METHOD_FLAG_NORMAL = 1,
  257. GDEXTENSION_METHOD_FLAG_EDITOR = 2,
  258. GDEXTENSION_METHOD_FLAG_CONST = 4,
  259. GDEXTENSION_METHOD_FLAG_VIRTUAL = 8,
  260. GDEXTENSION_METHOD_FLAG_VARARG = 16,
  261. GDEXTENSION_METHOD_FLAG_STATIC = 32,
  262. GDEXTENSION_METHOD_FLAGS_DEFAULT = GDEXTENSION_METHOD_FLAG_NORMAL,
  263. } GDExtensionClassMethodFlags;
  264. typedef enum {
  265. GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE,
  266. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8,
  267. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16,
  268. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32,
  269. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64,
  270. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8,
  271. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16,
  272. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32,
  273. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64,
  274. GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT,
  275. GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE
  276. } GDExtensionClassMethodArgumentMetadata;
  277. typedef void (*GDExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  278. typedef void (*GDExtensionClassMethodValidatedCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionVariantPtr r_return);
  279. typedef void (*GDExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  280. typedef struct {
  281. GDExtensionStringNamePtr name;
  282. void *method_userdata;
  283. GDExtensionClassMethodCall call_func;
  284. GDExtensionClassMethodPtrCall ptrcall_func;
  285. uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
  286. /* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored. */
  287. GDExtensionBool has_return_value;
  288. GDExtensionPropertyInfo *return_value_info;
  289. GDExtensionClassMethodArgumentMetadata return_value_metadata;
  290. /* Arguments: `arguments_info` and `arguments_metadata` are array of size `argument_count`.
  291. * Name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies.
  292. */
  293. uint32_t argument_count;
  294. GDExtensionPropertyInfo *arguments_info;
  295. GDExtensionClassMethodArgumentMetadata *arguments_metadata;
  296. /* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
  297. uint32_t default_argument_count;
  298. GDExtensionVariantPtr *default_arguments;
  299. } GDExtensionClassMethodInfo;
  300. /* SCRIPT INSTANCE EXTENSION */
  301. typedef void *GDExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation.
  302. typedef GDExtensionBool (*GDExtensionScriptInstanceSet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
  303. typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  304. typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
  305. typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list);
  306. typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
  307. typedef GDExtensionBool (*GDExtensionScriptInstancePropertyCanRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
  308. typedef GDExtensionBool (*GDExtensionScriptInstancePropertyGetRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  309. typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetOwner)(GDExtensionScriptInstanceDataPtr p_instance);
  310. typedef void (*GDExtensionScriptInstancePropertyStateAdd)(GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value, void *p_userdata);
  311. typedef void (*GDExtensionScriptInstanceGetPropertyState)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata);
  312. typedef const GDExtensionMethodInfo *(*GDExtensionScriptInstanceGetMethodList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
  313. typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list);
  314. typedef GDExtensionBool (*GDExtensionScriptInstanceHasMethod)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
  315. typedef void (*GDExtensionScriptInstanceCall)(GDExtensionScriptInstanceDataPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  316. typedef void (*GDExtensionScriptInstanceNotification)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what);
  317. typedef void (*GDExtensionScriptInstanceToString)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
  318. typedef void (*GDExtensionScriptInstanceRefCountIncremented)(GDExtensionScriptInstanceDataPtr p_instance);
  319. typedef GDExtensionBool (*GDExtensionScriptInstanceRefCountDecremented)(GDExtensionScriptInstanceDataPtr p_instance);
  320. typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetScript)(GDExtensionScriptInstanceDataPtr p_instance);
  321. typedef GDExtensionBool (*GDExtensionScriptInstanceIsPlaceholder)(GDExtensionScriptInstanceDataPtr p_instance);
  322. typedef void *GDExtensionScriptLanguagePtr;
  323. typedef GDExtensionScriptLanguagePtr (*GDExtensionScriptInstanceGetLanguage)(GDExtensionScriptInstanceDataPtr p_instance);
  324. typedef void (*GDExtensionScriptInstanceFree)(GDExtensionScriptInstanceDataPtr p_instance);
  325. typedef void *GDExtensionScriptInstancePtr; // Pointer to ScriptInstance.
  326. typedef struct {
  327. GDExtensionScriptInstanceSet set_func;
  328. GDExtensionScriptInstanceGet get_func;
  329. GDExtensionScriptInstanceGetPropertyList get_property_list_func;
  330. GDExtensionScriptInstanceFreePropertyList free_property_list_func;
  331. GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
  332. GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
  333. GDExtensionScriptInstanceGetOwner get_owner_func;
  334. GDExtensionScriptInstanceGetPropertyState get_property_state_func;
  335. GDExtensionScriptInstanceGetMethodList get_method_list_func;
  336. GDExtensionScriptInstanceFreeMethodList free_method_list_func;
  337. GDExtensionScriptInstanceGetPropertyType get_property_type_func;
  338. GDExtensionScriptInstanceHasMethod has_method_func;
  339. GDExtensionScriptInstanceCall call_func;
  340. GDExtensionScriptInstanceNotification notification_func;
  341. GDExtensionScriptInstanceToString to_string_func;
  342. GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
  343. GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
  344. GDExtensionScriptInstanceGetScript get_script_func;
  345. GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
  346. GDExtensionScriptInstanceSet set_fallback_func;
  347. GDExtensionScriptInstanceGet get_fallback_func;
  348. GDExtensionScriptInstanceGetLanguage get_language_func;
  349. GDExtensionScriptInstanceFree free_func;
  350. } GDExtensionScriptInstanceInfo;
  351. /* INITIALIZATION */
  352. typedef enum {
  353. GDEXTENSION_INITIALIZATION_CORE,
  354. GDEXTENSION_INITIALIZATION_SERVERS,
  355. GDEXTENSION_INITIALIZATION_SCENE,
  356. GDEXTENSION_INITIALIZATION_EDITOR,
  357. GDEXTENSION_MAX_INITIALIZATION_LEVEL,
  358. } GDExtensionInitializationLevel;
  359. typedef struct {
  360. /* Minimum initialization level required.
  361. * If Core or Servers, the extension needs editor or game restart to take effect */
  362. GDExtensionInitializationLevel minimum_initialization_level;
  363. /* Up to the user to supply when initializing */
  364. void *userdata;
  365. /* This function will be called multiple times for each initialization level. */
  366. void (*initialize)(void *userdata, GDExtensionInitializationLevel p_level);
  367. void (*deinitialize)(void *userdata, GDExtensionInitializationLevel p_level);
  368. } GDExtensionInitialization;
  369. typedef void (*GDExtensionInterfaceFunctionPtr)();
  370. typedef GDExtensionInterfaceFunctionPtr (*GDExtensionInterfaceGetProcAddress)(const char *p_function_name);
  371. /*
  372. * Each GDExtension should define a C function that matches the signature of GDExtensionInitializationFunction,
  373. * and export it so that it can be loaded via dlopen() or equivalent for the given platform.
  374. *
  375. * For example:
  376. *
  377. * GDExtensionBool my_extension_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
  378. *
  379. * This function's name must be specified as the 'entry_symbol' in the .gdextension file.
  380. *
  381. * This makes it the entry point of the GDExtension and will be called on initialization.
  382. *
  383. * The GDExtension can then modify the r_initialization structure, setting the minimum initialization level,
  384. * and providing pointers to functions that will be called at various stages of initialization/shutdown.
  385. *
  386. * The rest of the GDExtension's interface to Godot consists of function pointers that can be loaded
  387. * by calling p_get_proc_address("...") with the name of the function.
  388. *
  389. * For example:
  390. *
  391. * GDExtensionInterfaceGetGodotVersion *get_godot_version = (GDExtensionInterfaceGetGodotVersion)p_get_proc_address("get_godot_version");
  392. *
  393. * You can then call it like a normal function:
  394. *
  395. * GDExtensionGodotVersion godot_version;
  396. * get_godot_version(&godot_version);
  397. * printf("Godot v%d.%d.%d\n", godot_version.major, godot_version.minor, godot_version.patch);
  398. *
  399. * All of these interface functions are described below, together with the name that's used to load it,
  400. * and the function pointer typedef that shows its signature.
  401. */
  402. typedef GDExtensionBool (*GDExtensionInitializationFunction)(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
  403. /* INTERFACE */
  404. typedef struct {
  405. uint32_t major;
  406. uint32_t minor;
  407. uint32_t patch;
  408. const char *string;
  409. } GDExtensionGodotVersion;
  410. /**
  411. * @name get_godot_version
  412. * @since 4.1
  413. *
  414. * Gets the Godot version that the GDExtension was loaded into.
  415. *
  416. * @param r_godot_version A pointer to the structure to write the version information into.
  417. */
  418. typedef void (*GDExtensionInterfaceGetGodotVersion)(GDExtensionGodotVersion *r_godot_version);
  419. /* INTERFACE: Memory */
  420. /**
  421. * @name mem_alloc
  422. * @since 4.1
  423. *
  424. * Allocates memory.
  425. *
  426. * @param p_bytes The amount of memory to allocate in bytes.
  427. *
  428. * @return A pointer to the allocated memory, or NULL if unsuccessful.
  429. */
  430. typedef void *(*GDExtensionInterfaceMemAlloc)(size_t p_bytes);
  431. /**
  432. * @name mem_realloc
  433. * @since 4.1
  434. *
  435. * Reallocates memory.
  436. *
  437. * @param p_ptr A pointer to the previously allocated memory.
  438. * @param p_bytes The number of bytes to resize the memory block to.
  439. *
  440. * @return A pointer to the allocated memory, or NULL if unsuccessful.
  441. */
  442. typedef void *(*GDExtensionInterfaceMemRealloc)(void *p_ptr, size_t p_bytes);
  443. /**
  444. * @name mem_free
  445. * @since 4.1
  446. *
  447. * Frees memory.
  448. *
  449. * @param p_ptr A pointer to the previously allocated memory.
  450. */
  451. typedef void (*GDExtensionInterfaceMemFree)(void *p_ptr);
  452. /* INTERFACE: Godot Core */
  453. /**
  454. * @name print_error
  455. * @since 4.1
  456. *
  457. * Logs an error to Godot's built-in debugger and to the OS terminal.
  458. *
  459. * @param p_description The code trigging the error.
  460. * @param p_function The function name where the error occurred.
  461. * @param p_file The file where the error occurred.
  462. * @param p_line The line where the error occurred.
  463. * @param p_editor_notify Whether or not to notify the editor.
  464. */
  465. typedef void (*GDExtensionInterfacePrintError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  466. /**
  467. * @name print_error_with_message
  468. * @since 4.1
  469. *
  470. * Logs an error with a message to Godot's built-in debugger and to the OS terminal.
  471. *
  472. * @param p_description The code trigging the error.
  473. * @param p_message The message to show along with the error.
  474. * @param p_function The function name where the error occurred.
  475. * @param p_file The file where the error occurred.
  476. * @param p_line The line where the error occurred.
  477. * @param p_editor_notify Whether or not to notify the editor.
  478. */
  479. 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);
  480. /**
  481. * @name print_warning
  482. * @since 4.1
  483. *
  484. * Logs a warning to Godot's built-in debugger and to the OS terminal.
  485. *
  486. * @param p_description The code trigging the warning.
  487. * @param p_function The function name where the warning occurred.
  488. * @param p_file The file where the warning occurred.
  489. * @param p_line The line where the warning occurred.
  490. * @param p_editor_notify Whether or not to notify the editor.
  491. */
  492. typedef void (*GDExtensionInterfacePrintWarning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  493. /**
  494. * @name print_warning_with_message
  495. * @since 4.1
  496. *
  497. * Logs a warning with a message to Godot's built-in debugger and to the OS terminal.
  498. *
  499. * @param p_description The code trigging the warning.
  500. * @param p_message The message to show along with the warning.
  501. * @param p_function The function name where the warning occurred.
  502. * @param p_file The file where the warning occurred.
  503. * @param p_line The line where the warning occurred.
  504. * @param p_editor_notify Whether or not to notify the editor.
  505. */
  506. 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);
  507. /**
  508. * @name print_script_error
  509. * @since 4.1
  510. *
  511. * Logs a script error to Godot's built-in debugger and to the OS terminal.
  512. *
  513. * @param p_description The code trigging the error.
  514. * @param p_function The function name where the error occurred.
  515. * @param p_file The file where the error occurred.
  516. * @param p_line The line where the error occurred.
  517. * @param p_editor_notify Whether or not to notify the editor.
  518. */
  519. typedef void (*GDExtensionInterfacePrintScriptError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  520. /**
  521. * @name print_script_error_with_message
  522. * @since 4.1
  523. *
  524. * Logs a script error with a message to Godot's built-in debugger and to the OS terminal.
  525. *
  526. * @param p_description The code trigging the error.
  527. * @param p_message The message to show along with the error.
  528. * @param p_function The function name where the error occurred.
  529. * @param p_file The file where the error occurred.
  530. * @param p_line The line where the error occurred.
  531. * @param p_editor_notify Whether or not to notify the editor.
  532. */
  533. 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);
  534. /**
  535. * @name get_native_struct_size
  536. * @since 4.1
  537. *
  538. * Gets the size of a native struct (ex. ObjectID) in bytes.
  539. *
  540. * @param p_name A pointer to a StringName identifying the struct name.
  541. *
  542. * @return The size in bytes.
  543. */
  544. typedef uint64_t (*GDExtensionInterfaceGetNativeStructSize)(GDExtensionConstStringNamePtr p_name);
  545. /* INTERFACE: Variant */
  546. /**
  547. * @name variant_new_copy
  548. * @since 4.1
  549. *
  550. * Copies one Variant into a another.
  551. *
  552. * @param r_dest A pointer to the destination Variant.
  553. * @param p_src A pointer to the source Variant.
  554. */
  555. typedef void (*GDExtensionInterfaceVariantNewCopy)(GDExtensionUninitializedVariantPtr r_dest, GDExtensionConstVariantPtr p_src);
  556. /**
  557. * @name variant_new_nil
  558. * @since 4.1
  559. *
  560. * Creates a new Variant containing nil.
  561. *
  562. * @param r_dest A pointer to the destination Variant.
  563. */
  564. typedef void (*GDExtensionInterfaceVariantNewNil)(GDExtensionUninitializedVariantPtr r_dest);
  565. /**
  566. * @name variant_destroy
  567. * @since 4.1
  568. *
  569. * Destroys a Variant.
  570. *
  571. * @param p_self A pointer to the Variant to destroy.
  572. */
  573. typedef void (*GDExtensionInterfaceVariantDestroy)(GDExtensionVariantPtr p_self);
  574. /**
  575. * @name variant_call
  576. * @since 4.1
  577. *
  578. * Calls a method on a Variant.
  579. *
  580. * @param p_self A pointer to the Variant.
  581. * @param p_method A pointer to a StringName identifying the method.
  582. * @param p_args A pointer to a C array of Variant.
  583. * @param p_argument_count The number of arguments.
  584. * @param r_return A pointer a Variant which will be assigned the return value.
  585. * @param r_error A pointer the structure which will hold error information.
  586. *
  587. * @see Variant::callp()
  588. */
  589. typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
  590. /**
  591. * @name variant_call_static
  592. * @since 4.1
  593. *
  594. * Calls a static method on a Variant.
  595. *
  596. * @param p_self A pointer to the Variant.
  597. * @param p_method A pointer to a StringName identifying the method.
  598. * @param p_args A pointer to a C array of Variant.
  599. * @param p_argument_count The number of arguments.
  600. * @param r_return A pointer a Variant which will be assigned the return value.
  601. * @param r_error A pointer the structure which will be updated with error information.
  602. *
  603. * @see Variant::call_static()
  604. */
  605. typedef void (*GDExtensionInterfaceVariantCallStatic)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
  606. /**
  607. * @name variant_evaluate
  608. * @since 4.1
  609. *
  610. * Evaluate an operator on two Variants.
  611. *
  612. * @param p_op The operator to evaluate.
  613. * @param p_a The first Variant.
  614. * @param p_b The second Variant.
  615. * @param r_return A pointer a Variant which will be assigned the return value.
  616. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  617. *
  618. * @see Variant::evaluate()
  619. */
  620. typedef void (*GDExtensionInterfaceVariantEvaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionUninitializedVariantPtr r_return, GDExtensionBool *r_valid);
  621. /**
  622. * @name variant_set
  623. * @since 4.1
  624. *
  625. * Sets a key on a Variant to a value.
  626. *
  627. * @param p_self A pointer to the Variant.
  628. * @param p_key A pointer to a Variant representing the key.
  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. *
  632. * @see Variant::set()
  633. */
  634. typedef void (*GDExtensionInterfaceVariantSet)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  635. /**
  636. * @name variant_set_named
  637. * @since 4.1
  638. *
  639. * Sets a named key on a Variant to a value.
  640. *
  641. * @param p_self A pointer to the Variant.
  642. * @param p_key A pointer to a StringName representing the key.
  643. * @param p_value A pointer to a Variant representing the value.
  644. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  645. *
  646. * @see Variant::set_named()
  647. */
  648. typedef void (*GDExtensionInterfaceVariantSetNamed)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  649. /**
  650. * @name variant_set_keyed
  651. * @since 4.1
  652. *
  653. * Sets a keyed property on a Variant to a value.
  654. *
  655. * @param p_self A pointer to the Variant.
  656. * @param p_key A pointer to a Variant representing the key.
  657. * @param p_value A pointer to a Variant representing the value.
  658. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  659. *
  660. * @see Variant::set_keyed()
  661. */
  662. typedef void (*GDExtensionInterfaceVariantSetKeyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  663. /**
  664. * @name variant_set_indexed
  665. * @since 4.1
  666. *
  667. * Sets an index on a Variant to a value.
  668. *
  669. * @param p_self A pointer to the Variant.
  670. * @param p_index The index.
  671. * @param p_value A pointer to a Variant representing the value.
  672. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  673. * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
  674. */
  675. typedef void (*GDExtensionInterfaceVariantSetIndexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  676. /**
  677. * @name variant_get
  678. * @since 4.1
  679. *
  680. * Gets the value of a key from a Variant.
  681. *
  682. * @param p_self A pointer to the Variant.
  683. * @param p_key A pointer to a Variant representing the key.
  684. * @param r_ret A pointer to a Variant which will be assigned the value.
  685. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  686. */
  687. typedef void (*GDExtensionInterfaceVariantGet)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  688. /**
  689. * @name variant_get_named
  690. * @since 4.1
  691. *
  692. * Gets the value of a named key from a Variant.
  693. *
  694. * @param p_self A pointer to the Variant.
  695. * @param p_key A pointer to a StringName representing the key.
  696. * @param r_ret A pointer to a Variant which will be assigned the value.
  697. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  698. */
  699. typedef void (*GDExtensionInterfaceVariantGetNamed)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  700. /**
  701. * @name variant_get_keyed
  702. * @since 4.1
  703. *
  704. * Gets the value of a keyed property from a Variant.
  705. *
  706. * @param p_self A pointer to the Variant.
  707. * @param p_key A pointer to a Variant representing the key.
  708. * @param r_ret A pointer to a Variant which will be assigned the value.
  709. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  710. */
  711. typedef void (*GDExtensionInterfaceVariantGetKeyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  712. /**
  713. * @name variant_get_indexed
  714. * @since 4.1
  715. *
  716. * Gets the value of an index from a Variant.
  717. *
  718. * @param p_self A pointer to the Variant.
  719. * @param p_index The index.
  720. * @param r_ret A pointer to a Variant which will be assigned the value.
  721. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  722. * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
  723. */
  724. typedef void (*GDExtensionInterfaceVariantGetIndexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  725. /**
  726. * @name variant_iter_init
  727. * @since 4.1
  728. *
  729. * Initializes an iterator over a Variant.
  730. *
  731. * @param p_self A pointer to the Variant.
  732. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  733. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  734. *
  735. * @return true if the operation is valid; otherwise false.
  736. *
  737. * @see Variant::iter_init()
  738. */
  739. typedef GDExtensionBool (*GDExtensionInterfaceVariantIterInit)(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_iter, GDExtensionBool *r_valid);
  740. /**
  741. * @name variant_iter_next
  742. * @since 4.1
  743. *
  744. * Gets the next value for an iterator over a Variant.
  745. *
  746. * @param p_self A pointer to the Variant.
  747. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  748. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  749. *
  750. * @return true if the operation is valid; otherwise false.
  751. *
  752. * @see Variant::iter_next()
  753. */
  754. typedef GDExtensionBool (*GDExtensionInterfaceVariantIterNext)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
  755. /**
  756. * @name variant_iter_get
  757. * @since 4.1
  758. *
  759. * Gets the next value for an iterator over a Variant.
  760. *
  761. * @param p_self A pointer to the Variant.
  762. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  763. * @param r_ret A pointer to a Variant which will be assigned false if the operation is invalid.
  764. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  765. *
  766. * @see Variant::iter_get()
  767. */
  768. typedef void (*GDExtensionInterfaceVariantIterGet)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  769. /**
  770. * @name variant_hash
  771. * @since 4.1
  772. *
  773. * Gets the hash of a Variant.
  774. *
  775. * @param p_self A pointer to the Variant.
  776. *
  777. * @return The hash value.
  778. *
  779. * @see Variant::hash()
  780. */
  781. typedef GDExtensionInt (*GDExtensionInterfaceVariantHash)(GDExtensionConstVariantPtr p_self);
  782. /**
  783. * @name variant_recursive_hash
  784. * @since 4.1
  785. *
  786. * Gets the recursive hash of a Variant.
  787. *
  788. * @param p_self A pointer to the Variant.
  789. * @param p_recursion_count The number of recursive loops so far.
  790. *
  791. * @return The hash value.
  792. *
  793. * @see Variant::recursive_hash()
  794. */
  795. typedef GDExtensionInt (*GDExtensionInterfaceVariantRecursiveHash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count);
  796. /**
  797. * @name variant_hash_compare
  798. * @since 4.1
  799. *
  800. * Compares two Variants by their hash.
  801. *
  802. * @param p_self A pointer to the Variant.
  803. * @param p_other A pointer to the other Variant to compare it to.
  804. *
  805. * @return The hash value.
  806. *
  807. * @see Variant::hash_compare()
  808. */
  809. typedef GDExtensionBool (*GDExtensionInterfaceVariantHashCompare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other);
  810. /**
  811. * @name variant_booleanize
  812. * @since 4.1
  813. *
  814. * Converts a Variant to a boolean.
  815. *
  816. * @param p_self A pointer to the Variant.
  817. *
  818. * @return The boolean value of the Variant.
  819. */
  820. typedef GDExtensionBool (*GDExtensionInterfaceVariantBooleanize)(GDExtensionConstVariantPtr p_self);
  821. /**
  822. * @name variant_duplicate
  823. * @since 4.1
  824. *
  825. * Duplicates a Variant.
  826. *
  827. * @param p_self A pointer to the Variant.
  828. * @param r_ret A pointer to a Variant to store the duplicated value.
  829. * @param p_deep Whether or not to duplicate deeply (when supported by the Variant type).
  830. */
  831. typedef void (*GDExtensionInterfaceVariantDuplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep);
  832. /**
  833. * @name variant_stringify
  834. * @since 4.1
  835. *
  836. * Converts a Variant to a string.
  837. *
  838. * @param p_self A pointer to the Variant.
  839. * @param r_ret A pointer to a String to store the resulting value.
  840. */
  841. typedef void (*GDExtensionInterfaceVariantStringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret);
  842. /**
  843. * @name variant_get_type
  844. * @since 4.1
  845. *
  846. * Gets the type of a Variant.
  847. *
  848. * @param p_self A pointer to the Variant.
  849. *
  850. * @return The variant type.
  851. */
  852. typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtensionConstVariantPtr p_self);
  853. /**
  854. * @name variant_has_method
  855. * @since 4.1
  856. *
  857. * Checks if a Variant has the given method.
  858. *
  859. * @param p_self A pointer to the Variant.
  860. * @param p_method A pointer to a StringName with the method name.
  861. *
  862. * @return
  863. */
  864. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
  865. /**
  866. * @name variant_has_member
  867. * @since 4.1
  868. *
  869. * Checks if a type of Variant has the given member.
  870. *
  871. * @param p_type The Variant type.
  872. * @param p_member A pointer to a StringName with the member name.
  873. *
  874. * @return
  875. */
  876. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  877. /**
  878. * @name variant_has_key
  879. * @since 4.1
  880. *
  881. * Checks if a Variant has a key.
  882. *
  883. * @param p_self A pointer to the Variant.
  884. * @param p_key A pointer to a Variant representing the key.
  885. * @param r_valid A pointer to a boolean which will be set to false if the key doesn't exist.
  886. *
  887. * @return true if the key exists; otherwise false.
  888. */
  889. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasKey)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid);
  890. /**
  891. * @name variant_get_type_name
  892. * @since 4.1
  893. *
  894. * Gets the name of a Variant type.
  895. *
  896. * @param p_type The Variant type.
  897. * @param r_name A pointer to a String to store the Variant type name.
  898. */
  899. typedef void (*GDExtensionInterfaceVariantGetTypeName)(GDExtensionVariantType p_type, GDExtensionUninitializedStringPtr r_name);
  900. /**
  901. * @name variant_can_convert
  902. * @since 4.1
  903. *
  904. * Checks if Variants can be converted from one type to another.
  905. *
  906. * @param p_from The Variant type to convert from.
  907. * @param p_to The Variant type to convert to.
  908. *
  909. * @return true if the conversion is possible; otherwise false.
  910. */
  911. typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  912. /**
  913. * @name variant_can_convert_strict
  914. * @since 4.1
  915. *
  916. * Checks if Variant can be converted from one type to another using stricter rules.
  917. *
  918. * @param p_from The Variant type to convert from.
  919. * @param p_to The Variant type to convert to.
  920. *
  921. * @return true if the conversion is possible; otherwise false.
  922. */
  923. typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvertStrict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  924. /**
  925. * @name get_variant_from_type_constructor
  926. * @since 4.1
  927. *
  928. * Gets a pointer to a function that can create a Variant of the given type from a raw value.
  929. *
  930. * @param p_type The Variant type.
  931. *
  932. * @return A pointer to a function that can create a Variant of the given type from a raw value.
  933. */
  934. typedef GDExtensionVariantFromTypeConstructorFunc (*GDExtensionInterfaceGetVariantFromTypeConstructor)(GDExtensionVariantType p_type);
  935. /**
  936. * @name get_variant_to_type_constructor
  937. * @since 4.1
  938. *
  939. * Gets a pointer to a function that can get the raw value from a Variant of the given type.
  940. *
  941. * @param p_type The Variant type.
  942. *
  943. * @return A pointer to a function that can get the raw value from a Variant of the given type.
  944. */
  945. typedef GDExtensionTypeFromVariantConstructorFunc (*GDExtensionInterfaceGetVariantToTypeConstructor)(GDExtensionVariantType p_type);
  946. /**
  947. * @name variant_get_ptr_operator_evaluator
  948. * @since 4.1
  949. *
  950. * Gets a pointer to a function that can evaluate the given Variant operator on the given Variant types.
  951. *
  952. * @param p_operator The variant operator.
  953. * @param p_type_a The type of the first Variant.
  954. * @param p_type_b The type of the second Variant.
  955. *
  956. * @return A pointer to a function that can evaluate the given Variant operator on the given Variant types.
  957. */
  958. typedef GDExtensionPtrOperatorEvaluator (*GDExtensionInterfaceVariantGetPtrOperatorEvaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b);
  959. /**
  960. * @name variant_get_ptr_builtin_method
  961. * @since 4.1
  962. *
  963. * Gets a pointer to a function that can call a builtin method on a type of Variant.
  964. *
  965. * @param p_type The Variant type.
  966. * @param p_method A pointer to a StringName with the method name.
  967. * @param p_hash A hash representing the method signature.
  968. *
  969. * @return A pointer to a function that can call a builtin method on a type of Variant.
  970. */
  971. typedef GDExtensionPtrBuiltInMethod (*GDExtensionInterfaceVariantGetPtrBuiltinMethod)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash);
  972. /**
  973. * @name variant_get_ptr_constructor
  974. * @since 4.1
  975. *
  976. * Gets a pointer to a function that can call one of the constructors for a type of Variant.
  977. *
  978. * @param p_type The Variant type.
  979. * @param p_constructor The index of the constructor.
  980. *
  981. * @return A pointer to a function that can call one of the constructors for a type of Variant.
  982. */
  983. typedef GDExtensionPtrConstructor (*GDExtensionInterfaceVariantGetPtrConstructor)(GDExtensionVariantType p_type, int32_t p_constructor);
  984. /**
  985. * @name variant_get_ptr_destructor
  986. * @since 4.1
  987. *
  988. * Gets a pointer to a function than can call the destructor for a type of Variant.
  989. *
  990. * @param p_type The Variant type.
  991. *
  992. * @return A pointer to a function than can call the destructor for a type of Variant.
  993. */
  994. typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(GDExtensionVariantType p_type);
  995. /**
  996. * @name variant_construct
  997. * @since 4.1
  998. *
  999. * Constructs a Variant of the given type, using the first constructor that matches the given arguments.
  1000. *
  1001. * @param p_type The Variant type.
  1002. * @param p_base A pointer to a Variant to store the constructed value.
  1003. * @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor.
  1004. * @param p_argument_count The number of arguments to pass to the constructor.
  1005. * @param r_error A pointer the structure which will be updated with error information.
  1006. */
  1007. typedef void (*GDExtensionInterfaceVariantConstruct)(GDExtensionVariantType p_type, GDExtensionUninitializedVariantPtr r_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error);
  1008. /**
  1009. * @name variant_get_ptr_setter
  1010. * @since 4.1
  1011. *
  1012. * Gets a pointer to a function that can call a member's setter on the given Variant type.
  1013. *
  1014. * @param p_type The Variant type.
  1015. * @param p_member A pointer to a StringName with the member name.
  1016. *
  1017. * @return A pointer to a function that can call a member's setter on the given Variant type.
  1018. */
  1019. typedef GDExtensionPtrSetter (*GDExtensionInterfaceVariantGetPtrSetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  1020. /**
  1021. * @name variant_get_ptr_getter
  1022. * @since 4.1
  1023. *
  1024. * Gets a pointer to a function that can call a member's getter on the given Variant type.
  1025. *
  1026. * @param p_type The Variant type.
  1027. * @param p_member A pointer to a StringName with the member name.
  1028. *
  1029. * @return A pointer to a function that can call a member's getter on the given Variant type.
  1030. */
  1031. typedef GDExtensionPtrGetter (*GDExtensionInterfaceVariantGetPtrGetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  1032. /**
  1033. * @name variant_get_ptr_indexed_setter
  1034. * @since 4.1
  1035. *
  1036. * Gets a pointer to a function that can set an index on the given Variant type.
  1037. *
  1038. * @param p_type The Variant type.
  1039. *
  1040. * @return A pointer to a function that can set an index on the given Variant type.
  1041. */
  1042. typedef GDExtensionPtrIndexedSetter (*GDExtensionInterfaceVariantGetPtrIndexedSetter)(GDExtensionVariantType p_type);
  1043. /**
  1044. * @name variant_get_ptr_indexed_getter
  1045. * @since 4.1
  1046. *
  1047. * Gets a pointer to a function that can get an index on the given Variant type.
  1048. *
  1049. * @param p_type The Variant type.
  1050. *
  1051. * @return A pointer to a function that can get an index on the given Variant type.
  1052. */
  1053. typedef GDExtensionPtrIndexedGetter (*GDExtensionInterfaceVariantGetPtrIndexedGetter)(GDExtensionVariantType p_type);
  1054. /**
  1055. * @name variant_get_ptr_keyed_setter
  1056. * @since 4.1
  1057. *
  1058. * Gets a pointer to a function that can set a key on the given Variant type.
  1059. *
  1060. * @param p_type The Variant type.
  1061. *
  1062. * @return A pointer to a function that can set a key on the given Variant type.
  1063. */
  1064. typedef GDExtensionPtrKeyedSetter (*GDExtensionInterfaceVariantGetPtrKeyedSetter)(GDExtensionVariantType p_type);
  1065. /**
  1066. * @name variant_get_ptr_keyed_getter
  1067. * @since 4.1
  1068. *
  1069. * Gets a pointer to a function that can get a key on the given Variant type.
  1070. *
  1071. * @param p_type The Variant type.
  1072. *
  1073. * @return A pointer to a function that can get a key on the given Variant type.
  1074. */
  1075. typedef GDExtensionPtrKeyedGetter (*GDExtensionInterfaceVariantGetPtrKeyedGetter)(GDExtensionVariantType p_type);
  1076. /**
  1077. * @name variant_get_ptr_keyed_checker
  1078. * @since 4.1
  1079. *
  1080. * Gets a pointer to a function that can check a key on the given Variant type.
  1081. *
  1082. * @param p_type The Variant type.
  1083. *
  1084. * @return A pointer to a function that can check a key on the given Variant type.
  1085. */
  1086. typedef GDExtensionPtrKeyedChecker (*GDExtensionInterfaceVariantGetPtrKeyedChecker)(GDExtensionVariantType p_type);
  1087. /**
  1088. * @name variant_get_constant_value
  1089. * @since 4.1
  1090. *
  1091. * Gets the value of a constant from the given Variant type.
  1092. *
  1093. * @param p_type The Variant type.
  1094. * @param p_constant A pointer to a StringName with the constant name.
  1095. * @param r_ret A pointer to a Variant to store the value.
  1096. */
  1097. typedef void (*GDExtensionInterfaceVariantGetConstantValue)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionUninitializedVariantPtr r_ret);
  1098. /**
  1099. * @name variant_get_ptr_utility_function
  1100. * @since 4.1
  1101. *
  1102. * Gets a pointer to a function that can call a Variant utility function.
  1103. *
  1104. * @param p_function A pointer to a StringName with the function name.
  1105. * @param p_hash A hash representing the function signature.
  1106. *
  1107. * @return A pointer to a function that can call a Variant utility function.
  1108. */
  1109. typedef GDExtensionPtrUtilityFunction (*GDExtensionInterfaceVariantGetPtrUtilityFunction)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash);
  1110. /* INTERFACE: String Utilities */
  1111. /**
  1112. * @name string_new_with_latin1_chars
  1113. * @since 4.1
  1114. *
  1115. * Creates a String from a Latin-1 encoded C string.
  1116. *
  1117. * @param r_dest A pointer to a Variant to hold the newly created String.
  1118. * @param p_contents A pointer to a Latin-1 encoded C string (null terminated).
  1119. */
  1120. typedef void (*GDExtensionInterfaceStringNewWithLatin1Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents);
  1121. /**
  1122. * @name string_new_with_utf8_chars
  1123. * @since 4.1
  1124. *
  1125. * Creates a String from a UTF-8 encoded C string.
  1126. *
  1127. * @param r_dest A pointer to a Variant to hold the newly created String.
  1128. * @param p_contents A pointer to a UTF-8 encoded C string (null terminated).
  1129. */
  1130. typedef void (*GDExtensionInterfaceStringNewWithUtf8Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents);
  1131. /**
  1132. * @name string_new_with_utf16_chars
  1133. * @since 4.1
  1134. *
  1135. * Creates a String from a UTF-16 encoded C string.
  1136. *
  1137. * @param r_dest A pointer to a Variant to hold the newly created String.
  1138. * @param p_contents A pointer to a UTF-16 encoded C string (null terminated).
  1139. */
  1140. typedef void (*GDExtensionInterfaceStringNewWithUtf16Chars)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents);
  1141. /**
  1142. * @name string_new_with_utf32_chars
  1143. * @since 4.1
  1144. *
  1145. * Creates a String from a UTF-32 encoded C string.
  1146. *
  1147. * @param r_dest A pointer to a Variant to hold the newly created String.
  1148. * @param p_contents A pointer to a UTF-32 encoded C string (null terminated).
  1149. */
  1150. typedef void (*GDExtensionInterfaceStringNewWithUtf32Chars)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents);
  1151. /**
  1152. * @name string_new_with_wide_chars
  1153. * @since 4.1
  1154. *
  1155. * Creates a String from a wide C string.
  1156. *
  1157. * @param r_dest A pointer to a Variant to hold the newly created String.
  1158. * @param p_contents A pointer to a wide C string (null terminated).
  1159. */
  1160. typedef void (*GDExtensionInterfaceStringNewWithWideChars)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents);
  1161. /**
  1162. * @name string_new_with_latin1_chars_and_len
  1163. * @since 4.1
  1164. *
  1165. * Creates a String from a Latin-1 encoded C string with the given length.
  1166. *
  1167. * @param r_dest A pointer to a Variant to hold the newly created String.
  1168. * @param p_contents A pointer to a Latin-1 encoded C string.
  1169. * @param p_size The number of characters.
  1170. */
  1171. typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1172. /**
  1173. * @name string_new_with_utf8_chars_and_len
  1174. * @since 4.1
  1175. *
  1176. * Creates a String from a UTF-8 encoded C string with the given length.
  1177. *
  1178. * @param r_dest A pointer to a Variant to hold the newly created String.
  1179. * @param p_contents A pointer to a UTF-8 encoded C string.
  1180. * @param p_size The number of characters.
  1181. */
  1182. typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1183. /**
  1184. * @name string_new_with_utf16_chars_and_len
  1185. * @since 4.1
  1186. *
  1187. * Creates a String from a UTF-16 encoded C string with the given length.
  1188. *
  1189. * @param r_dest A pointer to a Variant to hold the newly created String.
  1190. * @param p_contents A pointer to a UTF-16 encoded C string.
  1191. * @param p_size The number of characters.
  1192. */
  1193. typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_size);
  1194. /**
  1195. * @name string_new_with_utf32_chars_and_len
  1196. * @since 4.1
  1197. *
  1198. * Creates a String from a UTF-32 encoded C string with the given length.
  1199. *
  1200. * @param r_dest A pointer to a Variant to hold the newly created String.
  1201. * @param p_contents A pointer to a UTF-32 encoded C string.
  1202. * @param p_size The number of characters.
  1203. */
  1204. typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_size);
  1205. /**
  1206. * @name string_new_with_wide_chars_and_len
  1207. * @since 4.1
  1208. *
  1209. * Creates a String from a wide C string with the given length.
  1210. *
  1211. * @param r_dest A pointer to a Variant to hold the newly created String.
  1212. * @param p_contents A pointer to a wide C string.
  1213. * @param p_size The number of characters.
  1214. */
  1215. typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_size);
  1216. /**
  1217. * @name string_to_latin1_chars
  1218. * @since 4.1
  1219. *
  1220. * Converts a String to a Latin-1 encoded C string.
  1221. *
  1222. * It doesn't write a null terminator.
  1223. *
  1224. * @param p_self A pointer to the String.
  1225. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1226. * @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.
  1227. *
  1228. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1229. */
  1230. typedef GDExtensionInt (*GDExtensionInterfaceStringToLatin1Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  1231. /**
  1232. * @name string_to_utf8_chars
  1233. * @since 4.1
  1234. *
  1235. * Converts a String to a UTF-8 encoded C string.
  1236. *
  1237. * It doesn't write a null terminator.
  1238. *
  1239. * @param p_self A pointer to the String.
  1240. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1241. * @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.
  1242. *
  1243. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1244. */
  1245. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf8Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  1246. /**
  1247. * @name string_to_utf16_chars
  1248. * @since 4.1
  1249. *
  1250. * Converts a String to a UTF-16 encoded C string.
  1251. *
  1252. * It doesn't write a null terminator.
  1253. *
  1254. * @param p_self A pointer to the String.
  1255. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1256. * @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.
  1257. *
  1258. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1259. */
  1260. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf16Chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length);
  1261. /**
  1262. * @name string_to_utf32_chars
  1263. * @since 4.1
  1264. *
  1265. * Converts a String to a UTF-32 encoded C string.
  1266. *
  1267. * It doesn't write a null terminator.
  1268. *
  1269. * @param p_self A pointer to the String.
  1270. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1271. * @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.
  1272. *
  1273. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1274. */
  1275. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf32Chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length);
  1276. /**
  1277. * @name string_to_wide_chars
  1278. * @since 4.1
  1279. *
  1280. * Converts a String to a wide C string.
  1281. *
  1282. * It doesn't write a null terminator.
  1283. *
  1284. * @param p_self A pointer to the String.
  1285. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1286. * @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.
  1287. *
  1288. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1289. */
  1290. typedef GDExtensionInt (*GDExtensionInterfaceStringToWideChars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length);
  1291. /**
  1292. * @name string_operator_index
  1293. * @since 4.1
  1294. *
  1295. * Gets a pointer to the character at the given index from a String.
  1296. *
  1297. * @param p_self A pointer to the String.
  1298. * @param p_index The index.
  1299. *
  1300. * @return A pointer to the requested character.
  1301. */
  1302. typedef char32_t *(*GDExtensionInterfaceStringOperatorIndex)(GDExtensionStringPtr p_self, GDExtensionInt p_index);
  1303. /**
  1304. * @name string_operator_index_const
  1305. * @since 4.1
  1306. *
  1307. * Gets a const pointer to the character at the given index from a String.
  1308. *
  1309. * @param p_self A pointer to the String.
  1310. * @param p_index The index.
  1311. *
  1312. * @return A const pointer to the requested character.
  1313. */
  1314. typedef const char32_t *(*GDExtensionInterfaceStringOperatorIndexConst)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index);
  1315. /**
  1316. * @name string_operator_plus_eq_string
  1317. * @since 4.1
  1318. *
  1319. * Appends another String to a String.
  1320. *
  1321. * @param p_self A pointer to the String.
  1322. * @param p_b A pointer to the other String to append.
  1323. */
  1324. typedef void (*GDExtensionInterfaceStringOperatorPlusEqString)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b);
  1325. /**
  1326. * @name string_operator_plus_eq_char
  1327. * @since 4.1
  1328. *
  1329. * Appends a character to a String.
  1330. *
  1331. * @param p_self A pointer to the String.
  1332. * @param p_b A pointer to the character to append.
  1333. */
  1334. typedef void (*GDExtensionInterfaceStringOperatorPlusEqChar)(GDExtensionStringPtr p_self, char32_t p_b);
  1335. /**
  1336. * @name string_operator_plus_eq_cstr
  1337. * @since 4.1
  1338. *
  1339. * Appends a Latin-1 encoded C string to a String.
  1340. *
  1341. * @param p_self A pointer to the String.
  1342. * @param p_b A pointer to a Latin-1 encoded C string (null terminated).
  1343. */
  1344. typedef void (*GDExtensionInterfaceStringOperatorPlusEqCstr)(GDExtensionStringPtr p_self, const char *p_b);
  1345. /**
  1346. * @name string_operator_plus_eq_wcstr
  1347. * @since 4.1
  1348. *
  1349. * Appends a wide C string to a String.
  1350. *
  1351. * @param p_self A pointer to the String.
  1352. * @param p_b A pointer to a wide C string (null terminated).
  1353. */
  1354. typedef void (*GDExtensionInterfaceStringOperatorPlusEqWcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b);
  1355. /**
  1356. * @name string_operator_plus_eq_c32str
  1357. * @since 4.1
  1358. *
  1359. * Appends a UTF-32 encoded C string to a String.
  1360. *
  1361. * @param p_self A pointer to the String.
  1362. * @param p_b A pointer to a UTF-32 encoded C string (null terminated).
  1363. */
  1364. typedef void (*GDExtensionInterfaceStringOperatorPlusEqC32str)(GDExtensionStringPtr p_self, const char32_t *p_b);
  1365. /* INTERFACE: XMLParser Utilities */
  1366. /**
  1367. * @name xml_parser_open_buffer
  1368. * @since 4.1
  1369. *
  1370. * Opens a raw XML buffer on an XMLParser instance.
  1371. *
  1372. * @param p_instance A pointer to an XMLParser object.
  1373. * @param p_buffer A pointer to the buffer.
  1374. * @param p_size The size of the buffer.
  1375. *
  1376. * @return A Godot error code (ex. OK, ERR_INVALID_DATA, etc).
  1377. *
  1378. * @see XMLParser::open_buffer()
  1379. */
  1380. typedef GDExtensionInt (*GDExtensionInterfaceXmlParserOpenBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size);
  1381. /* INTERFACE: FileAccess Utilities */
  1382. /**
  1383. * @name file_access_store_buffer
  1384. * @since 4.1
  1385. *
  1386. * Stores the given buffer using an instance of FileAccess.
  1387. *
  1388. * @param p_instance A pointer to a FileAccess object.
  1389. * @param p_src A pointer to the buffer.
  1390. * @param p_length The size of the buffer.
  1391. *
  1392. * @see FileAccess::store_buffer()
  1393. */
  1394. typedef void (*GDExtensionInterfaceFileAccessStoreBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length);
  1395. /**
  1396. * @name file_access_get_buffer
  1397. * @since 4.1
  1398. *
  1399. * Reads the next p_length bytes into the given buffer using an instance of FileAccess.
  1400. *
  1401. * @param p_instance A pointer to a FileAccess object.
  1402. * @param p_dst A pointer to the buffer to store the data.
  1403. * @param p_length The requested number of bytes to read.
  1404. *
  1405. * @return The actual number of bytes read (may be less than requested).
  1406. */
  1407. typedef uint64_t (*GDExtensionInterfaceFileAccessGetBuffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);
  1408. /* INTERFACE: WorkerThreadPool Utilities */
  1409. /**
  1410. * @name worker_thread_pool_add_native_group_task
  1411. * @since 4.1
  1412. *
  1413. * Adds a group task to an instance of WorkerThreadPool.
  1414. *
  1415. * @param p_instance A pointer to a WorkerThreadPool object.
  1416. * @param p_func A pointer to a function to run in the thread pool.
  1417. * @param p_userdata A pointer to arbitrary data which will be passed to p_func.
  1418. * @param p_tasks The number of tasks needed in the group.
  1419. * @param p_high_priority Whether or not this is a high priority task.
  1420. * @param p_description A pointer to a String with the task description.
  1421. *
  1422. * @return The task group ID.
  1423. *
  1424. * @see WorkerThreadPool::add_group_task()
  1425. */
  1426. 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);
  1427. /**
  1428. * @name worker_thread_pool_add_native_task
  1429. * @since 4.1
  1430. *
  1431. * Adds a task to an instance of WorkerThreadPool.
  1432. *
  1433. * @param p_instance A pointer to a WorkerThreadPool object.
  1434. * @param p_func A pointer to a function to run in the thread pool.
  1435. * @param p_userdata A pointer to arbitrary data which will be passed to p_func.
  1436. * @param p_high_priority Whether or not this is a high priority task.
  1437. * @param p_description A pointer to a String with the task description.
  1438. *
  1439. * @return The task ID.
  1440. */
  1441. typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
  1442. /* INTERFACE: Packed Array */
  1443. /**
  1444. * @name packed_byte_array_operator_index
  1445. * @since 4.1
  1446. *
  1447. * Gets a pointer to a byte in a PackedByteArray.
  1448. *
  1449. * @param p_self A pointer to a PackedByteArray object.
  1450. * @param p_index The index of the byte to get.
  1451. *
  1452. * @return A pointer to the requested byte.
  1453. */
  1454. typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1455. /**
  1456. * @name packed_byte_array_operator_index_const
  1457. * @since 4.1
  1458. *
  1459. * Gets a const pointer to a byte in a PackedByteArray.
  1460. *
  1461. * @param p_self A const pointer to a PackedByteArray object.
  1462. * @param p_index The index of the byte to get.
  1463. *
  1464. * @return A const pointer to the requested byte.
  1465. */
  1466. typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1467. /**
  1468. * @name packed_color_array_operator_index
  1469. * @since 4.1
  1470. *
  1471. * Gets a pointer to a color in a PackedColorArray.
  1472. *
  1473. * @param p_self A pointer to a PackedColorArray object.
  1474. * @param p_index The index of the Color to get.
  1475. *
  1476. * @return A pointer to the requested Color.
  1477. */
  1478. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1479. /**
  1480. * @name packed_color_array_operator_index_const
  1481. * @since 4.1
  1482. *
  1483. * Gets a const pointer to a color in a PackedColorArray.
  1484. *
  1485. * @param p_self A const pointer to a const PackedColorArray object.
  1486. * @param p_index The index of the Color to get.
  1487. *
  1488. * @return A const pointer to the requested Color.
  1489. */
  1490. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1491. /**
  1492. * @name packed_float32_array_operator_index
  1493. * @since 4.1
  1494. *
  1495. * Gets a pointer to a 32-bit float in a PackedFloat32Array.
  1496. *
  1497. * @param p_self A pointer to a PackedFloat32Array object.
  1498. * @param p_index The index of the float to get.
  1499. *
  1500. * @return A pointer to the requested 32-bit float.
  1501. */
  1502. typedef float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1503. /**
  1504. * @name packed_float32_array_operator_index_const
  1505. * @since 4.1
  1506. *
  1507. * Gets a const pointer to a 32-bit float in a PackedFloat32Array.
  1508. *
  1509. * @param p_self A const pointer to a PackedFloat32Array object.
  1510. * @param p_index The index of the float to get.
  1511. *
  1512. * @return A const pointer to the requested 32-bit float.
  1513. */
  1514. typedef const float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1515. /**
  1516. * @name packed_float64_array_operator_index
  1517. * @since 4.1
  1518. *
  1519. * Gets a pointer to a 64-bit float in a PackedFloat64Array.
  1520. *
  1521. * @param p_self A pointer to a PackedFloat64Array object.
  1522. * @param p_index The index of the float to get.
  1523. *
  1524. * @return A pointer to the requested 64-bit float.
  1525. */
  1526. typedef double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1527. /**
  1528. * @name packed_float64_array_operator_index_const
  1529. * @since 4.1
  1530. *
  1531. * Gets a const pointer to a 64-bit float in a PackedFloat64Array.
  1532. *
  1533. * @param p_self A const pointer to a PackedFloat64Array object.
  1534. * @param p_index The index of the float to get.
  1535. *
  1536. * @return A const pointer to the requested 64-bit float.
  1537. */
  1538. typedef const double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1539. /**
  1540. * @name packed_int32_array_operator_index
  1541. * @since 4.1
  1542. *
  1543. * Gets a pointer to a 32-bit integer in a PackedInt32Array.
  1544. *
  1545. * @param p_self A pointer to a PackedInt32Array object.
  1546. * @param p_index The index of the integer to get.
  1547. *
  1548. * @return A pointer to the requested 32-bit integer.
  1549. */
  1550. typedef int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1551. /**
  1552. * @name packed_int32_array_operator_index_const
  1553. * @since 4.1
  1554. *
  1555. * Gets a const pointer to a 32-bit integer in a PackedInt32Array.
  1556. *
  1557. * @param p_self A const pointer to a PackedInt32Array object.
  1558. * @param p_index The index of the integer to get.
  1559. *
  1560. * @return A const pointer to the requested 32-bit integer.
  1561. */
  1562. typedef const int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1563. /**
  1564. * @name packed_int64_array_operator_index
  1565. * @since 4.1
  1566. *
  1567. * Gets a pointer to a 64-bit integer in a PackedInt64Array.
  1568. *
  1569. * @param p_self A pointer to a PackedInt64Array object.
  1570. * @param p_index The index of the integer to get.
  1571. *
  1572. * @return A pointer to the requested 64-bit integer.
  1573. */
  1574. typedef int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1575. /**
  1576. * @name packed_int64_array_operator_index_const
  1577. * @since 4.1
  1578. *
  1579. * Gets a const pointer to a 64-bit integer in a PackedInt64Array.
  1580. *
  1581. * @param p_self A const pointer to a PackedInt64Array object.
  1582. * @param p_index The index of the integer to get.
  1583. *
  1584. * @return A const pointer to the requested 64-bit integer.
  1585. */
  1586. typedef const int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1587. /**
  1588. * @name packed_string_array_operator_index
  1589. * @since 4.1
  1590. *
  1591. * Gets a pointer to a string in a PackedStringArray.
  1592. *
  1593. * @param p_self A pointer to a PackedStringArray object.
  1594. * @param p_index The index of the String to get.
  1595. *
  1596. * @return A pointer to the requested String.
  1597. */
  1598. typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1599. /**
  1600. * @name packed_string_array_operator_index_const
  1601. * @since 4.1
  1602. *
  1603. * Gets a const pointer to a string in a PackedStringArray.
  1604. *
  1605. * @param p_self A const pointer to a PackedStringArray object.
  1606. * @param p_index The index of the String to get.
  1607. *
  1608. * @return A const pointer to the requested String.
  1609. */
  1610. typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1611. /**
  1612. * @name packed_vector2_array_operator_index
  1613. * @since 4.1
  1614. *
  1615. * Gets a pointer to a Vector2 in a PackedVector2Array.
  1616. *
  1617. * @param p_self A pointer to a PackedVector2Array object.
  1618. * @param p_index The index of the Vector2 to get.
  1619. *
  1620. * @return A pointer to the requested Vector2.
  1621. */
  1622. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1623. /**
  1624. * @name packed_vector2_array_operator_index_const
  1625. * @since 4.1
  1626. *
  1627. * Gets a const pointer to a Vector2 in a PackedVector2Array.
  1628. *
  1629. * @param p_self A const pointer to a PackedVector2Array object.
  1630. * @param p_index The index of the Vector2 to get.
  1631. *
  1632. * @return A const pointer to the requested Vector2.
  1633. */
  1634. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1635. /**
  1636. * @name packed_vector3_array_operator_index
  1637. * @since 4.1
  1638. *
  1639. * Gets a pointer to a Vector3 in a PackedVector3Array.
  1640. *
  1641. * @param p_self A pointer to a PackedVector3Array object.
  1642. * @param p_index The index of the Vector3 to get.
  1643. *
  1644. * @return A pointer to the requested Vector3.
  1645. */
  1646. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1647. /**
  1648. * @name packed_vector3_array_operator_index_const
  1649. * @since 4.1
  1650. *
  1651. * Gets a const pointer to a Vector3 in a PackedVector3Array.
  1652. *
  1653. * @param p_self A const pointer to a PackedVector3Array object.
  1654. * @param p_index The index of the Vector3 to get.
  1655. *
  1656. * @return A const pointer to the requested Vector3.
  1657. */
  1658. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1659. /**
  1660. * @name array_operator_index
  1661. * @since 4.1
  1662. *
  1663. * Gets a pointer to a Variant in an Array.
  1664. *
  1665. * @param p_self A pointer to an Array object.
  1666. * @param p_index The index of the Variant to get.
  1667. *
  1668. * @return A pointer to the requested Variant.
  1669. */
  1670. typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1671. /**
  1672. * @name array_operator_index_const
  1673. * @since 4.1
  1674. *
  1675. * Gets a const pointer to a Variant in an Array.
  1676. *
  1677. * @param p_self A const pointer to an Array object.
  1678. * @param p_index The index of the Variant to get.
  1679. *
  1680. * @return A const pointer to the requested Variant.
  1681. */
  1682. typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1683. /**
  1684. * @name array_ref
  1685. * @since 4.1
  1686. *
  1687. * Sets an Array to be a reference to another Array object.
  1688. *
  1689. * @param p_self A pointer to the Array object to update.
  1690. * @param p_from A pointer to the Array object to reference.
  1691. */
  1692. typedef void (*GDExtensionInterfaceArrayRef)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from);
  1693. /**
  1694. * @name array_set_typed
  1695. * @since 4.1
  1696. *
  1697. * Makes an Array into a typed Array.
  1698. *
  1699. * @param p_self A pointer to the Array.
  1700. * @param p_type The type of Variant the Array will store.
  1701. * @param p_class_name A pointer to a StringName with the name of the object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT).
  1702. * @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).
  1703. */
  1704. typedef void (*GDExtensionInterfaceArraySetTyped)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script);
  1705. /* INTERFACE: Dictionary */
  1706. /**
  1707. * @name dictionary_operator_index
  1708. * @since 4.1
  1709. *
  1710. * Gets a pointer to a Variant in a Dictionary with the given key.
  1711. *
  1712. * @param p_self A pointer to a Dictionary object.
  1713. * @param p_key A pointer to a Variant representing the key.
  1714. *
  1715. * @return A pointer to a Variant representing the value at the given key.
  1716. */
  1717. typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key);
  1718. /**
  1719. * @name dictionary_operator_index_const
  1720. * @since 4.1
  1721. *
  1722. * Gets a const pointer to a Variant in a Dictionary with the given key.
  1723. *
  1724. * @param p_self A const pointer to a Dictionary object.
  1725. * @param p_key A pointer to a Variant representing the key.
  1726. *
  1727. * @return A const pointer to a Variant representing the value at the given key.
  1728. */
  1729. typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key);
  1730. /* INTERFACE: Object */
  1731. /**
  1732. * @name object_method_bind_call
  1733. * @since 4.1
  1734. *
  1735. * Calls a method on an Object.
  1736. *
  1737. * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
  1738. * @param p_instance A pointer to the Object.
  1739. * @param p_args A pointer to a C array of Variants representing the arguments.
  1740. * @param p_arg_count The number of arguments.
  1741. * @param r_ret A pointer to Variant which will receive the return value.
  1742. * @param r_error A pointer to a GDExtensionCallError struct that will receive error information.
  1743. */
  1744. typedef void (*GDExtensionInterfaceObjectMethodBindCall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionUninitializedVariantPtr r_ret, GDExtensionCallError *r_error);
  1745. /**
  1746. * @name object_method_bind_ptrcall
  1747. * @since 4.1
  1748. *
  1749. * Calls a method on an Object (using a "ptrcall").
  1750. *
  1751. * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
  1752. * @param p_instance A pointer to the Object.
  1753. * @param p_args A pointer to a C array representing the arguments.
  1754. * @param r_ret A pointer to the Object that will receive the return value.
  1755. */
  1756. typedef void (*GDExtensionInterfaceObjectMethodBindPtrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  1757. /**
  1758. * @name object_destroy
  1759. * @since 4.1
  1760. *
  1761. * Destroys an Object.
  1762. *
  1763. * @param p_o A pointer to the Object.
  1764. */
  1765. typedef void (*GDExtensionInterfaceObjectDestroy)(GDExtensionObjectPtr p_o);
  1766. /**
  1767. * @name global_get_singleton
  1768. * @since 4.1
  1769. *
  1770. * Gets a global singleton by name.
  1771. *
  1772. * @param p_name A pointer to a StringName with the singleton name.
  1773. *
  1774. * @return A pointer to the singleton Object.
  1775. */
  1776. typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensionConstStringNamePtr p_name);
  1777. /**
  1778. * @name object_get_instance_binding
  1779. * @since 4.1
  1780. *
  1781. * Gets a pointer representing an Object's instance binding.
  1782. *
  1783. * @param p_o A pointer to the Object.
  1784. * @param p_library A token the library received by the GDExtension's entry point function.
  1785. * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
  1786. *
  1787. * @return
  1788. */
  1789. typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  1790. /**
  1791. * @name object_set_instance_binding
  1792. * @since 4.1
  1793. *
  1794. * Sets an Object's instance binding.
  1795. *
  1796. * @param p_o A pointer to the Object.
  1797. * @param p_library A token the library received by the GDExtension's entry point function.
  1798. * @param p_binding A pointer to the instance binding.
  1799. * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
  1800. */
  1801. typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  1802. /**
  1803. * @name object_set_instance
  1804. * @since 4.1
  1805. *
  1806. * Sets an extension class instance on a Object.
  1807. *
  1808. * @param p_o A pointer to the Object.
  1809. * @param p_classname A pointer to a StringName with the registered extension class's name.
  1810. * @param p_instance A pointer to the extension class instance.
  1811. */
  1812. 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. */
  1813. /**
  1814. * @name object_get_class_name
  1815. * @since 4.1
  1816. *
  1817. * Gets the class name of an Object.
  1818. *
  1819. * @param p_object A pointer to the Object.
  1820. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1821. * @param r_class_name A pointer to a String to receive the class name.
  1822. *
  1823. * @return true if successful in getting the class name; otherwise false.
  1824. */
  1825. typedef GDExtensionBool (*GDExtensionInterfaceObjectGetClassName)(GDExtensionConstObjectPtr p_object, GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringNamePtr r_class_name);
  1826. /**
  1827. * @name object_cast_to
  1828. * @since 4.1
  1829. *
  1830. * Casts an Object to a different type.
  1831. *
  1832. * @param p_object A pointer to the Object.
  1833. * @param p_class_tag A pointer uniquely identifying a built-in class in the ClassDB.
  1834. *
  1835. * @return Returns a pointer to the Object, or NULL if it can't be cast to the requested type.
  1836. */
  1837. typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectCastTo)(GDExtensionConstObjectPtr p_object, void *p_class_tag);
  1838. /**
  1839. * @name object_get_instance_from_id
  1840. * @since 4.1
  1841. *
  1842. * Gets an Object by its instance ID.
  1843. *
  1844. * @param p_instance_id The instance ID.
  1845. *
  1846. * @return A pointer to the Object.
  1847. */
  1848. typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectGetInstanceFromId)(GDObjectInstanceID p_instance_id);
  1849. /**
  1850. * @name object_get_instance_id
  1851. * @since 4.1
  1852. *
  1853. * Gets the instance ID from an Object.
  1854. *
  1855. * @param p_object A pointer to the Object.
  1856. *
  1857. * @return The instance ID.
  1858. */
  1859. typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensionConstObjectPtr p_object);
  1860. /* INTERFACE: Reference */
  1861. /**
  1862. * @name ref_get_object
  1863. * @since 4.1
  1864. *
  1865. * Gets the Object from a reference.
  1866. *
  1867. * @param p_ref A pointer to the reference.
  1868. *
  1869. * @return A pointer to the Object from the reference or NULL.
  1870. */
  1871. typedef GDExtensionObjectPtr (*GDExtensionInterfaceRefGetObject)(GDExtensionConstRefPtr p_ref);
  1872. /**
  1873. * @name ref_set_object
  1874. * @since 4.1
  1875. *
  1876. * Sets the Object referred to by a reference.
  1877. *
  1878. * @param p_ref A pointer to the reference.
  1879. * @param p_object A pointer to the Object to refer to.
  1880. */
  1881. typedef void (*GDExtensionInterfaceRefSetObject)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object);
  1882. /* INTERFACE: Script Instance */
  1883. /**
  1884. * @name script_instance_create
  1885. * @since 4.1
  1886. *
  1887. * Creates a script instance that contains the given info and instance data.
  1888. *
  1889. * @param p_info A pointer to a GDExtensionScriptInstanceInfo struct.
  1890. * @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.
  1891. *
  1892. * @return A pointer to a ScriptInstanceExtension object.
  1893. */
  1894. typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
  1895. /* INTERFACE: ClassDB */
  1896. /**
  1897. * @name classdb_construct_object
  1898. * @since 4.1
  1899. *
  1900. * Constructs an Object of the requested class.
  1901. *
  1902. * 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.
  1903. *
  1904. * @param p_classname A pointer to a StringName with the class name.
  1905. *
  1906. * @return A pointer to the newly created Object.
  1907. */
  1908. typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject)(GDExtensionConstStringNamePtr p_classname);
  1909. /**
  1910. * @name classdb_get_method_bind
  1911. * @since 4.1
  1912. *
  1913. * Gets a pointer to the MethodBind in ClassDB for the given class, method and hash.
  1914. *
  1915. * @param p_classname A pointer to a StringName with the class name.
  1916. * @param p_methodname A pointer to a StringName with the method name.
  1917. * @param p_hash A hash representing the function signature.
  1918. *
  1919. * @return A pointer to the MethodBind from ClassDB.
  1920. */
  1921. typedef GDExtensionMethodBindPtr (*GDExtensionInterfaceClassdbGetMethodBind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash);
  1922. /**
  1923. * @name classdb_get_class_tag
  1924. * @since 4.1
  1925. *
  1926. * Gets a pointer uniquely identifying the given built-in class in the ClassDB.
  1927. *
  1928. * @param p_classname A pointer to a StringName with the class name.
  1929. *
  1930. * @return A pointer uniquely identifying the built-in class in the ClassDB.
  1931. */
  1932. typedef void *(*GDExtensionInterfaceClassdbGetClassTag)(GDExtensionConstStringNamePtr p_classname);
  1933. /* INTERFACE: ClassDB Extension */
  1934. /**
  1935. * @name classdb_register_extension_class
  1936. * @since 4.1
  1937. *
  1938. * Registers an extension class in the ClassDB.
  1939. *
  1940. * Provided struct can be safely freed once the function returns.
  1941. *
  1942. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1943. * @param p_class_name A pointer to a StringName with the class name.
  1944. * @param p_parent_class_name A pointer to a StringName with the parent class name.
  1945. * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo struct.
  1946. */
  1947. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs);
  1948. /**
  1949. * @name classdb_register_extension_class_method
  1950. * @since 4.1
  1951. *
  1952. * Registers a method on an extension class in the ClassDB.
  1953. *
  1954. * Provided struct can be safely freed once the function returns.
  1955. *
  1956. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1957. * @param p_class_name A pointer to a StringName with the class name.
  1958. * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct.
  1959. */
  1960. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info);
  1961. /**
  1962. * @name classdb_register_extension_class_integer_constant
  1963. * @since 4.1
  1964. *
  1965. * Registers an integer constant on an extension class in the ClassDB.
  1966. *
  1967. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1968. * @param p_class_name A pointer to a StringName with the class name.
  1969. * @param p_enum_name A pointer to a StringName with the enum name.
  1970. * @param p_constant_name A pointer to a StringName with the constant name.
  1971. * @param p_constant_value The constant value.
  1972. * @param p_is_bitfield Whether or not this is a bit field.
  1973. */
  1974. 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);
  1975. /**
  1976. * @name classdb_register_extension_class_property
  1977. * @since 4.1
  1978. *
  1979. * Registers a property on an extension class in the ClassDB.
  1980. *
  1981. * Provided struct can be safely freed once the function returns.
  1982. *
  1983. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1984. * @param p_class_name A pointer to a StringName with the class name.
  1985. * @param p_info A pointer to a GDExtensionPropertyInfo struct.
  1986. * @param p_setter A pointer to a StringName with the name of the setter method.
  1987. * @param p_getter A pointer to a StringName with the name of the getter method.
  1988. */
  1989. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassProperty)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter);
  1990. /**
  1991. * @name classdb_register_extension_class_property_group
  1992. * @since 4.1
  1993. *
  1994. * Registers a property group on an extension class in the ClassDB.
  1995. *
  1996. * @param p_library A pointer the library received by the GDExtension's entry point function.
  1997. * @param p_class_name A pointer to a StringName with the class name.
  1998. * @param p_group_name A pointer to a String with the group name.
  1999. * @param p_prefix A pointer to a String with the prefix used by properties in this group.
  2000. */
  2001. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix);
  2002. /**
  2003. * @name classdb_register_extension_class_property_subgroup
  2004. * @since 4.1
  2005. *
  2006. * Registers a property subgroup on an extension class in the ClassDB.
  2007. *
  2008. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2009. * @param p_class_name A pointer to a StringName with the class name.
  2010. * @param p_subgroup_name A pointer to a String with the subgroup name.
  2011. * @param p_prefix A pointer to a String with the prefix used by properties in this subgroup.
  2012. */
  2013. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix);
  2014. /**
  2015. * @name classdb_register_extension_class_signal
  2016. * @since 4.1
  2017. *
  2018. * Registers a signal on an extension class in the ClassDB.
  2019. *
  2020. * Provided structs can be safely freed once the function returns.
  2021. *
  2022. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2023. * @param p_class_name A pointer to a StringName with the class name.
  2024. * @param p_signal_name A pointer to a StringName with the signal name.
  2025. * @param p_argument_info A pointer to a GDExtensionPropertyInfo struct.
  2026. * @param p_argument_count The number of arguments the signal receives.
  2027. */
  2028. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count);
  2029. /**
  2030. * @name classdb_unregister_extension_class
  2031. * @since 4.1
  2032. *
  2033. * Unregisters an extension class in the ClassDB.
  2034. *
  2035. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2036. * @param p_class_name A pointer to a StringName with the class name.
  2037. */
  2038. 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. */
  2039. /**
  2040. * @name get_library_path
  2041. * @since 4.1
  2042. *
  2043. * Gets the path to the current GDExtension library.
  2044. *
  2045. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2046. * @param r_path A pointer to a String which will receive the path.
  2047. */
  2048. typedef void (*GDExtensionInterfaceGetLibraryPath)(GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringPtr r_path);
  2049. /**
  2050. * @name editor_add_plugin
  2051. * @since 4.1
  2052. *
  2053. * Adds an editor plugin.
  2054. *
  2055. * It's safe to call during initialization.
  2056. *
  2057. * @param p_class_name A pointer to a StringName with the name of a class (descending from EditorPlugin) which is already registered with ClassDB.
  2058. */
  2059. typedef void (*GDExtensionInterfaceEditorAddPlugin)(GDExtensionConstStringNamePtr p_class_name);
  2060. /**
  2061. * @name editor_remove_plugin
  2062. * @since 4.1
  2063. *
  2064. * Removes an editor plugin.
  2065. *
  2066. * @param p_class_name A pointer to a StringName with the name of a class that was previously added as an editor plugin.
  2067. */
  2068. typedef void (*GDExtensionInterfaceEditorRemovePlugin)(GDExtensionConstStringNamePtr p_class_name);
  2069. #ifdef __cplusplus
  2070. }
  2071. #endif
  2072. #endif // GDEXTENSION_INTERFACE_H