gdextension_interface.h 120 KB

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