gdextension_interface.h 125 KB

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