gdextension_interface.h 132 KB

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