2
0

gdextension_interface.h 105 KB

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