gdextension_interface.h 131 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181
  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. #pragma once
  31. /* This is a C class header, you can copy it and use it directly in your own binders.
  32. * Together with the JSON file, you should be able to generate any binder.
  33. */
  34. #ifndef __cplusplus
  35. #include <stddef.h>
  36. #include <stdint.h>
  37. typedef uint32_t char32_t;
  38. typedef uint16_t char16_t;
  39. #else
  40. #include <cstddef>
  41. #include <cstdint>
  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_PACKED_VECTOR4_ARRAY,
  89. GDEXTENSION_VARIANT_TYPE_VARIANT_MAX
  90. } GDExtensionVariantType;
  91. typedef enum {
  92. /* comparison */
  93. GDEXTENSION_VARIANT_OP_EQUAL,
  94. GDEXTENSION_VARIANT_OP_NOT_EQUAL,
  95. GDEXTENSION_VARIANT_OP_LESS,
  96. GDEXTENSION_VARIANT_OP_LESS_EQUAL,
  97. GDEXTENSION_VARIANT_OP_GREATER,
  98. GDEXTENSION_VARIANT_OP_GREATER_EQUAL,
  99. /* mathematic */
  100. GDEXTENSION_VARIANT_OP_ADD,
  101. GDEXTENSION_VARIANT_OP_SUBTRACT,
  102. GDEXTENSION_VARIANT_OP_MULTIPLY,
  103. GDEXTENSION_VARIANT_OP_DIVIDE,
  104. GDEXTENSION_VARIANT_OP_NEGATE,
  105. GDEXTENSION_VARIANT_OP_POSITIVE,
  106. GDEXTENSION_VARIANT_OP_MODULE,
  107. GDEXTENSION_VARIANT_OP_POWER,
  108. /* bitwise */
  109. GDEXTENSION_VARIANT_OP_SHIFT_LEFT,
  110. GDEXTENSION_VARIANT_OP_SHIFT_RIGHT,
  111. GDEXTENSION_VARIANT_OP_BIT_AND,
  112. GDEXTENSION_VARIANT_OP_BIT_OR,
  113. GDEXTENSION_VARIANT_OP_BIT_XOR,
  114. GDEXTENSION_VARIANT_OP_BIT_NEGATE,
  115. /* logic */
  116. GDEXTENSION_VARIANT_OP_AND,
  117. GDEXTENSION_VARIANT_OP_OR,
  118. GDEXTENSION_VARIANT_OP_XOR,
  119. GDEXTENSION_VARIANT_OP_NOT,
  120. /* containment */
  121. GDEXTENSION_VARIANT_OP_IN,
  122. GDEXTENSION_VARIANT_OP_MAX
  123. } GDExtensionVariantOperator;
  124. // In this API there are multiple functions which expect the caller to pass a pointer
  125. // on return value as parameter.
  126. // In order to make it clear if the caller should initialize the return value or not
  127. // we have two flavor of types:
  128. // - `GDExtensionXXXPtr` for pointer on an initialized value
  129. // - `GDExtensionUninitializedXXXPtr` for pointer on uninitialized value
  130. //
  131. // Notes:
  132. // - Not respecting those requirements can seems harmless, but will lead to unexpected
  133. // segfault or memory leak (for instance with a specific compiler/OS, or when two
  134. // native extensions start doing ptrcall on each other).
  135. // - Initialization must be done with the function pointer returned by `variant_get_ptr_constructor`,
  136. // zero-initializing the variable should not be considered a valid initialization method here !
  137. // - Some types have no destructor (see `extension_api.json`'s `has_destructor` field), for
  138. // them it is always safe to skip the constructor for the return value if you are in a hurry ;-)
  139. typedef void *GDExtensionVariantPtr;
  140. typedef const void *GDExtensionConstVariantPtr;
  141. typedef void *GDExtensionUninitializedVariantPtr;
  142. typedef void *GDExtensionStringNamePtr;
  143. typedef const void *GDExtensionConstStringNamePtr;
  144. typedef void *GDExtensionUninitializedStringNamePtr;
  145. typedef void *GDExtensionStringPtr;
  146. typedef const void *GDExtensionConstStringPtr;
  147. typedef void *GDExtensionUninitializedStringPtr;
  148. typedef void *GDExtensionObjectPtr;
  149. typedef const void *GDExtensionConstObjectPtr;
  150. typedef void *GDExtensionUninitializedObjectPtr;
  151. typedef void *GDExtensionTypePtr;
  152. typedef const void *GDExtensionConstTypePtr;
  153. typedef void *GDExtensionUninitializedTypePtr;
  154. typedef const void *GDExtensionMethodBindPtr;
  155. typedef int64_t GDExtensionInt;
  156. typedef uint8_t GDExtensionBool;
  157. typedef uint64_t GDObjectInstanceID;
  158. typedef void *GDExtensionRefPtr;
  159. typedef const void *GDExtensionConstRefPtr;
  160. /* VARIANT DATA I/O */
  161. typedef enum {
  162. GDEXTENSION_CALL_OK,
  163. GDEXTENSION_CALL_ERROR_INVALID_METHOD,
  164. GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT, // Expected a different variant type.
  165. GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS, // Expected lower number of arguments.
  166. GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS, // Expected higher number of arguments.
  167. GDEXTENSION_CALL_ERROR_INSTANCE_IS_NULL,
  168. GDEXTENSION_CALL_ERROR_METHOD_NOT_CONST, // Used for const call.
  169. } GDExtensionCallErrorType;
  170. typedef struct {
  171. GDExtensionCallErrorType error;
  172. int32_t argument;
  173. int32_t expected;
  174. } GDExtensionCallError;
  175. typedef void (*GDExtensionVariantFromTypeConstructorFunc)(GDExtensionUninitializedVariantPtr, GDExtensionTypePtr);
  176. typedef void (*GDExtensionTypeFromVariantConstructorFunc)(GDExtensionUninitializedTypePtr, GDExtensionVariantPtr);
  177. typedef void *(*GDExtensionVariantGetInternalPtrFunc)(GDExtensionVariantPtr);
  178. typedef void (*GDExtensionPtrOperatorEvaluator)(GDExtensionConstTypePtr p_left, GDExtensionConstTypePtr p_right, GDExtensionTypePtr r_result);
  179. typedef void (*GDExtensionPtrBuiltInMethod)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return, int p_argument_count);
  180. typedef void (*GDExtensionPtrConstructor)(GDExtensionUninitializedTypePtr p_base, const GDExtensionConstTypePtr *p_args);
  181. typedef void (*GDExtensionPtrDestructor)(GDExtensionTypePtr p_base);
  182. typedef void (*GDExtensionPtrSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_value);
  183. typedef void (*GDExtensionPtrGetter)(GDExtensionConstTypePtr p_base, GDExtensionTypePtr r_value);
  184. typedef void (*GDExtensionPtrIndexedSetter)(GDExtensionTypePtr p_base, GDExtensionInt p_index, GDExtensionConstTypePtr p_value);
  185. typedef void (*GDExtensionPtrIndexedGetter)(GDExtensionConstTypePtr p_base, GDExtensionInt p_index, GDExtensionTypePtr r_value);
  186. typedef void (*GDExtensionPtrKeyedSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionConstTypePtr p_value);
  187. typedef void (*GDExtensionPtrKeyedGetter)(GDExtensionConstTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionTypePtr r_value);
  188. typedef uint32_t (*GDExtensionPtrKeyedChecker)(GDExtensionConstVariantPtr p_base, GDExtensionConstVariantPtr p_key);
  189. typedef void (*GDExtensionPtrUtilityFunction)(GDExtensionTypePtr r_return, const GDExtensionConstTypePtr *p_args, int p_argument_count);
  190. typedef GDExtensionObjectPtr (*GDExtensionClassConstructor)();
  191. typedef void *(*GDExtensionInstanceBindingCreateCallback)(void *p_token, void *p_instance);
  192. typedef void (*GDExtensionInstanceBindingFreeCallback)(void *p_token, void *p_instance, void *p_binding);
  193. typedef GDExtensionBool (*GDExtensionInstanceBindingReferenceCallback)(void *p_token, void *p_binding, GDExtensionBool p_reference);
  194. typedef struct {
  195. GDExtensionInstanceBindingCreateCallback create_callback;
  196. GDExtensionInstanceBindingFreeCallback free_callback;
  197. GDExtensionInstanceBindingReferenceCallback reference_callback;
  198. } GDExtensionInstanceBindingCallbacks;
  199. /* EXTENSION CLASSES */
  200. typedef void *GDExtensionClassInstancePtr;
  201. typedef GDExtensionBool (*GDExtensionClassSet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
  202. typedef GDExtensionBool (*GDExtensionClassGet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  203. typedef uint64_t (*GDExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance);
  204. typedef struct {
  205. GDExtensionVariantType type;
  206. GDExtensionStringNamePtr name;
  207. GDExtensionStringNamePtr class_name;
  208. uint32_t hint; // Bitfield of `PropertyHint` (defined in `extension_api.json`).
  209. GDExtensionStringPtr hint_string;
  210. uint32_t usage; // Bitfield of `PropertyUsageFlags` (defined in `extension_api.json`).
  211. } GDExtensionPropertyInfo;
  212. typedef struct {
  213. GDExtensionStringNamePtr name;
  214. GDExtensionPropertyInfo return_value;
  215. uint32_t flags; // Bitfield of `GDExtensionClassMethodFlags`.
  216. int32_t id;
  217. /* Arguments: `default_arguments` is an array of size `argument_count`. */
  218. uint32_t argument_count;
  219. GDExtensionPropertyInfo *arguments;
  220. /* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
  221. uint32_t default_argument_count;
  222. GDExtensionVariantPtr *default_arguments;
  223. } GDExtensionMethodInfo;
  224. typedef const GDExtensionPropertyInfo *(*GDExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count);
  225. typedef void (*GDExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list);
  226. typedef void (*GDExtensionClassFreePropertyList2)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list, uint32_t p_count);
  227. typedef GDExtensionBool (*GDExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name);
  228. typedef GDExtensionBool (*GDExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  229. typedef GDExtensionBool (*GDExtensionClassValidateProperty)(GDExtensionClassInstancePtr p_instance, GDExtensionPropertyInfo *p_property);
  230. typedef void (*GDExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionClassNotification2 instead.
  231. typedef void (*GDExtensionClassNotification2)(GDExtensionClassInstancePtr p_instance, int32_t p_what, GDExtensionBool p_reversed);
  232. typedef void (*GDExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr p_out);
  233. typedef void (*GDExtensionClassReference)(GDExtensionClassInstancePtr p_instance);
  234. typedef void (*GDExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance);
  235. typedef void (*GDExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  236. typedef GDExtensionObjectPtr (*GDExtensionClassCreateInstance)(void *p_class_userdata);
  237. typedef GDExtensionObjectPtr (*GDExtensionClassCreateInstance2)(void *p_class_userdata, GDExtensionBool p_notify_postinitialize);
  238. typedef void (*GDExtensionClassFreeInstance)(void *p_class_userdata, GDExtensionClassInstancePtr p_instance);
  239. typedef GDExtensionClassInstancePtr (*GDExtensionClassRecreateInstance)(void *p_class_userdata, GDExtensionObjectPtr p_object);
  240. typedef GDExtensionClassCallVirtual (*GDExtensionClassGetVirtual)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name);
  241. typedef GDExtensionClassCallVirtual (*GDExtensionClassGetVirtual2)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name, uint32_t p_hash);
  242. typedef void *(*GDExtensionClassGetVirtualCallData)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name);
  243. typedef void *(*GDExtensionClassGetVirtualCallData2)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name, uint32_t p_hash);
  244. typedef void (*GDExtensionClassCallVirtualWithData)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, void *p_virtual_call_userdata, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  245. typedef struct {
  246. GDExtensionBool is_virtual;
  247. GDExtensionBool is_abstract;
  248. GDExtensionClassSet set_func;
  249. GDExtensionClassGet get_func;
  250. GDExtensionClassGetPropertyList get_property_list_func;
  251. GDExtensionClassFreePropertyList free_property_list_func;
  252. GDExtensionClassPropertyCanRevert property_can_revert_func;
  253. GDExtensionClassPropertyGetRevert property_get_revert_func;
  254. GDExtensionClassNotification notification_func;
  255. GDExtensionClassToString to_string_func;
  256. GDExtensionClassReference reference_func;
  257. GDExtensionClassUnreference unreference_func;
  258. GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
  259. GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
  260. GDExtensionClassGetVirtual get_virtual_func; // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
  261. GDExtensionClassGetRID get_rid_func;
  262. void *class_userdata; // Per-class user data, later accessible in instance bindings.
  263. } GDExtensionClassCreationInfo; // Deprecated. Use GDExtensionClassCreationInfo4 instead.
  264. typedef struct {
  265. GDExtensionBool is_virtual;
  266. GDExtensionBool is_abstract;
  267. GDExtensionBool is_exposed;
  268. GDExtensionClassSet set_func;
  269. GDExtensionClassGet get_func;
  270. GDExtensionClassGetPropertyList get_property_list_func;
  271. GDExtensionClassFreePropertyList free_property_list_func;
  272. GDExtensionClassPropertyCanRevert property_can_revert_func;
  273. GDExtensionClassPropertyGetRevert property_get_revert_func;
  274. GDExtensionClassValidateProperty validate_property_func;
  275. GDExtensionClassNotification2 notification_func;
  276. GDExtensionClassToString to_string_func;
  277. GDExtensionClassReference reference_func;
  278. GDExtensionClassUnreference unreference_func;
  279. GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
  280. GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
  281. GDExtensionClassRecreateInstance recreate_instance_func;
  282. // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
  283. GDExtensionClassGetVirtual get_virtual_func;
  284. // Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that
  285. // need or benefit from extra data when calling virtual functions.
  286. // Returns user data that will be passed to `call_virtual_with_data_func`.
  287. // Returning `NULL` from this function signals to Godot that the virtual function is not overridden.
  288. // Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized.
  289. // You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`.
  290. GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
  291. // Used to call virtual functions when `get_virtual_call_data_func` is not null.
  292. GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
  293. GDExtensionClassGetRID get_rid_func;
  294. void *class_userdata; // Per-class user data, later accessible in instance bindings.
  295. } GDExtensionClassCreationInfo2; // Deprecated. Use GDExtensionClassCreationInfo4 instead.
  296. typedef struct {
  297. GDExtensionBool is_virtual;
  298. GDExtensionBool is_abstract;
  299. GDExtensionBool is_exposed;
  300. GDExtensionBool is_runtime;
  301. GDExtensionClassSet set_func;
  302. GDExtensionClassGet get_func;
  303. GDExtensionClassGetPropertyList get_property_list_func;
  304. GDExtensionClassFreePropertyList2 free_property_list_func;
  305. GDExtensionClassPropertyCanRevert property_can_revert_func;
  306. GDExtensionClassPropertyGetRevert property_get_revert_func;
  307. GDExtensionClassValidateProperty validate_property_func;
  308. GDExtensionClassNotification2 notification_func;
  309. GDExtensionClassToString to_string_func;
  310. GDExtensionClassReference reference_func;
  311. GDExtensionClassUnreference unreference_func;
  312. GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
  313. GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
  314. GDExtensionClassRecreateInstance recreate_instance_func;
  315. // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
  316. GDExtensionClassGetVirtual get_virtual_func;
  317. // Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that
  318. // need or benefit from extra data when calling virtual functions.
  319. // Returns user data that will be passed to `call_virtual_with_data_func`.
  320. // Returning `NULL` from this function signals to Godot that the virtual function is not overridden.
  321. // Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized.
  322. // You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`.
  323. GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
  324. // Used to call virtual functions when `get_virtual_call_data_func` is not null.
  325. GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
  326. GDExtensionClassGetRID get_rid_func;
  327. void *class_userdata; // Per-class user data, later accessible in instance bindings.
  328. } GDExtensionClassCreationInfo3; // Deprecated. Use GDExtensionClassCreationInfo4 instead.
  329. typedef struct {
  330. GDExtensionBool is_virtual;
  331. GDExtensionBool is_abstract;
  332. GDExtensionBool is_exposed;
  333. GDExtensionBool is_runtime;
  334. GDExtensionConstStringPtr icon_path;
  335. GDExtensionClassSet set_func;
  336. GDExtensionClassGet get_func;
  337. GDExtensionClassGetPropertyList get_property_list_func;
  338. GDExtensionClassFreePropertyList2 free_property_list_func;
  339. GDExtensionClassPropertyCanRevert property_can_revert_func;
  340. GDExtensionClassPropertyGetRevert property_get_revert_func;
  341. GDExtensionClassValidateProperty validate_property_func;
  342. GDExtensionClassNotification2 notification_func;
  343. GDExtensionClassToString to_string_func;
  344. GDExtensionClassReference reference_func;
  345. GDExtensionClassUnreference unreference_func;
  346. GDExtensionClassCreateInstance2 create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
  347. GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
  348. GDExtensionClassRecreateInstance recreate_instance_func;
  349. // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
  350. GDExtensionClassGetVirtual2 get_virtual_func;
  351. // Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that
  352. // need or benefit from extra data when calling virtual functions.
  353. // Returns user data that will be passed to `call_virtual_with_data_func`.
  354. // Returning `NULL` from this function signals to Godot that the virtual function is not overridden.
  355. // Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized.
  356. // You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`.
  357. GDExtensionClassGetVirtualCallData2 get_virtual_call_data_func;
  358. // Used to call virtual functions when `get_virtual_call_data_func` is not null.
  359. GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
  360. void *class_userdata; // Per-class user data, later accessible in instance bindings.
  361. } GDExtensionClassCreationInfo4;
  362. typedef void *GDExtensionClassLibraryPtr;
  363. /* Passed a pointer to a PackedStringArray that should be filled with the classes that may be used by the GDExtension. */
  364. typedef void (*GDExtensionEditorGetClassesUsedCallback)(GDExtensionTypePtr p_packed_string_array);
  365. /* Method */
  366. typedef enum {
  367. GDEXTENSION_METHOD_FLAG_NORMAL = 1,
  368. GDEXTENSION_METHOD_FLAG_EDITOR = 2,
  369. GDEXTENSION_METHOD_FLAG_CONST = 4,
  370. GDEXTENSION_METHOD_FLAG_VIRTUAL = 8,
  371. GDEXTENSION_METHOD_FLAG_VARARG = 16,
  372. GDEXTENSION_METHOD_FLAG_STATIC = 32,
  373. GDEXTENSION_METHOD_FLAGS_DEFAULT = GDEXTENSION_METHOD_FLAG_NORMAL,
  374. } GDExtensionClassMethodFlags;
  375. typedef enum {
  376. GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE,
  377. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8,
  378. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16,
  379. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32,
  380. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64,
  381. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8,
  382. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16,
  383. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32,
  384. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64,
  385. GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT,
  386. GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE,
  387. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_CHAR16,
  388. GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_CHAR32,
  389. } GDExtensionClassMethodArgumentMetadata;
  390. typedef void (*GDExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  391. typedef void (*GDExtensionClassMethodValidatedCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionVariantPtr r_return);
  392. typedef void (*GDExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  393. typedef struct {
  394. GDExtensionStringNamePtr name;
  395. void *method_userdata;
  396. GDExtensionClassMethodCall call_func;
  397. GDExtensionClassMethodPtrCall ptrcall_func;
  398. uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
  399. /* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored.
  400. *
  401. * @todo Consider dropping `has_return_value` and making the other two properties match `GDExtensionMethodInfo` and `GDExtensionClassVirtualMethod` for consistency in future version of this struct.
  402. */
  403. GDExtensionBool has_return_value;
  404. GDExtensionPropertyInfo *return_value_info;
  405. GDExtensionClassMethodArgumentMetadata return_value_metadata;
  406. /* Arguments: `arguments_info` and `arguments_metadata` are array of size `argument_count`.
  407. * Name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies.
  408. *
  409. * @todo Consider renaming `arguments_info` to `arguments` for consistency in future version of this struct.
  410. */
  411. uint32_t argument_count;
  412. GDExtensionPropertyInfo *arguments_info;
  413. GDExtensionClassMethodArgumentMetadata *arguments_metadata;
  414. /* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
  415. uint32_t default_argument_count;
  416. GDExtensionVariantPtr *default_arguments;
  417. } GDExtensionClassMethodInfo;
  418. typedef struct {
  419. GDExtensionStringNamePtr name;
  420. uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
  421. GDExtensionPropertyInfo return_value;
  422. GDExtensionClassMethodArgumentMetadata return_value_metadata;
  423. uint32_t argument_count;
  424. GDExtensionPropertyInfo *arguments;
  425. GDExtensionClassMethodArgumentMetadata *arguments_metadata;
  426. } GDExtensionClassVirtualMethodInfo;
  427. typedef void (*GDExtensionCallableCustomCall)(void *callable_userdata, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  428. typedef GDExtensionBool (*GDExtensionCallableCustomIsValid)(void *callable_userdata);
  429. typedef void (*GDExtensionCallableCustomFree)(void *callable_userdata);
  430. typedef uint32_t (*GDExtensionCallableCustomHash)(void *callable_userdata);
  431. typedef GDExtensionBool (*GDExtensionCallableCustomEqual)(void *callable_userdata_a, void *callable_userdata_b);
  432. typedef GDExtensionBool (*GDExtensionCallableCustomLessThan)(void *callable_userdata_a, void *callable_userdata_b);
  433. typedef void (*GDExtensionCallableCustomToString)(void *callable_userdata, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
  434. typedef GDExtensionInt (*GDExtensionCallableCustomGetArgumentCount)(void *callable_userdata, GDExtensionBool *r_is_valid);
  435. typedef struct {
  436. /* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
  437. *
  438. * `token` should point to an address that uniquely identifies the GDExtension (for example, the
  439. * `GDExtensionClassLibraryPtr` passed to the entry symbol function.
  440. *
  441. * `hash_func`, `equal_func`, and `less_than_func` are optional. If not provided both `call_func` and
  442. * `callable_userdata` together are used as the identity of the callable for hashing and comparison purposes.
  443. *
  444. * The hash returned by `hash_func` is cached, `hash_func` will not be called more than once per callable.
  445. *
  446. * `is_valid_func` is necessary if the validity of the callable can change before destruction.
  447. *
  448. * `free_func` is necessary if `callable_userdata` needs to be cleaned up when the callable is freed.
  449. */
  450. void *callable_userdata;
  451. void *token;
  452. GDObjectInstanceID object_id;
  453. GDExtensionCallableCustomCall call_func;
  454. GDExtensionCallableCustomIsValid is_valid_func;
  455. GDExtensionCallableCustomFree free_func;
  456. GDExtensionCallableCustomHash hash_func;
  457. GDExtensionCallableCustomEqual equal_func;
  458. GDExtensionCallableCustomLessThan less_than_func;
  459. GDExtensionCallableCustomToString to_string_func;
  460. } GDExtensionCallableCustomInfo; // Deprecated. Use GDExtensionCallableCustomInfo2 instead.
  461. typedef struct {
  462. /* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
  463. *
  464. * `token` should point to an address that uniquely identifies the GDExtension (for example, the
  465. * `GDExtensionClassLibraryPtr` passed to the entry symbol function.
  466. *
  467. * `hash_func`, `equal_func`, and `less_than_func` are optional. If not provided both `call_func` and
  468. * `callable_userdata` together are used as the identity of the callable for hashing and comparison purposes.
  469. *
  470. * The hash returned by `hash_func` is cached, `hash_func` will not be called more than once per callable.
  471. *
  472. * `is_valid_func` is necessary if the validity of the callable can change before destruction.
  473. *
  474. * `free_func` is necessary if `callable_userdata` needs to be cleaned up when the callable is freed.
  475. */
  476. void *callable_userdata;
  477. void *token;
  478. GDObjectInstanceID object_id;
  479. GDExtensionCallableCustomCall call_func;
  480. GDExtensionCallableCustomIsValid is_valid_func;
  481. GDExtensionCallableCustomFree free_func;
  482. GDExtensionCallableCustomHash hash_func;
  483. GDExtensionCallableCustomEqual equal_func;
  484. GDExtensionCallableCustomLessThan less_than_func;
  485. GDExtensionCallableCustomToString to_string_func;
  486. GDExtensionCallableCustomGetArgumentCount get_argument_count_func;
  487. } GDExtensionCallableCustomInfo2;
  488. /* SCRIPT INSTANCE EXTENSION */
  489. typedef void *GDExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation.
  490. typedef GDExtensionBool (*GDExtensionScriptInstanceSet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
  491. typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  492. typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
  493. typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list); // Deprecated. Use GDExtensionScriptInstanceFreePropertyList2 instead.
  494. typedef void (*GDExtensionScriptInstanceFreePropertyList2)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list, uint32_t p_count);
  495. typedef GDExtensionBool (*GDExtensionScriptInstanceGetClassCategory)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_class_category);
  496. typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
  497. typedef GDExtensionBool (*GDExtensionScriptInstanceValidateProperty)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_property);
  498. typedef GDExtensionBool (*GDExtensionScriptInstancePropertyCanRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
  499. typedef GDExtensionBool (*GDExtensionScriptInstancePropertyGetRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
  500. typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetOwner)(GDExtensionScriptInstanceDataPtr p_instance);
  501. typedef void (*GDExtensionScriptInstancePropertyStateAdd)(GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value, void *p_userdata);
  502. typedef void (*GDExtensionScriptInstanceGetPropertyState)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata);
  503. typedef const GDExtensionMethodInfo *(*GDExtensionScriptInstanceGetMethodList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
  504. typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list); // Deprecated. Use GDExtensionScriptInstanceFreeMethodList2 instead.
  505. typedef void (*GDExtensionScriptInstanceFreeMethodList2)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list, uint32_t p_count);
  506. typedef GDExtensionBool (*GDExtensionScriptInstanceHasMethod)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
  507. typedef GDExtensionInt (*GDExtensionScriptInstanceGetMethodArgumentCount)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
  508. typedef void (*GDExtensionScriptInstanceCall)(GDExtensionScriptInstanceDataPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
  509. typedef void (*GDExtensionScriptInstanceNotification)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionScriptInstanceNotification2 instead.
  510. typedef void (*GDExtensionScriptInstanceNotification2)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what, GDExtensionBool p_reversed);
  511. typedef void (*GDExtensionScriptInstanceToString)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
  512. typedef void (*GDExtensionScriptInstanceRefCountIncremented)(GDExtensionScriptInstanceDataPtr p_instance);
  513. typedef GDExtensionBool (*GDExtensionScriptInstanceRefCountDecremented)(GDExtensionScriptInstanceDataPtr p_instance);
  514. typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetScript)(GDExtensionScriptInstanceDataPtr p_instance);
  515. typedef GDExtensionBool (*GDExtensionScriptInstanceIsPlaceholder)(GDExtensionScriptInstanceDataPtr p_instance);
  516. typedef void *GDExtensionScriptLanguagePtr;
  517. typedef GDExtensionScriptLanguagePtr (*GDExtensionScriptInstanceGetLanguage)(GDExtensionScriptInstanceDataPtr p_instance);
  518. typedef void (*GDExtensionScriptInstanceFree)(GDExtensionScriptInstanceDataPtr p_instance);
  519. typedef void *GDExtensionScriptInstancePtr; // Pointer to ScriptInstance.
  520. typedef struct {
  521. GDExtensionScriptInstanceSet set_func;
  522. GDExtensionScriptInstanceGet get_func;
  523. GDExtensionScriptInstanceGetPropertyList get_property_list_func;
  524. GDExtensionScriptInstanceFreePropertyList free_property_list_func;
  525. GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
  526. GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
  527. GDExtensionScriptInstanceGetOwner get_owner_func;
  528. GDExtensionScriptInstanceGetPropertyState get_property_state_func;
  529. GDExtensionScriptInstanceGetMethodList get_method_list_func;
  530. GDExtensionScriptInstanceFreeMethodList free_method_list_func;
  531. GDExtensionScriptInstanceGetPropertyType get_property_type_func;
  532. GDExtensionScriptInstanceHasMethod has_method_func;
  533. GDExtensionScriptInstanceCall call_func;
  534. GDExtensionScriptInstanceNotification notification_func;
  535. GDExtensionScriptInstanceToString to_string_func;
  536. GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
  537. GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
  538. GDExtensionScriptInstanceGetScript get_script_func;
  539. GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
  540. GDExtensionScriptInstanceSet set_fallback_func;
  541. GDExtensionScriptInstanceGet get_fallback_func;
  542. GDExtensionScriptInstanceGetLanguage get_language_func;
  543. GDExtensionScriptInstanceFree free_func;
  544. } GDExtensionScriptInstanceInfo; // Deprecated. Use GDExtensionScriptInstanceInfo3 instead.
  545. typedef struct {
  546. GDExtensionScriptInstanceSet set_func;
  547. GDExtensionScriptInstanceGet get_func;
  548. GDExtensionScriptInstanceGetPropertyList get_property_list_func;
  549. GDExtensionScriptInstanceFreePropertyList free_property_list_func;
  550. GDExtensionScriptInstanceGetClassCategory get_class_category_func; // Optional. Set to NULL for the default behavior.
  551. GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
  552. GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
  553. GDExtensionScriptInstanceGetOwner get_owner_func;
  554. GDExtensionScriptInstanceGetPropertyState get_property_state_func;
  555. GDExtensionScriptInstanceGetMethodList get_method_list_func;
  556. GDExtensionScriptInstanceFreeMethodList free_method_list_func;
  557. GDExtensionScriptInstanceGetPropertyType get_property_type_func;
  558. GDExtensionScriptInstanceValidateProperty validate_property_func;
  559. GDExtensionScriptInstanceHasMethod has_method_func;
  560. GDExtensionScriptInstanceCall call_func;
  561. GDExtensionScriptInstanceNotification2 notification_func;
  562. GDExtensionScriptInstanceToString to_string_func;
  563. GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
  564. GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
  565. GDExtensionScriptInstanceGetScript get_script_func;
  566. GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
  567. GDExtensionScriptInstanceSet set_fallback_func;
  568. GDExtensionScriptInstanceGet get_fallback_func;
  569. GDExtensionScriptInstanceGetLanguage get_language_func;
  570. GDExtensionScriptInstanceFree free_func;
  571. } GDExtensionScriptInstanceInfo2; // Deprecated. Use GDExtensionScriptInstanceInfo3 instead.
  572. typedef struct {
  573. GDExtensionScriptInstanceSet set_func;
  574. GDExtensionScriptInstanceGet get_func;
  575. GDExtensionScriptInstanceGetPropertyList get_property_list_func;
  576. GDExtensionScriptInstanceFreePropertyList2 free_property_list_func;
  577. GDExtensionScriptInstanceGetClassCategory get_class_category_func; // Optional. Set to NULL for the default behavior.
  578. GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
  579. GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
  580. GDExtensionScriptInstanceGetOwner get_owner_func;
  581. GDExtensionScriptInstanceGetPropertyState get_property_state_func;
  582. GDExtensionScriptInstanceGetMethodList get_method_list_func;
  583. GDExtensionScriptInstanceFreeMethodList2 free_method_list_func;
  584. GDExtensionScriptInstanceGetPropertyType get_property_type_func;
  585. GDExtensionScriptInstanceValidateProperty validate_property_func;
  586. GDExtensionScriptInstanceHasMethod has_method_func;
  587. GDExtensionScriptInstanceGetMethodArgumentCount get_method_argument_count_func;
  588. GDExtensionScriptInstanceCall call_func;
  589. GDExtensionScriptInstanceNotification2 notification_func;
  590. GDExtensionScriptInstanceToString to_string_func;
  591. GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
  592. GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
  593. GDExtensionScriptInstanceGetScript get_script_func;
  594. GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
  595. GDExtensionScriptInstanceSet set_fallback_func;
  596. GDExtensionScriptInstanceGet get_fallback_func;
  597. GDExtensionScriptInstanceGetLanguage get_language_func;
  598. GDExtensionScriptInstanceFree free_func;
  599. } GDExtensionScriptInstanceInfo3;
  600. typedef void (*GDExtensionWorkerThreadPoolGroupTask)(void *, uint32_t);
  601. typedef void (*GDExtensionWorkerThreadPoolTask)(void *);
  602. /* INITIALIZATION */
  603. typedef enum {
  604. GDEXTENSION_INITIALIZATION_CORE,
  605. GDEXTENSION_INITIALIZATION_SERVERS,
  606. GDEXTENSION_INITIALIZATION_SCENE,
  607. GDEXTENSION_INITIALIZATION_EDITOR,
  608. GDEXTENSION_MAX_INITIALIZATION_LEVEL,
  609. } GDExtensionInitializationLevel;
  610. typedef void (*GDExtensionInitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
  611. typedef void (*GDExtensionDeinitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
  612. typedef struct {
  613. /* Minimum initialization level required.
  614. * If Core or Servers, the extension needs editor or game restart to take effect */
  615. GDExtensionInitializationLevel minimum_initialization_level;
  616. /* Up to the user to supply when initializing */
  617. void *userdata;
  618. /* This function will be called multiple times for each initialization level. */
  619. GDExtensionInitializeCallback initialize;
  620. GDExtensionDeinitializeCallback deinitialize;
  621. } GDExtensionInitialization;
  622. typedef void (*GDExtensionInterfaceFunctionPtr)();
  623. typedef GDExtensionInterfaceFunctionPtr (*GDExtensionInterfaceGetProcAddress)(const char *p_function_name);
  624. /*
  625. * Each GDExtension should define a C function that matches the signature of GDExtensionInitializationFunction,
  626. * and export it so that it can be loaded via dlopen() or equivalent for the given platform.
  627. *
  628. * For example:
  629. *
  630. * GDExtensionBool my_extension_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
  631. *
  632. * This function's name must be specified as the 'entry_symbol' in the .gdextension file.
  633. *
  634. * This makes it the entry point of the GDExtension and will be called on initialization.
  635. *
  636. * The GDExtension can then modify the r_initialization structure, setting the minimum initialization level,
  637. * and providing pointers to functions that will be called at various stages of initialization/shutdown.
  638. *
  639. * The rest of the GDExtension's interface to Godot consists of function pointers that can be loaded
  640. * by calling p_get_proc_address("...") with the name of the function.
  641. *
  642. * For example:
  643. *
  644. * GDExtensionInterfaceGetGodotVersion get_godot_version = (GDExtensionInterfaceGetGodotVersion)p_get_proc_address("get_godot_version");
  645. *
  646. * (Note that snippet may cause "cast between incompatible function types" on some compilers, you can
  647. * silence this by adding an intermediary `void*` cast.)
  648. *
  649. * You can then call it like a normal function:
  650. *
  651. * GDExtensionGodotVersion godot_version;
  652. * get_godot_version(&godot_version);
  653. * printf("Godot v%d.%d.%d\n", godot_version.major, godot_version.minor, godot_version.patch);
  654. *
  655. * All of these interface functions are described below, together with the name that's used to load it,
  656. * and the function pointer typedef that shows its signature.
  657. */
  658. typedef GDExtensionBool (*GDExtensionInitializationFunction)(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
  659. /* INTERFACE */
  660. typedef struct {
  661. uint32_t major;
  662. uint32_t minor;
  663. uint32_t patch;
  664. const char *string;
  665. } GDExtensionGodotVersion;
  666. typedef struct {
  667. uint32_t major;
  668. uint32_t minor;
  669. uint32_t patch;
  670. uint32_t hex; // Full version encoded as hexadecimal with one byte (2 hex digits) per number (e.g. for "3.1.12" it would be 0x03010C)
  671. const char *status; // (e.g. "stable", "beta", "rc1", "rc2")
  672. const char *build; // (e.g. "custom_build")
  673. const char *hash; // Full Git commit hash.
  674. uint64_t timestamp; // Git commit date UNIX timestamp in seconds, or 0 if unavailable.
  675. const char *string; // (e.g. "Godot v3.1.4.stable.official.mono")
  676. } GDExtensionGodotVersion2;
  677. /* Called when starting the main loop. */
  678. typedef void (*GDExtensionMainLoopStartupCallback)();
  679. /* Called when shutting down the main loop. */
  680. typedef void (*GDExtensionMainLoopShutdownCallback)();
  681. /* Called for every frame iteration of the main loop. */
  682. typedef void (*GDExtensionMainLoopFrameCallback)();
  683. typedef struct {
  684. // Will be called after Godot is started and is fully initialized.
  685. GDExtensionMainLoopStartupCallback startup_func;
  686. // Will be called before Godot is shutdown when it is still fully initialized.
  687. GDExtensionMainLoopShutdownCallback shutdown_func;
  688. // Will be called for each process frame. This will run after all `_process()` methods on Node, and before `ScriptServer::frame()`.
  689. // This is intended to be the equivalent of `ScriptLanguage::frame()` for GDExtension language bindings that don't use the script API.
  690. GDExtensionMainLoopFrameCallback frame_func;
  691. } GDExtensionMainLoopCallbacks;
  692. /**
  693. * @name get_godot_version
  694. * @since 4.1
  695. * @deprecated in Godot 4.5. Use `get_godot_version2` instead.
  696. *
  697. * Gets the Godot version that the GDExtension was loaded into.
  698. *
  699. * @param r_godot_version A pointer to the structure to write the version information into.
  700. */
  701. typedef void (*GDExtensionInterfaceGetGodotVersion)(GDExtensionGodotVersion *r_godot_version);
  702. /**
  703. * @name get_godot_version2
  704. * @since 4.5
  705. *
  706. * Gets the Godot version that the GDExtension was loaded into.
  707. *
  708. * @param r_godot_version A pointer to the structure to write the version information into.
  709. */
  710. typedef void (*GDExtensionInterfaceGetGodotVersion2)(GDExtensionGodotVersion2 *r_godot_version);
  711. /* INTERFACE: Memory */
  712. /**
  713. * @name mem_alloc
  714. * @since 4.1
  715. *
  716. * Allocates memory.
  717. *
  718. * @param p_bytes The amount of memory to allocate in bytes.
  719. *
  720. * @return A pointer to the allocated memory, or NULL if unsuccessful.
  721. */
  722. typedef void *(*GDExtensionInterfaceMemAlloc)(size_t p_bytes);
  723. /**
  724. * @name mem_realloc
  725. * @since 4.1
  726. *
  727. * Reallocates memory.
  728. *
  729. * @param p_ptr A pointer to the previously allocated memory.
  730. * @param p_bytes The number of bytes to resize the memory block to.
  731. *
  732. * @return A pointer to the allocated memory, or NULL if unsuccessful.
  733. */
  734. typedef void *(*GDExtensionInterfaceMemRealloc)(void *p_ptr, size_t p_bytes);
  735. /**
  736. * @name mem_free
  737. * @since 4.1
  738. *
  739. * Frees memory.
  740. *
  741. * @param p_ptr A pointer to the previously allocated memory.
  742. */
  743. typedef void (*GDExtensionInterfaceMemFree)(void *p_ptr);
  744. /* INTERFACE: Godot Core */
  745. /**
  746. * @name print_error
  747. * @since 4.1
  748. *
  749. * Logs an error to Godot's built-in debugger and to the OS terminal.
  750. *
  751. * @param p_description The code triggering the error.
  752. * @param p_function The function name where the error occurred.
  753. * @param p_file The file where the error occurred.
  754. * @param p_line The line where the error occurred.
  755. * @param p_editor_notify Whether or not to notify the editor.
  756. */
  757. typedef void (*GDExtensionInterfacePrintError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  758. /**
  759. * @name print_error_with_message
  760. * @since 4.1
  761. *
  762. * Logs an error with a message to Godot's built-in debugger and to the OS terminal.
  763. *
  764. * @param p_description The code triggering the error.
  765. * @param p_message The message to show along with the error.
  766. * @param p_function The function name where the error occurred.
  767. * @param p_file The file where the error occurred.
  768. * @param p_line The line where the error occurred.
  769. * @param p_editor_notify Whether or not to notify the editor.
  770. */
  771. 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);
  772. /**
  773. * @name print_warning
  774. * @since 4.1
  775. *
  776. * Logs a warning to Godot's built-in debugger and to the OS terminal.
  777. *
  778. * @param p_description The code triggering the warning.
  779. * @param p_function The function name where the warning occurred.
  780. * @param p_file The file where the warning occurred.
  781. * @param p_line The line where the warning occurred.
  782. * @param p_editor_notify Whether or not to notify the editor.
  783. */
  784. typedef void (*GDExtensionInterfacePrintWarning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  785. /**
  786. * @name print_warning_with_message
  787. * @since 4.1
  788. *
  789. * Logs a warning with a message to Godot's built-in debugger and to the OS terminal.
  790. *
  791. * @param p_description The code triggering the warning.
  792. * @param p_message The message to show along with the warning.
  793. * @param p_function The function name where the warning occurred.
  794. * @param p_file The file where the warning occurred.
  795. * @param p_line The line where the warning occurred.
  796. * @param p_editor_notify Whether or not to notify the editor.
  797. */
  798. 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);
  799. /**
  800. * @name print_script_error
  801. * @since 4.1
  802. *
  803. * Logs a script error to Godot's built-in debugger and to the OS terminal.
  804. *
  805. * @param p_description The code triggering the error.
  806. * @param p_function The function name where the error occurred.
  807. * @param p_file The file where the error occurred.
  808. * @param p_line The line where the error occurred.
  809. * @param p_editor_notify Whether or not to notify the editor.
  810. */
  811. typedef void (*GDExtensionInterfacePrintScriptError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
  812. /**
  813. * @name print_script_error_with_message
  814. * @since 4.1
  815. *
  816. * Logs a script error with a message to Godot's built-in debugger and to the OS terminal.
  817. *
  818. * @param p_description The code triggering the error.
  819. * @param p_message The message to show along with the error.
  820. * @param p_function The function name where the error occurred.
  821. * @param p_file The file where the error occurred.
  822. * @param p_line The line where the error occurred.
  823. * @param p_editor_notify Whether or not to notify the editor.
  824. */
  825. 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);
  826. /**
  827. * @name get_native_struct_size
  828. * @since 4.1
  829. *
  830. * Gets the size of a native struct (ex. ObjectID) in bytes.
  831. *
  832. * @param p_name A pointer to a StringName identifying the struct name.
  833. *
  834. * @return The size in bytes.
  835. */
  836. typedef uint64_t (*GDExtensionInterfaceGetNativeStructSize)(GDExtensionConstStringNamePtr p_name);
  837. /* INTERFACE: Variant */
  838. /**
  839. * @name variant_new_copy
  840. * @since 4.1
  841. *
  842. * Copies one Variant into a another.
  843. *
  844. * @param r_dest A pointer to the destination Variant.
  845. * @param p_src A pointer to the source Variant.
  846. */
  847. typedef void (*GDExtensionInterfaceVariantNewCopy)(GDExtensionUninitializedVariantPtr r_dest, GDExtensionConstVariantPtr p_src);
  848. /**
  849. * @name variant_new_nil
  850. * @since 4.1
  851. *
  852. * Creates a new Variant containing nil.
  853. *
  854. * @param r_dest A pointer to the destination Variant.
  855. */
  856. typedef void (*GDExtensionInterfaceVariantNewNil)(GDExtensionUninitializedVariantPtr r_dest);
  857. /**
  858. * @name variant_destroy
  859. * @since 4.1
  860. *
  861. * Destroys a Variant.
  862. *
  863. * @param p_self A pointer to the Variant to destroy.
  864. */
  865. typedef void (*GDExtensionInterfaceVariantDestroy)(GDExtensionVariantPtr p_self);
  866. /**
  867. * @name variant_call
  868. * @since 4.1
  869. *
  870. * Calls a method on a Variant.
  871. *
  872. * @param p_self A pointer to the Variant.
  873. * @param p_method A pointer to a StringName identifying the method.
  874. * @param p_args A pointer to a C array of Variant.
  875. * @param p_argument_count The number of arguments.
  876. * @param r_return A pointer a Variant which will be assigned the return value.
  877. * @param r_error A pointer the structure which will hold error information.
  878. *
  879. * @see Variant::callp()
  880. */
  881. typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
  882. /**
  883. * @name variant_call_static
  884. * @since 4.1
  885. *
  886. * Calls a static method on a Variant.
  887. *
  888. * @param p_type The variant type.
  889. * @param p_method A pointer to a StringName identifying the method.
  890. * @param p_args A pointer to a C array of Variant.
  891. * @param p_argument_count The number of arguments.
  892. * @param r_return A pointer a Variant which will be assigned the return value.
  893. * @param r_error A pointer the structure which will be updated with error information.
  894. *
  895. * @see Variant::call_static()
  896. */
  897. typedef void (*GDExtensionInterfaceVariantCallStatic)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
  898. /**
  899. * @name variant_evaluate
  900. * @since 4.1
  901. *
  902. * Evaluate an operator on two Variants.
  903. *
  904. * @param p_op The operator to evaluate.
  905. * @param p_a The first Variant.
  906. * @param p_b The second Variant.
  907. * @param r_return A pointer a Variant which will be assigned the return value.
  908. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  909. *
  910. * @see Variant::evaluate()
  911. */
  912. typedef void (*GDExtensionInterfaceVariantEvaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionUninitializedVariantPtr r_return, GDExtensionBool *r_valid);
  913. /**
  914. * @name variant_set
  915. * @since 4.1
  916. *
  917. * Sets a key on a Variant to a value.
  918. *
  919. * @param p_self A pointer to the Variant.
  920. * @param p_key A pointer to a Variant representing the key.
  921. * @param p_value A pointer to a Variant representing the value.
  922. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  923. *
  924. * @see Variant::set()
  925. */
  926. typedef void (*GDExtensionInterfaceVariantSet)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  927. /**
  928. * @name variant_set_named
  929. * @since 4.1
  930. *
  931. * Sets a named key on a Variant to a value.
  932. *
  933. * @param p_self A pointer to the Variant.
  934. * @param p_key A pointer to a StringName representing the key.
  935. * @param p_value A pointer to a Variant representing the value.
  936. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  937. *
  938. * @see Variant::set_named()
  939. */
  940. typedef void (*GDExtensionInterfaceVariantSetNamed)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  941. /**
  942. * @name variant_set_keyed
  943. * @since 4.1
  944. *
  945. * Sets a keyed property on a Variant to a value.
  946. *
  947. * @param p_self A pointer to the Variant.
  948. * @param p_key A pointer to a Variant representing the key.
  949. * @param p_value A pointer to a Variant representing the value.
  950. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  951. *
  952. * @see Variant::set_keyed()
  953. */
  954. typedef void (*GDExtensionInterfaceVariantSetKeyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
  955. /**
  956. * @name variant_set_indexed
  957. * @since 4.1
  958. *
  959. * Sets an index on a Variant to a value.
  960. *
  961. * @param p_self A pointer to the Variant.
  962. * @param p_index The index.
  963. * @param p_value A pointer to a Variant representing the value.
  964. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  965. * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
  966. */
  967. typedef void (*GDExtensionInterfaceVariantSetIndexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  968. /**
  969. * @name variant_get
  970. * @since 4.1
  971. *
  972. * Gets the value of a key from a Variant.
  973. *
  974. * @param p_self A pointer to the Variant.
  975. * @param p_key A pointer to a Variant representing the key.
  976. * @param r_ret A pointer to a Variant which will be assigned the value.
  977. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  978. */
  979. typedef void (*GDExtensionInterfaceVariantGet)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  980. /**
  981. * @name variant_get_named
  982. * @since 4.1
  983. *
  984. * Gets the value of a named key from a Variant.
  985. *
  986. * @param p_self A pointer to the Variant.
  987. * @param p_key A pointer to a StringName representing the key.
  988. * @param r_ret A pointer to a Variant which will be assigned the value.
  989. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  990. */
  991. typedef void (*GDExtensionInterfaceVariantGetNamed)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  992. /**
  993. * @name variant_get_keyed
  994. * @since 4.1
  995. *
  996. * Gets the value of a keyed property from a Variant.
  997. *
  998. * @param p_self A pointer to the Variant.
  999. * @param p_key A pointer to a Variant representing the key.
  1000. * @param r_ret A pointer to a Variant which will be assigned the value.
  1001. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  1002. */
  1003. typedef void (*GDExtensionInterfaceVariantGetKeyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  1004. /**
  1005. * @name variant_get_indexed
  1006. * @since 4.1
  1007. *
  1008. * Gets the value of an index from a Variant.
  1009. *
  1010. * @param p_self A pointer to the Variant.
  1011. * @param p_index The index.
  1012. * @param r_ret A pointer to a Variant which will be assigned the value.
  1013. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  1014. * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
  1015. */
  1016. typedef void (*GDExtensionInterfaceVariantGetIndexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
  1017. /**
  1018. * @name variant_iter_init
  1019. * @since 4.1
  1020. *
  1021. * Initializes an iterator over a Variant.
  1022. *
  1023. * @param p_self A pointer to the Variant.
  1024. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  1025. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  1026. *
  1027. * @return true if the operation is valid; otherwise false.
  1028. *
  1029. * @see Variant::iter_init()
  1030. */
  1031. typedef GDExtensionBool (*GDExtensionInterfaceVariantIterInit)(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_iter, GDExtensionBool *r_valid);
  1032. /**
  1033. * @name variant_iter_next
  1034. * @since 4.1
  1035. *
  1036. * Gets the next value for an iterator over a Variant.
  1037. *
  1038. * @param p_self A pointer to the Variant.
  1039. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  1040. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  1041. *
  1042. * @return true if the operation is valid; otherwise false.
  1043. *
  1044. * @see Variant::iter_next()
  1045. */
  1046. typedef GDExtensionBool (*GDExtensionInterfaceVariantIterNext)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
  1047. /**
  1048. * @name variant_iter_get
  1049. * @since 4.1
  1050. *
  1051. * Gets the next value for an iterator over a Variant.
  1052. *
  1053. * @param p_self A pointer to the Variant.
  1054. * @param r_iter A pointer to a Variant which will be assigned the iterator.
  1055. * @param r_ret A pointer to a Variant which will be assigned false if the operation is invalid.
  1056. * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
  1057. *
  1058. * @see Variant::iter_get()
  1059. */
  1060. typedef void (*GDExtensionInterfaceVariantIterGet)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
  1061. /**
  1062. * @name variant_hash
  1063. * @since 4.1
  1064. *
  1065. * Gets the hash of a Variant.
  1066. *
  1067. * @param p_self A pointer to the Variant.
  1068. *
  1069. * @return The hash value.
  1070. *
  1071. * @see Variant::hash()
  1072. */
  1073. typedef GDExtensionInt (*GDExtensionInterfaceVariantHash)(GDExtensionConstVariantPtr p_self);
  1074. /**
  1075. * @name variant_recursive_hash
  1076. * @since 4.1
  1077. *
  1078. * Gets the recursive hash of a Variant.
  1079. *
  1080. * @param p_self A pointer to the Variant.
  1081. * @param p_recursion_count The number of recursive loops so far.
  1082. *
  1083. * @return The hash value.
  1084. *
  1085. * @see Variant::recursive_hash()
  1086. */
  1087. typedef GDExtensionInt (*GDExtensionInterfaceVariantRecursiveHash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count);
  1088. /**
  1089. * @name variant_hash_compare
  1090. * @since 4.1
  1091. *
  1092. * Compares two Variants by their hash.
  1093. *
  1094. * @param p_self A pointer to the Variant.
  1095. * @param p_other A pointer to the other Variant to compare it to.
  1096. *
  1097. * @return The hash value.
  1098. *
  1099. * @see Variant::hash_compare()
  1100. */
  1101. typedef GDExtensionBool (*GDExtensionInterfaceVariantHashCompare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other);
  1102. /**
  1103. * @name variant_booleanize
  1104. * @since 4.1
  1105. *
  1106. * Converts a Variant to a boolean.
  1107. *
  1108. * @param p_self A pointer to the Variant.
  1109. *
  1110. * @return The boolean value of the Variant.
  1111. */
  1112. typedef GDExtensionBool (*GDExtensionInterfaceVariantBooleanize)(GDExtensionConstVariantPtr p_self);
  1113. /**
  1114. * @name variant_duplicate
  1115. * @since 4.1
  1116. *
  1117. * Duplicates a Variant.
  1118. *
  1119. * @param p_self A pointer to the Variant.
  1120. * @param r_ret A pointer to a Variant to store the duplicated value.
  1121. * @param p_deep Whether or not to duplicate deeply (when supported by the Variant type).
  1122. */
  1123. typedef void (*GDExtensionInterfaceVariantDuplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep);
  1124. /**
  1125. * @name variant_stringify
  1126. * @since 4.1
  1127. *
  1128. * Converts a Variant to a string.
  1129. *
  1130. * @param p_self A pointer to the Variant.
  1131. * @param r_ret A pointer to a String to store the resulting value.
  1132. */
  1133. typedef void (*GDExtensionInterfaceVariantStringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret);
  1134. /**
  1135. * @name variant_get_type
  1136. * @since 4.1
  1137. *
  1138. * Gets the type of a Variant.
  1139. *
  1140. * @param p_self A pointer to the Variant.
  1141. *
  1142. * @return The variant type.
  1143. */
  1144. typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtensionConstVariantPtr p_self);
  1145. /**
  1146. * @name variant_has_method
  1147. * @since 4.1
  1148. *
  1149. * Checks if a Variant has the given method.
  1150. *
  1151. * @param p_self A pointer to the Variant.
  1152. * @param p_method A pointer to a StringName with the method name.
  1153. *
  1154. * @return true if the variant has the given method; otherwise false.
  1155. */
  1156. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
  1157. /**
  1158. * @name variant_has_member
  1159. * @since 4.1
  1160. *
  1161. * Checks if a type of Variant has the given member.
  1162. *
  1163. * @param p_type The Variant type.
  1164. * @param p_member A pointer to a StringName with the member name.
  1165. *
  1166. * @return true if the variant has the given method; otherwise false.
  1167. */
  1168. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  1169. /**
  1170. * @name variant_has_key
  1171. * @since 4.1
  1172. *
  1173. * Checks if a Variant has a key.
  1174. *
  1175. * @param p_self A pointer to the Variant.
  1176. * @param p_key A pointer to a Variant representing the key.
  1177. * @param r_valid A pointer to a boolean which will be set to false if the key doesn't exist.
  1178. *
  1179. * @return true if the key exists; otherwise false.
  1180. */
  1181. typedef GDExtensionBool (*GDExtensionInterfaceVariantHasKey)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid);
  1182. /**
  1183. * @name variant_get_object_instance_id
  1184. * @since 4.4
  1185. *
  1186. * Gets the object instance ID from a variant of type GDEXTENSION_VARIANT_TYPE_OBJECT.
  1187. *
  1188. * If the variant isn't of type GDEXTENSION_VARIANT_TYPE_OBJECT, then zero will be returned.
  1189. * The instance ID will be returned even if the object is no longer valid - use `object_get_instance_by_id()` to check if the object is still valid.
  1190. *
  1191. * @param p_self A pointer to the Variant.
  1192. *
  1193. * @return The instance ID for the contained object.
  1194. */
  1195. typedef GDObjectInstanceID (*GDExtensionInterfaceVariantGetObjectInstanceId)(GDExtensionConstVariantPtr p_self);
  1196. /**
  1197. * @name variant_get_type_name
  1198. * @since 4.1
  1199. *
  1200. * Gets the name of a Variant type.
  1201. *
  1202. * @param p_type The Variant type.
  1203. * @param r_name A pointer to a String to store the Variant type name.
  1204. */
  1205. typedef void (*GDExtensionInterfaceVariantGetTypeName)(GDExtensionVariantType p_type, GDExtensionUninitializedStringPtr r_name);
  1206. /**
  1207. * @name variant_can_convert
  1208. * @since 4.1
  1209. *
  1210. * Checks if Variants can be converted from one type to another.
  1211. *
  1212. * @param p_from The Variant type to convert from.
  1213. * @param p_to The Variant type to convert to.
  1214. *
  1215. * @return true if the conversion is possible; otherwise false.
  1216. */
  1217. typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  1218. /**
  1219. * @name variant_can_convert_strict
  1220. * @since 4.1
  1221. *
  1222. * Checks if Variant can be converted from one type to another using stricter rules.
  1223. *
  1224. * @param p_from The Variant type to convert from.
  1225. * @param p_to The Variant type to convert to.
  1226. *
  1227. * @return true if the conversion is possible; otherwise false.
  1228. */
  1229. typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvertStrict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
  1230. /**
  1231. * @name get_variant_from_type_constructor
  1232. * @since 4.1
  1233. *
  1234. * Gets a pointer to a function that can create a Variant of the given type from a raw value.
  1235. *
  1236. * @param p_type The Variant type.
  1237. *
  1238. * @return A pointer to a function that can create a Variant of the given type from a raw value.
  1239. */
  1240. typedef GDExtensionVariantFromTypeConstructorFunc (*GDExtensionInterfaceGetVariantFromTypeConstructor)(GDExtensionVariantType p_type);
  1241. /**
  1242. * @name get_variant_to_type_constructor
  1243. * @since 4.1
  1244. *
  1245. * Gets a pointer to a function that can get the raw value from a Variant of the given type.
  1246. *
  1247. * @param p_type The Variant type.
  1248. *
  1249. * @return A pointer to a function that can get the raw value from a Variant of the given type.
  1250. */
  1251. typedef GDExtensionTypeFromVariantConstructorFunc (*GDExtensionInterfaceGetVariantToTypeConstructor)(GDExtensionVariantType p_type);
  1252. /**
  1253. * @name variant_get_ptr_internal_getter
  1254. * @since 4.4
  1255. *
  1256. * Provides a function pointer for retrieving a pointer to a variant's internal value.
  1257. * Access to a variant's internal value can be used to modify it in-place, or to retrieve its value without the overhead of variant conversion functions.
  1258. * It is recommended to cache the getter for all variant types in a function table to avoid retrieval overhead upon use.
  1259. *
  1260. * @note Each function assumes the variant's type has already been determined and matches the function.
  1261. * Invoking the function with a variant of a mismatched type has undefined behavior, and may lead to a segmentation fault.
  1262. *
  1263. * @param p_type The Variant type.
  1264. *
  1265. * @return A pointer to a type-specific function that returns a pointer to the internal value of a variant. Check the implementation of this function (gdextension_variant_get_ptr_internal_getter) for pointee type info of each variant type.
  1266. */
  1267. typedef GDExtensionVariantGetInternalPtrFunc (*GDExtensionInterfaceGetVariantGetInternalPtrFunc)(GDExtensionVariantType p_type);
  1268. /**
  1269. * @name variant_get_ptr_operator_evaluator
  1270. * @since 4.1
  1271. *
  1272. * Gets a pointer to a function that can evaluate the given Variant operator on the given Variant types.
  1273. *
  1274. * @param p_operator The variant operator.
  1275. * @param p_type_a The type of the first Variant.
  1276. * @param p_type_b The type of the second Variant.
  1277. *
  1278. * @return A pointer to a function that can evaluate the given Variant operator on the given Variant types.
  1279. */
  1280. typedef GDExtensionPtrOperatorEvaluator (*GDExtensionInterfaceVariantGetPtrOperatorEvaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b);
  1281. /**
  1282. * @name variant_get_ptr_builtin_method
  1283. * @since 4.1
  1284. *
  1285. * Gets a pointer to a function that can call a builtin method on a type of Variant.
  1286. *
  1287. * @param p_type The Variant type.
  1288. * @param p_method A pointer to a StringName with the method name.
  1289. * @param p_hash A hash representing the method signature.
  1290. *
  1291. * @return A pointer to a function that can call a builtin method on a type of Variant.
  1292. */
  1293. typedef GDExtensionPtrBuiltInMethod (*GDExtensionInterfaceVariantGetPtrBuiltinMethod)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash);
  1294. /**
  1295. * @name variant_get_ptr_constructor
  1296. * @since 4.1
  1297. *
  1298. * Gets a pointer to a function that can call one of the constructors for a type of Variant.
  1299. *
  1300. * @param p_type The Variant type.
  1301. * @param p_constructor The index of the constructor.
  1302. *
  1303. * @return A pointer to a function that can call one of the constructors for a type of Variant.
  1304. */
  1305. typedef GDExtensionPtrConstructor (*GDExtensionInterfaceVariantGetPtrConstructor)(GDExtensionVariantType p_type, int32_t p_constructor);
  1306. /**
  1307. * @name variant_get_ptr_destructor
  1308. * @since 4.1
  1309. *
  1310. * Gets a pointer to a function than can call the destructor for a type of Variant.
  1311. *
  1312. * @param p_type The Variant type.
  1313. *
  1314. * @return A pointer to a function than can call the destructor for a type of Variant.
  1315. */
  1316. typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(GDExtensionVariantType p_type);
  1317. /**
  1318. * @name variant_construct
  1319. * @since 4.1
  1320. *
  1321. * Constructs a Variant of the given type, using the first constructor that matches the given arguments.
  1322. *
  1323. * @param p_type The Variant type.
  1324. * @param r_base A pointer to a Variant to store the constructed value.
  1325. * @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor.
  1326. * @param p_argument_count The number of arguments to pass to the constructor.
  1327. * @param r_error A pointer the structure which will be updated with error information.
  1328. */
  1329. typedef void (*GDExtensionInterfaceVariantConstruct)(GDExtensionVariantType p_type, GDExtensionUninitializedVariantPtr r_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error);
  1330. /**
  1331. * @name variant_get_ptr_setter
  1332. * @since 4.1
  1333. *
  1334. * Gets a pointer to a function that can call a member's setter on the given Variant type.
  1335. *
  1336. * @param p_type The Variant type.
  1337. * @param p_member A pointer to a StringName with the member name.
  1338. *
  1339. * @return A pointer to a function that can call a member's setter on the given Variant type.
  1340. */
  1341. typedef GDExtensionPtrSetter (*GDExtensionInterfaceVariantGetPtrSetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  1342. /**
  1343. * @name variant_get_ptr_getter
  1344. * @since 4.1
  1345. *
  1346. * Gets a pointer to a function that can call a member's getter on the given Variant type.
  1347. *
  1348. * @param p_type The Variant type.
  1349. * @param p_member A pointer to a StringName with the member name.
  1350. *
  1351. * @return A pointer to a function that can call a member's getter on the given Variant type.
  1352. */
  1353. typedef GDExtensionPtrGetter (*GDExtensionInterfaceVariantGetPtrGetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
  1354. /**
  1355. * @name variant_get_ptr_indexed_setter
  1356. * @since 4.1
  1357. *
  1358. * Gets a pointer to a function that can set an index on the given Variant type.
  1359. *
  1360. * @param p_type The Variant type.
  1361. *
  1362. * @return A pointer to a function that can set an index on the given Variant type.
  1363. */
  1364. typedef GDExtensionPtrIndexedSetter (*GDExtensionInterfaceVariantGetPtrIndexedSetter)(GDExtensionVariantType p_type);
  1365. /**
  1366. * @name variant_get_ptr_indexed_getter
  1367. * @since 4.1
  1368. *
  1369. * Gets a pointer to a function that can get an index on the given Variant type.
  1370. *
  1371. * @param p_type The Variant type.
  1372. *
  1373. * @return A pointer to a function that can get an index on the given Variant type.
  1374. */
  1375. typedef GDExtensionPtrIndexedGetter (*GDExtensionInterfaceVariantGetPtrIndexedGetter)(GDExtensionVariantType p_type);
  1376. /**
  1377. * @name variant_get_ptr_keyed_setter
  1378. * @since 4.1
  1379. *
  1380. * Gets a pointer to a function that can set a key on the given Variant type.
  1381. *
  1382. * @param p_type The Variant type.
  1383. *
  1384. * @return A pointer to a function that can set a key on the given Variant type.
  1385. */
  1386. typedef GDExtensionPtrKeyedSetter (*GDExtensionInterfaceVariantGetPtrKeyedSetter)(GDExtensionVariantType p_type);
  1387. /**
  1388. * @name variant_get_ptr_keyed_getter
  1389. * @since 4.1
  1390. *
  1391. * Gets a pointer to a function that can get a key on the given Variant type.
  1392. *
  1393. * @param p_type The Variant type.
  1394. *
  1395. * @return A pointer to a function that can get a key on the given Variant type.
  1396. */
  1397. typedef GDExtensionPtrKeyedGetter (*GDExtensionInterfaceVariantGetPtrKeyedGetter)(GDExtensionVariantType p_type);
  1398. /**
  1399. * @name variant_get_ptr_keyed_checker
  1400. * @since 4.1
  1401. *
  1402. * Gets a pointer to a function that can check a key on the given Variant type.
  1403. *
  1404. * @param p_type The Variant type.
  1405. *
  1406. * @return A pointer to a function that can check a key on the given Variant type.
  1407. */
  1408. typedef GDExtensionPtrKeyedChecker (*GDExtensionInterfaceVariantGetPtrKeyedChecker)(GDExtensionVariantType p_type);
  1409. /**
  1410. * @name variant_get_constant_value
  1411. * @since 4.1
  1412. *
  1413. * Gets the value of a constant from the given Variant type.
  1414. *
  1415. * @param p_type The Variant type.
  1416. * @param p_constant A pointer to a StringName with the constant name.
  1417. * @param r_ret A pointer to a Variant to store the value.
  1418. */
  1419. typedef void (*GDExtensionInterfaceVariantGetConstantValue)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionUninitializedVariantPtr r_ret);
  1420. /**
  1421. * @name variant_get_ptr_utility_function
  1422. * @since 4.1
  1423. *
  1424. * Gets a pointer to a function that can call a Variant utility function.
  1425. *
  1426. * @param p_function A pointer to a StringName with the function name.
  1427. * @param p_hash A hash representing the function signature.
  1428. *
  1429. * @return A pointer to a function that can call a Variant utility function.
  1430. */
  1431. typedef GDExtensionPtrUtilityFunction (*GDExtensionInterfaceVariantGetPtrUtilityFunction)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash);
  1432. /* INTERFACE: String Utilities */
  1433. /**
  1434. * @name string_new_with_latin1_chars
  1435. * @since 4.1
  1436. *
  1437. * Creates a String from a Latin-1 encoded C string.
  1438. *
  1439. * @param r_dest A pointer to a Variant to hold the newly created String.
  1440. * @param p_contents A pointer to a Latin-1 encoded C string (null terminated).
  1441. */
  1442. typedef void (*GDExtensionInterfaceStringNewWithLatin1Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents);
  1443. /**
  1444. * @name string_new_with_utf8_chars
  1445. * @since 4.1
  1446. *
  1447. * Creates a String from a UTF-8 encoded C string.
  1448. *
  1449. * @param r_dest A pointer to a Variant to hold the newly created String.
  1450. * @param p_contents A pointer to a UTF-8 encoded C string (null terminated).
  1451. */
  1452. typedef void (*GDExtensionInterfaceStringNewWithUtf8Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents);
  1453. /**
  1454. * @name string_new_with_utf16_chars
  1455. * @since 4.1
  1456. *
  1457. * Creates a String from a UTF-16 encoded C string.
  1458. *
  1459. * @param r_dest A pointer to a Variant to hold the newly created String.
  1460. * @param p_contents A pointer to a UTF-16 encoded C string (null terminated).
  1461. */
  1462. typedef void (*GDExtensionInterfaceStringNewWithUtf16Chars)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents);
  1463. /**
  1464. * @name string_new_with_utf32_chars
  1465. * @since 4.1
  1466. *
  1467. * Creates a String from a UTF-32 encoded C string.
  1468. *
  1469. * @param r_dest A pointer to a Variant to hold the newly created String.
  1470. * @param p_contents A pointer to a UTF-32 encoded C string (null terminated).
  1471. */
  1472. typedef void (*GDExtensionInterfaceStringNewWithUtf32Chars)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents);
  1473. /**
  1474. * @name string_new_with_wide_chars
  1475. * @since 4.1
  1476. *
  1477. * Creates a String from a wide C string.
  1478. *
  1479. * @param r_dest A pointer to a Variant to hold the newly created String.
  1480. * @param p_contents A pointer to a wide C string (null terminated).
  1481. */
  1482. typedef void (*GDExtensionInterfaceStringNewWithWideChars)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents);
  1483. /**
  1484. * @name string_new_with_latin1_chars_and_len
  1485. * @since 4.1
  1486. *
  1487. * Creates a String from a Latin-1 encoded C string with the given length.
  1488. *
  1489. * @param r_dest A pointer to a Variant to hold the newly created String.
  1490. * @param p_contents A pointer to a Latin-1 encoded C string.
  1491. * @param p_size The number of characters (= number of bytes).
  1492. */
  1493. typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1494. /**
  1495. * @name string_new_with_utf8_chars_and_len
  1496. * @since 4.1
  1497. * @deprecated in Godot 4.3. Use `string_new_with_utf8_chars_and_len2` instead.
  1498. *
  1499. * Creates a String from a UTF-8 encoded C string with the given length.
  1500. *
  1501. * @param r_dest A pointer to a Variant to hold the newly created String.
  1502. * @param p_contents A pointer to a UTF-8 encoded C string.
  1503. * @param p_size The number of bytes (not code units).
  1504. */
  1505. typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1506. /**
  1507. * @name string_new_with_utf8_chars_and_len2
  1508. * @since 4.3
  1509. *
  1510. * Creates a String from a UTF-8 encoded C string with the given length.
  1511. *
  1512. * @param r_dest A pointer to a Variant to hold the newly created String.
  1513. * @param p_contents A pointer to a UTF-8 encoded C string.
  1514. * @param p_size The number of bytes (not code units).
  1515. *
  1516. * @return Error code signifying if the operation successful.
  1517. */
  1518. typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen2)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1519. /**
  1520. * @name string_new_with_utf16_chars_and_len
  1521. * @since 4.1
  1522. * @deprecated in Godot 4.3. Use `string_new_with_utf16_chars_and_len2` instead.
  1523. *
  1524. * Creates a String from a UTF-16 encoded C string with the given length.
  1525. *
  1526. * @param r_dest A pointer to a Variant to hold the newly created String.
  1527. * @param p_contents A pointer to a UTF-16 encoded C string.
  1528. * @param p_char_count The number of characters (not bytes).
  1529. */
  1530. typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count);
  1531. /**
  1532. * @name string_new_with_utf16_chars_and_len2
  1533. * @since 4.3
  1534. *
  1535. * Creates a String from a UTF-16 encoded C string with the given length.
  1536. *
  1537. * @param r_dest A pointer to a Variant to hold the newly created String.
  1538. * @param p_contents A pointer to a UTF-16 encoded C string.
  1539. * @param p_char_count The number of characters (not bytes).
  1540. * @param p_default_little_endian If true, UTF-16 use little endian.
  1541. *
  1542. * @return Error code signifying if the operation successful.
  1543. */
  1544. typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen2)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count, GDExtensionBool p_default_little_endian);
  1545. /**
  1546. * @name string_new_with_utf32_chars_and_len
  1547. * @since 4.1
  1548. *
  1549. * Creates a String from a UTF-32 encoded C string with the given length.
  1550. *
  1551. * @param r_dest A pointer to a Variant to hold the newly created String.
  1552. * @param p_contents A pointer to a UTF-32 encoded C string.
  1553. * @param p_char_count The number of characters (not bytes).
  1554. */
  1555. typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_char_count);
  1556. /**
  1557. * @name string_new_with_wide_chars_and_len
  1558. * @since 4.1
  1559. *
  1560. * Creates a String from a wide C string with the given length.
  1561. *
  1562. * @param r_dest A pointer to a Variant to hold the newly created String.
  1563. * @param p_contents A pointer to a wide C string.
  1564. * @param p_char_count The number of characters (not bytes).
  1565. */
  1566. typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_char_count);
  1567. /**
  1568. * @name string_to_latin1_chars
  1569. * @since 4.1
  1570. *
  1571. * Converts a String to a Latin-1 encoded C string.
  1572. *
  1573. * It doesn't write a null terminator.
  1574. *
  1575. * @param p_self A pointer to the String.
  1576. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1577. * @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.
  1578. *
  1579. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1580. */
  1581. typedef GDExtensionInt (*GDExtensionInterfaceStringToLatin1Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  1582. /**
  1583. * @name string_to_utf8_chars
  1584. * @since 4.1
  1585. *
  1586. * Converts a String to a UTF-8 encoded C string.
  1587. *
  1588. * It doesn't write a null terminator.
  1589. *
  1590. * @param p_self A pointer to the String.
  1591. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1592. * @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.
  1593. *
  1594. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1595. */
  1596. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf8Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
  1597. /**
  1598. * @name string_to_utf16_chars
  1599. * @since 4.1
  1600. *
  1601. * Converts a String to a UTF-16 encoded C string.
  1602. *
  1603. * It doesn't write a null terminator.
  1604. *
  1605. * @param p_self A pointer to the String.
  1606. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1607. * @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.
  1608. *
  1609. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1610. */
  1611. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf16Chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length);
  1612. /**
  1613. * @name string_to_utf32_chars
  1614. * @since 4.1
  1615. *
  1616. * Converts a String to a UTF-32 encoded C string.
  1617. *
  1618. * It doesn't write a null terminator.
  1619. *
  1620. * @param p_self A pointer to the String.
  1621. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1622. * @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.
  1623. *
  1624. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1625. */
  1626. typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf32Chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length);
  1627. /**
  1628. * @name string_to_wide_chars
  1629. * @since 4.1
  1630. *
  1631. * Converts a String to a wide C string.
  1632. *
  1633. * It doesn't write a null terminator.
  1634. *
  1635. * @param p_self A pointer to the String.
  1636. * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
  1637. * @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.
  1638. *
  1639. * @return The resulting encoded string length in characters (not bytes), not including a null terminator.
  1640. */
  1641. typedef GDExtensionInt (*GDExtensionInterfaceStringToWideChars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length);
  1642. /**
  1643. * @name string_operator_index
  1644. * @since 4.1
  1645. *
  1646. * Gets a pointer to the character at the given index from a String.
  1647. *
  1648. * @param p_self A pointer to the String.
  1649. * @param p_index The index.
  1650. *
  1651. * @return A pointer to the requested character.
  1652. */
  1653. typedef char32_t *(*GDExtensionInterfaceStringOperatorIndex)(GDExtensionStringPtr p_self, GDExtensionInt p_index);
  1654. /**
  1655. * @name string_operator_index_const
  1656. * @since 4.1
  1657. *
  1658. * Gets a const pointer to the character at the given index from a String.
  1659. *
  1660. * @param p_self A pointer to the String.
  1661. * @param p_index The index.
  1662. *
  1663. * @return A const pointer to the requested character.
  1664. */
  1665. typedef const char32_t *(*GDExtensionInterfaceStringOperatorIndexConst)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index);
  1666. /**
  1667. * @name string_operator_plus_eq_string
  1668. * @since 4.1
  1669. *
  1670. * Appends another String to a String.
  1671. *
  1672. * @param p_self A pointer to the String.
  1673. * @param p_b A pointer to the other String to append.
  1674. */
  1675. typedef void (*GDExtensionInterfaceStringOperatorPlusEqString)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b);
  1676. /**
  1677. * @name string_operator_plus_eq_char
  1678. * @since 4.1
  1679. *
  1680. * Appends a character to a String.
  1681. *
  1682. * @param p_self A pointer to the String.
  1683. * @param p_b A pointer to the character to append.
  1684. */
  1685. typedef void (*GDExtensionInterfaceStringOperatorPlusEqChar)(GDExtensionStringPtr p_self, char32_t p_b);
  1686. /**
  1687. * @name string_operator_plus_eq_cstr
  1688. * @since 4.1
  1689. *
  1690. * Appends a Latin-1 encoded C string to a String.
  1691. *
  1692. * @param p_self A pointer to the String.
  1693. * @param p_b A pointer to a Latin-1 encoded C string (null terminated).
  1694. */
  1695. typedef void (*GDExtensionInterfaceStringOperatorPlusEqCstr)(GDExtensionStringPtr p_self, const char *p_b);
  1696. /**
  1697. * @name string_operator_plus_eq_wcstr
  1698. * @since 4.1
  1699. *
  1700. * Appends a wide C string to a String.
  1701. *
  1702. * @param p_self A pointer to the String.
  1703. * @param p_b A pointer to a wide C string (null terminated).
  1704. */
  1705. typedef void (*GDExtensionInterfaceStringOperatorPlusEqWcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b);
  1706. /**
  1707. * @name string_operator_plus_eq_c32str
  1708. * @since 4.1
  1709. *
  1710. * Appends a UTF-32 encoded C string to a String.
  1711. *
  1712. * @param p_self A pointer to the String.
  1713. * @param p_b A pointer to a UTF-32 encoded C string (null terminated).
  1714. */
  1715. typedef void (*GDExtensionInterfaceStringOperatorPlusEqC32str)(GDExtensionStringPtr p_self, const char32_t *p_b);
  1716. /**
  1717. * @name string_resize
  1718. * @since 4.2
  1719. *
  1720. * Resizes the underlying string data to the given number of characters.
  1721. *
  1722. * Space needs to be allocated for the null terminating character ('\0') which
  1723. * also must be added manually, in order for all string functions to work correctly.
  1724. *
  1725. * Warning: This is an error-prone operation - only use it if there's no other
  1726. * efficient way to accomplish your goal.
  1727. *
  1728. * @param p_self A pointer to the String.
  1729. * @param p_resize The new length for the String.
  1730. *
  1731. * @return Error code signifying if the operation successful.
  1732. */
  1733. typedef GDExtensionInt (*GDExtensionInterfaceStringResize)(GDExtensionStringPtr p_self, GDExtensionInt p_resize);
  1734. /* INTERFACE: StringName Utilities */
  1735. /**
  1736. * @name string_name_new_with_latin1_chars
  1737. * @since 4.2
  1738. *
  1739. * Creates a StringName from a Latin-1 encoded C string.
  1740. *
  1741. * If `p_is_static` is true, then:
  1742. * - The StringName will reuse the `p_contents` buffer instead of copying it.
  1743. * You must guarantee that the buffer remains valid for the duration of the application (e.g. string literal).
  1744. * - You must not call a destructor for this StringName. Incrementing the initial reference once should achieve this.
  1745. *
  1746. * `p_is_static` is purely an optimization and can easily introduce undefined behavior if used wrong. In case of doubt, set it to false.
  1747. *
  1748. * @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed.
  1749. * @param p_contents A pointer to a C string (null terminated and Latin-1 or ASCII encoded).
  1750. * @param p_is_static Whether the StringName reuses the buffer directly (see above).
  1751. */
  1752. typedef void (*GDExtensionInterfaceStringNameNewWithLatin1Chars)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionBool p_is_static);
  1753. /**
  1754. * @name string_name_new_with_utf8_chars
  1755. * @since 4.2
  1756. *
  1757. * Creates a StringName from a UTF-8 encoded C string.
  1758. *
  1759. * @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed.
  1760. * @param p_contents A pointer to a C string (null terminated and UTF-8 encoded).
  1761. */
  1762. typedef void (*GDExtensionInterfaceStringNameNewWithUtf8Chars)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents);
  1763. /**
  1764. * @name string_name_new_with_utf8_chars_and_len
  1765. * @since 4.2
  1766. *
  1767. * Creates a StringName from a UTF-8 encoded string with a given number of characters.
  1768. *
  1769. * @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed.
  1770. * @param p_contents A pointer to a C string (null terminated and UTF-8 encoded).
  1771. * @param p_size The number of bytes (not UTF-8 code points).
  1772. */
  1773. typedef void (*GDExtensionInterfaceStringNameNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionInt p_size);
  1774. /* INTERFACE: XMLParser Utilities */
  1775. /**
  1776. * @name xml_parser_open_buffer
  1777. * @since 4.1
  1778. *
  1779. * Opens a raw XML buffer on an XMLParser instance.
  1780. *
  1781. * @param p_instance A pointer to an XMLParser object.
  1782. * @param p_buffer A pointer to the buffer.
  1783. * @param p_size The size of the buffer.
  1784. *
  1785. * @return A Godot error code (ex. OK, ERR_INVALID_DATA, etc).
  1786. *
  1787. * @see XMLParser::open_buffer()
  1788. */
  1789. typedef GDExtensionInt (*GDExtensionInterfaceXmlParserOpenBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size);
  1790. /* INTERFACE: FileAccess Utilities */
  1791. /**
  1792. * @name file_access_store_buffer
  1793. * @since 4.1
  1794. *
  1795. * Stores the given buffer using an instance of FileAccess.
  1796. *
  1797. * @param p_instance A pointer to a FileAccess object.
  1798. * @param p_src A pointer to the buffer.
  1799. * @param p_length The size of the buffer.
  1800. *
  1801. * @see FileAccess::store_buffer()
  1802. */
  1803. typedef void (*GDExtensionInterfaceFileAccessStoreBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length);
  1804. /**
  1805. * @name file_access_get_buffer
  1806. * @since 4.1
  1807. *
  1808. * Reads the next p_length bytes into the given buffer using an instance of FileAccess.
  1809. *
  1810. * @param p_instance A pointer to a FileAccess object.
  1811. * @param p_dst A pointer to the buffer to store the data.
  1812. * @param p_length The requested number of bytes to read.
  1813. *
  1814. * @return The actual number of bytes read (may be less than requested).
  1815. */
  1816. typedef uint64_t (*GDExtensionInterfaceFileAccessGetBuffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);
  1817. /* INTERFACE: Image Utilities */
  1818. /**
  1819. * @name image_ptrw
  1820. * @since 4.3
  1821. *
  1822. * Returns writable pointer to internal Image buffer.
  1823. *
  1824. * @param p_instance A pointer to a Image object.
  1825. *
  1826. * @return Pointer to internal Image buffer.
  1827. *
  1828. * @see Image::ptrw()
  1829. */
  1830. typedef uint8_t *(*GDExtensionInterfaceImagePtrw)(GDExtensionObjectPtr p_instance);
  1831. /**
  1832. * @name image_ptr
  1833. * @since 4.3
  1834. *
  1835. * Returns read only pointer to internal Image buffer.
  1836. *
  1837. * @param p_instance A pointer to a Image object.
  1838. *
  1839. * @return Pointer to internal Image buffer.
  1840. *
  1841. * @see Image::ptr()
  1842. */
  1843. typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_instance);
  1844. /* INTERFACE: WorkerThreadPool Utilities */
  1845. /**
  1846. * @name worker_thread_pool_add_native_group_task
  1847. * @since 4.1
  1848. *
  1849. * Adds a group task to an instance of WorkerThreadPool.
  1850. *
  1851. * @param p_instance A pointer to a WorkerThreadPool object.
  1852. * @param p_func A pointer to a function to run in the thread pool.
  1853. * @param p_userdata A pointer to arbitrary data which will be passed to p_func.
  1854. * @param p_elements The number of element needed in the group.
  1855. * @param p_tasks The number of tasks needed in the group.
  1856. * @param p_high_priority Whether or not this is a high priority task.
  1857. * @param p_description A pointer to a String with the task description.
  1858. *
  1859. * @return The task group ID.
  1860. *
  1861. * @see WorkerThreadPool::add_group_task()
  1862. */
  1863. typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExtensionObjectPtr p_instance, GDExtensionWorkerThreadPoolGroupTask p_func, void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
  1864. /**
  1865. * @name worker_thread_pool_add_native_task
  1866. * @since 4.1
  1867. *
  1868. * Adds a task to an instance of WorkerThreadPool.
  1869. *
  1870. * @param p_instance A pointer to a WorkerThreadPool object.
  1871. * @param p_func A pointer to a function to run in the thread pool.
  1872. * @param p_userdata A pointer to arbitrary data which will be passed to p_func.
  1873. * @param p_high_priority Whether or not this is a high priority task.
  1874. * @param p_description A pointer to a String with the task description.
  1875. *
  1876. * @return The task ID.
  1877. */
  1878. typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, GDExtensionWorkerThreadPoolTask p_func, void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
  1879. /* INTERFACE: Packed Array */
  1880. /**
  1881. * @name packed_byte_array_operator_index
  1882. * @since 4.1
  1883. *
  1884. * Gets a pointer to a byte in a PackedByteArray.
  1885. *
  1886. * @param p_self A pointer to a PackedByteArray object.
  1887. * @param p_index The index of the byte to get.
  1888. *
  1889. * @return A pointer to the requested byte.
  1890. */
  1891. typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1892. /**
  1893. * @name packed_byte_array_operator_index_const
  1894. * @since 4.1
  1895. *
  1896. * Gets a const pointer to a byte in a PackedByteArray.
  1897. *
  1898. * @param p_self A const pointer to a PackedByteArray object.
  1899. * @param p_index The index of the byte to get.
  1900. *
  1901. * @return A const pointer to the requested byte.
  1902. */
  1903. typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1904. /**
  1905. * @name packed_float32_array_operator_index
  1906. * @since 4.1
  1907. *
  1908. * Gets a pointer to a 32-bit float in a PackedFloat32Array.
  1909. *
  1910. * @param p_self A pointer to a PackedFloat32Array object.
  1911. * @param p_index The index of the float to get.
  1912. *
  1913. * @return A pointer to the requested 32-bit float.
  1914. */
  1915. typedef float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1916. /**
  1917. * @name packed_float32_array_operator_index_const
  1918. * @since 4.1
  1919. *
  1920. * Gets a const pointer to a 32-bit float in a PackedFloat32Array.
  1921. *
  1922. * @param p_self A const pointer to a PackedFloat32Array object.
  1923. * @param p_index The index of the float to get.
  1924. *
  1925. * @return A const pointer to the requested 32-bit float.
  1926. */
  1927. typedef const float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1928. /**
  1929. * @name packed_float64_array_operator_index
  1930. * @since 4.1
  1931. *
  1932. * Gets a pointer to a 64-bit float in a PackedFloat64Array.
  1933. *
  1934. * @param p_self A pointer to a PackedFloat64Array object.
  1935. * @param p_index The index of the float to get.
  1936. *
  1937. * @return A pointer to the requested 64-bit float.
  1938. */
  1939. typedef double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1940. /**
  1941. * @name packed_float64_array_operator_index_const
  1942. * @since 4.1
  1943. *
  1944. * Gets a const pointer to a 64-bit float in a PackedFloat64Array.
  1945. *
  1946. * @param p_self A const pointer to a PackedFloat64Array object.
  1947. * @param p_index The index of the float to get.
  1948. *
  1949. * @return A const pointer to the requested 64-bit float.
  1950. */
  1951. typedef const double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1952. /**
  1953. * @name packed_int32_array_operator_index
  1954. * @since 4.1
  1955. *
  1956. * Gets a pointer to a 32-bit integer in a PackedInt32Array.
  1957. *
  1958. * @param p_self A pointer to a PackedInt32Array object.
  1959. * @param p_index The index of the integer to get.
  1960. *
  1961. * @return A pointer to the requested 32-bit integer.
  1962. */
  1963. typedef int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1964. /**
  1965. * @name packed_int32_array_operator_index_const
  1966. * @since 4.1
  1967. *
  1968. * Gets a const pointer to a 32-bit integer in a PackedInt32Array.
  1969. *
  1970. * @param p_self A const pointer to a PackedInt32Array object.
  1971. * @param p_index The index of the integer to get.
  1972. *
  1973. * @return A const pointer to the requested 32-bit integer.
  1974. */
  1975. typedef const int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  1976. /**
  1977. * @name packed_int64_array_operator_index
  1978. * @since 4.1
  1979. *
  1980. * Gets a pointer to a 64-bit integer in a PackedInt64Array.
  1981. *
  1982. * @param p_self A pointer to a PackedInt64Array object.
  1983. * @param p_index The index of the integer to get.
  1984. *
  1985. * @return A pointer to the requested 64-bit integer.
  1986. */
  1987. typedef int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  1988. /**
  1989. * @name packed_int64_array_operator_index_const
  1990. * @since 4.1
  1991. *
  1992. * Gets a const pointer to a 64-bit integer in a PackedInt64Array.
  1993. *
  1994. * @param p_self A const pointer to a PackedInt64Array object.
  1995. * @param p_index The index of the integer to get.
  1996. *
  1997. * @return A const pointer to the requested 64-bit integer.
  1998. */
  1999. typedef const int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  2000. /**
  2001. * @name packed_string_array_operator_index
  2002. * @since 4.1
  2003. *
  2004. * Gets a pointer to a string in a PackedStringArray.
  2005. *
  2006. * @param p_self A pointer to a PackedStringArray object.
  2007. * @param p_index The index of the String to get.
  2008. *
  2009. * @return A pointer to the requested String.
  2010. */
  2011. typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  2012. /**
  2013. * @name packed_string_array_operator_index_const
  2014. * @since 4.1
  2015. *
  2016. * Gets a const pointer to a string in a PackedStringArray.
  2017. *
  2018. * @param p_self A const pointer to a PackedStringArray object.
  2019. * @param p_index The index of the String to get.
  2020. *
  2021. * @return A const pointer to the requested String.
  2022. */
  2023. typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  2024. /**
  2025. * @name packed_vector2_array_operator_index
  2026. * @since 4.1
  2027. *
  2028. * Gets a pointer to a Vector2 in a PackedVector2Array.
  2029. *
  2030. * @param p_self A pointer to a PackedVector2Array object.
  2031. * @param p_index The index of the Vector2 to get.
  2032. *
  2033. * @return A pointer to the requested Vector2.
  2034. */
  2035. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  2036. /**
  2037. * @name packed_vector2_array_operator_index_const
  2038. * @since 4.1
  2039. *
  2040. * Gets a const pointer to a Vector2 in a PackedVector2Array.
  2041. *
  2042. * @param p_self A const pointer to a PackedVector2Array object.
  2043. * @param p_index The index of the Vector2 to get.
  2044. *
  2045. * @return A const pointer to the requested Vector2.
  2046. */
  2047. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  2048. /**
  2049. * @name packed_vector3_array_operator_index
  2050. * @since 4.1
  2051. *
  2052. * Gets a pointer to a Vector3 in a PackedVector3Array.
  2053. *
  2054. * @param p_self A pointer to a PackedVector3Array object.
  2055. * @param p_index The index of the Vector3 to get.
  2056. *
  2057. * @return A pointer to the requested Vector3.
  2058. */
  2059. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  2060. /**
  2061. * @name packed_vector3_array_operator_index_const
  2062. * @since 4.1
  2063. *
  2064. * Gets a const pointer to a Vector3 in a PackedVector3Array.
  2065. *
  2066. * @param p_self A const pointer to a PackedVector3Array object.
  2067. * @param p_index The index of the Vector3 to get.
  2068. *
  2069. * @return A const pointer to the requested Vector3.
  2070. */
  2071. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  2072. /**
  2073. * @name packed_vector4_array_operator_index
  2074. * @since 4.3
  2075. *
  2076. * Gets a pointer to a Vector4 in a PackedVector4Array.
  2077. *
  2078. * @param p_self A pointer to a PackedVector4Array object.
  2079. * @param p_index The index of the Vector4 to get.
  2080. *
  2081. * @return A pointer to the requested Vector4.
  2082. */
  2083. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector4ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  2084. /**
  2085. * @name packed_vector4_array_operator_index_const
  2086. * @since 4.3
  2087. *
  2088. * Gets a const pointer to a Vector4 in a PackedVector4Array.
  2089. *
  2090. * @param p_self A const pointer to a PackedVector4Array object.
  2091. * @param p_index The index of the Vector4 to get.
  2092. *
  2093. * @return A const pointer to the requested Vector4.
  2094. */
  2095. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector4ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  2096. /**
  2097. * @name packed_color_array_operator_index
  2098. * @since 4.1
  2099. *
  2100. * Gets a pointer to a color in a PackedColorArray.
  2101. *
  2102. * @param p_self A pointer to a PackedColorArray object.
  2103. * @param p_index The index of the Color to get.
  2104. *
  2105. * @return A pointer to the requested Color.
  2106. */
  2107. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  2108. /**
  2109. * @name packed_color_array_operator_index_const
  2110. * @since 4.1
  2111. *
  2112. * Gets a const pointer to a color in a PackedColorArray.
  2113. *
  2114. * @param p_self A const pointer to a PackedColorArray object.
  2115. * @param p_index The index of the Color to get.
  2116. *
  2117. * @return A const pointer to the requested Color.
  2118. */
  2119. typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  2120. /**
  2121. * @name array_operator_index
  2122. * @since 4.1
  2123. *
  2124. * Gets a pointer to a Variant in an Array.
  2125. *
  2126. * @param p_self A pointer to an Array object.
  2127. * @param p_index The index of the Variant to get.
  2128. *
  2129. * @return A pointer to the requested Variant.
  2130. */
  2131. typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
  2132. /**
  2133. * @name array_operator_index_const
  2134. * @since 4.1
  2135. *
  2136. * Gets a const pointer to a Variant in an Array.
  2137. *
  2138. * @param p_self A const pointer to an Array object.
  2139. * @param p_index The index of the Variant to get.
  2140. *
  2141. * @return A const pointer to the requested Variant.
  2142. */
  2143. typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
  2144. /**
  2145. * @name array_ref
  2146. * @since 4.1
  2147. * @deprecated in Godot 4.5. use `Array::operator=` instead.
  2148. *
  2149. * Sets an Array to be a reference to another Array object.
  2150. *
  2151. * @param p_self A pointer to the Array object to update.
  2152. * @param p_from A pointer to the Array object to reference.
  2153. */
  2154. typedef void (*GDExtensionInterfaceArrayRef)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from);
  2155. /**
  2156. * @name array_set_typed
  2157. * @since 4.1
  2158. *
  2159. * Makes an Array into a typed Array.
  2160. *
  2161. * @param p_self A pointer to the Array.
  2162. * @param p_type The type of Variant the Array will store.
  2163. * @param p_class_name A pointer to a StringName with the name of the object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT).
  2164. * @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).
  2165. */
  2166. typedef void (*GDExtensionInterfaceArraySetTyped)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script);
  2167. /* INTERFACE: Dictionary */
  2168. /**
  2169. * @name dictionary_operator_index
  2170. * @since 4.1
  2171. *
  2172. * Gets a pointer to a Variant in a Dictionary with the given key.
  2173. *
  2174. * @param p_self A pointer to a Dictionary object.
  2175. * @param p_key A pointer to a Variant representing the key.
  2176. *
  2177. * @return A pointer to a Variant representing the value at the given key.
  2178. */
  2179. typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key);
  2180. /**
  2181. * @name dictionary_operator_index_const
  2182. * @since 4.1
  2183. *
  2184. * Gets a const pointer to a Variant in a Dictionary with the given key.
  2185. *
  2186. * @param p_self A const pointer to a Dictionary object.
  2187. * @param p_key A pointer to a Variant representing the key.
  2188. *
  2189. * @return A const pointer to a Variant representing the value at the given key.
  2190. */
  2191. typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key);
  2192. /**
  2193. * @name dictionary_set_typed
  2194. * @since 4.4
  2195. *
  2196. * Makes a Dictionary into a typed Dictionary.
  2197. *
  2198. * @param p_self A pointer to the Dictionary.
  2199. * @param p_key_type The type of Variant the Dictionary key will store.
  2200. * @param p_key_class_name A pointer to a StringName with the name of the object (if p_key_type is GDEXTENSION_VARIANT_TYPE_OBJECT).
  2201. * @param p_key_script A pointer to a Script object (if p_key_type is GDEXTENSION_VARIANT_TYPE_OBJECT and the base class is extended by a script).
  2202. * @param p_value_type The type of Variant the Dictionary value will store.
  2203. * @param p_value_class_name A pointer to a StringName with the name of the object (if p_value_type is GDEXTENSION_VARIANT_TYPE_OBJECT).
  2204. * @param p_value_script A pointer to a Script object (if p_value_type is GDEXTENSION_VARIANT_TYPE_OBJECT and the base class is extended by a script).
  2205. */
  2206. typedef void (*GDExtensionInterfaceDictionarySetTyped)(GDExtensionTypePtr p_self, GDExtensionVariantType p_key_type, GDExtensionConstStringNamePtr p_key_class_name, GDExtensionConstVariantPtr p_key_script, GDExtensionVariantType p_value_type, GDExtensionConstStringNamePtr p_value_class_name, GDExtensionConstVariantPtr p_value_script);
  2207. /* INTERFACE: Object */
  2208. /**
  2209. * @name object_method_bind_call
  2210. * @since 4.1
  2211. *
  2212. * Calls a method on an Object.
  2213. *
  2214. * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
  2215. * @param p_instance A pointer to the Object.
  2216. * @param p_args A pointer to a C array of Variants representing the arguments.
  2217. * @param p_arg_count The number of arguments.
  2218. * @param r_ret A pointer to Variant which will receive the return value.
  2219. * @param r_error A pointer to a GDExtensionCallError struct that will receive error information.
  2220. */
  2221. typedef void (*GDExtensionInterfaceObjectMethodBindCall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionUninitializedVariantPtr r_ret, GDExtensionCallError *r_error);
  2222. /**
  2223. * @name object_method_bind_ptrcall
  2224. * @since 4.1
  2225. *
  2226. * Calls a method on an Object (using a "ptrcall").
  2227. *
  2228. * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
  2229. * @param p_instance A pointer to the Object.
  2230. * @param p_args A pointer to a C array representing the arguments.
  2231. * @param r_ret A pointer to the Object that will receive the return value.
  2232. */
  2233. typedef void (*GDExtensionInterfaceObjectMethodBindPtrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
  2234. /**
  2235. * @name object_destroy
  2236. * @since 4.1
  2237. *
  2238. * Destroys an Object.
  2239. *
  2240. * @param p_o A pointer to the Object.
  2241. */
  2242. typedef void (*GDExtensionInterfaceObjectDestroy)(GDExtensionObjectPtr p_o);
  2243. /**
  2244. * @name global_get_singleton
  2245. * @since 4.1
  2246. *
  2247. * Gets a global singleton by name.
  2248. *
  2249. * @param p_name A pointer to a StringName with the singleton name.
  2250. *
  2251. * @return A pointer to the singleton Object.
  2252. */
  2253. typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensionConstStringNamePtr p_name);
  2254. /**
  2255. * @name object_get_instance_binding
  2256. * @since 4.1
  2257. *
  2258. * Gets a pointer representing an Object's instance binding.
  2259. *
  2260. * @param p_o A pointer to the Object.
  2261. * @param p_token A token the library received by the GDExtension's entry point function.
  2262. * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
  2263. *
  2264. * @return A pointer to the instance binding.
  2265. */
  2266. typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  2267. /**
  2268. * @name object_set_instance_binding
  2269. * @since 4.1
  2270. *
  2271. * Sets an Object's instance binding.
  2272. *
  2273. * @param p_o A pointer to the Object.
  2274. * @param p_token A token the library received by the GDExtension's entry point function.
  2275. * @param p_binding A pointer to the instance binding.
  2276. * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
  2277. */
  2278. typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks);
  2279. /**
  2280. * @name object_free_instance_binding
  2281. * @since 4.2
  2282. *
  2283. * Free an Object's instance binding.
  2284. *
  2285. * @param p_o A pointer to the Object.
  2286. * @param p_token A token the library received by the GDExtension's entry point function.
  2287. */
  2288. typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token);
  2289. /**
  2290. * @name object_set_instance
  2291. * @since 4.1
  2292. *
  2293. * Sets an extension class instance on a Object.
  2294. *
  2295. * `p_classname` should be a registered extension class and should extend the `p_o` Object's class.
  2296. *
  2297. * @param p_o A pointer to the Object.
  2298. * @param p_classname A pointer to a StringName with the registered extension class's name.
  2299. * @param p_instance A pointer to the extension class instance.
  2300. */
  2301. typedef void (*GDExtensionInterfaceObjectSetInstance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance);
  2302. /**
  2303. * @name object_get_class_name
  2304. * @since 4.1
  2305. *
  2306. * Gets the class name of an Object.
  2307. *
  2308. * If the GDExtension wraps the Godot object in an abstraction specific to its class, this is the
  2309. * function that should be used to determine which wrapper to use.
  2310. *
  2311. * @param p_object A pointer to the Object.
  2312. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2313. * @param r_class_name A pointer to a String to receive the class name.
  2314. *
  2315. * @return true if successful in getting the class name; otherwise false.
  2316. */
  2317. typedef GDExtensionBool (*GDExtensionInterfaceObjectGetClassName)(GDExtensionConstObjectPtr p_object, GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringNamePtr r_class_name);
  2318. /**
  2319. * @name object_cast_to
  2320. * @since 4.1
  2321. *
  2322. * Casts an Object to a different type.
  2323. *
  2324. * @param p_object A pointer to the Object.
  2325. * @param p_class_tag A pointer uniquely identifying a built-in class in the ClassDB.
  2326. *
  2327. * @return Returns a pointer to the Object, or NULL if it can't be cast to the requested type.
  2328. */
  2329. typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectCastTo)(GDExtensionConstObjectPtr p_object, void *p_class_tag);
  2330. /**
  2331. * @name object_get_instance_from_id
  2332. * @since 4.1
  2333. *
  2334. * Gets an Object by its instance ID.
  2335. *
  2336. * @param p_instance_id The instance ID.
  2337. *
  2338. * @return A pointer to the Object.
  2339. */
  2340. typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectGetInstanceFromId)(GDObjectInstanceID p_instance_id);
  2341. /**
  2342. * @name object_get_instance_id
  2343. * @since 4.1
  2344. *
  2345. * Gets the instance ID from an Object.
  2346. *
  2347. * @param p_object A pointer to the Object.
  2348. *
  2349. * @return The instance ID.
  2350. */
  2351. typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensionConstObjectPtr p_object);
  2352. /**
  2353. * @name object_has_script_method
  2354. * @since 4.3
  2355. *
  2356. * Checks if this object has a script with the given method.
  2357. *
  2358. * @param p_object A pointer to the Object.
  2359. * @param p_method A pointer to a StringName identifying the method.
  2360. *
  2361. * @return true if the object has a script and that script has a method with the given name. Returns false if the object has no script.
  2362. */
  2363. typedef GDExtensionBool (*GDExtensionInterfaceObjectHasScriptMethod)(GDExtensionConstObjectPtr p_object, GDExtensionConstStringNamePtr p_method);
  2364. /**
  2365. * @name object_call_script_method
  2366. * @since 4.3
  2367. *
  2368. * Call the given script method on this object.
  2369. *
  2370. * @param p_object A pointer to the Object.
  2371. * @param p_method A pointer to a StringName identifying the method.
  2372. * @param p_args A pointer to a C array of Variant.
  2373. * @param p_argument_count The number of arguments.
  2374. * @param r_return A pointer a Variant which will be assigned the return value.
  2375. * @param r_error A pointer the structure which will hold error information.
  2376. */
  2377. typedef void (*GDExtensionInterfaceObjectCallScriptMethod)(GDExtensionObjectPtr p_object, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
  2378. /* INTERFACE: Reference */
  2379. /**
  2380. * @name ref_get_object
  2381. * @since 4.1
  2382. *
  2383. * Gets the Object from a reference.
  2384. *
  2385. * @param p_ref A pointer to the reference.
  2386. *
  2387. * @return A pointer to the Object from the reference or NULL.
  2388. */
  2389. typedef GDExtensionObjectPtr (*GDExtensionInterfaceRefGetObject)(GDExtensionConstRefPtr p_ref);
  2390. /**
  2391. * @name ref_set_object
  2392. * @since 4.1
  2393. *
  2394. * Sets the Object referred to by a reference.
  2395. *
  2396. * @param p_ref A pointer to the reference.
  2397. * @param p_object A pointer to the Object to refer to.
  2398. */
  2399. typedef void (*GDExtensionInterfaceRefSetObject)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object);
  2400. /* INTERFACE: Script Instance */
  2401. /**
  2402. * @name script_instance_create
  2403. * @since 4.1
  2404. * @deprecated in Godot 4.2. Use `script_instance_create3` instead.
  2405. *
  2406. * Creates a script instance that contains the given info and instance data.
  2407. *
  2408. * @param p_info A pointer to a GDExtensionScriptInstanceInfo struct.
  2409. * @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.
  2410. *
  2411. * @return A pointer to a ScriptInstanceExtension object.
  2412. */
  2413. typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
  2414. /**
  2415. * @name script_instance_create2
  2416. * @since 4.2
  2417. * @deprecated in Godot 4.3. Use `script_instance_create3` instead.
  2418. *
  2419. * Creates a script instance that contains the given info and instance data.
  2420. *
  2421. * @param p_info A pointer to a GDExtensionScriptInstanceInfo2 struct.
  2422. * @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.
  2423. *
  2424. * @return A pointer to a ScriptInstanceExtension object.
  2425. */
  2426. typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate2)(const GDExtensionScriptInstanceInfo2 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
  2427. /**
  2428. * @name script_instance_create3
  2429. * @since 4.3
  2430. *
  2431. * Creates a script instance that contains the given info and instance data.
  2432. *
  2433. * @param p_info A pointer to a GDExtensionScriptInstanceInfo3 struct.
  2434. * @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.
  2435. *
  2436. * @return A pointer to a ScriptInstanceExtension object.
  2437. */
  2438. typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate3)(const GDExtensionScriptInstanceInfo3 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
  2439. /**
  2440. * @name placeholder_script_instance_create
  2441. * @since 4.2
  2442. *
  2443. * Creates a placeholder script instance for a given script and instance.
  2444. *
  2445. * This interface is optional as a custom placeholder could also be created with script_instance_create().
  2446. *
  2447. * @param p_language A pointer to a ScriptLanguage.
  2448. * @param p_script A pointer to a Script.
  2449. * @param p_owner A pointer to an Object.
  2450. *
  2451. * @return A pointer to a PlaceHolderScriptInstance object.
  2452. */
  2453. typedef GDExtensionScriptInstancePtr (*GDExtensionInterfacePlaceHolderScriptInstanceCreate)(GDExtensionObjectPtr p_language, GDExtensionObjectPtr p_script, GDExtensionObjectPtr p_owner);
  2454. /**
  2455. * @name placeholder_script_instance_update
  2456. * @since 4.2
  2457. *
  2458. * Updates a placeholder script instance with the given properties and values.
  2459. *
  2460. * The passed in placeholder must be an instance of PlaceHolderScriptInstance
  2461. * such as the one returned by placeholder_script_instance_create().
  2462. *
  2463. * @param p_placeholder A pointer to a PlaceHolderScriptInstance.
  2464. * @param p_properties A pointer to an Array of Dictionary representing PropertyInfo.
  2465. * @param p_values A pointer to a Dictionary mapping StringName to Variant values.
  2466. */
  2467. typedef void (*GDExtensionInterfacePlaceHolderScriptInstanceUpdate)(GDExtensionScriptInstancePtr p_placeholder, GDExtensionConstTypePtr p_properties, GDExtensionConstTypePtr p_values);
  2468. /**
  2469. * @name object_get_script_instance
  2470. * @since 4.2
  2471. *
  2472. * Get the script instance data attached to this object.
  2473. *
  2474. * @param p_object A pointer to the Object.
  2475. * @param p_language A pointer to the language expected for this script instance.
  2476. *
  2477. * @return A GDExtensionScriptInstanceDataPtr that was attached to this object as part of script_instance_create.
  2478. */
  2479. typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptInstance)(GDExtensionConstObjectPtr p_object, GDExtensionObjectPtr p_language);
  2480. /**
  2481. * @name object_set_script_instance
  2482. * @since 4.5
  2483. *
  2484. * Set the script instance data attached to this object.
  2485. *
  2486. * @param p_object A pointer to the Object.
  2487. * @param p_script_instance A pointer to the script instance data to attach to this object.
  2488. */
  2489. typedef void (*GDExtensionInterfaceObjectSetScriptInstance)(GDExtensionObjectPtr p_object, GDExtensionScriptInstanceDataPtr p_script_instance);
  2490. /* INTERFACE: Callable */
  2491. /**
  2492. * @name callable_custom_create
  2493. * @since 4.2
  2494. * @deprecated in Godot 4.3. Use `callable_custom_create2` instead.
  2495. *
  2496. * Creates a custom Callable object from a function pointer.
  2497. *
  2498. * Provided struct can be safely freed once the function returns.
  2499. *
  2500. * @param r_callable A pointer that will receive the new Callable.
  2501. * @param p_callable_custom_info The info required to construct a Callable.
  2502. */
  2503. typedef void (*GDExtensionInterfaceCallableCustomCreate)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo *p_callable_custom_info);
  2504. /**
  2505. * @name callable_custom_create2
  2506. * @since 4.3
  2507. *
  2508. * Creates a custom Callable object from a function pointer.
  2509. *
  2510. * Provided struct can be safely freed once the function returns.
  2511. *
  2512. * @param r_callable A pointer that will receive the new Callable.
  2513. * @param p_callable_custom_info The info required to construct a Callable.
  2514. */
  2515. typedef void (*GDExtensionInterfaceCallableCustomCreate2)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo2 *p_callable_custom_info);
  2516. /**
  2517. * @name callable_custom_get_userdata
  2518. * @since 4.2
  2519. *
  2520. * Retrieves the userdata pointer from a custom Callable.
  2521. *
  2522. * 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.
  2523. *
  2524. * @param p_callable A pointer to a Callable.
  2525. * @param p_token A pointer to an address that uniquely identifies the GDExtension.
  2526. *
  2527. * @return The userdata pointer given when creating this custom Callable.
  2528. */
  2529. typedef void *(*GDExtensionInterfaceCallableCustomGetUserData)(GDExtensionConstTypePtr p_callable, void *p_token);
  2530. /* INTERFACE: ClassDB */
  2531. /**
  2532. * @name classdb_construct_object
  2533. * @since 4.1
  2534. * @deprecated in Godot 4.4. Use `classdb_construct_object2` instead.
  2535. *
  2536. * Constructs an Object of the requested class.
  2537. *
  2538. * 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.
  2539. *
  2540. * @param p_classname A pointer to a StringName with the class name.
  2541. *
  2542. * @return A pointer to the newly created Object.
  2543. */
  2544. typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject)(GDExtensionConstStringNamePtr p_classname);
  2545. /**
  2546. * @name classdb_construct_object2
  2547. * @since 4.4
  2548. *
  2549. * Constructs an Object of the requested class.
  2550. *
  2551. * 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.
  2552. *
  2553. * "NOTIFICATION_POSTINITIALIZE" must be sent after construction.
  2554. *
  2555. * @param p_classname A pointer to a StringName with the class name.
  2556. *
  2557. * @return A pointer to the newly created Object.
  2558. */
  2559. typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject2)(GDExtensionConstStringNamePtr p_classname);
  2560. /**
  2561. * @name classdb_get_method_bind
  2562. * @since 4.1
  2563. *
  2564. * Gets a pointer to the MethodBind in ClassDB for the given class, method and hash.
  2565. *
  2566. * @param p_classname A pointer to a StringName with the class name.
  2567. * @param p_methodname A pointer to a StringName with the method name.
  2568. * @param p_hash A hash representing the function signature.
  2569. *
  2570. * @return A pointer to the MethodBind from ClassDB.
  2571. */
  2572. typedef GDExtensionMethodBindPtr (*GDExtensionInterfaceClassdbGetMethodBind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash);
  2573. /**
  2574. * @name classdb_get_class_tag
  2575. * @since 4.1
  2576. *
  2577. * Gets a pointer uniquely identifying the given built-in class in the ClassDB.
  2578. *
  2579. * @param p_classname A pointer to a StringName with the class name.
  2580. *
  2581. * @return A pointer uniquely identifying the built-in class in the ClassDB.
  2582. */
  2583. typedef void *(*GDExtensionInterfaceClassdbGetClassTag)(GDExtensionConstStringNamePtr p_classname);
  2584. /* INTERFACE: ClassDB Extension */
  2585. /**
  2586. * @name classdb_register_extension_class
  2587. * @since 4.1
  2588. * @deprecated in Godot 4.2. Use `classdb_register_extension_class4` instead.
  2589. *
  2590. * Registers an extension class in the ClassDB.
  2591. *
  2592. * Provided struct can be safely freed once the function returns.
  2593. *
  2594. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2595. * @param p_class_name A pointer to a StringName with the class name.
  2596. * @param p_parent_class_name A pointer to a StringName with the parent class name.
  2597. * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo struct.
  2598. */
  2599. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs);
  2600. /**
  2601. * @name classdb_register_extension_class2
  2602. * @since 4.2
  2603. * @deprecated in Godot 4.3. Use `classdb_register_extension_class4` instead.
  2604. *
  2605. * Registers an extension class in the ClassDB.
  2606. *
  2607. * Provided struct can be safely freed once the function returns.
  2608. *
  2609. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2610. * @param p_class_name A pointer to a StringName with the class name.
  2611. * @param p_parent_class_name A pointer to a StringName with the parent class name.
  2612. * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo2 struct.
  2613. */
  2614. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass2)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo2 *p_extension_funcs);
  2615. /**
  2616. * @name classdb_register_extension_class3
  2617. * @since 4.3
  2618. * @deprecated in Godot 4.4. Use `classdb_register_extension_class4` instead.
  2619. *
  2620. * Registers an extension class in the ClassDB.
  2621. *
  2622. * Provided struct can be safely freed once the function returns.
  2623. *
  2624. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2625. * @param p_class_name A pointer to a StringName with the class name.
  2626. * @param p_parent_class_name A pointer to a StringName with the parent class name.
  2627. * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo2 struct.
  2628. */
  2629. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass3)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo3 *p_extension_funcs);
  2630. /**
  2631. * @name classdb_register_extension_class4
  2632. * @since 4.4
  2633. *
  2634. * Registers an extension class in the ClassDB.
  2635. *
  2636. * Provided struct can be safely freed once the function returns.
  2637. *
  2638. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2639. * @param p_class_name A pointer to a StringName with the class name.
  2640. * @param p_parent_class_name A pointer to a StringName with the parent class name.
  2641. * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo2 struct.
  2642. */
  2643. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass4)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo4 *p_extension_funcs);
  2644. /**
  2645. * @name classdb_register_extension_class_method
  2646. * @since 4.1
  2647. *
  2648. * Registers a method on an extension class in the ClassDB.
  2649. *
  2650. * Provided struct can be safely freed once the function returns.
  2651. *
  2652. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2653. * @param p_class_name A pointer to a StringName with the class name.
  2654. * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct.
  2655. */
  2656. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info);
  2657. /**
  2658. * @name classdb_register_extension_class_virtual_method
  2659. * @since 4.3
  2660. *
  2661. * Registers a virtual method on an extension class in ClassDB, that can be implemented by scripts or other extensions.
  2662. *
  2663. * Provided struct can be safely freed once the function returns.
  2664. *
  2665. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2666. * @param p_class_name A pointer to a StringName with the class name.
  2667. * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct.
  2668. */
  2669. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassVirtualMethodInfo *p_method_info);
  2670. /**
  2671. * @name classdb_register_extension_class_integer_constant
  2672. * @since 4.1
  2673. *
  2674. * Registers an integer constant on an extension class in the ClassDB.
  2675. *
  2676. * Note about registering bitfield values (if p_is_bitfield is true): even though p_constant_value is signed, language bindings are
  2677. * advised to treat bitfields as uint64_t, since this is generally clearer and can prevent mistakes like using -1 for setting all bits.
  2678. * Language APIs should thus provide an abstraction that registers bitfields (uint64_t) separately from regular constants (int64_t).
  2679. *
  2680. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2681. * @param p_class_name A pointer to a StringName with the class name.
  2682. * @param p_enum_name A pointer to a StringName with the enum name.
  2683. * @param p_constant_name A pointer to a StringName with the constant name.
  2684. * @param p_constant_value The constant value.
  2685. * @param p_is_bitfield Whether or not this constant is part of a bitfield.
  2686. */
  2687. 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);
  2688. /**
  2689. * @name classdb_register_extension_class_property
  2690. * @since 4.1
  2691. *
  2692. * Registers a property on an extension class in the ClassDB.
  2693. *
  2694. * Provided struct can be safely freed once the function returns.
  2695. *
  2696. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2697. * @param p_class_name A pointer to a StringName with the class name.
  2698. * @param p_info A pointer to a GDExtensionPropertyInfo struct.
  2699. * @param p_setter A pointer to a StringName with the name of the setter method.
  2700. * @param p_getter A pointer to a StringName with the name of the getter method.
  2701. */
  2702. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassProperty)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter);
  2703. /**
  2704. * @name classdb_register_extension_class_property_indexed
  2705. * @since 4.2
  2706. *
  2707. * Registers an indexed property on an extension class in the ClassDB.
  2708. *
  2709. * Provided struct can be safely freed once the function returns.
  2710. *
  2711. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2712. * @param p_class_name A pointer to a StringName with the class name.
  2713. * @param p_info A pointer to a GDExtensionPropertyInfo struct.
  2714. * @param p_setter A pointer to a StringName with the name of the setter method.
  2715. * @param p_getter A pointer to a StringName with the name of the getter method.
  2716. * @param p_index The index to pass as the first argument to the getter and setter methods.
  2717. */
  2718. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter, GDExtensionInt p_index);
  2719. /**
  2720. * @name classdb_register_extension_class_property_group
  2721. * @since 4.1
  2722. *
  2723. * Registers a property group on an extension class in the ClassDB.
  2724. *
  2725. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2726. * @param p_class_name A pointer to a StringName with the class name.
  2727. * @param p_group_name A pointer to a String with the group name.
  2728. * @param p_prefix A pointer to a String with the prefix used by properties in this group.
  2729. */
  2730. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix);
  2731. /**
  2732. * @name classdb_register_extension_class_property_subgroup
  2733. * @since 4.1
  2734. *
  2735. * Registers a property subgroup on an extension class in the ClassDB.
  2736. *
  2737. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2738. * @param p_class_name A pointer to a StringName with the class name.
  2739. * @param p_subgroup_name A pointer to a String with the subgroup name.
  2740. * @param p_prefix A pointer to a String with the prefix used by properties in this subgroup.
  2741. */
  2742. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix);
  2743. /**
  2744. * @name classdb_register_extension_class_signal
  2745. * @since 4.1
  2746. *
  2747. * Registers a signal on an extension class in the ClassDB.
  2748. *
  2749. * Provided structs can be safely freed once the function returns.
  2750. *
  2751. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2752. * @param p_class_name A pointer to a StringName with the class name.
  2753. * @param p_signal_name A pointer to a StringName with the signal name.
  2754. * @param p_argument_info A pointer to a GDExtensionPropertyInfo struct.
  2755. * @param p_argument_count The number of arguments the signal receives.
  2756. */
  2757. typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count);
  2758. /**
  2759. * @name classdb_unregister_extension_class
  2760. * @since 4.1
  2761. *
  2762. * Unregisters an extension class in the ClassDB.
  2763. *
  2764. * Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first.
  2765. *
  2766. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2767. * @param p_class_name A pointer to a StringName with the class name.
  2768. */
  2769. typedef void (*GDExtensionInterfaceClassdbUnregisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name);
  2770. /**
  2771. * @name get_library_path
  2772. * @since 4.1
  2773. *
  2774. * Gets the path to the current GDExtension library.
  2775. *
  2776. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2777. * @param r_path A pointer to a String which will receive the path.
  2778. */
  2779. typedef void (*GDExtensionInterfaceGetLibraryPath)(GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringPtr r_path);
  2780. /**
  2781. * @name editor_add_plugin
  2782. * @since 4.1
  2783. *
  2784. * Adds an editor plugin.
  2785. *
  2786. * It's safe to call during initialization.
  2787. *
  2788. * @param p_class_name A pointer to a StringName with the name of a class (descending from EditorPlugin) which is already registered with ClassDB.
  2789. */
  2790. typedef void (*GDExtensionInterfaceEditorAddPlugin)(GDExtensionConstStringNamePtr p_class_name);
  2791. /**
  2792. * @name editor_remove_plugin
  2793. * @since 4.1
  2794. *
  2795. * Removes an editor plugin.
  2796. *
  2797. * @param p_class_name A pointer to a StringName with the name of a class that was previously added as an editor plugin.
  2798. */
  2799. typedef void (*GDExtensionInterfaceEditorRemovePlugin)(GDExtensionConstStringNamePtr p_class_name);
  2800. /**
  2801. * @name editor_help_load_xml_from_utf8_chars
  2802. * @since 4.3
  2803. *
  2804. * Loads new XML-formatted documentation data in the editor.
  2805. *
  2806. * The provided pointer can be immediately freed once the function returns.
  2807. *
  2808. * @param p_data A pointer to a UTF-8 encoded C string (null terminated).
  2809. */
  2810. typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars)(const char *p_data);
  2811. /**
  2812. * @name editor_help_load_xml_from_utf8_chars_and_len
  2813. * @since 4.3
  2814. *
  2815. * Loads new XML-formatted documentation data in the editor.
  2816. *
  2817. * The provided pointer can be immediately freed once the function returns.
  2818. *
  2819. * @param p_data A pointer to a UTF-8 encoded C string.
  2820. * @param p_size The number of bytes (not code units).
  2821. */
  2822. typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen)(const char *p_data, GDExtensionInt p_size);
  2823. /**
  2824. * @name editor_register_get_classes_used_callback
  2825. * @since 4.5
  2826. *
  2827. * Registers a callback that Godot can call to get the list of all classes (from ClassDB) that may be used by the calling GDExtension.
  2828. *
  2829. * This is used by the editor to generate a build profile (in "Tools" > "Engine Compilation Configuration Editor..." > "Detect from project"),
  2830. * in order to recompile Godot with only the classes used.
  2831. * In the provided callback, the GDExtension should provide the list of classes that _may_ be used statically, thus the time of invocation shouldn't matter.
  2832. * If a GDExtension doesn't register a callback, Godot will assume that it could be using any classes.
  2833. *
  2834. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2835. * @param p_callback The callback to retrieve the list of classes used.
  2836. */
  2837. typedef void (*GDExtensionInterfaceEditorRegisterGetClassesUsedCallback)(GDExtensionClassLibraryPtr p_library, GDExtensionEditorGetClassesUsedCallback p_callback);
  2838. /**
  2839. * @name register_main_loop_callbacks
  2840. * @since 4.5
  2841. *
  2842. * Registers callbacks to be called at different phases of the main loop.
  2843. *
  2844. * @param p_library A pointer the library received by the GDExtension's entry point function.
  2845. * @param p_callbacks A pointer to the structure that contains the callbacks.
  2846. */
  2847. typedef void (*GDExtensionInterfaceRegisterMainLoopCallbacks)(GDExtensionClassLibraryPtr p_library, const GDExtensionMainLoopCallbacks *p_callbacks);
  2848. #ifdef __cplusplus
  2849. }
  2850. #endif