gdextension_interface.cpp 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. /**************************************************************************/
  2. /* gdextension_interface.cpp */
  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. #include "gdextension_interface.h"
  31. #include "core/config/engine.h"
  32. #include "core/extension/gdextension.h"
  33. #include "core/io/file_access.h"
  34. #include "core/io/xml_parser.h"
  35. #include "core/object/class_db.h"
  36. #include "core/object/script_language_extension.h"
  37. #include "core/object/worker_thread_pool.h"
  38. #include "core/os/memory.h"
  39. #include "core/variant/variant.h"
  40. #include "core/version.h"
  41. // Core interface functions.
  42. GDExtensionInterfaceFunctionPtr gdextension_get_proc_address(const char *p_name) {
  43. return GDExtension::get_interface_function(p_name);
  44. }
  45. static void gdextension_get_godot_version(GDExtensionGodotVersion *r_godot_version) {
  46. r_godot_version->major = VERSION_MAJOR;
  47. r_godot_version->minor = VERSION_MINOR;
  48. r_godot_version->patch = VERSION_PATCH;
  49. r_godot_version->string = VERSION_FULL_NAME;
  50. }
  51. // Memory Functions
  52. static void *gdextension_mem_alloc(size_t p_size) {
  53. return memalloc(p_size);
  54. }
  55. static void *gdextension_mem_realloc(void *p_mem, size_t p_size) {
  56. return memrealloc(p_mem, p_size);
  57. }
  58. static void gdextension_mem_free(void *p_mem) {
  59. memfree(p_mem);
  60. }
  61. // Helper print functions.
  62. static void gdextension_print_error(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify) {
  63. _err_print_error(p_function, p_file, p_line, p_description, p_editor_notify, ERR_HANDLER_ERROR);
  64. }
  65. static void gdextension_print_error_with_message(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify) {
  66. _err_print_error(p_function, p_file, p_line, p_description, p_message, p_editor_notify, ERR_HANDLER_ERROR);
  67. }
  68. static void gdextension_print_warning(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify) {
  69. _err_print_error(p_function, p_file, p_line, p_description, p_editor_notify, ERR_HANDLER_WARNING);
  70. }
  71. static void gdextension_print_warning_with_message(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify) {
  72. _err_print_error(p_function, p_file, p_line, p_description, p_message, p_editor_notify, ERR_HANDLER_WARNING);
  73. }
  74. static void gdextension_print_script_error(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify) {
  75. _err_print_error(p_function, p_file, p_line, p_description, p_editor_notify, ERR_HANDLER_SCRIPT);
  76. }
  77. static void gdextension_print_script_error_with_message(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify) {
  78. _err_print_error(p_function, p_file, p_line, p_description, p_message, p_editor_notify, ERR_HANDLER_SCRIPT);
  79. }
  80. uint64_t gdextension_get_native_struct_size(GDExtensionConstStringNamePtr p_name) {
  81. const StringName name = *reinterpret_cast<const StringName *>(p_name);
  82. return ClassDB::get_native_struct_size(name);
  83. }
  84. // Variant functions
  85. static void gdextension_variant_new_copy(GDExtensionUninitializedVariantPtr r_dest, GDExtensionConstVariantPtr p_src) {
  86. memnew_placement(reinterpret_cast<Variant *>(r_dest), Variant(*reinterpret_cast<const Variant *>(p_src)));
  87. }
  88. static void gdextension_variant_new_nil(GDExtensionUninitializedVariantPtr r_dest) {
  89. memnew_placement(reinterpret_cast<Variant *>(r_dest), Variant);
  90. }
  91. static void gdextension_variant_destroy(GDExtensionVariantPtr p_self) {
  92. reinterpret_cast<Variant *>(p_self)->~Variant();
  93. }
  94. // variant type
  95. static void gdextension_variant_call(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argcount, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error) {
  96. Variant *self = (Variant *)p_self;
  97. const StringName method = *reinterpret_cast<const StringName *>(p_method);
  98. const Variant **args = (const Variant **)p_args;
  99. Callable::CallError error;
  100. memnew_placement(r_return, Variant);
  101. Variant *ret = reinterpret_cast<Variant *>(r_return);
  102. self->callp(method, args, p_argcount, *ret, error);
  103. if (r_error) {
  104. r_error->error = (GDExtensionCallErrorType)(error.error);
  105. r_error->argument = error.argument;
  106. r_error->expected = error.expected;
  107. }
  108. }
  109. static void gdextension_variant_call_static(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argcount, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error) {
  110. Variant::Type type = (Variant::Type)p_type;
  111. const StringName method = *reinterpret_cast<const StringName *>(p_method);
  112. const Variant **args = (const Variant **)p_args;
  113. Callable::CallError error;
  114. memnew_placement(r_return, Variant);
  115. Variant *ret = reinterpret_cast<Variant *>(r_return);
  116. Variant::call_static(type, method, args, p_argcount, *ret, error);
  117. if (r_error) {
  118. r_error->error = (GDExtensionCallErrorType)error.error;
  119. r_error->argument = error.argument;
  120. r_error->expected = error.expected;
  121. }
  122. }
  123. static void gdextension_variant_evaluate(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionUninitializedVariantPtr r_return, GDExtensionBool *r_valid) {
  124. Variant::Operator op = (Variant::Operator)p_op;
  125. const Variant *a = (const Variant *)p_a;
  126. const Variant *b = (const Variant *)p_b;
  127. bool valid;
  128. memnew_placement(r_return, Variant);
  129. Variant *ret = reinterpret_cast<Variant *>(r_return);
  130. Variant::evaluate(op, *a, *b, *ret, valid);
  131. *r_valid = valid;
  132. }
  133. static void gdextension_variant_set(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid) {
  134. Variant *self = (Variant *)p_self;
  135. const Variant *key = (const Variant *)p_key;
  136. const Variant *value = (const Variant *)p_value;
  137. bool valid;
  138. self->set(*key, *value, &valid);
  139. *r_valid = valid;
  140. }
  141. static void gdextension_variant_set_named(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid) {
  142. Variant *self = (Variant *)p_self;
  143. const StringName *key = (const StringName *)p_key;
  144. const Variant *value = (const Variant *)p_value;
  145. bool valid;
  146. self->set_named(*key, *value, valid);
  147. *r_valid = valid;
  148. }
  149. static void gdextension_variant_set_keyed(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid) {
  150. Variant *self = (Variant *)p_self;
  151. const Variant *key = (const Variant *)p_key;
  152. const Variant *value = (const Variant *)p_value;
  153. bool valid;
  154. self->set_keyed(*key, *value, valid);
  155. *r_valid = valid;
  156. }
  157. static void gdextension_variant_set_indexed(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob) {
  158. Variant *self = (Variant *)p_self;
  159. const Variant *value = (const Variant *)p_value;
  160. bool valid;
  161. bool oob;
  162. self->set_indexed(p_index, *value, valid, oob);
  163. *r_valid = valid;
  164. *r_oob = oob;
  165. }
  166. static void gdextension_variant_get(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid) {
  167. const Variant *self = (const Variant *)p_self;
  168. const Variant *key = (const Variant *)p_key;
  169. bool valid;
  170. memnew_placement(r_ret, Variant(self->get(*key, &valid)));
  171. *r_valid = valid;
  172. }
  173. static void gdextension_variant_get_named(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid) {
  174. const Variant *self = (const Variant *)p_self;
  175. const StringName *key = (const StringName *)p_key;
  176. bool valid;
  177. memnew_placement(r_ret, Variant(self->get_named(*key, valid)));
  178. *r_valid = valid;
  179. }
  180. static void gdextension_variant_get_keyed(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid) {
  181. const Variant *self = (const Variant *)p_self;
  182. const Variant *key = (const Variant *)p_key;
  183. bool valid;
  184. memnew_placement(r_ret, Variant(self->get_keyed(*key, valid)));
  185. *r_valid = valid;
  186. }
  187. static void gdextension_variant_get_indexed(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob) {
  188. const Variant *self = (const Variant *)p_self;
  189. bool valid;
  190. bool oob;
  191. memnew_placement(r_ret, Variant(self->get_indexed(p_index, valid, oob)));
  192. *r_valid = valid;
  193. *r_oob = oob;
  194. }
  195. /// Iteration.
  196. static GDExtensionBool gdextension_variant_iter_init(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_iter, GDExtensionBool *r_valid) {
  197. const Variant *self = (const Variant *)p_self;
  198. memnew_placement(r_iter, Variant);
  199. Variant *iter = reinterpret_cast<Variant *>(r_iter);
  200. bool valid;
  201. bool ret = self->iter_init(*iter, valid);
  202. *r_valid = valid;
  203. return ret;
  204. }
  205. static GDExtensionBool gdextension_variant_iter_next(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid) {
  206. const Variant *self = (const Variant *)p_self;
  207. Variant *iter = (Variant *)r_iter;
  208. bool valid;
  209. bool ret = self->iter_next(*iter, valid);
  210. *r_valid = valid;
  211. return ret;
  212. }
  213. static void gdextension_variant_iter_get(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid) {
  214. const Variant *self = (const Variant *)p_self;
  215. Variant *iter = (Variant *)r_iter;
  216. bool valid;
  217. memnew_placement(r_ret, Variant(self->iter_get(*iter, valid)));
  218. *r_valid = valid;
  219. }
  220. /// Variant functions.
  221. static GDExtensionInt gdextension_variant_hash(GDExtensionConstVariantPtr p_self) {
  222. const Variant *self = (const Variant *)p_self;
  223. return self->hash();
  224. }
  225. static GDExtensionInt gdextension_variant_recursive_hash(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count) {
  226. const Variant *self = (const Variant *)p_self;
  227. return self->recursive_hash(p_recursion_count);
  228. }
  229. static GDExtensionBool gdextension_variant_hash_compare(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other) {
  230. const Variant *self = (const Variant *)p_self;
  231. const Variant *other = (const Variant *)p_other;
  232. return self->hash_compare(*other);
  233. }
  234. static GDExtensionBool gdextension_variant_booleanize(GDExtensionConstVariantPtr p_self) {
  235. const Variant *self = (const Variant *)p_self;
  236. return self->booleanize();
  237. }
  238. static void gdextension_variant_duplicate(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool p_deep) {
  239. const Variant *self = (const Variant *)p_self;
  240. memnew_placement(r_ret, Variant(self->duplicate(p_deep)));
  241. }
  242. static void gdextension_variant_stringify(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_ret) {
  243. const Variant *self = (const Variant *)p_self;
  244. memnew_placement(r_ret, String(*self));
  245. }
  246. static GDExtensionVariantType gdextension_variant_get_type(GDExtensionConstVariantPtr p_self) {
  247. const Variant *self = (const Variant *)p_self;
  248. return (GDExtensionVariantType)self->get_type();
  249. }
  250. static GDExtensionBool gdextension_variant_has_method(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method) {
  251. const Variant *self = (const Variant *)p_self;
  252. const StringName *method = (const StringName *)p_method;
  253. return self->has_method(*method);
  254. }
  255. static GDExtensionBool gdextension_variant_has_member(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member) {
  256. return Variant::has_member((Variant::Type)p_type, *((const StringName *)p_member));
  257. }
  258. static GDExtensionBool gdextension_variant_has_key(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid) {
  259. const Variant *self = (const Variant *)p_self;
  260. const Variant *key = (const Variant *)p_key;
  261. bool valid;
  262. bool ret = self->has_key(*key, valid);
  263. *r_valid = valid;
  264. return ret;
  265. }
  266. static void gdextension_variant_get_type_name(GDExtensionVariantType p_type, GDExtensionUninitializedVariantPtr r_ret) {
  267. String name = Variant::get_type_name((Variant::Type)p_type);
  268. memnew_placement(r_ret, String(name));
  269. }
  270. static GDExtensionBool gdextension_variant_can_convert(GDExtensionVariantType p_from, GDExtensionVariantType p_to) {
  271. return Variant::can_convert((Variant::Type)p_from, (Variant::Type)p_to);
  272. }
  273. static GDExtensionBool gdextension_variant_can_convert_strict(GDExtensionVariantType p_from, GDExtensionVariantType p_to) {
  274. return Variant::can_convert_strict((Variant::Type)p_from, (Variant::Type)p_to);
  275. }
  276. // Variant interaction.
  277. static GDExtensionVariantFromTypeConstructorFunc gdextension_get_variant_from_type_constructor(GDExtensionVariantType p_type) {
  278. switch (p_type) {
  279. case GDEXTENSION_VARIANT_TYPE_BOOL:
  280. return VariantTypeConstructor<bool>::variant_from_type;
  281. case GDEXTENSION_VARIANT_TYPE_INT:
  282. return VariantTypeConstructor<int64_t>::variant_from_type;
  283. case GDEXTENSION_VARIANT_TYPE_FLOAT:
  284. return VariantTypeConstructor<double>::variant_from_type;
  285. case GDEXTENSION_VARIANT_TYPE_STRING:
  286. return VariantTypeConstructor<String>::variant_from_type;
  287. case GDEXTENSION_VARIANT_TYPE_VECTOR2:
  288. return VariantTypeConstructor<Vector2>::variant_from_type;
  289. case GDEXTENSION_VARIANT_TYPE_VECTOR2I:
  290. return VariantTypeConstructor<Vector2i>::variant_from_type;
  291. case GDEXTENSION_VARIANT_TYPE_RECT2:
  292. return VariantTypeConstructor<Rect2>::variant_from_type;
  293. case GDEXTENSION_VARIANT_TYPE_RECT2I:
  294. return VariantTypeConstructor<Rect2i>::variant_from_type;
  295. case GDEXTENSION_VARIANT_TYPE_VECTOR3:
  296. return VariantTypeConstructor<Vector3>::variant_from_type;
  297. case GDEXTENSION_VARIANT_TYPE_VECTOR3I:
  298. return VariantTypeConstructor<Vector3i>::variant_from_type;
  299. case GDEXTENSION_VARIANT_TYPE_TRANSFORM2D:
  300. return VariantTypeConstructor<Transform2D>::variant_from_type;
  301. case GDEXTENSION_VARIANT_TYPE_VECTOR4:
  302. return VariantTypeConstructor<Vector4>::variant_from_type;
  303. case GDEXTENSION_VARIANT_TYPE_VECTOR4I:
  304. return VariantTypeConstructor<Vector4i>::variant_from_type;
  305. case GDEXTENSION_VARIANT_TYPE_PLANE:
  306. return VariantTypeConstructor<Plane>::variant_from_type;
  307. case GDEXTENSION_VARIANT_TYPE_QUATERNION:
  308. return VariantTypeConstructor<Quaternion>::variant_from_type;
  309. case GDEXTENSION_VARIANT_TYPE_AABB:
  310. return VariantTypeConstructor<AABB>::variant_from_type;
  311. case GDEXTENSION_VARIANT_TYPE_BASIS:
  312. return VariantTypeConstructor<Basis>::variant_from_type;
  313. case GDEXTENSION_VARIANT_TYPE_TRANSFORM3D:
  314. return VariantTypeConstructor<Transform3D>::variant_from_type;
  315. case GDEXTENSION_VARIANT_TYPE_PROJECTION:
  316. return VariantTypeConstructor<Projection>::variant_from_type;
  317. case GDEXTENSION_VARIANT_TYPE_COLOR:
  318. return VariantTypeConstructor<Color>::variant_from_type;
  319. case GDEXTENSION_VARIANT_TYPE_STRING_NAME:
  320. return VariantTypeConstructor<StringName>::variant_from_type;
  321. case GDEXTENSION_VARIANT_TYPE_NODE_PATH:
  322. return VariantTypeConstructor<NodePath>::variant_from_type;
  323. case GDEXTENSION_VARIANT_TYPE_RID:
  324. return VariantTypeConstructor<RID>::variant_from_type;
  325. case GDEXTENSION_VARIANT_TYPE_OBJECT:
  326. return VariantTypeConstructor<Object *>::variant_from_type;
  327. case GDEXTENSION_VARIANT_TYPE_CALLABLE:
  328. return VariantTypeConstructor<Callable>::variant_from_type;
  329. case GDEXTENSION_VARIANT_TYPE_SIGNAL:
  330. return VariantTypeConstructor<Signal>::variant_from_type;
  331. case GDEXTENSION_VARIANT_TYPE_DICTIONARY:
  332. return VariantTypeConstructor<Dictionary>::variant_from_type;
  333. case GDEXTENSION_VARIANT_TYPE_ARRAY:
  334. return VariantTypeConstructor<Array>::variant_from_type;
  335. case GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY:
  336. return VariantTypeConstructor<PackedByteArray>::variant_from_type;
  337. case GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY:
  338. return VariantTypeConstructor<PackedInt32Array>::variant_from_type;
  339. case GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY:
  340. return VariantTypeConstructor<PackedInt64Array>::variant_from_type;
  341. case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY:
  342. return VariantTypeConstructor<PackedFloat32Array>::variant_from_type;
  343. case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY:
  344. return VariantTypeConstructor<PackedFloat64Array>::variant_from_type;
  345. case GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY:
  346. return VariantTypeConstructor<PackedStringArray>::variant_from_type;
  347. case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY:
  348. return VariantTypeConstructor<PackedVector2Array>::variant_from_type;
  349. case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY:
  350. return VariantTypeConstructor<PackedVector3Array>::variant_from_type;
  351. case GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY:
  352. return VariantTypeConstructor<PackedColorArray>::variant_from_type;
  353. case GDEXTENSION_VARIANT_TYPE_NIL:
  354. case GDEXTENSION_VARIANT_TYPE_VARIANT_MAX:
  355. ERR_FAIL_V_MSG(nullptr, "Getting Variant conversion function with invalid type");
  356. }
  357. ERR_FAIL_V_MSG(nullptr, "Getting Variant conversion function with invalid type");
  358. }
  359. static GDExtensionTypeFromVariantConstructorFunc gdextension_get_variant_to_type_constructor(GDExtensionVariantType p_type) {
  360. switch (p_type) {
  361. case GDEXTENSION_VARIANT_TYPE_BOOL:
  362. return VariantTypeConstructor<bool>::type_from_variant;
  363. case GDEXTENSION_VARIANT_TYPE_INT:
  364. return VariantTypeConstructor<int64_t>::type_from_variant;
  365. case GDEXTENSION_VARIANT_TYPE_FLOAT:
  366. return VariantTypeConstructor<double>::type_from_variant;
  367. case GDEXTENSION_VARIANT_TYPE_STRING:
  368. return VariantTypeConstructor<String>::type_from_variant;
  369. case GDEXTENSION_VARIANT_TYPE_VECTOR2:
  370. return VariantTypeConstructor<Vector2>::type_from_variant;
  371. case GDEXTENSION_VARIANT_TYPE_VECTOR2I:
  372. return VariantTypeConstructor<Vector2i>::type_from_variant;
  373. case GDEXTENSION_VARIANT_TYPE_RECT2:
  374. return VariantTypeConstructor<Rect2>::type_from_variant;
  375. case GDEXTENSION_VARIANT_TYPE_RECT2I:
  376. return VariantTypeConstructor<Rect2i>::type_from_variant;
  377. case GDEXTENSION_VARIANT_TYPE_VECTOR3:
  378. return VariantTypeConstructor<Vector3>::type_from_variant;
  379. case GDEXTENSION_VARIANT_TYPE_VECTOR3I:
  380. return VariantTypeConstructor<Vector3i>::type_from_variant;
  381. case GDEXTENSION_VARIANT_TYPE_TRANSFORM2D:
  382. return VariantTypeConstructor<Transform2D>::type_from_variant;
  383. case GDEXTENSION_VARIANT_TYPE_VECTOR4:
  384. return VariantTypeConstructor<Vector4>::type_from_variant;
  385. case GDEXTENSION_VARIANT_TYPE_VECTOR4I:
  386. return VariantTypeConstructor<Vector4i>::type_from_variant;
  387. case GDEXTENSION_VARIANT_TYPE_PLANE:
  388. return VariantTypeConstructor<Plane>::type_from_variant;
  389. case GDEXTENSION_VARIANT_TYPE_QUATERNION:
  390. return VariantTypeConstructor<Quaternion>::type_from_variant;
  391. case GDEXTENSION_VARIANT_TYPE_AABB:
  392. return VariantTypeConstructor<AABB>::type_from_variant;
  393. case GDEXTENSION_VARIANT_TYPE_BASIS:
  394. return VariantTypeConstructor<Basis>::type_from_variant;
  395. case GDEXTENSION_VARIANT_TYPE_TRANSFORM3D:
  396. return VariantTypeConstructor<Transform3D>::type_from_variant;
  397. case GDEXTENSION_VARIANT_TYPE_PROJECTION:
  398. return VariantTypeConstructor<Projection>::type_from_variant;
  399. case GDEXTENSION_VARIANT_TYPE_COLOR:
  400. return VariantTypeConstructor<Color>::type_from_variant;
  401. case GDEXTENSION_VARIANT_TYPE_STRING_NAME:
  402. return VariantTypeConstructor<StringName>::type_from_variant;
  403. case GDEXTENSION_VARIANT_TYPE_NODE_PATH:
  404. return VariantTypeConstructor<NodePath>::type_from_variant;
  405. case GDEXTENSION_VARIANT_TYPE_RID:
  406. return VariantTypeConstructor<RID>::type_from_variant;
  407. case GDEXTENSION_VARIANT_TYPE_OBJECT:
  408. return VariantTypeConstructor<Object *>::type_from_variant;
  409. case GDEXTENSION_VARIANT_TYPE_CALLABLE:
  410. return VariantTypeConstructor<Callable>::type_from_variant;
  411. case GDEXTENSION_VARIANT_TYPE_SIGNAL:
  412. return VariantTypeConstructor<Signal>::type_from_variant;
  413. case GDEXTENSION_VARIANT_TYPE_DICTIONARY:
  414. return VariantTypeConstructor<Dictionary>::type_from_variant;
  415. case GDEXTENSION_VARIANT_TYPE_ARRAY:
  416. return VariantTypeConstructor<Array>::type_from_variant;
  417. case GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY:
  418. return VariantTypeConstructor<PackedByteArray>::type_from_variant;
  419. case GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY:
  420. return VariantTypeConstructor<PackedInt32Array>::type_from_variant;
  421. case GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY:
  422. return VariantTypeConstructor<PackedInt64Array>::type_from_variant;
  423. case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY:
  424. return VariantTypeConstructor<PackedFloat32Array>::type_from_variant;
  425. case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY:
  426. return VariantTypeConstructor<PackedFloat64Array>::type_from_variant;
  427. case GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY:
  428. return VariantTypeConstructor<PackedStringArray>::type_from_variant;
  429. case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY:
  430. return VariantTypeConstructor<PackedVector2Array>::type_from_variant;
  431. case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY:
  432. return VariantTypeConstructor<PackedVector3Array>::type_from_variant;
  433. case GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY:
  434. return VariantTypeConstructor<PackedColorArray>::type_from_variant;
  435. case GDEXTENSION_VARIANT_TYPE_NIL:
  436. case GDEXTENSION_VARIANT_TYPE_VARIANT_MAX:
  437. ERR_FAIL_V_MSG(nullptr, "Getting Variant conversion function with invalid type");
  438. }
  439. ERR_FAIL_V_MSG(nullptr, "Getting Variant conversion function with invalid type");
  440. }
  441. // ptrcalls
  442. static GDExtensionPtrOperatorEvaluator gdextension_variant_get_ptr_operator_evaluator(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b) {
  443. return (GDExtensionPtrOperatorEvaluator)Variant::get_ptr_operator_evaluator(Variant::Operator(p_operator), Variant::Type(p_type_a), Variant::Type(p_type_b));
  444. }
  445. static GDExtensionPtrBuiltInMethod gdextension_variant_get_ptr_builtin_method(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash) {
  446. const StringName method = *reinterpret_cast<const StringName *>(p_method);
  447. uint32_t hash = Variant::get_builtin_method_hash(Variant::Type(p_type), method);
  448. if (hash != p_hash) {
  449. ERR_PRINT_ONCE("Error getting method " + method + ", hash mismatch.");
  450. return nullptr;
  451. }
  452. return (GDExtensionPtrBuiltInMethod)Variant::get_ptr_builtin_method(Variant::Type(p_type), method);
  453. }
  454. static GDExtensionPtrConstructor gdextension_variant_get_ptr_constructor(GDExtensionVariantType p_type, int32_t p_constructor) {
  455. return (GDExtensionPtrConstructor)Variant::get_ptr_constructor(Variant::Type(p_type), p_constructor);
  456. }
  457. static GDExtensionPtrDestructor gdextension_variant_get_ptr_destructor(GDExtensionVariantType p_type) {
  458. return (GDExtensionPtrDestructor)Variant::get_ptr_destructor(Variant::Type(p_type));
  459. }
  460. static void gdextension_variant_construct(GDExtensionVariantType p_type, GDExtensionUninitializedVariantPtr r_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error) {
  461. memnew_placement(r_base, Variant);
  462. Variant *base = reinterpret_cast<Variant *>(r_base);
  463. Callable::CallError error;
  464. Variant::construct(Variant::Type(p_type), *base, (const Variant **)p_args, p_argument_count, error);
  465. if (r_error) {
  466. r_error->error = (GDExtensionCallErrorType)(error.error);
  467. r_error->argument = error.argument;
  468. r_error->expected = error.expected;
  469. }
  470. }
  471. static GDExtensionPtrSetter gdextension_variant_get_ptr_setter(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member) {
  472. const StringName member = *reinterpret_cast<const StringName *>(p_member);
  473. return (GDExtensionPtrSetter)Variant::get_member_ptr_setter(Variant::Type(p_type), member);
  474. }
  475. static GDExtensionPtrGetter gdextension_variant_get_ptr_getter(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member) {
  476. const StringName member = *reinterpret_cast<const StringName *>(p_member);
  477. return (GDExtensionPtrGetter)Variant::get_member_ptr_getter(Variant::Type(p_type), member);
  478. }
  479. static GDExtensionPtrIndexedSetter gdextension_variant_get_ptr_indexed_setter(GDExtensionVariantType p_type) {
  480. return (GDExtensionPtrIndexedSetter)Variant::get_member_ptr_indexed_setter(Variant::Type(p_type));
  481. }
  482. static GDExtensionPtrIndexedGetter gdextension_variant_get_ptr_indexed_getter(GDExtensionVariantType p_type) {
  483. return (GDExtensionPtrIndexedGetter)Variant::get_member_ptr_indexed_getter(Variant::Type(p_type));
  484. }
  485. static GDExtensionPtrKeyedSetter gdextension_variant_get_ptr_keyed_setter(GDExtensionVariantType p_type) {
  486. return (GDExtensionPtrKeyedSetter)Variant::get_member_ptr_keyed_setter(Variant::Type(p_type));
  487. }
  488. static GDExtensionPtrKeyedGetter gdextension_variant_get_ptr_keyed_getter(GDExtensionVariantType p_type) {
  489. return (GDExtensionPtrKeyedGetter)Variant::get_member_ptr_keyed_getter(Variant::Type(p_type));
  490. }
  491. static GDExtensionPtrKeyedChecker gdextension_variant_get_ptr_keyed_checker(GDExtensionVariantType p_type) {
  492. return (GDExtensionPtrKeyedChecker)Variant::get_member_ptr_keyed_checker(Variant::Type(p_type));
  493. }
  494. static void gdextension_variant_get_constant_value(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionUninitializedVariantPtr r_ret) {
  495. StringName constant = *reinterpret_cast<const StringName *>(p_constant);
  496. memnew_placement(r_ret, Variant(Variant::get_constant_value(Variant::Type(p_type), constant)));
  497. }
  498. static GDExtensionPtrUtilityFunction gdextension_variant_get_ptr_utility_function(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash) {
  499. StringName function = *reinterpret_cast<const StringName *>(p_function);
  500. uint32_t hash = Variant::get_utility_function_hash(function);
  501. if (hash != p_hash) {
  502. ERR_PRINT_ONCE("Error getting utility function " + function + ", hash mismatch.");
  503. return nullptr;
  504. }
  505. return (GDExtensionPtrUtilityFunction)Variant::get_ptr_utility_function(function);
  506. }
  507. //string helpers
  508. static void gdextension_string_new_with_latin1_chars(GDExtensionUninitializedStringPtr r_dest, const char *p_contents) {
  509. memnew_placement(r_dest, String(p_contents));
  510. }
  511. static void gdextension_string_new_with_utf8_chars(GDExtensionUninitializedStringPtr r_dest, const char *p_contents) {
  512. memnew_placement(r_dest, String);
  513. String *dest = reinterpret_cast<String *>(r_dest);
  514. dest->parse_utf8(p_contents);
  515. }
  516. static void gdextension_string_new_with_utf16_chars(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents) {
  517. memnew_placement(r_dest, String);
  518. String *dest = reinterpret_cast<String *>(r_dest);
  519. dest->parse_utf16(p_contents);
  520. }
  521. static void gdextension_string_new_with_utf32_chars(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents) {
  522. memnew_placement(r_dest, String((const char32_t *)p_contents));
  523. }
  524. static void gdextension_string_new_with_wide_chars(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents) {
  525. if constexpr (sizeof(wchar_t) == 2) {
  526. // wchar_t is 16 bit, parse.
  527. memnew_placement(r_dest, String);
  528. String *dest = reinterpret_cast<String *>(r_dest);
  529. dest->parse_utf16((const char16_t *)p_contents);
  530. } else {
  531. // wchar_t is 32 bit, copy.
  532. memnew_placement(r_dest, String((const char32_t *)p_contents));
  533. }
  534. }
  535. static void gdextension_string_new_with_latin1_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size) {
  536. memnew_placement(r_dest, String(p_contents, p_size));
  537. }
  538. static void gdextension_string_new_with_utf8_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size) {
  539. memnew_placement(r_dest, String);
  540. String *dest = reinterpret_cast<String *>(r_dest);
  541. dest->parse_utf8(p_contents, p_size);
  542. }
  543. static void gdextension_string_new_with_utf16_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_size) {
  544. memnew_placement(r_dest, String);
  545. String *dest = reinterpret_cast<String *>(r_dest);
  546. dest->parse_utf16(p_contents, p_size);
  547. }
  548. static void gdextension_string_new_with_utf32_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_size) {
  549. memnew_placement(r_dest, String((const char32_t *)p_contents, p_size));
  550. }
  551. static void gdextension_string_new_with_wide_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_size) {
  552. if constexpr (sizeof(wchar_t) == 2) {
  553. // wchar_t is 16 bit, parse.
  554. memnew_placement(r_dest, String);
  555. String *dest = reinterpret_cast<String *>(r_dest);
  556. dest->parse_utf16((const char16_t *)p_contents, p_size);
  557. } else {
  558. // wchar_t is 32 bit, copy.
  559. memnew_placement(r_dest, String((const char32_t *)p_contents, p_size));
  560. }
  561. }
  562. static GDExtensionInt gdextension_string_to_latin1_chars(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length) {
  563. String *self = (String *)p_self;
  564. CharString cs = self->ascii(true);
  565. GDExtensionInt len = cs.length();
  566. if (r_text) {
  567. const char *s_text = cs.ptr();
  568. for (GDExtensionInt i = 0; i < MIN(len, p_max_write_length); i++) {
  569. r_text[i] = s_text[i];
  570. }
  571. }
  572. return len;
  573. }
  574. static GDExtensionInt gdextension_string_to_utf8_chars(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length) {
  575. String *self = (String *)p_self;
  576. CharString cs = self->utf8();
  577. GDExtensionInt len = cs.length();
  578. if (r_text) {
  579. const char *s_text = cs.ptr();
  580. for (GDExtensionInt i = 0; i < MIN(len, p_max_write_length); i++) {
  581. r_text[i] = s_text[i];
  582. }
  583. }
  584. return len;
  585. }
  586. static GDExtensionInt gdextension_string_to_utf16_chars(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length) {
  587. String *self = (String *)p_self;
  588. Char16String cs = self->utf16();
  589. GDExtensionInt len = cs.length();
  590. if (r_text) {
  591. const char16_t *s_text = cs.ptr();
  592. for (GDExtensionInt i = 0; i < MIN(len, p_max_write_length); i++) {
  593. r_text[i] = s_text[i];
  594. }
  595. }
  596. return len;
  597. }
  598. static GDExtensionInt gdextension_string_to_utf32_chars(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length) {
  599. String *self = (String *)p_self;
  600. GDExtensionInt len = self->length();
  601. if (r_text) {
  602. const char32_t *s_text = self->ptr();
  603. for (GDExtensionInt i = 0; i < MIN(len, p_max_write_length); i++) {
  604. r_text[i] = s_text[i];
  605. }
  606. }
  607. return len;
  608. }
  609. static GDExtensionInt gdextension_string_to_wide_chars(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length) {
  610. if constexpr (sizeof(wchar_t) == 4) {
  611. return gdextension_string_to_utf32_chars(p_self, (char32_t *)r_text, p_max_write_length);
  612. } else {
  613. return gdextension_string_to_utf16_chars(p_self, (char16_t *)r_text, p_max_write_length);
  614. }
  615. }
  616. static char32_t *gdextension_string_operator_index(GDExtensionStringPtr p_self, GDExtensionInt p_index) {
  617. String *self = (String *)p_self;
  618. if (unlikely(p_index < 0 || p_index >= self->length() + 1)) {
  619. return nullptr;
  620. }
  621. return &self->ptrw()[p_index];
  622. }
  623. static const char32_t *gdextension_string_operator_index_const(GDExtensionConstStringPtr p_self, GDExtensionInt p_index) {
  624. const String *self = (const String *)p_self;
  625. if (unlikely(p_index < 0 || p_index >= self->length() + 1)) {
  626. return nullptr;
  627. }
  628. return &self->ptr()[p_index];
  629. }
  630. static void gdextension_string_operator_plus_eq_string(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b) {
  631. String *self = (String *)p_self;
  632. const String *b = (const String *)p_b;
  633. *self += *b;
  634. }
  635. static void gdextension_string_operator_plus_eq_char(GDExtensionStringPtr p_self, char32_t p_b) {
  636. String *self = (String *)p_self;
  637. *self += p_b;
  638. }
  639. static void gdextension_string_operator_plus_eq_cstr(GDExtensionStringPtr p_self, const char *p_b) {
  640. String *self = (String *)p_self;
  641. *self += p_b;
  642. }
  643. static void gdextension_string_operator_plus_eq_wcstr(GDExtensionStringPtr p_self, const wchar_t *p_b) {
  644. String *self = (String *)p_self;
  645. *self += p_b;
  646. }
  647. static void gdextension_string_operator_plus_eq_c32str(GDExtensionStringPtr p_self, const char32_t *p_b) {
  648. String *self = (String *)p_self;
  649. *self += p_b;
  650. }
  651. static GDExtensionInt gdextension_xml_parser_open_buffer(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size) {
  652. XMLParser *xml = (XMLParser *)p_instance;
  653. return (GDExtensionInt)xml->_open_buffer(p_buffer, p_size);
  654. }
  655. static void gdextension_file_access_store_buffer(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length) {
  656. FileAccess *fa = (FileAccess *)p_instance;
  657. fa->store_buffer(p_src, p_length);
  658. }
  659. static uint64_t gdextension_file_access_get_buffer(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length) {
  660. const FileAccess *fa = (FileAccess *)p_instance;
  661. return fa->get_buffer(p_dst, p_length);
  662. }
  663. static int64_t gdextension_worker_thread_pool_add_native_group_task(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) {
  664. WorkerThreadPool *p = (WorkerThreadPool *)p_instance;
  665. const String *description = (const String *)p_description;
  666. return (int64_t)p->add_native_group_task(p_func, p_userdata, p_elements, p_tasks, static_cast<bool>(p_high_priority), *description);
  667. }
  668. static int64_t gdextension_worker_thread_pool_add_native_task(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description) {
  669. WorkerThreadPool *p = (WorkerThreadPool *)p_instance;
  670. const String *description = (const String *)p_description;
  671. return (int64_t)p->add_native_task(p_func, p_userdata, static_cast<bool>(p_high_priority), *description);
  672. }
  673. /* Packed array functions */
  674. static uint8_t *gdextension_packed_byte_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  675. PackedByteArray *self = (PackedByteArray *)p_self;
  676. if (unlikely(p_index < 0 || p_index >= self->size())) {
  677. return nullptr;
  678. }
  679. return &self->ptrw()[p_index];
  680. }
  681. static const uint8_t *gdextension_packed_byte_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  682. const PackedByteArray *self = (const PackedByteArray *)p_self;
  683. if (unlikely(p_index < 0 || p_index >= self->size())) {
  684. return nullptr;
  685. }
  686. return &self->ptr()[p_index];
  687. }
  688. static GDExtensionTypePtr gdextension_packed_color_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  689. PackedColorArray *self = (PackedColorArray *)p_self;
  690. if (unlikely(p_index < 0 || p_index >= self->size())) {
  691. return nullptr;
  692. }
  693. return (GDExtensionTypePtr)&self->ptrw()[p_index];
  694. }
  695. static GDExtensionTypePtr gdextension_packed_color_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  696. const PackedColorArray *self = (const PackedColorArray *)p_self;
  697. if (unlikely(p_index < 0 || p_index >= self->size())) {
  698. return nullptr;
  699. }
  700. return (GDExtensionTypePtr)&self->ptr()[p_index];
  701. }
  702. static float *gdextension_packed_float32_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  703. PackedFloat32Array *self = (PackedFloat32Array *)p_self;
  704. if (unlikely(p_index < 0 || p_index >= self->size())) {
  705. return nullptr;
  706. }
  707. return &self->ptrw()[p_index];
  708. }
  709. static const float *gdextension_packed_float32_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  710. const PackedFloat32Array *self = (const PackedFloat32Array *)p_self;
  711. if (unlikely(p_index < 0 || p_index >= self->size())) {
  712. return nullptr;
  713. }
  714. return &self->ptr()[p_index];
  715. }
  716. static double *gdextension_packed_float64_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  717. PackedFloat64Array *self = (PackedFloat64Array *)p_self;
  718. if (unlikely(p_index < 0 || p_index >= self->size())) {
  719. return nullptr;
  720. }
  721. return &self->ptrw()[p_index];
  722. }
  723. static const double *gdextension_packed_float64_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  724. const PackedFloat64Array *self = (const PackedFloat64Array *)p_self;
  725. if (unlikely(p_index < 0 || p_index >= self->size())) {
  726. return nullptr;
  727. }
  728. return &self->ptr()[p_index];
  729. }
  730. static int32_t *gdextension_packed_int32_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  731. PackedInt32Array *self = (PackedInt32Array *)p_self;
  732. if (unlikely(p_index < 0 || p_index >= self->size())) {
  733. return nullptr;
  734. }
  735. return &self->ptrw()[p_index];
  736. }
  737. static const int32_t *gdextension_packed_int32_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  738. const PackedInt32Array *self = (const PackedInt32Array *)p_self;
  739. if (unlikely(p_index < 0 || p_index >= self->size())) {
  740. return nullptr;
  741. }
  742. return &self->ptr()[p_index];
  743. }
  744. static int64_t *gdextension_packed_int64_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  745. PackedInt64Array *self = (PackedInt64Array *)p_self;
  746. if (unlikely(p_index < 0 || p_index >= self->size())) {
  747. return nullptr;
  748. }
  749. return &self->ptrw()[p_index];
  750. }
  751. static const int64_t *gdextension_packed_int64_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  752. const PackedInt64Array *self = (const PackedInt64Array *)p_self;
  753. if (unlikely(p_index < 0 || p_index >= self->size())) {
  754. return nullptr;
  755. }
  756. return &self->ptr()[p_index];
  757. }
  758. static GDExtensionStringPtr gdextension_packed_string_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  759. PackedStringArray *self = (PackedStringArray *)p_self;
  760. if (unlikely(p_index < 0 || p_index >= self->size())) {
  761. return nullptr;
  762. }
  763. return (GDExtensionStringPtr)&self->ptrw()[p_index];
  764. }
  765. static GDExtensionStringPtr gdextension_packed_string_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  766. const PackedStringArray *self = (const PackedStringArray *)p_self;
  767. if (unlikely(p_index < 0 || p_index >= self->size())) {
  768. return nullptr;
  769. }
  770. return (GDExtensionStringPtr)&self->ptr()[p_index];
  771. }
  772. static GDExtensionTypePtr gdextension_packed_vector2_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  773. PackedVector2Array *self = (PackedVector2Array *)p_self;
  774. if (unlikely(p_index < 0 || p_index >= self->size())) {
  775. return nullptr;
  776. }
  777. return (GDExtensionTypePtr)&self->ptrw()[p_index];
  778. }
  779. static GDExtensionTypePtr gdextension_packed_vector2_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  780. const PackedVector2Array *self = (const PackedVector2Array *)p_self;
  781. if (unlikely(p_index < 0 || p_index >= self->size())) {
  782. return nullptr;
  783. }
  784. return (GDExtensionTypePtr)&self->ptr()[p_index];
  785. }
  786. static GDExtensionTypePtr gdextension_packed_vector3_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  787. PackedVector3Array *self = (PackedVector3Array *)p_self;
  788. if (unlikely(p_index < 0 || p_index >= self->size())) {
  789. return nullptr;
  790. }
  791. return (GDExtensionTypePtr)&self->ptrw()[p_index];
  792. }
  793. static GDExtensionTypePtr gdextension_packed_vector3_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  794. const PackedVector3Array *self = (const PackedVector3Array *)p_self;
  795. if (unlikely(p_index < 0 || p_index >= self->size())) {
  796. return nullptr;
  797. }
  798. return (GDExtensionTypePtr)&self->ptr()[p_index];
  799. }
  800. static GDExtensionVariantPtr gdextension_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) {
  801. Array *self = (Array *)p_self;
  802. if (unlikely(p_index < 0 || p_index >= self->size())) {
  803. return nullptr;
  804. }
  805. return (GDExtensionVariantPtr)&self->operator[](p_index);
  806. }
  807. static GDExtensionVariantPtr gdextension_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) {
  808. const Array *self = (const Array *)p_self;
  809. if (unlikely(p_index < 0 || p_index >= self->size())) {
  810. return nullptr;
  811. }
  812. return (GDExtensionVariantPtr)&self->operator[](p_index);
  813. }
  814. void gdextension_array_ref(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from) {
  815. Array *self = (Array *)p_self;
  816. const Array *from = (const Array *)p_from;
  817. self->_ref(*from);
  818. }
  819. void gdextension_array_set_typed(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script) {
  820. Array *self = reinterpret_cast<Array *>(p_self);
  821. const StringName *class_name = reinterpret_cast<const StringName *>(p_class_name);
  822. const Variant *script = reinterpret_cast<const Variant *>(p_script);
  823. self->set_typed((uint32_t)p_type, *class_name, *script);
  824. }
  825. /* Dictionary functions */
  826. static GDExtensionVariantPtr gdextension_dictionary_operator_index(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key) {
  827. Dictionary *self = (Dictionary *)p_self;
  828. return (GDExtensionVariantPtr)&self->operator[](*(const Variant *)p_key);
  829. }
  830. static GDExtensionVariantPtr gdextension_dictionary_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key) {
  831. const Dictionary *self = (const Dictionary *)p_self;
  832. return (GDExtensionVariantPtr)&self->operator[](*(const Variant *)p_key);
  833. }
  834. /* OBJECT API */
  835. static void gdextension_object_method_bind_call(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error) {
  836. const MethodBind *mb = reinterpret_cast<const MethodBind *>(p_method_bind);
  837. Object *o = (Object *)p_instance;
  838. const Variant **args = (const Variant **)p_args;
  839. Callable::CallError error;
  840. memnew_placement(r_return, Variant(mb->call(o, args, p_arg_count, error)));
  841. if (r_error) {
  842. r_error->error = (GDExtensionCallErrorType)(error.error);
  843. r_error->argument = error.argument;
  844. r_error->expected = error.expected;
  845. }
  846. }
  847. static void gdextension_object_method_bind_ptrcall(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr p_ret) {
  848. const MethodBind *mb = reinterpret_cast<const MethodBind *>(p_method_bind);
  849. Object *o = (Object *)p_instance;
  850. mb->ptrcall(o, (const void **)p_args, p_ret);
  851. }
  852. static void gdextension_object_destroy(GDExtensionObjectPtr p_o) {
  853. memdelete((Object *)p_o);
  854. }
  855. static GDExtensionObjectPtr gdextension_global_get_singleton(GDExtensionConstStringNamePtr p_name) {
  856. const StringName name = *reinterpret_cast<const StringName *>(p_name);
  857. return (GDExtensionObjectPtr)Engine::get_singleton()->get_singleton_object(name);
  858. }
  859. static void *gdextension_object_get_instance_binding(GDExtensionObjectPtr p_object, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks) {
  860. Object *o = (Object *)p_object;
  861. return o->get_instance_binding(p_token, p_callbacks);
  862. }
  863. static void gdextension_object_set_instance_binding(GDExtensionObjectPtr p_object, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks) {
  864. Object *o = (Object *)p_object;
  865. o->set_instance_binding(p_token, p_binding, p_callbacks);
  866. }
  867. static void gdextension_object_set_instance(GDExtensionObjectPtr p_object, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance) {
  868. const StringName classname = *reinterpret_cast<const StringName *>(p_classname);
  869. Object *o = (Object *)p_object;
  870. ClassDB::set_object_extension_instance(o, classname, p_instance);
  871. }
  872. static GDExtensionObjectPtr gdextension_object_get_instance_from_id(GDObjectInstanceID p_instance_id) {
  873. return (GDExtensionObjectPtr)ObjectDB::get_instance(ObjectID(p_instance_id));
  874. }
  875. static GDExtensionBool gdextension_object_get_class_name(GDExtensionConstObjectPtr p_object, GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringNamePtr r_class_name) {
  876. if (!p_object) {
  877. return false;
  878. }
  879. const Object *o = (const Object *)p_object;
  880. memnew_placement(r_class_name, StringName);
  881. StringName *class_name = reinterpret_cast<StringName *>(r_class_name);
  882. *class_name = o->get_class_name_for_extension((GDExtension *)p_library);
  883. return true;
  884. }
  885. static GDExtensionObjectPtr gdextension_object_cast_to(GDExtensionConstObjectPtr p_object, void *p_class_tag) {
  886. if (!p_object) {
  887. return nullptr;
  888. }
  889. Object *o = (Object *)p_object;
  890. return o->is_class_ptr(p_class_tag) ? (GDExtensionObjectPtr)o : (GDExtensionObjectPtr) nullptr;
  891. }
  892. static GDObjectInstanceID gdextension_object_get_instance_id(GDExtensionConstObjectPtr p_object) {
  893. const Object *o = (const Object *)p_object;
  894. return (GDObjectInstanceID)o->get_instance_id();
  895. }
  896. static GDExtensionObjectPtr gdextension_ref_get_object(GDExtensionConstRefPtr p_ref) {
  897. const Ref<RefCounted> *ref = (const Ref<RefCounted> *)p_ref;
  898. if (ref == nullptr || ref->is_null()) {
  899. return (GDExtensionObjectPtr) nullptr;
  900. } else {
  901. return (GDExtensionObjectPtr)ref->ptr();
  902. }
  903. }
  904. static void gdextension_ref_set_object(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object) {
  905. Ref<RefCounted> *ref = (Ref<RefCounted> *)p_ref;
  906. ERR_FAIL_NULL(ref);
  907. Object *o = (RefCounted *)p_object;
  908. ref->reference_ptr(o);
  909. }
  910. static GDExtensionScriptInstancePtr gdextension_script_instance_create(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data) {
  911. ScriptInstanceExtension *script_instance_extension = memnew(ScriptInstanceExtension);
  912. script_instance_extension->instance = p_instance_data;
  913. script_instance_extension->native_info = p_info;
  914. return reinterpret_cast<GDExtensionScriptInstancePtr>(script_instance_extension);
  915. }
  916. static GDExtensionMethodBindPtr gdextension_classdb_get_method_bind(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash) {
  917. const StringName classname = *reinterpret_cast<const StringName *>(p_classname);
  918. const StringName methodname = *reinterpret_cast<const StringName *>(p_methodname);
  919. bool exists = false;
  920. MethodBind *mb = ClassDB::get_method_with_compatibility(classname, methodname, p_hash, &exists);
  921. if (!mb && exists) {
  922. ERR_PRINT("Method '" + classname + "." + methodname + "' has changed and no compatibility fallback has been provided. Please open an issue.");
  923. return nullptr;
  924. }
  925. ERR_FAIL_COND_V(!mb, nullptr);
  926. if (mb->get_hash() != p_hash) {
  927. ERR_PRINT("Hash mismatch for method '" + classname + "." + methodname + "'.");
  928. return nullptr;
  929. }
  930. return (GDExtensionMethodBindPtr)mb;
  931. }
  932. static GDExtensionObjectPtr gdextension_classdb_construct_object(GDExtensionConstStringNamePtr p_classname) {
  933. const StringName classname = *reinterpret_cast<const StringName *>(p_classname);
  934. return (GDExtensionObjectPtr)ClassDB::instantiate(classname);
  935. }
  936. static void *gdextension_classdb_get_class_tag(GDExtensionConstStringNamePtr p_classname) {
  937. const StringName classname = *reinterpret_cast<const StringName *>(p_classname);
  938. ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(classname);
  939. return class_info ? class_info->class_ptr : nullptr;
  940. }
  941. static void gdextension_editor_add_plugin(GDExtensionConstStringNamePtr p_classname) {
  942. #ifdef TOOLS_ENABLED
  943. const StringName classname = *reinterpret_cast<const StringName *>(p_classname);
  944. GDExtensionEditorPlugins::add_extension_class(classname);
  945. #endif
  946. }
  947. static void gdextension_editor_remove_plugin(GDExtensionConstStringNamePtr p_classname) {
  948. #ifdef TOOLS_ENABLED
  949. const StringName classname = *reinterpret_cast<const StringName *>(p_classname);
  950. GDExtensionEditorPlugins::remove_extension_class(classname);
  951. #endif
  952. }
  953. #define REGISTER_INTERFACE_FUNC(m_name) GDExtension::register_interface_function(#m_name, (GDExtensionInterfaceFunctionPtr)&gdextension_##m_name)
  954. void gdextension_setup_interface() {
  955. REGISTER_INTERFACE_FUNC(get_godot_version);
  956. REGISTER_INTERFACE_FUNC(mem_alloc);
  957. REGISTER_INTERFACE_FUNC(mem_realloc);
  958. REGISTER_INTERFACE_FUNC(mem_free);
  959. REGISTER_INTERFACE_FUNC(print_error);
  960. REGISTER_INTERFACE_FUNC(print_error_with_message);
  961. REGISTER_INTERFACE_FUNC(print_warning);
  962. REGISTER_INTERFACE_FUNC(print_warning_with_message);
  963. REGISTER_INTERFACE_FUNC(print_script_error);
  964. REGISTER_INTERFACE_FUNC(print_script_error_with_message);
  965. REGISTER_INTERFACE_FUNC(get_native_struct_size);
  966. REGISTER_INTERFACE_FUNC(variant_new_copy);
  967. REGISTER_INTERFACE_FUNC(variant_new_nil);
  968. REGISTER_INTERFACE_FUNC(variant_destroy);
  969. REGISTER_INTERFACE_FUNC(variant_call);
  970. REGISTER_INTERFACE_FUNC(variant_call_static);
  971. REGISTER_INTERFACE_FUNC(variant_evaluate);
  972. REGISTER_INTERFACE_FUNC(variant_set);
  973. REGISTER_INTERFACE_FUNC(variant_set_named);
  974. REGISTER_INTERFACE_FUNC(variant_set_keyed);
  975. REGISTER_INTERFACE_FUNC(variant_set_indexed);
  976. REGISTER_INTERFACE_FUNC(variant_get);
  977. REGISTER_INTERFACE_FUNC(variant_get_named);
  978. REGISTER_INTERFACE_FUNC(variant_get_keyed);
  979. REGISTER_INTERFACE_FUNC(variant_get_indexed);
  980. REGISTER_INTERFACE_FUNC(variant_iter_init);
  981. REGISTER_INTERFACE_FUNC(variant_iter_next);
  982. REGISTER_INTERFACE_FUNC(variant_iter_get);
  983. REGISTER_INTERFACE_FUNC(variant_hash);
  984. REGISTER_INTERFACE_FUNC(variant_recursive_hash);
  985. REGISTER_INTERFACE_FUNC(variant_hash_compare);
  986. REGISTER_INTERFACE_FUNC(variant_booleanize);
  987. REGISTER_INTERFACE_FUNC(variant_duplicate);
  988. REGISTER_INTERFACE_FUNC(variant_stringify);
  989. REGISTER_INTERFACE_FUNC(variant_get_type);
  990. REGISTER_INTERFACE_FUNC(variant_has_method);
  991. REGISTER_INTERFACE_FUNC(variant_has_member);
  992. REGISTER_INTERFACE_FUNC(variant_has_key);
  993. REGISTER_INTERFACE_FUNC(variant_get_type_name);
  994. REGISTER_INTERFACE_FUNC(variant_can_convert);
  995. REGISTER_INTERFACE_FUNC(variant_can_convert_strict);
  996. REGISTER_INTERFACE_FUNC(get_variant_from_type_constructor);
  997. REGISTER_INTERFACE_FUNC(get_variant_to_type_constructor);
  998. REGISTER_INTERFACE_FUNC(variant_get_ptr_operator_evaluator);
  999. REGISTER_INTERFACE_FUNC(variant_get_ptr_builtin_method);
  1000. REGISTER_INTERFACE_FUNC(variant_get_ptr_constructor);
  1001. REGISTER_INTERFACE_FUNC(variant_get_ptr_destructor);
  1002. REGISTER_INTERFACE_FUNC(variant_construct);
  1003. REGISTER_INTERFACE_FUNC(variant_get_ptr_setter);
  1004. REGISTER_INTERFACE_FUNC(variant_get_ptr_getter);
  1005. REGISTER_INTERFACE_FUNC(variant_get_ptr_indexed_setter);
  1006. REGISTER_INTERFACE_FUNC(variant_get_ptr_indexed_getter);
  1007. REGISTER_INTERFACE_FUNC(variant_get_ptr_keyed_setter);
  1008. REGISTER_INTERFACE_FUNC(variant_get_ptr_keyed_getter);
  1009. REGISTER_INTERFACE_FUNC(variant_get_ptr_keyed_checker);
  1010. REGISTER_INTERFACE_FUNC(variant_get_constant_value);
  1011. REGISTER_INTERFACE_FUNC(variant_get_ptr_utility_function);
  1012. REGISTER_INTERFACE_FUNC(string_new_with_latin1_chars);
  1013. REGISTER_INTERFACE_FUNC(string_new_with_utf8_chars);
  1014. REGISTER_INTERFACE_FUNC(string_new_with_utf16_chars);
  1015. REGISTER_INTERFACE_FUNC(string_new_with_utf32_chars);
  1016. REGISTER_INTERFACE_FUNC(string_new_with_wide_chars);
  1017. REGISTER_INTERFACE_FUNC(string_new_with_latin1_chars_and_len);
  1018. REGISTER_INTERFACE_FUNC(string_new_with_utf8_chars_and_len);
  1019. REGISTER_INTERFACE_FUNC(string_new_with_utf16_chars_and_len);
  1020. REGISTER_INTERFACE_FUNC(string_new_with_utf32_chars_and_len);
  1021. REGISTER_INTERFACE_FUNC(string_new_with_wide_chars_and_len);
  1022. REGISTER_INTERFACE_FUNC(string_to_latin1_chars);
  1023. REGISTER_INTERFACE_FUNC(string_to_utf8_chars);
  1024. REGISTER_INTERFACE_FUNC(string_to_utf16_chars);
  1025. REGISTER_INTERFACE_FUNC(string_to_utf32_chars);
  1026. REGISTER_INTERFACE_FUNC(string_to_wide_chars);
  1027. REGISTER_INTERFACE_FUNC(string_operator_index);
  1028. REGISTER_INTERFACE_FUNC(string_operator_index_const);
  1029. REGISTER_INTERFACE_FUNC(string_operator_plus_eq_string);
  1030. REGISTER_INTERFACE_FUNC(string_operator_plus_eq_char);
  1031. REGISTER_INTERFACE_FUNC(string_operator_plus_eq_cstr);
  1032. REGISTER_INTERFACE_FUNC(string_operator_plus_eq_wcstr);
  1033. REGISTER_INTERFACE_FUNC(string_operator_plus_eq_c32str);
  1034. REGISTER_INTERFACE_FUNC(xml_parser_open_buffer);
  1035. REGISTER_INTERFACE_FUNC(file_access_store_buffer);
  1036. REGISTER_INTERFACE_FUNC(file_access_get_buffer);
  1037. REGISTER_INTERFACE_FUNC(worker_thread_pool_add_native_group_task);
  1038. REGISTER_INTERFACE_FUNC(worker_thread_pool_add_native_task);
  1039. REGISTER_INTERFACE_FUNC(packed_byte_array_operator_index);
  1040. REGISTER_INTERFACE_FUNC(packed_byte_array_operator_index_const);
  1041. REGISTER_INTERFACE_FUNC(packed_color_array_operator_index);
  1042. REGISTER_INTERFACE_FUNC(packed_color_array_operator_index_const);
  1043. REGISTER_INTERFACE_FUNC(packed_float32_array_operator_index);
  1044. REGISTER_INTERFACE_FUNC(packed_float32_array_operator_index_const);
  1045. REGISTER_INTERFACE_FUNC(packed_float64_array_operator_index);
  1046. REGISTER_INTERFACE_FUNC(packed_float64_array_operator_index_const);
  1047. REGISTER_INTERFACE_FUNC(packed_int32_array_operator_index);
  1048. REGISTER_INTERFACE_FUNC(packed_int32_array_operator_index_const);
  1049. REGISTER_INTERFACE_FUNC(packed_int64_array_operator_index);
  1050. REGISTER_INTERFACE_FUNC(packed_int64_array_operator_index_const);
  1051. REGISTER_INTERFACE_FUNC(packed_string_array_operator_index);
  1052. REGISTER_INTERFACE_FUNC(packed_string_array_operator_index_const);
  1053. REGISTER_INTERFACE_FUNC(packed_vector2_array_operator_index);
  1054. REGISTER_INTERFACE_FUNC(packed_vector2_array_operator_index_const);
  1055. REGISTER_INTERFACE_FUNC(packed_vector3_array_operator_index);
  1056. REGISTER_INTERFACE_FUNC(packed_vector3_array_operator_index_const);
  1057. REGISTER_INTERFACE_FUNC(array_operator_index);
  1058. REGISTER_INTERFACE_FUNC(array_operator_index_const);
  1059. REGISTER_INTERFACE_FUNC(array_ref);
  1060. REGISTER_INTERFACE_FUNC(array_set_typed);
  1061. REGISTER_INTERFACE_FUNC(dictionary_operator_index);
  1062. REGISTER_INTERFACE_FUNC(dictionary_operator_index_const);
  1063. REGISTER_INTERFACE_FUNC(object_method_bind_call);
  1064. REGISTER_INTERFACE_FUNC(object_method_bind_ptrcall);
  1065. REGISTER_INTERFACE_FUNC(object_destroy);
  1066. REGISTER_INTERFACE_FUNC(global_get_singleton);
  1067. REGISTER_INTERFACE_FUNC(object_get_instance_binding);
  1068. REGISTER_INTERFACE_FUNC(object_set_instance_binding);
  1069. REGISTER_INTERFACE_FUNC(object_set_instance);
  1070. REGISTER_INTERFACE_FUNC(object_get_class_name);
  1071. REGISTER_INTERFACE_FUNC(object_cast_to);
  1072. REGISTER_INTERFACE_FUNC(object_get_instance_from_id);
  1073. REGISTER_INTERFACE_FUNC(object_get_instance_id);
  1074. REGISTER_INTERFACE_FUNC(ref_get_object);
  1075. REGISTER_INTERFACE_FUNC(ref_set_object);
  1076. REGISTER_INTERFACE_FUNC(script_instance_create);
  1077. REGISTER_INTERFACE_FUNC(classdb_construct_object);
  1078. REGISTER_INTERFACE_FUNC(classdb_get_method_bind);
  1079. REGISTER_INTERFACE_FUNC(classdb_get_class_tag);
  1080. REGISTER_INTERFACE_FUNC(editor_add_plugin);
  1081. REGISTER_INTERFACE_FUNC(editor_remove_plugin);
  1082. }
  1083. #undef REGISTER_INTERFACE_FUNCTION