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