gdextension_interface.h 107 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683
  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 GDExtensionBool (*GDExtensionClassValidateProperty)(GDExtensionClassInstancePtr p_instance, GDExtensionPropertyInfo *p_property);
  227. typedef void (*GDExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionClassNotification2 instead.
  228. typedef void (*GDExtensionClassNotification2)(GDExtensionClassInstancePtr p_instance, int32_t p_what, GDExtensionBool p_reversed);
  229. typedef void (*GDExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr p_out);
  230. typedef void (*GDExtensionClassReference)(GDExtensionClassInstancePtr p_instance);
  231. typedef void (*GDExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance);
  232. typedef void (*GDExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  233. typedef GDExtensionObjectPtr (*GDExtensionClassCreateInstance)(void *p_class_userdata);
  234. typedef void (*GDExtensionClassFreeInstance)(void *p_class_userdata, GDExtensionClassInstancePtr p_instance);
  235. typedef GDExtensionClassInstancePtr (*GDExtensionClassRecreateInstance)(void *p_class_userdata, GDExtensionObjectPtr p_object);
  236. typedef GDExtensionClassCallVirtual (*GDExtensionClassGetVirtual)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name);
  237. typedef void *(*GDExtensionClassGetVirtualCallData)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name);
  238. typedef void (*GDExtensionClassCallVirtualWithData)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, void *p_virtual_call_userdata, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  239. typedef struct {
  240. GDExtensionBool is_virtual;
  241. GDExtensionBool is_abstract;
  242. GDExtensionClassSet set_func;
  243. GDExtensionClassGet get_func;
  244. GDExtensionClassGetPropertyList get_property_list_func;
  245. GDExtensionClassFreePropertyList free_property_list_func;
  246. GDExtensionClassPropertyCanRevert property_can_revert_func;
  247. GDExtensionClassPropertyGetRevert property_get_revert_func;
  248. GDExtensionClassNotification notification_func;
  249. GDExtensionClassToString to_string_func;
  250. GDExtensionClassReference reference_func;
  251. GDExtensionClassUnreference unreference_func;
  252. GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
  253. GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
  254. GDExtensionClassGetVirtual get_virtual_func; // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
  255. GDExtensionClassGetRID get_rid_func;
  256. void *class_userdata; // Per-class user data, later accessible in instance bindings.
  257. } GDExtensionClassCreationInfo; // Deprecated. Use GDExtensionClassCreationInfo2 instead.
  258. typedef struct {
  259. GDExtensionBool is_virtual;
  260. GDExtensionBool is_abstract;
  261. GDExtensionBool is_exposed;
  262. GDExtensionClassSet set_func;
  263. GDExtensionClassGet get_func;
  264. GDExtensionClassGetPropertyList get_property_list_func;
  265. GDExtensionClassFreePropertyList free_property_list_func;
  266. GDExtensionClassPropertyCanRevert property_can_revert_func;
  267. GDExtensionClassPropertyGetRevert property_get_revert_func;
  268. GDExtensionClassValidateProperty validate_property_func;
  269. GDExtensionClassNotification2 notification_func;
  270. GDExtensionClassToString to_string_func;
  271. GDExtensionClassReference reference_func;
  272. GDExtensionClassUnreference unreference_func;
  273. GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
  274. GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
  275. GDExtensionClassRecreateInstance recreate_instance_func;
  276. // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
  277. GDExtensionClassGetVirtual get_virtual_func;
  278. // Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that
  279. // need or benefit from extra data when calling virtual functions.
  280. // Returns user data that will be passed to `call_virtual_with_data_func`.
  281. // Returning `NULL` from this function signals to Godot that the virtual function is not overridden.
  282. // Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized.
  283. // You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`.
  284. GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
  285. // Used to call virtual functions when `get_virtual_call_data_func` is not null.
  286. GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
  287. GDExtensionClassGetRID get_rid_func;
  288. void *class_userdata; // Per-class user data, later accessible in instance bindings.
  289. } GDExtensionClassCreationInfo2;
  290. typedef void *GDExtensionClassLibraryPtr;
  291. /* Method */
  292. typedef enum {
  293. GDEXTENSION_METHOD_FLAG_NORMAL = 1,
  294. GDEXTENSION_METHOD_FLAG_EDITOR = 2,
  295. GDEXTENSION_METHOD_FLAG_CONST = 4,
  296. GDEXTENSION_METHOD_FLAG_VIRTUAL = 8,
  297. GDEXTENSION_METHOD_FLAG_VARARG = 16,
  298. GDEXTENSION_METHOD_FLAG_STATIC = 32,
  299. GDEXTENSION_METHOD_FLAGS_DEFAULT = GDEXTENSION_METHOD_FLAG_NORMAL,
  300. } GDExtensionClassMethodFlags;
  301. typedef enum {
  302. GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE,
  303. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8,
  304. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16,
  305. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32,
  306. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64,
  307. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8,
  308. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16,
  309. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32,
  310. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64,
  311. GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT,
  312. GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE
  313. } GDExtensionClassMethodArgumentMetadata;
  314. typedef void (*GDExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  315. typedef void (*GDExtensionClassMethodValidatedCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionVariantPtr r_return);
  316. typedef void (*GDExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  317. typedef struct {
  318. GDExtensionStringNamePtr name;
  319. void *method_userdata;
  320. GDExtensionClassMethodCall call_func;
  321. GDExtensionClassMethodPtrCall ptrcall_func;
  322. uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
  323. /* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored.
  324. *
  325. * @todo Consider dropping `has_return_value` and making the other two properties match `GDExtensionMethodInfo` and `GDExtensionClassVirtualMethod` for consistency in future version of this struct.
  326. */
  327. GDExtensionBool has_return_value;
  328. GDExtensionPropertyInfo *return_value_info;
  329. GDExtensionClassMethodArgumentMetadata return_value_metadata;
  330. /* Arguments: `arguments_info` and `arguments_metadata` are array of size `argument_count`.
  331. * Name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies.
  332. *
  333. * @todo Consider renaming `arguments_info` to `arguments` for consistency in future version of this struct.
  334. */
  335. uint32_t argument_count;
  336. GDExtensionPropertyInfo *arguments_info;
  337. GDExtensionClassMethodArgumentMetadata *arguments_metadata;
  338. /* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
  339. uint32_t default_argument_count;
  340. GDExtensionVariantPtr *default_arguments;
  341. } GDExtensionClassMethodInfo;
  342. typedef struct {
  343. GDExtensionStringNamePtr name;
  344. uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
  345. GDExtensionPropertyInfo return_value;
  346. GDExtensionClassMethodArgumentMetadata return_value_metadata;
  347. uint32_t argument_count;
  348. GDExtensionPropertyInfo *arguments;
  349. GDExtensionClassMethodArgumentMetadata *arguments_metadata;
  350. } GDExtensionClassVirtualMethodInfo;
  351. typedef void (*GDExtensionCallableCustomCall)(void *callable_userdata, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  352. typedef GDExtensionBool (*GDExtensionCallableCustomIsValid)(void *callable_userdata);
  353. typedef void (*GDExtensionCallableCustomFree)(void *callable_userdata);
  354. typedef uint32_t (*GDExtensionCallableCustomHash)(void *callable_userdata);
  355. typedef GDExtensionBool (*GDExtensionCallableCustomEqual)(void *callable_userdata_a, void *callable_userdata_b);
  356. typedef GDExtensionBool (*GDExtensionCallableCustomLessThan)(void *callable_userdata_a, void *callable_userdata_b);
  357. typedef void (*GDExtensionCallableCustomToString)(void *callable_userdata, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
  358. typedef struct {
  359. /* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
  360. *
  361. * `token` should point to an address that uniquely identifies the GDExtension (for example, the
  362. * `GDExtensionClassLibraryPtr` passed to the entry symbol function.
  363. *
  364. * `hash_func`, `equal_func`, and `less_than_func` are optional. If not provided both `call_func` and
  365. * `callable_userdata` together are used as the identity of the callable for hashing and comparison purposes.
  366. *
  367. * The hash returned by `hash_func` is cached, `hash_func` will not be called more than once per callable.
  368. *
  369. * `is_valid_func` is necessary if the validity of the callable can change before destruction.
  370. *
  371. * `free_func` is necessary if `callable_userdata` needs to be cleaned up when the callable is freed.
  372. */
  373. void *callable_userdata;
  374. void *token;
  375. GDObjectInstanceID object_id;
  376. GDExtensionCallableCustomCall call_func;
  377. GDExtensionCallableCustomIsValid is_valid_func;
  378. GDExtensionCallableCustomFree free_func;
  379. GDExtensionCallableCustomHash hash_func;
  380. GDExtensionCallableCustomEqual equal_func;
  381. GDExtensionCallableCustomLessThan less_than_func;
  382. GDExtensionCallableCustomToString to_string_func;
  383. } GDExtensionCallableCustomInfo;
  384. /* SCRIPT INSTANCE EXTENSION */
  385. typedef void *GDExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation.
  386. typedef GDExtensionBool (*GDExtensionScriptInstanceSet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
  387. typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  388. typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
  389. typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list);
  390. typedef GDExtensionBool (*GDExtensionScriptInstanceGetClassCategory)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_class_category);
  391. typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
  392. typedef GDExtensionBool (*GDExtensionScriptInstanceValidateProperty)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_property);
  393. typedef GDExtensionBool (*GDExtensionScriptInstancePropertyCanRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
  394. typedef GDExtensionBool (*GDExtensionScriptInstancePropertyGetRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  395. typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetOwner)(GDExtensionScriptInstanceDataPtr p_instance);
  396. typedef void (*GDExtensionScriptInstancePropertyStateAdd)(GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value, void *p_userdata);
  397. typedef void (*GDExtensionScriptInstanceGetPropertyState)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata);
  398. typedef const GDExtensionMethodInfo *(*GDExtensionScriptInstanceGetMethodList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
  399. typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list);
  400. typedef GDExtensionBool (*GDExtensionScriptInstanceHasMethod)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
  401. typedef void (*GDExtensionScriptInstanceCall)(GDExtensionScriptInstanceDataPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  402. typedef void (*GDExtensionScriptInstanceNotification)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionScriptInstanceNotification2 instead.
  403. typedef void (*GDExtensionScriptInstanceNotification2)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what, GDExtensionBool p_reversed);
  404. typedef void (*GDExtensionScriptInstanceToString)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
  405. typedef void (*GDExtensionScriptInstanceRefCountIncremented)(GDExtensionScriptInstanceDataPtr p_instance);
  406. typedef GDExtensionBool (*GDExtensionScriptInstanceRefCountDecremented)(GDExtensionScriptInstanceDataPtr p_instance);
  407. typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetScript)(GDExtensionScriptInstanceDataPtr p_instance);
  408. typedef GDExtensionBool (*GDExtensionScriptInstanceIsPlaceholder)(GDExtensionScriptInstanceDataPtr p_instance);
  409. typedef void *GDExtensionScriptLanguagePtr;
  410. typedef GDExtensionScriptLanguagePtr (*GDExtensionScriptInstanceGetLanguage)(GDExtensionScriptInstanceDataPtr p_instance);
  411. typedef void (*GDExtensionScriptInstanceFree)(GDExtensionScriptInstanceDataPtr p_instance);
  412. typedef void *GDExtensionScriptInstancePtr; // Pointer to ScriptInstance.
  413. typedef struct {
  414. GDExtensionScriptInstanceSet set_func;
  415. GDExtensionScriptInstanceGet get_func;
  416. GDExtensionScriptInstanceGetPropertyList get_property_list_func;
  417. GDExtensionScriptInstanceFreePropertyList free_property_list_func;
  418. GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
  419. GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
  420. GDExtensionScriptInstanceGetOwner get_owner_func;
  421. GDExtensionScriptInstanceGetPropertyState get_property_state_func;
  422. GDExtensionScriptInstanceGetMethodList get_method_list_func;
  423. GDExtensionScriptInstanceFreeMethodList free_method_list_func;
  424. GDExtensionScriptInstanceGetPropertyType get_property_type_func;
  425. GDExtensionScriptInstanceHasMethod has_method_func;
  426. GDExtensionScriptInstanceCall call_func;
  427. GDExtensionScriptInstanceNotification notification_func;
  428. GDExtensionScriptInstanceToString to_string_func;
  429. GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
  430. GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
  431. GDExtensionScriptInstanceGetScript get_script_func;
  432. GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
  433. GDExtensionScriptInstanceSet set_fallback_func;
  434. GDExtensionScriptInstanceGet get_fallback_func;
  435. GDExtensionScriptInstanceGetLanguage get_language_func;
  436. GDExtensionScriptInstanceFree free_func;
  437. } GDExtensionScriptInstanceInfo; // Deprecated. Use GDExtensionScriptInstanceInfo2 instead.
  438. typedef struct {
  439. GDExtensionScriptInstanceSet set_func;
  440. GDExtensionScriptInstanceGet get_func;
  441. GDExtensionScriptInstanceGetPropertyList get_property_list_func;
  442. GDExtensionScriptInstanceFreePropertyList free_property_list_func;
  443. GDExtensionScriptInstanceGetClassCategory get_class_category_func; // Optional. Set to NULL for the default behavior.
  444. GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
  445. GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
  446. GDExtensionScriptInstanceGetOwner get_owner_func;
  447. GDExtensionScriptInstanceGetPropertyState get_property_state_func;
  448. GDExtensionScriptInstanceGetMethodList get_method_list_func;
  449. GDExtensionScriptInstanceFreeMethodList free_method_list_func;
  450. GDExtensionScriptInstanceGetPropertyType get_property_type_func;
  451. GDExtensionScriptInstanceValidateProperty validate_property_func;
  452. GDExtensionScriptInstanceHasMethod has_method_func;
  453. GDExtensionScriptInstanceCall call_func;
  454. GDExtensionScriptInstanceNotification2 notification_func;
  455. GDExtensionScriptInstanceToString to_string_func;
  456. GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
  457. GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
  458. GDExtensionScriptInstanceGetScript get_script_func;
  459. GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
  460. GDExtensionScriptInstanceSet set_fallback_func;
  461. GDExtensionScriptInstanceGet get_fallback_func;
  462. GDExtensionScriptInstanceGetLanguage get_language_func;
  463. GDExtensionScriptInstanceFree free_func;
  464. } GDExtensionScriptInstanceInfo2;
  465. /* INITIALIZATION */
  466. typedef enum {
  467. GDEXTENSION_INITIALIZATION_CORE,
  468. GDEXTENSION_INITIALIZATION_SERVERS,
  469. GDEXTENSION_INITIALIZATION_SCENE,
  470. GDEXTENSION_INITIALIZATION_EDITOR,
  471. GDEXTENSION_MAX_INITIALIZATION_LEVEL,
  472. } GDExtensionInitializationLevel;
  473. typedef struct {
  474. /* Minimum initialization level required.
  475. * If Core or Servers, the extension needs editor or game restart to take effect */
  476. GDExtensionInitializationLevel minimum_initialization_level;
  477. /* Up to the user to supply when initializing */
  478. void *userdata;
  479. /* This function will be called multiple times for each initialization level. */
  480. void (*initialize)(void *userdata, GDExtensionInitializationLevel p_level);
  481. void (*deinitialize)(void *userdata, GDExtensionInitializationLevel p_level);
  482. } GDExtensionInitialization;
  483. typedef void (*GDExtensionInterfaceFunctionPtr)();
  484. typedef GDExtensionInterfaceFunctionPtr (*GDExtensionInterfaceGetProcAddress)(const char *p_function_name);
  485. /*
  486. * Each GDExtension should define a C function that matches the signature of GDExtensionInitializationFunction,
  487. * and export it so that it can be loaded via dlopen() or equivalent for the given platform.
  488. *
  489. * For example:
  490. *
  491. * GDExtensionBool my_extension_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
  492. *
  493. * This function's name must be specified as the 'entry_symbol' in the .gdextension file.
  494. *
  495. * This makes it the entry point of the GDExtension and will be called on initialization.
  496. *
  497. * The GDExtension can then modify the r_initialization structure, setting the minimum initialization level,
  498. * and providing pointers to functions that will be called at various stages of initialization/shutdown.
  499. *
  500. * The rest of the GDExtension's interface to Godot consists of function pointers that can be loaded
  501. * by calling p_get_proc_address("...") with the name of the function.
  502. *
  503. * For example:
  504. *
  505. * GDExtensionInterfaceGetGodotVersion get_godot_version = (GDExtensionInterfaceGetGodotVersion)p_get_proc_address("get_godot_version");
  506. *
  507. * (Note that snippet may cause "cast between incompatible function types" on some compilers, you can
  508. * silence this by adding an intermediary `void*` cast.)
  509. *
  510. * You can then call it like a normal function:
  511. *
  512. * GDExtensionGodotVersion godot_version;
  513. * get_godot_version(&godot_version);
  514. * printf("Godot v%d.%d.%d\n", godot_version.major, godot_version.minor, godot_version.patch);
  515. *
  516. * All of these interface functions are described below, together with the name that's used to load it,
  517. * and the function pointer typedef that shows its signature.
  518. */
  519. typedef GDExtensionBool (*GDExtensionInitializationFunction)(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
  520. /* INTERFACE */
  521. typedef struct {
  522. uint32_t major;
  523. uint32_t minor;
  524. uint32_t patch;
  525. const char *string;
  526. } GDExtensionGodotVersion;
  527. /**
  528. * @name get_godot_version
  529. * @since 4.1
  530. *
  531. * Gets the Godot version that the GDExtension was loaded into.
  532. *
  533. * @param r_godot_version A pointer to the structure to write the version information into.
  534. */
  535. typedef void (*GDExtensionInterfaceGetGodotVersion)(GDExtensionGodotVersion *r_godot_version);
  536. /* INTERFACE: Memory */
  537. /**
  538. * @name mem_alloc
  539. * @since 4.1
  540. *
  541. * Allocates memory.
  542. *
  543. * @param p_bytes The amount of memory to allocate in bytes.
  544. *
  545. * @return A pointer to the allocated memory, or NULL if unsuccessful.
  546. */
  547. typedef void *(*GDExtensionInterfaceMemAlloc)(size_t p_bytes);
  548. /**
  549. * @name mem_realloc
  550. * @since 4.1
  551. *
  552. * Reallocates memory.
  553. *
  554. * @param p_ptr A pointer to the previously allocated memory.
  555. * @param p_bytes The number of bytes to resize the memory block to.
  556. *
  557. * @return A pointer to the allocated memory, or NULL if unsuccessful.
  558. */
  559. typedef void *(*GDExtensionInterfaceMemRealloc)(void *p_ptr, size_t p_bytes);
  560. /**
  561. * @name mem_free
  562. * @since 4.1
  563. *
  564. * Frees memory.
  565. *
  566. * @param p_ptr A pointer to the previously allocated memory.
  567. */
  568. typedef void (*GDExtensionInterfaceMemFree)(void *p_ptr);
  569. /* INTERFACE: Godot Core */
  570. /**
  571. * @name print_error
  572. * @since 4.1
  573. *
  574. * Logs an error to Godot's built-in debugger and to the OS terminal.
  575. *
  576. * @param p_description The code trigging the error.
  577. * @param p_function The function name where the error occurred.
  578. * @param p_file The file where the error occurred.
  579. * @param p_line The line where the error occurred.
  580. * @param p_editor_notify Whether or not to notify the editor.
  581. */
  582. typedef void (*GDExtensionInterfacePrintError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  583. /**
  584. * @name print_error_with_message
  585. * @since 4.1
  586. *
  587. * Logs an error with a message to Godot's built-in debugger and to the OS terminal.
  588. *
  589. * @param p_description The code trigging the error.
  590. * @param p_message The message to show along with the error.
  591. * @param p_function The function name where the error occurred.
  592. * @param p_file The file where the error occurred.
  593. * @param p_line The line where the error occurred.
  594. * @param p_editor_notify Whether or not to notify the editor.
  595. */
  596. 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);
  597. /**
  598. * @name print_warning
  599. * @since 4.1
  600. *
  601. * Logs a warning to Godot's built-in debugger and to the OS terminal.
  602. *
  603. * @param p_description The code trigging the warning.
  604. * @param p_function The function name where the warning occurred.
  605. * @param p_file The file where the warning occurred.
  606. * @param p_line The line where the warning occurred.
  607. * @param p_editor_notify Whether or not to notify the editor.
  608. */
  609. typedef void (*GDExtensionInterfacePrintWarning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  610. /**
  611. * @name print_warning_with_message
  612. * @since 4.1
  613. *
  614. * Logs a warning with a message to Godot's built-in debugger and to the OS terminal.
  615. *
  616. * @param p_description The code trigging the warning.
  617. * @param p_message The message to show along with the warning.
  618. * @param p_function The function name where the warning occurred.
  619. * @param p_file The file where the warning occurred.
  620. * @param p_line The line where the warning occurred.
  621. * @param p_editor_notify Whether or not to notify the editor.
  622. */
  623. 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);
  624. /**
  625. * @name print_script_error
  626. * @since 4.1
  627. *
  628. * Logs a script error to Godot's built-in debugger and to the OS terminal.
  629. *
  630. * @param p_description The code trigging the error.
  631. * @param p_function The function name where the error occurred.
  632. * @param p_file The file where the error occurred.
  633. * @param p_line The line where the error occurred.
  634. * @param p_editor_notify Whether or not to notify the editor.
  635. */
  636. typedef void (*GDExtensionInterfacePrintScriptError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  637. /**
  638. * @name print_script_error_with_message
  639. * @since 4.1
  640. *
  641. * Logs a script error with a message to Godot's built-in debugger and to the OS terminal.
  642. *
  643. * @param p_description The code trigging the error.
  644. * @param p_message The message to show along with the error.
  645. * @param p_function The function name where the error occurred.
  646. * @param p_file The file where the error occurred.
  647. * @param p_line The line where the error occurred.
  648. * @param p_editor_notify Whether or not to notify the editor.
  649. */
  650. 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);
  651. /**
  652. * @name get_native_struct_size
  653. * @since 4.1
  654. *
  655. * Gets the size of a native struct (ex. ObjectID) in bytes.
  656. *
  657. * @param p_name A pointer to a StringName identifying the struct name.
  658. *
  659. * @return The size in bytes.
  660. */
  661. typedef uint64_t (*GDExtensionInterfaceGetNativeStructSize)(GDExtensionConstStringNamePtr p_name);
  662. /* INTERFACE: Variant */
  663. /**
  664. * @name variant_new_copy
  665. * @since 4.1
  666. *
  667. * Copies one Variant into a another.
  668. *
  669. * @param r_dest A pointer to the destination Variant.
  670. * @param p_src A pointer to the source Variant.
  671. */
  672. typedef void (*GDExtensionInterfaceVariantNewCopy)(GDExtensionUninitializedVariantPtr r_dest, GDExtensionConstVariantPtr p_src);
  673. /**
  674. * @name variant_new_nil
  675. * @since 4.1
  676. *
  677. * Creates a new Variant containing nil.
  678. *
  679. * @param r_dest A pointer to the destination Variant.
  680. */
  681. typedef void (*GDExtensionInterfaceVariantNewNil)(GDExtensionUninitializedVariantPtr r_dest);
  682. /**
  683. * @name variant_destroy
  684. * @since 4.1
  685. *
  686. * Destroys a Variant.
  687. *
  688. * @param p_self A pointer to the Variant to destroy.
  689. */
  690. typedef void (*GDExtensionInterfaceVariantDestroy)(GDExtensionVariantPtr p_self);
  691. /**
  692. * @name variant_call
  693. * @since 4.1
  694. *
  695. * Calls a method on a Variant.
  696. *
  697. * @param p_self A pointer to the Variant.
  698. * @param p_method A pointer to a StringName identifying the method.
  699. * @param p_args A pointer to a C array of Variant.
  700. * @param p_argument_count The number of arguments.
  701. * @param r_return A pointer a Variant which will be assigned the return value.
  702. * @param r_error A pointer the structure which will hold error information.
  703. *
  704. * @see Variant::callp()
  705. */
  706. typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
  707. /**
  708. * @name variant_call_static
  709. * @since 4.1
  710. *
  711. * Calls a static method on a Variant.
  712. *
  713. * @param p_self A pointer to the Variant.
  714. * @param p_method A pointer to a StringName identifying the method.
  715. * @param p_args A pointer to a C array of Variant.
  716. * @param p_argument_count The number of arguments.
  717. * @param r_return A pointer a Variant which will be assigned the return value.
  718. * @param r_error A pointer the structure which will be updated with error information.
  719. *
  720. * @see Variant::call_static()
  721. */
  722. typedef void (*GDExtensionInterfaceVariantCallStatic)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
  723. /**
  724. * @name variant_evaluate
  725. * @since 4.1
  726. *
  727. * Evaluate an operator on two Variants.
  728. *
  729. * @param p_op The operator to evaluate.
  730. * @param p_a The first Variant.
  731. * @param p_b The second Variant.
  732. * @param r_return A pointer a Variant which will be assigned the return value.
  733. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  734. *
  735. * @see Variant::evaluate()
  736. */
  737. typedef void (*GDExtensionInterfaceVariantEvaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionUninitializedVariantPtr r_return, GDExtensionBool *r_valid);
  738. /**
  739. * @name variant_set
  740. * @since 4.1
  741. *
  742. * Sets a key on a Variant to a value.
  743. *
  744. * @param p_self A pointer to the Variant.
  745. * @param p_key A pointer to a Variant representing the key.
  746. * @param p_value A pointer to a Variant representing the value.
  747. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  748. *
  749. * @see Variant::set()
  750. */
  751. typedef void (*GDExtensionInterfaceVariantSet)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  752. /**
  753. * @name variant_set_named
  754. * @since 4.1
  755. *
  756. * Sets a named key on a Variant to a value.
  757. *
  758. * @param p_self A pointer to the Variant.
  759. * @param p_key A pointer to a StringName representing the key.
  760. * @param p_value A pointer to a Variant representing the value.
  761. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  762. *
  763. * @see Variant::set_named()
  764. */
  765. typedef void (*GDExtensionInterfaceVariantSetNamed)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  766. /**
  767. * @name variant_set_keyed
  768. * @since 4.1
  769. *
  770. * Sets a keyed property on a Variant to a value.
  771. *
  772. * @param p_self A pointer to the Variant.
  773. * @param p_key A pointer to a Variant representing the key.
  774. * @param p_value A pointer to a Variant representing the value.
  775. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  776. *
  777. * @see Variant::set_keyed()
  778. */
  779. typedef void (*GDExtensionInterfaceVariantSetKeyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  780. /**
  781. * @name variant_set_indexed
  782. * @since 4.1
  783. *
  784. * Sets an index on a Variant to a value.
  785. *
  786. * @param p_self A pointer to the Variant.
  787. * @param p_index The index.
  788. * @param p_value A pointer to a Variant representing the value.
  789. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  790. * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
  791. */
  792. typedef void (*GDExtensionInterfaceVariantSetIndexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  793. /**
  794. * @name variant_get
  795. * @since 4.1
  796. *
  797. * Gets the value of a key from a Variant.
  798. *
  799. * @param p_self A pointer to the Variant.
  800. * @param p_key A pointer to a Variant representing the key.
  801. * @param r_ret A pointer to a Variant which will be assigned the value.
  802. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  803. */
  804. typedef void (*GDExtensionInterfaceVariantGet)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  805. /**
  806. * @name variant_get_named
  807. * @since 4.1
  808. *
  809. * Gets the value of a named key from a Variant.
  810. *
  811. * @param p_self A pointer to the Variant.
  812. * @param p_key A pointer to a StringName representing the key.
  813. * @param r_ret A pointer to a Variant which will be assigned the value.
  814. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  815. */
  816. typedef void (*GDExtensionInterfaceVariantGetNamed)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  817. /**
  818. * @name variant_get_keyed
  819. * @since 4.1
  820. *
  821. * Gets the value of a keyed property from a Variant.
  822. *
  823. * @param p_self A pointer to the Variant.
  824. * @param p_key A pointer to a Variant representing the key.
  825. * @param r_ret A pointer to a Variant which will be assigned the value.
  826. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  827. */
  828. typedef void (*GDExtensionInterfaceVariantGetKeyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  829. /**
  830. * @name variant_get_indexed
  831. * @since 4.1
  832. *
  833. * Gets the value of an index from a Variant.
  834. *
  835. * @param p_self A pointer to the Variant.
  836. * @param p_index The index.
  837. * @param r_ret A pointer to a Variant which will be assigned the value.
  838. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  839. * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
  840. */
  841. typedef void (*GDExtensionInterfaceVariantGetIndexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  842. /**
  843. * @name variant_iter_init
  844. * @since 4.1
  845. *
  846. * Initializes an iterator over a Variant.
  847. *
  848. * @param p_self A pointer to the Variant.
  849. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  850. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  851. *
  852. * @return true if the operation is valid; otherwise false.
  853. *
  854. * @see Variant::iter_init()
  855. */
  856. typedef GDExtensionBool (*GDExtensionInterfaceVariantIterInit)(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_iter, GDExtensionBool *r_valid);
  857. /**
  858. * @name variant_iter_next
  859. * @since 4.1
  860. *
  861. * Gets the next value for an iterator over a Variant.
  862. *
  863. * @param p_self A pointer to the Variant.
  864. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  865. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  866. *
  867. * @return true if the operation is valid; otherwise false.
  868. *
  869. * @see Variant::iter_next()
  870. */
  871. typedef GDExtensionBool (*GDExtensionInterfaceVariantIterNext)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
  872. /**
  873. * @name variant_iter_get
  874. * @since 4.1
  875. *
  876. * Gets the next value for an iterator over a Variant.
  877. *
  878. * @param p_self A pointer to the Variant.
  879. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  880. * @param r_ret A pointer to a Variant which will be assigned false if the operation is invalid.
  881. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  882. *
  883. * @see Variant::iter_get()
  884. */
  885. typedef void (*GDExtensionInterfaceVariantIterGet)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  886. /**
  887. * @name variant_hash
  888. * @since 4.1
  889. *
  890. * Gets the hash of a Variant.
  891. *
  892. * @param p_self A pointer to the Variant.
  893. *
  894. * @return The hash value.
  895. *
  896. * @see Variant::hash()
  897. */
  898. typedef GDExtensionInt (*GDExtensionInterfaceVariantHash)(GDExtensionConstVariantPtr p_self);
  899. /**
  900. * @name variant_recursive_hash
  901. * @since 4.1
  902. *
  903. * Gets the recursive hash of a Variant.
  904. *
  905. * @param p_self A pointer to the Variant.
  906. * @param p_recursion_count The number of recursive loops so far.
  907. *
  908. * @return The hash value.
  909. *
  910. * @see Variant::recursive_hash()
  911. */
  912. typedef GDExtensionInt (*GDExtensionInterfaceVariantRecursiveHash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count);
  913. /**
  914. * @name variant_hash_compare
  915. * @since 4.1
  916. *
  917. * Compares two Variants by their hash.
  918. *
  919. * @param p_self A pointer to the Variant.
  920. * @param p_other A pointer to the other Variant to compare it to.
  921. *
  922. * @return The hash value.
  923. *
  924. * @see Variant::hash_compare()
  925. */
  926. typedef GDExtensionBool (*GDExtensionInterfaceVariantHashCompare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other);
  927. /**
  928. * @name variant_booleanize
  929. * @since 4.1
  930. *
  931. * Converts a Variant to a boolean.
  932. *
  933. * @param p_self A pointer to the Variant.
  934. *
  935. * @return The boolean value of the Variant.
  936. */
  937. typedef GDExtensionBool (*GDExtensionInterfaceVariantBooleanize)(GDExtensionConstVariantPtr p_self);
  938. /**
  939. * @name variant_duplicate
  940. * @since 4.1
  941. *
  942. * Duplicates a Variant.
  943. *
  944. * @param p_self A pointer to the Variant.
  945. * @param r_ret A pointer to a Variant to store the duplicated value.
  946. * @param p_deep Whether or not to duplicate deeply (when supported by the Variant type).
  947. */
  948. typedef void (*GDExtensionInterfaceVariantDuplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep);
  949. /**
  950. * @name variant_stringify
  951. * @since 4.1
  952. *
  953. * Converts a Variant to a string.
  954. *
  955. * @param p_self A pointer to the Variant.
  956. * @param r_ret A pointer to a String to store the resulting value.
  957. */
  958. typedef void (*GDExtensionInterfaceVariantStringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret);
  959. /**
  960. * @name variant_get_type
  961. * @since 4.1
  962. *
  963. * Gets the type of a Variant.
  964. *
  965. * @param p_self A pointer to the Variant.
  966. *
  967. * @return The variant type.
  968. */
  969. typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtensionConstVariantPtr p_self);
  970. /**
  971. * @name variant_has_method
  972. * @since 4.1
  973. *
  974. * Checks if a Variant has the given method.
  975. *
  976. * @param p_self A pointer to the Variant.
  977. * @param p_method A pointer to a StringName with the method name.
  978. *
  979. * @return
  980. */
  981. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
  982. /**
  983. * @name variant_has_member
  984. * @since 4.1
  985. *
  986. * Checks if a type of Variant has the given member.
  987. *
  988. * @param p_type The Variant type.
  989. * @param p_member A pointer to a StringName with the member name.
  990. *
  991. * @return
  992. */
  993. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  994. /**
  995. * @name variant_has_key
  996. * @since 4.1
  997. *
  998. * Checks if a Variant has a key.
  999. *
  1000. * @param p_self A pointer to the Variant.
  1001. * @param p_key A pointer to a Variant representing the key.
  1002. * @param r_valid A pointer to a boolean which will be set to false if the key doesn't exist.
  1003. *
  1004. * @return true if the key exists; otherwise false.
  1005. */
  1006. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasKey)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid);
  1007. /**
  1008. * @name variant_get_type_name
  1009. * @since 4.1
  1010. *
  1011. * Gets the name of a Variant type.
  1012. *
  1013. * @param p_type The Variant type.
  1014. * @param r_name A pointer to a String to store the Variant type name.
  1015. */
  1016. typedef void (*GDExtensionInterfaceVariantGetTypeName)(GDExtensionVariantType p_type, GDExtensionUninitializedStringPtr r_name);
  1017. /**
  1018. * @name variant_can_convert
  1019. * @since 4.1
  1020. *
  1021. * Checks if Variants can be converted from one type to another.
  1022. *
  1023. * @param p_from The Variant type to convert from.
  1024. * @param p_to The Variant type to convert to.
  1025. *
  1026. * @return true if the conversion is possible; otherwise false.
  1027. */
  1028. typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  1029. /**
  1030. * @name variant_can_convert_strict
  1031. * @since 4.1
  1032. *
  1033. * Checks if Variant can be converted from one type to another using stricter rules.
  1034. *
  1035. * @param p_from The Variant type to convert from.
  1036. * @param p_to The Variant type to convert to.
  1037. *
  1038. * @return true if the conversion is possible; otherwise false.
  1039. */
  1040. typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvertStrict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  1041. /**
  1042. * @name get_variant_from_type_constructor
  1043. * @since 4.1
  1044. *
  1045. * Gets a pointer to a function that can create a Variant of the given type from a raw value.
  1046. *
  1047. * @param p_type The Variant type.
  1048. *
  1049. * @return A pointer to a function that can create a Variant of the given type from a raw value.
  1050. */
  1051. typedef GDExtensionVariantFromTypeConstructorFunc (*GDExtensionInterfaceGetVariantFromTypeConstructor)(GDExtensionVariantType p_type);
  1052. /**
  1053. * @name get_variant_to_type_constructor
  1054. * @since 4.1
  1055. *
  1056. * Gets a pointer to a function that can get the raw value from a Variant of the given type.
  1057. *
  1058. * @param p_type The Variant type.
  1059. *
  1060. * @return A pointer to a function that can get the raw value from a Variant of the given type.
  1061. */
  1062. typedef GDExtensionTypeFromVariantConstructorFunc (*GDExtensionInterfaceGetVariantToTypeConstructor)(GDExtensionVariantType p_type);
  1063. /**
  1064. * @name variant_get_ptr_operator_evaluator
  1065. * @since 4.1
  1066. *
  1067. * Gets a pointer to a function that can evaluate the given Variant operator on the given Variant types.
  1068. *
  1069. * @param p_operator The variant operator.
  1070. * @param p_type_a The type of the first Variant.
  1071. * @param p_type_b The type of the second Variant.
  1072. *
  1073. * @return A pointer to a function that can evaluate the given Variant operator on the given Variant types.
  1074. */
  1075. typedef GDExtensionPtrOperatorEvaluator (*GDExtensionInterfaceVariantGetPtrOperatorEvaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b);
  1076. /**
  1077. * @name variant_get_ptr_builtin_method
  1078. * @since 4.1
  1079. *
  1080. * Gets a pointer to a function that can call a builtin method on a type of Variant.
  1081. *
  1082. * @param p_type The Variant type.
  1083. * @param p_method A pointer to a StringName with the method name.
  1084. * @param p_hash A hash representing the method signature.
  1085. *
  1086. * @return A pointer to a function that can call a builtin method on a type of Variant.
  1087. */
  1088. typedef GDExtensionPtrBuiltInMethod (*GDExtensionInterfaceVariantGetPtrBuiltinMethod)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash);
  1089. /**
  1090. * @name variant_get_ptr_constructor
  1091. * @since 4.1
  1092. *
  1093. * Gets a pointer to a function that can call one of the constructors for a type of Variant.
  1094. *
  1095. * @param p_type The Variant type.
  1096. * @param p_constructor The index of the constructor.
  1097. *
  1098. * @return A pointer to a function that can call one of the constructors for a type of Variant.
  1099. */
  1100. typedef GDExtensionPtrConstructor (*GDExtensionInterfaceVariantGetPtrConstructor)(GDExtensionVariantType p_type, int32_t p_constructor);
  1101. /**
  1102. * @name variant_get_ptr_destructor
  1103. * @since 4.1
  1104. *
  1105. * Gets a pointer to a function than can call the destructor for a type of Variant.
  1106. *
  1107. * @param p_type The Variant type.
  1108. *
  1109. * @return A pointer to a function than can call the destructor for a type of Variant.
  1110. */
  1111. typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(GDExtensionVariantType p_type);
  1112. /**
  1113. * @name variant_construct
  1114. * @since 4.1
  1115. *
  1116. * Constructs a Variant of the given type, using the first constructor that matches the given arguments.
  1117. *
  1118. * @param p_type The Variant type.
  1119. * @param p_base A pointer to a Variant to store the constructed value.
  1120. * @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor.
  1121. * @param p_argument_count The number of arguments to pass to the constructor.
  1122. * @param r_error A pointer the structure which will be updated with error information.
  1123. */
  1124. typedef void (*GDExtensionInterfaceVariantConstruct)(GDExtensionVariantType p_type, GDExtensionUninitializedVariantPtr r_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error);
  1125. /**
  1126. * @name variant_get_ptr_setter
  1127. * @since 4.1
  1128. *
  1129. * Gets a pointer to a function that can call a member's setter on the given Variant type.
  1130. *
  1131. * @param p_type The Variant type.
  1132. * @param p_member A pointer to a StringName with the member name.
  1133. *
  1134. * @return A pointer to a function that can call a member's setter on the given Variant type.
  1135. */
  1136. typedef GDExtensionPtrSetter (*GDExtensionInterfaceVariantGetPtrSetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  1137. /**
  1138. * @name variant_get_ptr_getter
  1139. * @since 4.1
  1140. *
  1141. * Gets a pointer to a function that can call a member's getter on the given Variant type.
  1142. *
  1143. * @param p_type The Variant type.
  1144. * @param p_member A pointer to a StringName with the member name.
  1145. *
  1146. * @return A pointer to a function that can call a member's getter on the given Variant type.
  1147. */
  1148. typedef GDExtensionPtrGetter (*GDExtensionInterfaceVariantGetPtrGetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  1149. /**
  1150. * @name variant_get_ptr_indexed_setter
  1151. * @since 4.1
  1152. *
  1153. * Gets a pointer to a function that can set an index on the given Variant type.
  1154. *
  1155. * @param p_type The Variant type.
  1156. *
  1157. * @return A pointer to a function that can set an index on the given Variant type.
  1158. */
  1159. typedef GDExtensionPtrIndexedSetter (*GDExtensionInterfaceVariantGetPtrIndexedSetter)(GDExtensionVariantType p_type);
  1160. /**
  1161. * @name variant_get_ptr_indexed_getter
  1162. * @since 4.1
  1163. *
  1164. * Gets a pointer to a function that can get an index on the given Variant type.
  1165. *
  1166. * @param p_type The Variant type.
  1167. *
  1168. * @return A pointer to a function that can get an index on the given Variant type.
  1169. */
  1170. typedef GDExtensionPtrIndexedGetter (*GDExtensionInterfaceVariantGetPtrIndexedGetter)(GDExtensionVariantType p_type);
  1171. /**
  1172. * @name variant_get_ptr_keyed_setter
  1173. * @since 4.1
  1174. *
  1175. * Gets a pointer to a function that can set a key on the given Variant type.
  1176. *
  1177. * @param p_type The Variant type.
  1178. *
  1179. * @return A pointer to a function that can set a key on the given Variant type.
  1180. */
  1181. typedef GDExtensionPtrKeyedSetter (*GDExtensionInterfaceVariantGetPtrKeyedSetter)(GDExtensionVariantType p_type);
  1182. /**
  1183. * @name variant_get_ptr_keyed_getter
  1184. * @since 4.1
  1185. *
  1186. * Gets a pointer to a function that can get a key on the given Variant type.
  1187. *
  1188. * @param p_type The Variant type.
  1189. *
  1190. * @return A pointer to a function that can get a key on the given Variant type.
  1191. */
  1192. typedef GDExtensionPtrKeyedGetter (*GDExtensionInterfaceVariantGetPtrKeyedGetter)(GDExtensionVariantType p_type);
  1193. /**
  1194. * @name variant_get_ptr_keyed_checker
  1195. * @since 4.1
  1196. *
  1197. * Gets a pointer to a function that can check a key on the given Variant type.
  1198. *
  1199. * @param p_type The Variant type.
  1200. *
  1201. * @return A pointer to a function that can check a key on the given Variant type.
  1202. */
  1203. typedef GDExtensionPtrKeyedChecker (*GDExtensionInterfaceVariantGetPtrKeyedChecker)(GDExtensionVariantType p_type);
  1204. /**
  1205. * @name variant_get_constant_value
  1206. * @since 4.1
  1207. *
  1208. * Gets the value of a constant from the given Variant type.
  1209. *
  1210. * @param p_type The Variant type.
  1211. * @param p_constant A pointer to a StringName with the constant name.
  1212. * @param r_ret A pointer to a Variant to store the value.
  1213. */
  1214. typedef void (*GDExtensionInterfaceVariantGetConstantValue)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionUninitializedVariantPtr r_ret);
  1215. /**
  1216. * @name variant_get_ptr_utility_function
  1217. * @since 4.1
  1218. *
  1219. * Gets a pointer to a function that can call a Variant utility function.
  1220. *
  1221. * @param p_function A pointer to a StringName with the function name.
  1222. * @param p_hash A hash representing the function signature.
  1223. *
  1224. * @return A pointer to a function that can call a Variant utility function.
  1225. */
  1226. typedef GDExtensionPtrUtilityFunction (*GDExtensionInterfaceVariantGetPtrUtilityFunction)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash);
  1227. /* INTERFACE: String Utilities */
  1228. /**
  1229. * @name string_new_with_latin1_chars
  1230. * @since 4.1
  1231. *
  1232. * Creates a String from a Latin-1 encoded C string.
  1233. *
  1234. * @param r_dest A pointer to a Variant to hold the newly created String.
  1235. * @param p_contents A pointer to a Latin-1 encoded C string (null terminated).
  1236. */
  1237. typedef void (*GDExtensionInterfaceStringNewWithLatin1Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents);
  1238. /**
  1239. * @name string_new_with_utf8_chars
  1240. * @since 4.1
  1241. *
  1242. * Creates a String from a UTF-8 encoded C string.
  1243. *
  1244. * @param r_dest A pointer to a Variant to hold the newly created String.
  1245. * @param p_contents A pointer to a UTF-8 encoded C string (null terminated).
  1246. */
  1247. typedef void (*GDExtensionInterfaceStringNewWithUtf8Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents);
  1248. /**
  1249. * @name string_new_with_utf16_chars
  1250. * @since 4.1
  1251. *
  1252. * Creates a String from a UTF-16 encoded C string.
  1253. *
  1254. * @param r_dest A pointer to a Variant to hold the newly created String.
  1255. * @param p_contents A pointer to a UTF-16 encoded C string (null terminated).
  1256. */
  1257. typedef void (*GDExtensionInterfaceStringNewWithUtf16Chars)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents);
  1258. /**
  1259. * @name string_new_with_utf32_chars
  1260. * @since 4.1
  1261. *
  1262. * Creates a String from a UTF-32 encoded C string.
  1263. *
  1264. * @param r_dest A pointer to a Variant to hold the newly created String.
  1265. * @param p_contents A pointer to a UTF-32 encoded C string (null terminated).
  1266. */
  1267. typedef void (*GDExtensionInterfaceStringNewWithUtf32Chars)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents);
  1268. /**
  1269. * @name string_new_with_wide_chars
  1270. * @since 4.1
  1271. *
  1272. * Creates a String from a wide C string.
  1273. *
  1274. * @param r_dest A pointer to a Variant to hold the newly created String.
  1275. * @param p_contents A pointer to a wide C string (null terminated).
  1276. */
  1277. typedef void (*GDExtensionInterfaceStringNewWithWideChars)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents);
  1278. /**
  1279. * @name string_new_with_latin1_chars_and_len
  1280. * @since 4.1
  1281. *
  1282. * Creates a String from a Latin-1 encoded C string with the given length.
  1283. *
  1284. * @param r_dest A pointer to a Variant to hold the newly created String.
  1285. * @param p_contents A pointer to a Latin-1 encoded C string.
  1286. * @param p_size The number of characters (= number of bytes).
  1287. */
  1288. typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1289. /**
  1290. * @name string_new_with_utf8_chars_and_len
  1291. * @since 4.1
  1292. *
  1293. * Creates a String from a UTF-8 encoded C string with the given length.
  1294. *
  1295. * @param r_dest A pointer to a Variant to hold the newly created String.
  1296. * @param p_contents A pointer to a UTF-8 encoded C string.
  1297. * @param p_size The number of bytes (not code units).
  1298. */
  1299. typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1300. /**
  1301. * @name string_new_with_utf16_chars_and_len
  1302. * @since 4.1
  1303. *
  1304. * Creates a String from a UTF-16 encoded C string with the given length.
  1305. *
  1306. * @param r_dest A pointer to a Variant to hold the newly created String.
  1307. * @param p_contents A pointer to a UTF-16 encoded C string.
  1308. * @param p_size The number of characters (not bytes).
  1309. */
  1310. typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count);
  1311. /**
  1312. * @name string_new_with_utf32_chars_and_len
  1313. * @since 4.1
  1314. *
  1315. * Creates a String from a UTF-32 encoded C string with the given length.
  1316. *
  1317. * @param r_dest A pointer to a Variant to hold the newly created String.
  1318. * @param p_contents A pointer to a UTF-32 encoded C string.
  1319. * @param p_size The number of characters (not bytes).
  1320. */
  1321. typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_char_count);
  1322. /**
  1323. * @name string_new_with_wide_chars_and_len
  1324. * @since 4.1
  1325. *
  1326. * Creates a String from a wide C string with the given length.
  1327. *
  1328. * @param r_dest A pointer to a Variant to hold the newly created String.
  1329. * @param p_contents A pointer to a wide C string.
  1330. * @param p_size The number of characters (not bytes).
  1331. */
  1332. typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_char_count);
  1333. /**
  1334. * @name string_to_latin1_chars
  1335. * @since 4.1
  1336. *
  1337. * Converts a String to a Latin-1 encoded C string.
  1338. *
  1339. * It doesn't write a null terminator.
  1340. *
  1341. * @param p_self A pointer to the String.
  1342. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1343. * @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.
  1344. *
  1345. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1346. */
  1347. typedef GDExtensionInt (*GDExtensionInterfaceStringToLatin1Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  1348. /**
  1349. * @name string_to_utf8_chars
  1350. * @since 4.1
  1351. *
  1352. * Converts a String to a UTF-8 encoded C string.
  1353. *
  1354. * It doesn't write a null terminator.
  1355. *
  1356. * @param p_self A pointer to the String.
  1357. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1358. * @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.
  1359. *
  1360. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1361. */
  1362. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf8Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  1363. /**
  1364. * @name string_to_utf16_chars
  1365. * @since 4.1
  1366. *
  1367. * Converts a String to a UTF-16 encoded C string.
  1368. *
  1369. * It doesn't write a null terminator.
  1370. *
  1371. * @param p_self A pointer to the String.
  1372. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1373. * @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.
  1374. *
  1375. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1376. */
  1377. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf16Chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length);
  1378. /**
  1379. * @name string_to_utf32_chars
  1380. * @since 4.1
  1381. *
  1382. * Converts a String to a UTF-32 encoded C string.
  1383. *
  1384. * It doesn't write a null terminator.
  1385. *
  1386. * @param p_self A pointer to the String.
  1387. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1388. * @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.
  1389. *
  1390. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1391. */
  1392. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf32Chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length);
  1393. /**
  1394. * @name string_to_wide_chars
  1395. * @since 4.1
  1396. *
  1397. * Converts a String to a wide C string.
  1398. *
  1399. * It doesn't write a null terminator.
  1400. *
  1401. * @param p_self A pointer to the String.
  1402. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1403. * @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.
  1404. *
  1405. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1406. */
  1407. typedef GDExtensionInt (*GDExtensionInterfaceStringToWideChars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length);
  1408. /**
  1409. * @name string_operator_index
  1410. * @since 4.1
  1411. *
  1412. * Gets a pointer to the character at the given index from a String.
  1413. *
  1414. * @param p_self A pointer to the String.
  1415. * @param p_index The index.
  1416. *
  1417. * @return A pointer to the requested character.
  1418. */
  1419. typedef char32_t *(*GDExtensionInterfaceStringOperatorIndex)(GDExtensionStringPtr p_self, GDExtensionInt p_index);
  1420. /**
  1421. * @name string_operator_index_const
  1422. * @since 4.1
  1423. *
  1424. * Gets a const pointer to the character at the given index from a String.
  1425. *
  1426. * @param p_self A pointer to the String.
  1427. * @param p_index The index.
  1428. *
  1429. * @return A const pointer to the requested character.
  1430. */
  1431. typedef const char32_t *(*GDExtensionInterfaceStringOperatorIndexConst)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index);
  1432. /**
  1433. * @name string_operator_plus_eq_string
  1434. * @since 4.1
  1435. *
  1436. * Appends another String to a String.
  1437. *
  1438. * @param p_self A pointer to the String.
  1439. * @param p_b A pointer to the other String to append.
  1440. */
  1441. typedef void (*GDExtensionInterfaceStringOperatorPlusEqString)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b);
  1442. /**
  1443. * @name string_operator_plus_eq_char
  1444. * @since 4.1
  1445. *
  1446. * Appends a character to a String.
  1447. *
  1448. * @param p_self A pointer to the String.
  1449. * @param p_b A pointer to the character to append.
  1450. */
  1451. typedef void (*GDExtensionInterfaceStringOperatorPlusEqChar)(GDExtensionStringPtr p_self, char32_t p_b);
  1452. /**
  1453. * @name string_operator_plus_eq_cstr
  1454. * @since 4.1
  1455. *
  1456. * Appends a Latin-1 encoded C string to a String.
  1457. *
  1458. * @param p_self A pointer to the String.
  1459. * @param p_b A pointer to a Latin-1 encoded C string (null terminated).
  1460. */
  1461. typedef void (*GDExtensionInterfaceStringOperatorPlusEqCstr)(GDExtensionStringPtr p_self, const char *p_b);
  1462. /**
  1463. * @name string_operator_plus_eq_wcstr
  1464. * @since 4.1
  1465. *
  1466. * Appends a wide C string to a String.
  1467. *
  1468. * @param p_self A pointer to the String.
  1469. * @param p_b A pointer to a wide C string (null terminated).
  1470. */
  1471. typedef void (*GDExtensionInterfaceStringOperatorPlusEqWcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b);
  1472. /**
  1473. * @name string_operator_plus_eq_c32str
  1474. * @since 4.1
  1475. *
  1476. * Appends a UTF-32 encoded C string to a String.
  1477. *
  1478. * @param p_self A pointer to the String.
  1479. * @param p_b A pointer to a UTF-32 encoded C string (null terminated).
  1480. */
  1481. typedef void (*GDExtensionInterfaceStringOperatorPlusEqC32str)(GDExtensionStringPtr p_self, const char32_t *p_b);
  1482. /**
  1483. * @name string_resize
  1484. * @since 4.2
  1485. *
  1486. * Resizes the underlying string data to the given number of characters.
  1487. *
  1488. * Space needs to be allocated for the null terminating character ('\0') which
  1489. * also must be added manually, in order for all string functions to work correctly.
  1490. *
  1491. * Warning: This is an error-prone operation - only use it if there's no other
  1492. * efficient way to accomplish your goal.
  1493. *
  1494. * @param p_self A pointer to the String.
  1495. * @param p_resize The new length for the String.
  1496. *
  1497. * @return Error code signifying if the operation successful.
  1498. */
  1499. typedef GDExtensionInt (*GDExtensionInterfaceStringResize)(GDExtensionStringPtr p_self, GDExtensionInt p_resize);
  1500. /* INTERFACE: StringName Utilities */
  1501. /**
  1502. * @name string_name_new_with_latin1_chars
  1503. * @since 4.2
  1504. *
  1505. * Creates a StringName from a Latin-1 encoded C string.
  1506. *
  1507. * If `p_is_static` is true, then:
  1508. * - The StringName will reuse the `p_contents` buffer instead of copying it.
  1509. * You must guarantee that the buffer remains valid for the duration of the application (e.g. string literal).
  1510. * - You must not call a destructor for this StringName. Incrementing the initial reference once should achieve this.
  1511. *
  1512. * `p_is_static` is purely an optimization and can easily introduce undefined behavior if used wrong. In case of doubt, set it to false.
  1513. *
  1514. * @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed.
  1515. * @param p_contents A pointer to a C string (null terminated and Latin-1 or ASCII encoded).
  1516. * @param p_is_static Whether the StringName reuses the buffer directly (see above).
  1517. */
  1518. typedef void (*GDExtensionInterfaceStringNameNewWithLatin1Chars)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionBool p_is_static);
  1519. /**
  1520. * @name string_name_new_with_utf8_chars
  1521. * @since 4.2
  1522. *
  1523. * Creates a StringName from a UTF-8 encoded C string.
  1524. *
  1525. * @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed.
  1526. * @param p_contents A pointer to a C string (null terminated and UTF-8 encoded).
  1527. */
  1528. typedef void (*GDExtensionInterfaceStringNameNewWithUtf8Chars)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents);
  1529. /**
  1530. * @name string_name_new_with_utf8_chars_and_len
  1531. * @since 4.2
  1532. *
  1533. * Creates a StringName from a UTF-8 encoded string with a given number of characters.
  1534. *
  1535. * @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed.
  1536. * @param p_contents A pointer to a C string (null terminated and UTF-8 encoded).
  1537. * @param p_size The number of bytes (not UTF-8 code points).
  1538. */
  1539. typedef void (*GDExtensionInterfaceStringNameNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1540. /* INTERFACE: XMLParser Utilities */
  1541. /**
  1542. * @name xml_parser_open_buffer
  1543. * @since 4.1
  1544. *
  1545. * Opens a raw XML buffer on an XMLParser instance.
  1546. *
  1547. * @param p_instance A pointer to an XMLParser object.
  1548. * @param p_buffer A pointer to the buffer.
  1549. * @param p_size The size of the buffer.
  1550. *
  1551. * @return A Godot error code (ex. OK, ERR_INVALID_DATA, etc).
  1552. *
  1553. * @see XMLParser::open_buffer()
  1554. */
  1555. typedef GDExtensionInt (*GDExtensionInterfaceXmlParserOpenBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size);
  1556. /* INTERFACE: FileAccess Utilities */
  1557. /**
  1558. * @name file_access_store_buffer
  1559. * @since 4.1
  1560. *
  1561. * Stores the given buffer using an instance of FileAccess.
  1562. *
  1563. * @param p_instance A pointer to a FileAccess object.
  1564. * @param p_src A pointer to the buffer.
  1565. * @param p_length The size of the buffer.
  1566. *
  1567. * @see FileAccess::store_buffer()
  1568. */
  1569. typedef void (*GDExtensionInterfaceFileAccessStoreBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length);
  1570. /**
  1571. * @name file_access_get_buffer
  1572. * @since 4.1
  1573. *
  1574. * Reads the next p_length bytes into the given buffer using an instance of FileAccess.
  1575. *
  1576. * @param p_instance A pointer to a FileAccess object.
  1577. * @param p_dst A pointer to the buffer to store the data.
  1578. * @param p_length The requested number of bytes to read.
  1579. *
  1580. * @return The actual number of bytes read (may be less than requested).
  1581. */
  1582. typedef uint64_t (*GDExtensionInterfaceFileAccessGetBuffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);
  1583. /* INTERFACE: WorkerThreadPool Utilities */
  1584. /**
  1585. * @name worker_thread_pool_add_native_group_task
  1586. * @since 4.1
  1587. *
  1588. * Adds a group task to an instance of WorkerThreadPool.
  1589. *
  1590. * @param p_instance A pointer to a WorkerThreadPool object.
  1591. * @param p_func A pointer to a function to run in the thread pool.
  1592. * @param p_userdata A pointer to arbitrary data which will be passed to p_func.
  1593. * @param p_tasks The number of tasks needed in the group.
  1594. * @param p_high_priority Whether or not this is a high priority task.
  1595. * @param p_description A pointer to a String with the task description.
  1596. *
  1597. * @return The task group ID.
  1598. *
  1599. * @see WorkerThreadPool::add_group_task()
  1600. */
  1601. 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);
  1602. /**
  1603. * @name worker_thread_pool_add_native_task
  1604. * @since 4.1
  1605. *
  1606. * Adds a task to an instance of WorkerThreadPool.
  1607. *
  1608. * @param p_instance A pointer to a WorkerThreadPool object.
  1609. * @param p_func A pointer to a function to run in the thread pool.
  1610. * @param p_userdata A pointer to arbitrary data which will be passed to p_func.
  1611. * @param p_high_priority Whether or not this is a high priority task.
  1612. * @param p_description A pointer to a String with the task description.
  1613. *
  1614. * @return The task ID.
  1615. */
  1616. typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
  1617. /* INTERFACE: Packed Array */
  1618. /**
  1619. * @name packed_byte_array_operator_index
  1620. * @since 4.1
  1621. *
  1622. * Gets a pointer to a byte in a PackedByteArray.
  1623. *
  1624. * @param p_self A pointer to a PackedByteArray object.
  1625. * @param p_index The index of the byte to get.
  1626. *
  1627. * @return A pointer to the requested byte.
  1628. */
  1629. typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1630. /**
  1631. * @name packed_byte_array_operator_index_const
  1632. * @since 4.1
  1633. *
  1634. * Gets a const pointer to a byte in a PackedByteArray.
  1635. *
  1636. * @param p_self A const pointer to a PackedByteArray object.
  1637. * @param p_index The index of the byte to get.
  1638. *
  1639. * @return A const pointer to the requested byte.
  1640. */
  1641. typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1642. /**
  1643. * @name packed_color_array_operator_index
  1644. * @since 4.1
  1645. *
  1646. * Gets a pointer to a color in a PackedColorArray.
  1647. *
  1648. * @param p_self A pointer to a PackedColorArray object.
  1649. * @param p_index The index of the Color to get.
  1650. *
  1651. * @return A pointer to the requested Color.
  1652. */
  1653. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1654. /**
  1655. * @name packed_color_array_operator_index_const
  1656. * @since 4.1
  1657. *
  1658. * Gets a const pointer to a color in a PackedColorArray.
  1659. *
  1660. * @param p_self A const pointer to a const PackedColorArray object.
  1661. * @param p_index The index of the Color to get.
  1662. *
  1663. * @return A const pointer to the requested Color.
  1664. */
  1665. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1666. /**
  1667. * @name packed_float32_array_operator_index
  1668. * @since 4.1
  1669. *
  1670. * Gets a pointer to a 32-bit float in a PackedFloat32Array.
  1671. *
  1672. * @param p_self A pointer to a PackedFloat32Array object.
  1673. * @param p_index The index of the float to get.
  1674. *
  1675. * @return A pointer to the requested 32-bit float.
  1676. */
  1677. typedef float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1678. /**
  1679. * @name packed_float32_array_operator_index_const
  1680. * @since 4.1
  1681. *
  1682. * Gets a const pointer to a 32-bit float in a PackedFloat32Array.
  1683. *
  1684. * @param p_self A const pointer to a PackedFloat32Array object.
  1685. * @param p_index The index of the float to get.
  1686. *
  1687. * @return A const pointer to the requested 32-bit float.
  1688. */
  1689. typedef const float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1690. /**
  1691. * @name packed_float64_array_operator_index
  1692. * @since 4.1
  1693. *
  1694. * Gets a pointer to a 64-bit float in a PackedFloat64Array.
  1695. *
  1696. * @param p_self A pointer to a PackedFloat64Array object.
  1697. * @param p_index The index of the float to get.
  1698. *
  1699. * @return A pointer to the requested 64-bit float.
  1700. */
  1701. typedef double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1702. /**
  1703. * @name packed_float64_array_operator_index_const
  1704. * @since 4.1
  1705. *
  1706. * Gets a const pointer to a 64-bit float in a PackedFloat64Array.
  1707. *
  1708. * @param p_self A const pointer to a PackedFloat64Array object.
  1709. * @param p_index The index of the float to get.
  1710. *
  1711. * @return A const pointer to the requested 64-bit float.
  1712. */
  1713. typedef const double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1714. /**
  1715. * @name packed_int32_array_operator_index
  1716. * @since 4.1
  1717. *
  1718. * Gets a pointer to a 32-bit integer in a PackedInt32Array.
  1719. *
  1720. * @param p_self A pointer to a PackedInt32Array object.
  1721. * @param p_index The index of the integer to get.
  1722. *
  1723. * @return A pointer to the requested 32-bit integer.
  1724. */
  1725. typedef int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1726. /**
  1727. * @name packed_int32_array_operator_index_const
  1728. * @since 4.1
  1729. *
  1730. * Gets a const pointer to a 32-bit integer in a PackedInt32Array.
  1731. *
  1732. * @param p_self A const pointer to a PackedInt32Array object.
  1733. * @param p_index The index of the integer to get.
  1734. *
  1735. * @return A const pointer to the requested 32-bit integer.
  1736. */
  1737. typedef const int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1738. /**
  1739. * @name packed_int64_array_operator_index
  1740. * @since 4.1
  1741. *
  1742. * Gets a pointer to a 64-bit integer in a PackedInt64Array.
  1743. *
  1744. * @param p_self A pointer to a PackedInt64Array object.
  1745. * @param p_index The index of the integer to get.
  1746. *
  1747. * @return A pointer to the requested 64-bit integer.
  1748. */
  1749. typedef int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1750. /**
  1751. * @name packed_int64_array_operator_index_const
  1752. * @since 4.1
  1753. *
  1754. * Gets a const pointer to a 64-bit integer in a PackedInt64Array.
  1755. *
  1756. * @param p_self A const pointer to a PackedInt64Array object.
  1757. * @param p_index The index of the integer to get.
  1758. *
  1759. * @return A const pointer to the requested 64-bit integer.
  1760. */
  1761. typedef const int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1762. /**
  1763. * @name packed_string_array_operator_index
  1764. * @since 4.1
  1765. *
  1766. * Gets a pointer to a string in a PackedStringArray.
  1767. *
  1768. * @param p_self A pointer to a PackedStringArray object.
  1769. * @param p_index The index of the String to get.
  1770. *
  1771. * @return A pointer to the requested String.
  1772. */
  1773. typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1774. /**
  1775. * @name packed_string_array_operator_index_const
  1776. * @since 4.1
  1777. *
  1778. * Gets a const pointer to a string in a PackedStringArray.
  1779. *
  1780. * @param p_self A const pointer to a PackedStringArray object.
  1781. * @param p_index The index of the String to get.
  1782. *
  1783. * @return A const pointer to the requested String.
  1784. */
  1785. typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1786. /**
  1787. * @name packed_vector2_array_operator_index
  1788. * @since 4.1
  1789. *
  1790. * Gets a pointer to a Vector2 in a PackedVector2Array.
  1791. *
  1792. * @param p_self A pointer to a PackedVector2Array object.
  1793. * @param p_index The index of the Vector2 to get.
  1794. *
  1795. * @return A pointer to the requested Vector2.
  1796. */
  1797. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1798. /**
  1799. * @name packed_vector2_array_operator_index_const
  1800. * @since 4.1
  1801. *
  1802. * Gets a const pointer to a Vector2 in a PackedVector2Array.
  1803. *
  1804. * @param p_self A const pointer to a PackedVector2Array object.
  1805. * @param p_index The index of the Vector2 to get.
  1806. *
  1807. * @return A const pointer to the requested Vector2.
  1808. */
  1809. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1810. /**
  1811. * @name packed_vector3_array_operator_index
  1812. * @since 4.1
  1813. *
  1814. * Gets a pointer to a Vector3 in a PackedVector3Array.
  1815. *
  1816. * @param p_self A pointer to a PackedVector3Array object.
  1817. * @param p_index The index of the Vector3 to get.
  1818. *
  1819. * @return A pointer to the requested Vector3.
  1820. */
  1821. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1822. /**
  1823. * @name packed_vector3_array_operator_index_const
  1824. * @since 4.1
  1825. *
  1826. * Gets a const pointer to a Vector3 in a PackedVector3Array.
  1827. *
  1828. * @param p_self A const pointer to a PackedVector3Array object.
  1829. * @param p_index The index of the Vector3 to get.
  1830. *
  1831. * @return A const pointer to the requested Vector3.
  1832. */
  1833. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1834. /**
  1835. * @name array_operator_index
  1836. * @since 4.1
  1837. *
  1838. * Gets a pointer to a Variant in an Array.
  1839. *
  1840. * @param p_self A pointer to an Array object.
  1841. * @param p_index The index of the Variant to get.
  1842. *
  1843. * @return A pointer to the requested Variant.
  1844. */
  1845. typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1846. /**
  1847. * @name array_operator_index_const
  1848. * @since 4.1
  1849. *
  1850. * Gets a const pointer to a Variant in an Array.
  1851. *
  1852. * @param p_self A const pointer to an Array object.
  1853. * @param p_index The index of the Variant to get.
  1854. *
  1855. * @return A const pointer to the requested Variant.
  1856. */
  1857. typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1858. /**
  1859. * @name array_ref
  1860. * @since 4.1
  1861. *
  1862. * Sets an Array to be a reference to another Array object.
  1863. *
  1864. * @param p_self A pointer to the Array object to update.
  1865. * @param p_from A pointer to the Array object to reference.
  1866. */
  1867. typedef void (*GDExtensionInterfaceArrayRef)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from);
  1868. /**
  1869. * @name array_set_typed
  1870. * @since 4.1
  1871. *
  1872. * Makes an Array into a typed Array.
  1873. *
  1874. * @param p_self A pointer to the Array.
  1875. * @param p_type The type of Variant the Array will store.
  1876. * @param p_class_name A pointer to a StringName with the name of the object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT).
  1877. * @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).
  1878. */
  1879. typedef void (*GDExtensionInterfaceArraySetTyped)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script);
  1880. /* INTERFACE: Dictionary */
  1881. /**
  1882. * @name dictionary_operator_index
  1883. * @since 4.1
  1884. *
  1885. * Gets a pointer to a Variant in a Dictionary with the given key.
  1886. *
  1887. * @param p_self A pointer to a Dictionary object.
  1888. * @param p_key A pointer to a Variant representing the key.
  1889. *
  1890. * @return A pointer to a Variant representing the value at the given key.
  1891. */
  1892. typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key);
  1893. /**
  1894. * @name dictionary_operator_index_const
  1895. * @since 4.1
  1896. *
  1897. * Gets a const pointer to a Variant in a Dictionary with the given key.
  1898. *
  1899. * @param p_self A const pointer to a Dictionary object.
  1900. * @param p_key A pointer to a Variant representing the key.
  1901. *
  1902. * @return A const pointer to a Variant representing the value at the given key.
  1903. */
  1904. typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key);
  1905. /* INTERFACE: Object */
  1906. /**
  1907. * @name object_method_bind_call
  1908. * @since 4.1
  1909. *
  1910. * Calls a method on an Object.
  1911. *
  1912. * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
  1913. * @param p_instance A pointer to the Object.
  1914. * @param p_args A pointer to a C array of Variants representing the arguments.
  1915. * @param p_arg_count The number of arguments.
  1916. * @param r_ret A pointer to Variant which will receive the return value.
  1917. * @param r_error A pointer to a GDExtensionCallError struct that will receive error information.
  1918. */
  1919. typedef void (*GDExtensionInterfaceObjectMethodBindCall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionUninitializedVariantPtr r_ret, GDExtensionCallError *r_error);
  1920. /**
  1921. * @name object_method_bind_ptrcall
  1922. * @since 4.1
  1923. *
  1924. * Calls a method on an Object (using a "ptrcall").
  1925. *
  1926. * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
  1927. * @param p_instance A pointer to the Object.
  1928. * @param p_args A pointer to a C array representing the arguments.
  1929. * @param r_ret A pointer to the Object that will receive the return value.
  1930. */
  1931. typedef void (*GDExtensionInterfaceObjectMethodBindPtrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  1932. /**
  1933. * @name object_destroy
  1934. * @since 4.1
  1935. *
  1936. * Destroys an Object.
  1937. *
  1938. * @param p_o A pointer to the Object.
  1939. */
  1940. typedef void (*GDExtensionInterfaceObjectDestroy)(GDExtensionObjectPtr p_o);
  1941. /**
  1942. * @name global_get_singleton
  1943. * @since 4.1
  1944. *
  1945. * Gets a global singleton by name.
  1946. *
  1947. * @param p_name A pointer to a StringName with the singleton name.
  1948. *
  1949. * @return A pointer to the singleton Object.
  1950. */
  1951. typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensionConstStringNamePtr p_name);
  1952. /**
  1953. * @name object_get_instance_binding
  1954. * @since 4.1
  1955. *
  1956. * Gets a pointer representing an Object's instance binding.
  1957. *
  1958. * @param p_o A pointer to the Object.
  1959. * @param p_library A token the library received by the GDExtension's entry point function.
  1960. * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
  1961. *
  1962. * @return
  1963. */
  1964. typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  1965. /**
  1966. * @name object_set_instance_binding
  1967. * @since 4.1
  1968. *
  1969. * Sets an Object's instance binding.
  1970. *
  1971. * @param p_o A pointer to the Object.
  1972. * @param p_library A token the library received by the GDExtension's entry point function.
  1973. * @param p_binding A pointer to the instance binding.
  1974. * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
  1975. */
  1976. typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  1977. /**
  1978. * @name object_free_instance_binding
  1979. * @since 4.2
  1980. *
  1981. * Free an Object's instance binding.
  1982. *
  1983. * @param p_o A pointer to the Object.
  1984. * @param p_library A token the library received by the GDExtension's entry point function.
  1985. */
  1986. typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token);
  1987. /**
  1988. * @name object_set_instance
  1989. * @since 4.1
  1990. *
  1991. * Sets an extension class instance on a Object.
  1992. *
  1993. * @param p_o A pointer to the Object.
  1994. * @param p_classname A pointer to a StringName with the registered extension class's name.
  1995. * @param p_instance A pointer to the extension class instance.
  1996. */
  1997. 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. */
  1998. /**
  1999. * @name object_get_class_name
  2000. * @since 4.1
  2001. *
  2002. * Gets the class name of an Object.
  2003. *
  2004. * @param p_object A pointer to the Object.
  2005. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2006. * @param r_class_name A pointer to a String to receive the class name.
  2007. *
  2008. * @return true if successful in getting the class name; otherwise false.
  2009. */
  2010. typedef GDExtensionBool (*GDExtensionInterfaceObjectGetClassName)(GDExtensionConstObjectPtr p_object, GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringNamePtr r_class_name);
  2011. /**
  2012. * @name object_cast_to
  2013. * @since 4.1
  2014. *
  2015. * Casts an Object to a different type.
  2016. *
  2017. * @param p_object A pointer to the Object.
  2018. * @param p_class_tag A pointer uniquely identifying a built-in class in the ClassDB.
  2019. *
  2020. * @return Returns a pointer to the Object, or NULL if it can't be cast to the requested type.
  2021. */
  2022. typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectCastTo)(GDExtensionConstObjectPtr p_object, void *p_class_tag);
  2023. /**
  2024. * @name object_get_instance_from_id
  2025. * @since 4.1
  2026. *
  2027. * Gets an Object by its instance ID.
  2028. *
  2029. * @param p_instance_id The instance ID.
  2030. *
  2031. * @return A pointer to the Object.
  2032. */
  2033. typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectGetInstanceFromId)(GDObjectInstanceID p_instance_id);
  2034. /**
  2035. * @name object_get_instance_id
  2036. * @since 4.1
  2037. *
  2038. * Gets the instance ID from an Object.
  2039. *
  2040. * @param p_object A pointer to the Object.
  2041. *
  2042. * @return The instance ID.
  2043. */
  2044. typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensionConstObjectPtr p_object);
  2045. /**
  2046. * @name object_has_script_method
  2047. * @since 4.3
  2048. *
  2049. * Checks if this object has a script with the given method.
  2050. *
  2051. * @param p_object A pointer to the Object.
  2052. * @param p_method A pointer to a StringName identifying the method.
  2053. *
  2054. * @returns true if the object has a script and that script has a method with the given name. Returns false if the object has no script.
  2055. */
  2056. typedef GDExtensionBool (*GDExtensionInterfaceObjectHasScriptMethod)(GDExtensionConstObjectPtr p_object, GDExtensionConstStringNamePtr p_method);
  2057. /**
  2058. * @name object_call_script_method
  2059. * @since 4.3
  2060. *
  2061. * Call the given script method on this object.
  2062. *
  2063. * @param p_object A pointer to the Object.
  2064. * @param p_method A pointer to a StringName identifying the method.
  2065. * @param p_args A pointer to a C array of Variant.
  2066. * @param p_argument_count The number of arguments.
  2067. * @param r_return A pointer a Variant which will be assigned the return value.
  2068. * @param r_error A pointer the structure which will hold error information.
  2069. */
  2070. typedef void (*GDExtensionInterfaceObjectCallScriptMethod)(GDExtensionObjectPtr p_object, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
  2071. /* INTERFACE: Reference */
  2072. /**
  2073. * @name ref_get_object
  2074. * @since 4.1
  2075. *
  2076. * Gets the Object from a reference.
  2077. *
  2078. * @param p_ref A pointer to the reference.
  2079. *
  2080. * @return A pointer to the Object from the reference or NULL.
  2081. */
  2082. typedef GDExtensionObjectPtr (*GDExtensionInterfaceRefGetObject)(GDExtensionConstRefPtr p_ref);
  2083. /**
  2084. * @name ref_set_object
  2085. * @since 4.1
  2086. *
  2087. * Sets the Object referred to by a reference.
  2088. *
  2089. * @param p_ref A pointer to the reference.
  2090. * @param p_object A pointer to the Object to refer to.
  2091. */
  2092. typedef void (*GDExtensionInterfaceRefSetObject)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object);
  2093. /* INTERFACE: Script Instance */
  2094. /**
  2095. * @name script_instance_create
  2096. * @since 4.1
  2097. * @deprecated in Godot 4.2. Use `script_instance_create2` instead.
  2098. *
  2099. * Creates a script instance that contains the given info and instance data.
  2100. *
  2101. * @param p_info A pointer to a GDExtensionScriptInstanceInfo struct.
  2102. * @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.
  2103. *
  2104. * @return A pointer to a ScriptInstanceExtension object.
  2105. */
  2106. typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
  2107. /**
  2108. * @name script_instance_create2
  2109. * @since 4.2
  2110. *
  2111. * Creates a script instance that contains the given info and instance data.
  2112. *
  2113. * @param p_info A pointer to a GDExtensionScriptInstanceInfo2 struct.
  2114. * @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.
  2115. *
  2116. * @return A pointer to a ScriptInstanceExtension object.
  2117. */
  2118. typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate2)(const GDExtensionScriptInstanceInfo2 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
  2119. /**
  2120. * @name placeholder_script_instance_create
  2121. * @since 4.2
  2122. *
  2123. * Creates a placeholder script instance for a given script and instance.
  2124. *
  2125. * This interface is optional as a custom placeholder could also be created with script_instance_create().
  2126. *
  2127. * @param p_language A pointer to a ScriptLanguage.
  2128. * @param p_script A pointer to a Script.
  2129. * @param p_owner A pointer to an Object.
  2130. *
  2131. * @return A pointer to a PlaceHolderScriptInstance object.
  2132. */
  2133. typedef GDExtensionScriptInstancePtr (*GDExtensionInterfacePlaceHolderScriptInstanceCreate)(GDExtensionObjectPtr p_language, GDExtensionObjectPtr p_script, GDExtensionObjectPtr p_owner);
  2134. /**
  2135. * @name placeholder_script_instance_update
  2136. * @since 4.2
  2137. *
  2138. * Updates a placeholder script instance with the given properties and values.
  2139. *
  2140. * The passed in placeholder must be an instance of PlaceHolderScriptInstance
  2141. * such as the one returned by placeholder_script_instance_create().
  2142. *
  2143. * @param p_placeholder A pointer to a PlaceHolderScriptInstance.
  2144. * @param p_properties A pointer to an Array of Dictionary representing PropertyInfo.
  2145. * @param p_values A pointer to a Dictionary mapping StringName to Variant values.
  2146. */
  2147. typedef void (*GDExtensionInterfacePlaceHolderScriptInstanceUpdate)(GDExtensionScriptInstancePtr p_placeholder, GDExtensionConstTypePtr p_properties, GDExtensionConstTypePtr p_values);
  2148. /**
  2149. * @name object_get_script_instance
  2150. * @since 4.2
  2151. *
  2152. * Get the script instance data attached to this object.
  2153. *
  2154. * @param p_object A pointer to the Object.
  2155. * @param p_language A pointer to the language expected for this script instance.
  2156. *
  2157. * @return A GDExtensionScriptInstanceDataPtr that was attached to this object as part of script_instance_create.
  2158. */
  2159. typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptInstance)(GDExtensionConstObjectPtr p_object, GDExtensionObjectPtr p_language);
  2160. /* INTERFACE: Callable */
  2161. /**
  2162. * @name callable_custom_create
  2163. * @since 4.2
  2164. *
  2165. * Creates a custom Callable object from a function pointer.
  2166. *
  2167. * Provided struct can be safely freed once the function returns.
  2168. *
  2169. * @param r_callable A pointer that will receive the new Callable.
  2170. * @param p_callable_custom_info The info required to construct a Callable.
  2171. */
  2172. typedef void (*GDExtensionInterfaceCallableCustomCreate)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo *p_callable_custom_info);
  2173. /**
  2174. * @name callable_custom_get_userdata
  2175. * @since 4.2
  2176. *
  2177. * Retrieves the userdata pointer from a custom Callable.
  2178. *
  2179. * If the Callable is not a custom Callable or the token does not match the one provided to callable_custom_create() via GDExtensionCallableCustomInfo then NULL will be returned.
  2180. *
  2181. * @param p_callable A pointer to a Callable.
  2182. * @param p_token A pointer to an address that uniquely identifies the GDExtension.
  2183. */
  2184. typedef void *(*GDExtensionInterfaceCallableCustomGetUserData)(GDExtensionConstTypePtr p_callable, void *p_token);
  2185. /* INTERFACE: ClassDB */
  2186. /**
  2187. * @name classdb_construct_object
  2188. * @since 4.1
  2189. *
  2190. * Constructs an Object of the requested class.
  2191. *
  2192. * 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.
  2193. *
  2194. * @param p_classname A pointer to a StringName with the class name.
  2195. *
  2196. * @return A pointer to the newly created Object.
  2197. */
  2198. typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject)(GDExtensionConstStringNamePtr p_classname);
  2199. /**
  2200. * @name classdb_get_method_bind
  2201. * @since 4.1
  2202. *
  2203. * Gets a pointer to the MethodBind in ClassDB for the given class, method and hash.
  2204. *
  2205. * @param p_classname A pointer to a StringName with the class name.
  2206. * @param p_methodname A pointer to a StringName with the method name.
  2207. * @param p_hash A hash representing the function signature.
  2208. *
  2209. * @return A pointer to the MethodBind from ClassDB.
  2210. */
  2211. typedef GDExtensionMethodBindPtr (*GDExtensionInterfaceClassdbGetMethodBind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash);
  2212. /**
  2213. * @name classdb_get_class_tag
  2214. * @since 4.1
  2215. *
  2216. * Gets a pointer uniquely identifying the given built-in class in the ClassDB.
  2217. *
  2218. * @param p_classname A pointer to a StringName with the class name.
  2219. *
  2220. * @return A pointer uniquely identifying the built-in class in the ClassDB.
  2221. */
  2222. typedef void *(*GDExtensionInterfaceClassdbGetClassTag)(GDExtensionConstStringNamePtr p_classname);
  2223. /* INTERFACE: ClassDB Extension */
  2224. /**
  2225. * @name classdb_register_extension_class
  2226. * @since 4.1
  2227. * @deprecated in Godot 4.2. Use `classdb_register_extension_class2` instead.
  2228. *
  2229. * Registers an extension class in the ClassDB.
  2230. *
  2231. * Provided struct can be safely freed once the function returns.
  2232. *
  2233. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2234. * @param p_class_name A pointer to a StringName with the class name.
  2235. * @param p_parent_class_name A pointer to a StringName with the parent class name.
  2236. * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo struct.
  2237. */
  2238. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs);
  2239. /**
  2240. * @name classdb_register_extension_class2
  2241. * @since 4.2
  2242. *
  2243. * Registers an extension class in the ClassDB.
  2244. *
  2245. * Provided struct can be safely freed once the function returns.
  2246. *
  2247. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2248. * @param p_class_name A pointer to a StringName with the class name.
  2249. * @param p_parent_class_name A pointer to a StringName with the parent class name.
  2250. * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo2 struct.
  2251. */
  2252. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass2)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo2 *p_extension_funcs);
  2253. /**
  2254. * @name classdb_register_extension_class_method
  2255. * @since 4.1
  2256. *
  2257. * Registers a method on an extension class in the ClassDB.
  2258. *
  2259. * Provided struct can be safely freed once the function returns.
  2260. *
  2261. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2262. * @param p_class_name A pointer to a StringName with the class name.
  2263. * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct.
  2264. */
  2265. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info);
  2266. /**
  2267. * @name classdb_register_extension_class_virtual_method
  2268. * @since 4.3
  2269. *
  2270. * Registers a virtual method on an extension class in ClassDB, that can be implemented by scripts or other extensions.
  2271. *
  2272. * Provided struct can be safely freed once the function returns.
  2273. *
  2274. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2275. * @param p_class_name A pointer to a StringName with the class name.
  2276. * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct.
  2277. */
  2278. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassVirtualMethodInfo *p_method_info);
  2279. /**
  2280. * @name classdb_register_extension_class_integer_constant
  2281. * @since 4.1
  2282. *
  2283. * Registers an integer constant on an extension class in the ClassDB.
  2284. *
  2285. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2286. * @param p_class_name A pointer to a StringName with the class name.
  2287. * @param p_enum_name A pointer to a StringName with the enum name.
  2288. * @param p_constant_name A pointer to a StringName with the constant name.
  2289. * @param p_constant_value The constant value.
  2290. * @param p_is_bitfield Whether or not this is a bit field.
  2291. */
  2292. 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);
  2293. /**
  2294. * @name classdb_register_extension_class_property
  2295. * @since 4.1
  2296. *
  2297. * Registers a property on an extension class in the ClassDB.
  2298. *
  2299. * Provided struct can be safely freed once the function returns.
  2300. *
  2301. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2302. * @param p_class_name A pointer to a StringName with the class name.
  2303. * @param p_info A pointer to a GDExtensionPropertyInfo struct.
  2304. * @param p_setter A pointer to a StringName with the name of the setter method.
  2305. * @param p_getter A pointer to a StringName with the name of the getter method.
  2306. */
  2307. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassProperty)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter);
  2308. /**
  2309. * @name classdb_register_extension_class_property_indexed
  2310. * @since 4.2
  2311. *
  2312. * Registers an indexed property on an extension class in the ClassDB.
  2313. *
  2314. * Provided struct can be safely freed once the function returns.
  2315. *
  2316. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2317. * @param p_class_name A pointer to a StringName with the class name.
  2318. * @param p_info A pointer to a GDExtensionPropertyInfo struct.
  2319. * @param p_setter A pointer to a StringName with the name of the setter method.
  2320. * @param p_getter A pointer to a StringName with the name of the getter method.
  2321. * @param p_index The index to pass as the first argument to the getter and setter methods.
  2322. */
  2323. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter, GDExtensionInt p_index);
  2324. /**
  2325. * @name classdb_register_extension_class_property_group
  2326. * @since 4.1
  2327. *
  2328. * Registers a property group on an extension class in the ClassDB.
  2329. *
  2330. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2331. * @param p_class_name A pointer to a StringName with the class name.
  2332. * @param p_group_name A pointer to a String with the group name.
  2333. * @param p_prefix A pointer to a String with the prefix used by properties in this group.
  2334. */
  2335. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix);
  2336. /**
  2337. * @name classdb_register_extension_class_property_subgroup
  2338. * @since 4.1
  2339. *
  2340. * Registers a property subgroup on an extension class in the ClassDB.
  2341. *
  2342. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2343. * @param p_class_name A pointer to a StringName with the class name.
  2344. * @param p_subgroup_name A pointer to a String with the subgroup name.
  2345. * @param p_prefix A pointer to a String with the prefix used by properties in this subgroup.
  2346. */
  2347. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix);
  2348. /**
  2349. * @name classdb_register_extension_class_signal
  2350. * @since 4.1
  2351. *
  2352. * Registers a signal on an extension class in the ClassDB.
  2353. *
  2354. * Provided structs can be safely freed once the function returns.
  2355. *
  2356. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2357. * @param p_class_name A pointer to a StringName with the class name.
  2358. * @param p_signal_name A pointer to a StringName with the signal name.
  2359. * @param p_argument_info A pointer to a GDExtensionPropertyInfo struct.
  2360. * @param p_argument_count The number of arguments the signal receives.
  2361. */
  2362. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count);
  2363. /**
  2364. * @name classdb_unregister_extension_class
  2365. * @since 4.1
  2366. *
  2367. * Unregisters an extension class in the ClassDB.
  2368. *
  2369. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2370. * @param p_class_name A pointer to a StringName with the class name.
  2371. */
  2372. 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. */
  2373. /**
  2374. * @name get_library_path
  2375. * @since 4.1
  2376. *
  2377. * Gets the path to the current GDExtension library.
  2378. *
  2379. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2380. * @param r_path A pointer to a String which will receive the path.
  2381. */
  2382. typedef void (*GDExtensionInterfaceGetLibraryPath)(GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringPtr r_path);
  2383. /**
  2384. * @name editor_add_plugin
  2385. * @since 4.1
  2386. *
  2387. * Adds an editor plugin.
  2388. *
  2389. * It's safe to call during initialization.
  2390. *
  2391. * @param p_class_name A pointer to a StringName with the name of a class (descending from EditorPlugin) which is already registered with ClassDB.
  2392. */
  2393. typedef void (*GDExtensionInterfaceEditorAddPlugin)(GDExtensionConstStringNamePtr p_class_name);
  2394. /**
  2395. * @name editor_remove_plugin
  2396. * @since 4.1
  2397. *
  2398. * Removes an editor plugin.
  2399. *
  2400. * @param p_class_name A pointer to a StringName with the name of a class that was previously added as an editor plugin.
  2401. */
  2402. typedef void (*GDExtensionInterfaceEditorRemovePlugin)(GDExtensionConstStringNamePtr p_class_name);
  2403. #ifdef __cplusplus
  2404. }
  2405. #endif
  2406. #endif // GDEXTENSION_INTERFACE_H