| 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.gen.h" |
| 32 | |
| 33 | #include "core/config/engine.h" |
| 34 | #include "core/extension/gdextension.h" |
| 35 | #include "core/extension/gdextension_special_compat_hashes.h" |
| 36 | #include "core/io/file_access.h" |
| 37 | #include "core/io/image.h" |
| 38 | #include "core/io/xml_parser.h" |
| 39 | #include "core/object/class_db.h" |
| 40 | #include "core/object/script_language_extension.h" |
| 41 | #include "core/object/worker_thread_pool.h" |
| 42 | #include "core/os/memory.h" |
| 43 | #include "core/variant/variant.h" |
| 44 | #include "core/version.h" |
| 45 | |
| 46 | class CallableCustomExtension : public CallableCustom { |
| 47 | void *userdata; |
| 48 | void *token; |
| 49 | |
| 50 | ObjectID object; |
| 51 | |
| 52 | GDExtensionCallableCustomCall call_func; |
| 53 | GDExtensionCallableCustomIsValid is_valid_func; |
| 54 | GDExtensionCallableCustomFree free_func; |
| 55 | |
| 56 | GDExtensionCallableCustomEqual equal_func; |
| 57 | GDExtensionCallableCustomLessThan less_than_func; |
| 58 | |
| 59 | GDExtensionCallableCustomToString to_string_func; |
| 60 | |
| 61 | GDExtensionCallableCustomGetArgumentCount get_argument_count_func; |
| 62 | |
| 63 | uint32_t _hash; |
| 64 | |
| 65 | static bool default_compare_equal(const CallableCustom *p_a, const CallableCustom *p_b) { |
| 66 | const CallableCustomExtension *a = static_cast<const CallableCustomExtension *>(p_a); |
| 67 | const CallableCustomExtension *b = static_cast<const CallableCustomExtension *>(p_b); |
| 68 | |
| 69 | if (a->call_func != b->call_func || a->userdata != b->userdata) { |
| 70 | return false; |
| 71 | } |
| 72 | return true; |
| 73 | } |
| 74 | |
| 75 | static bool default_compare_less(const CallableCustom *p_a, const CallableCustom *p_b) { |
| 76 | const CallableCustomExtension *a = static_cast<const CallableCustomExtension *>(p_a); |
| 77 | const CallableCustomExtension *b = static_cast<const CallableCustomExtension *>(p_b); |
| 78 | |
| 79 | if (a->call_func != b->call_func) { |
| 80 | return a->call_func < b->call_func; |
| 81 | } |
| 82 | return a->userdata < b->userdata; |
| 83 | } |
| 84 | |
| 85 | static bool custom_compare_equal(const CallableCustom *p_a, const CallableCustom *p_b) { |
| 86 | const CallableCustomExtension *a = static_cast<const CallableCustomExtension *>(p_a); |
| 87 | const CallableCustomExtension *b = static_cast<const CallableCustomExtension *>(p_b); |
| 88 | |
| 89 | if (a->equal_func != b->equal_func) { |
| 90 | return false; |
| 91 | } |
| 92 | return a->equal_func(a->userdata, b->userdata); |
| 93 | } |
| 94 | |
| 95 | static bool custom_compare_less(const CallableCustom *p_a, const CallableCustom *p_b) { |
| 96 | const CallableCustomExtension *a = static_cast<const CallableCustomExtension *>(p_a); |
| 97 | const CallableCustomExtension *b = static_cast<const CallableCustomExtension *>(p_b); |
| 98 | |
| 99 | if (a->less_than_func != b->less_than_func) { |
| 100 | return default_compare_less(p_a, p_b); |
| 101 | } |
| 102 | return a->less_than_func(a->userdata, b->userdata); |
| 103 | } |
| 104 | |
| 105 | public: |
| 106 | uint32_t hash() const override { |
| 107 | return _hash; |
| 108 | } |
| 109 | |
| 110 | String get_as_text() const override { |
| 111 | if (to_string_func != nullptr) { |
| 112 | String out; |
| 113 | GDExtensionBool is_valid = false; |
| 114 | |
| 115 | to_string_func(userdata, &is_valid, (GDExtensionStringPtr)&out); |
| 116 | |
| 117 | if (is_valid) { |
| 118 | return out; |
| 119 | } |
| 120 | } |
| 121 | return "<CallableCustom>"; |
| 122 | } |
| 123 | |
| 124 | CompareEqualFunc get_compare_equal_func() const override { |
| 125 | return (equal_func != nullptr) ? custom_compare_equal : default_compare_equal; |
| 126 | } |
| 127 | |
| 128 | CompareLessFunc get_compare_less_func() const override { |
| 129 | return (less_than_func != nullptr) ? custom_compare_less : default_compare_less; |
| 130 | } |
| 131 | |
| 132 | bool is_valid() const override { |
| 133 | if (is_valid_func != nullptr && !is_valid_func(userdata)) { |
| 134 | return false; |
| 135 | } |
| 136 | return call_func != nullptr; |
| 137 | } |
| 138 | |
| 139 | StringName get_method() const override { |
| 140 | return StringName(); |
| 141 | } |
| 142 | |
| 143 | ObjectID get_object() const override { |
| 144 | return object; |
| 145 | } |
| 146 | |
| 147 | int get_argument_count(bool &r_is_valid) const override { |
| 148 | if (get_argument_count_func != nullptr) { |
| 149 | GDExtensionBool is_valid = false; |
| 150 | |
| 151 | GDExtensionInt ret = get_argument_count_func(userdata, &is_valid); |
| 152 | |
| 153 | if (is_valid) { |
| 154 | r_is_valid = true; |
| 155 | return ret; |
| 156 | } |
| 157 | } |
| 158 | r_is_valid = false; |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | void *get_userdata(void *p_token) const { |
| 163 | return (p_token == token) ? userdata : nullptr; |
| 164 | } |
| 165 | |
| 166 | void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const override { |
| 167 | GDExtensionCallError error; |
| 168 | |
| 169 | call_func(userdata, (GDExtensionConstVariantPtr *)p_arguments, p_argcount, (GDExtensionVariantPtr)&r_return_value, &error); |
| 170 | |
| 171 | r_call_error.error = (Callable::CallError::Error)error.error; |
| 172 | r_call_error.argument = error.argument; |
| 173 | r_call_error.expected = error.expected; |
| 174 | } |
| 175 | |
| 176 | #ifndef DISABLE_DEPRECATED |
| 177 | CallableCustomExtension(GDExtensionCallableCustomInfo *p_info) { |
| 178 | userdata = p_info->callable_userdata; |
| 179 | token = p_info->token; |
| 180 | |
| 181 | object = p_info->object_id; |
| 182 | |
| 183 | call_func = p_info->call_func; |
| 184 | is_valid_func = p_info->is_valid_func; |
| 185 | free_func = p_info->free_func; |
| 186 | |
| 187 | equal_func = p_info->equal_func; |
| 188 | less_than_func = p_info->less_than_func; |
| 189 | |
| 190 | to_string_func = p_info->to_string_func; |
| 191 | |
| 192 | get_argument_count_func = nullptr; |
| 193 | |
| 194 | // Pre-calculate the hash. |
| 195 | if (p_info->hash_func != nullptr) { |
| 196 | _hash = p_info->hash_func(userdata); |
| 197 | } else { |
| 198 | _hash = hash_murmur3_one_64((uint64_t)call_func); |
| 199 | _hash = hash_murmur3_one_64((uint64_t)userdata, _hash); |
| 200 | } |
| 201 | } |
| 202 | #endif |
| 203 | |
| 204 | CallableCustomExtension(GDExtensionCallableCustomInfo2 *p_info) { |
| 205 | userdata = p_info->callable_userdata; |
| 206 | token = p_info->token; |
| 207 | |
| 208 | object = p_info->object_id; |
| 209 | |
| 210 | call_func = p_info->call_func; |
| 211 | is_valid_func = p_info->is_valid_func; |
| 212 | free_func = p_info->free_func; |
| 213 | |
| 214 | equal_func = p_info->equal_func; |
| 215 | less_than_func = p_info->less_than_func; |
| 216 | |
| 217 | to_string_func = p_info->to_string_func; |
| 218 | |
| 219 | get_argument_count_func = p_info->get_argument_count_func; |
| 220 | |
| 221 | // Pre-calculate the hash. |
| 222 | if (p_info->hash_func != nullptr) { |
| 223 | _hash = p_info->hash_func(userdata); |
| 224 | } else { |
| 225 | _hash = hash_murmur3_one_64((uint64_t)call_func); |
| 226 | _hash = hash_murmur3_one_64((uint64_t)userdata, _hash); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | ~CallableCustomExtension() { |
| 231 | if (free_func != nullptr) { |
| 232 | free_func(userdata); |
| 233 | } |
| 234 | } |
| 235 | }; |
| 236 | |
| 237 | // Core interface functions. |
| 238 | GDExtensionInterfaceFunctionPtr gdextension_get_proc_address(const char *p_name) { |
| 239 | return GDExtension::get_interface_function(p_name); |
| 240 | } |
| 241 | |
| 242 | #ifndef DISABLE_DEPRECATED |
| 243 | static void gdextension_get_godot_version(GDExtensionGodotVersion *r_godot_version) { |
| 244 | r_godot_version->major = GODOT_VERSION_MAJOR; |
| 245 | r_godot_version->minor = GODOT_VERSION_MINOR; |
| 246 | r_godot_version->patch = GODOT_VERSION_PATCH; |
| 247 | r_godot_version->string = GODOT_VERSION_FULL_NAME; |
| 248 | } |
| 249 | #endif |
| 250 | |
| 251 | static void gdextension_get_godot_version2(GDExtensionGodotVersion2 *r_godot_version) { |
| 252 | r_godot_version->major = GODOT_VERSION_MAJOR; |
| 253 | r_godot_version->minor = GODOT_VERSION_MINOR; |
| 254 | r_godot_version->patch = GODOT_VERSION_PATCH; |
| 255 | r_godot_version->hex = GODOT_VERSION_HEX; |
| 256 | r_godot_version->status = GODOT_VERSION_STATUS; |
| 257 | r_godot_version->build = GODOT_VERSION_BUILD; |
| 258 | r_godot_version->hash = GODOT_VERSION_HASH; |
| 259 | r_godot_version->timestamp = GODOT_VERSION_TIMESTAMP; |
| 260 | r_godot_version->string = GODOT_VERSION_FULL_NAME; |
| 261 | } |
| 262 | |
| 263 | // Memory Functions |
| 264 | #ifndef DISABLE_DEPRECATED |
| 265 | static void *gdextension_mem_alloc(size_t p_size) { |
| 266 | return memalloc(p_size); |
| 267 | } |
| 268 | |
| 269 | static void *gdextension_mem_realloc(void *p_mem, size_t p_size) { |
| 270 | return memrealloc(p_mem, p_size); |
| 271 | } |
| 272 | |
| 273 | static void gdextension_mem_free(void *p_mem) { |
| 274 | memfree(p_mem); |
| 275 | } |
| 276 | #endif |
| 277 | |
| 278 | static void *gdextension_mem_alloc2(size_t p_size, GDExtensionBool p_prepad_align) { |
| 279 | return Memory::alloc_static(p_size, p_prepad_align); |
| 280 | } |
| 281 | |
| 282 | static void *gdextension_mem_realloc2(void *p_mem, size_t p_size, GDExtensionBool p_prepad_align) { |
| 283 | return Memory::realloc_static(p_mem, p_size, p_prepad_align); |
| 284 | } |
| 285 | |
| 286 | static void gdextension_mem_free2(void *p_mem, GDExtensionBool p_prepad_align) { |
| 287 | Memory::free_static(p_mem, p_prepad_align); |
| 288 | } |
| 289 | |
| 290 | // Helper print functions. |
| 291 | 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) { |
| 292 | _err_print_error(p_function, p_file, p_line, p_description, p_editor_notify, ERR_HANDLER_ERROR); |
| 293 | } |
| 294 | 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) { |
| 295 | _err_print_error(p_function, p_file, p_line, p_description, p_message, p_editor_notify, ERR_HANDLER_ERROR); |
| 296 | } |
| 297 | 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) { |
| 298 | _err_print_error(p_function, p_file, p_line, p_description, p_editor_notify, ERR_HANDLER_WARNING); |
| 299 | } |
| 300 | 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) { |
| 301 | _err_print_error(p_function, p_file, p_line, p_description, p_message, p_editor_notify, ERR_HANDLER_WARNING); |
| 302 | } |
| 303 | 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) { |
| 304 | _err_print_error(p_function, p_file, p_line, p_description, p_editor_notify, ERR_HANDLER_SCRIPT); |
| 305 | } |
| 306 | 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) { |
| 307 | _err_print_error(p_function, p_file, p_line, p_description, p_message, p_editor_notify, ERR_HANDLER_SCRIPT); |
| 308 | } |
| 309 | |
| 310 | uint64_t gdextension_get_native_struct_size(GDExtensionConstStringNamePtr p_name) { |
| 311 | const StringName name = *reinterpret_cast<const StringName *>(p_name); |
| 312 | return ClassDB::get_native_struct_size(name); |
| 313 | } |
| 314 | |
| 315 | // Variant functions |
| 316 | |
| 317 | static void gdextension_variant_new_copy(GDExtensionUninitializedVariantPtr r_dest, GDExtensionConstVariantPtr p_src) { |
| 318 | memnew_placement(reinterpret_cast<Variant *>(r_dest), Variant(*reinterpret_cast<const Variant *>(p_src))); |
| 319 | } |
| 320 | static void gdextension_variant_new_nil(GDExtensionUninitializedVariantPtr r_dest) { |
| 321 | memnew_placement(reinterpret_cast<Variant *>(r_dest), Variant); |
| 322 | } |
| 323 | static void gdextension_variant_destroy(GDExtensionVariantPtr p_self) { |
| 324 | reinterpret_cast<Variant *>(p_self)->~Variant(); |
| 325 | } |
| 326 | |
| 327 | // variant type |
| 328 | |
| 329 | static void gdextension_variant_call(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argcount, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error) { |
| 330 | Variant *self = (Variant *)p_self; |
| 331 | const StringName method = *reinterpret_cast<const StringName *>(p_method); |
| 332 | const Variant **args = (const Variant **)p_args; |
| 333 | Callable::CallError error; |
| 334 | memnew_placement(r_return, Variant); |
| 335 | Variant *ret = reinterpret_cast<Variant *>(r_return); |
| 336 | self->callp(method, args, p_argcount, *ret, error); |
| 337 | |
| 338 | if (r_error) { |
| 339 | r_error->error = (GDExtensionCallErrorType)(error.error); |
| 340 | r_error->argument = error.argument; |
| 341 | r_error->expected = error.expected; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | 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) { |
| 346 | Variant::Type type = (Variant::Type)p_type; |
| 347 | const StringName method = *reinterpret_cast<const StringName *>(p_method); |
| 348 | const Variant **args = (const Variant **)p_args; |
| 349 | Callable::CallError error; |
| 350 | memnew_placement(r_return, Variant); |
| 351 | Variant *ret = reinterpret_cast<Variant *>(r_return); |
| 352 | Variant::call_static(type, method, args, p_argcount, *ret, error); |
| 353 | |
| 354 | if (r_error) { |
| 355 | r_error->error = (GDExtensionCallErrorType)error.error; |
| 356 | r_error->argument = error.argument; |
| 357 | r_error->expected = error.expected; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | static void gdextension_variant_evaluate(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionUninitializedVariantPtr r_return, GDExtensionBool *r_valid) { |
| 362 | Variant::Operator op = (Variant::Operator)p_op; |
| 363 | const Variant *a = (const Variant *)p_a; |
| 364 | const Variant *b = (const Variant *)p_b; |
| 365 | bool valid; |
| 366 | memnew_placement(r_return, Variant); |
| 367 | Variant *ret = reinterpret_cast<Variant *>(r_return); |
| 368 | Variant::evaluate(op, *a, *b, *ret, valid); |
| 369 | *r_valid = valid; |
| 370 | } |
| 371 | |
| 372 | static void gdextension_variant_set(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid) { |
| 373 | Variant *self = (Variant *)p_self; |
| 374 | const Variant *key = (const Variant *)p_key; |
| 375 | const Variant *value = (const Variant *)p_value; |
| 376 | |
| 377 | bool valid; |
| 378 | self->set(*key, *value, &valid); |
| 379 | *r_valid = valid; |
| 380 | } |
| 381 | |
| 382 | static void gdextension_variant_set_named(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid) { |
| 383 | Variant *self = (Variant *)p_self; |
| 384 | const StringName *key = (const StringName *)p_key; |
| 385 | const Variant *value = (const Variant *)p_value; |
| 386 | |
| 387 | bool valid; |
| 388 | self->set_named(*key, *value, valid); |
| 389 | *r_valid = valid; |
| 390 | } |
| 391 | |
| 392 | static void gdextension_variant_set_keyed(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid) { |
| 393 | Variant *self = (Variant *)p_self; |
| 394 | const Variant *key = (const Variant *)p_key; |
| 395 | const Variant *value = (const Variant *)p_value; |
| 396 | |
| 397 | bool valid; |
| 398 | self->set_keyed(*key, *value, valid); |
| 399 | *r_valid = valid; |
| 400 | } |
| 401 | |
| 402 | static void gdextension_variant_set_indexed(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob) { |
| 403 | Variant *self = (Variant *)p_self; |
| 404 | const Variant *value = (const Variant *)p_value; |
| 405 | |
| 406 | bool valid; |
| 407 | bool oob; |
| 408 | self->set_indexed(p_index, *value, valid, oob); |
| 409 | *r_valid = valid; |
| 410 | *r_oob = oob; |
| 411 | } |
| 412 | |
| 413 | static void gdextension_variant_get(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid) { |
| 414 | const Variant *self = (const Variant *)p_self; |
| 415 | const Variant *key = (const Variant *)p_key; |
| 416 | |
| 417 | bool valid; |
| 418 | memnew_placement(r_ret, Variant(self->get(*key, &valid))); |
| 419 | *r_valid = valid; |
| 420 | } |
| 421 | |
| 422 | static void gdextension_variant_get_named(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid) { |
| 423 | const Variant *self = (const Variant *)p_self; |
| 424 | const StringName *key = (const StringName *)p_key; |
| 425 | |
| 426 | bool valid; |
| 427 | memnew_placement(r_ret, Variant(self->get_named(*key, valid))); |
| 428 | *r_valid = valid; |
| 429 | } |
| 430 | |
| 431 | static void gdextension_variant_get_keyed(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid) { |
| 432 | const Variant *self = (const Variant *)p_self; |
| 433 | const Variant *key = (const Variant *)p_key; |
| 434 | |
| 435 | bool valid; |
| 436 | memnew_placement(r_ret, Variant(self->get_keyed(*key, valid))); |
| 437 | *r_valid = valid; |
| 438 | } |
| 439 | |
| 440 | static void gdextension_variant_get_indexed(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob) { |
| 441 | const Variant *self = (const Variant *)p_self; |
| 442 | |
| 443 | bool valid; |
| 444 | bool oob; |
| 445 | memnew_placement(r_ret, Variant(self->get_indexed(p_index, valid, oob))); |
| 446 | *r_valid = valid; |
| 447 | *r_oob = oob; |
| 448 | } |
| 449 | |
| 450 | /// Iteration. |
| 451 | static GDExtensionBool gdextension_variant_iter_init(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_iter, GDExtensionBool *r_valid) { |
| 452 | const Variant *self = (const Variant *)p_self; |
| 453 | memnew_placement(r_iter, Variant); |
| 454 | Variant *iter = reinterpret_cast<Variant *>(r_iter); |
| 455 | |
| 456 | bool valid; |
| 457 | bool ret = self->iter_init(*iter, valid); |
| 458 | *r_valid = valid; |
| 459 | return ret; |
| 460 | } |
| 461 | |
| 462 | static GDExtensionBool gdextension_variant_iter_next(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid) { |
| 463 | const Variant *self = (const Variant *)p_self; |
| 464 | Variant *iter = (Variant *)r_iter; |
| 465 | |
| 466 | bool valid; |
| 467 | bool ret = self->iter_next(*iter, valid); |
| 468 | *r_valid = valid; |
| 469 | return ret; |
| 470 | } |
| 471 | |
| 472 | static void gdextension_variant_iter_get(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid) { |
| 473 | const Variant *self = (const Variant *)p_self; |
| 474 | Variant *iter = (Variant *)r_iter; |
| 475 | |
| 476 | bool valid; |
| 477 | memnew_placement(r_ret, Variant(self->iter_get(*iter, valid))); |
| 478 | *r_valid = valid; |
| 479 | } |
| 480 | |
| 481 | /// Variant functions. |
| 482 | static GDExtensionInt gdextension_variant_hash(GDExtensionConstVariantPtr p_self) { |
| 483 | const Variant *self = (const Variant *)p_self; |
| 484 | return self->hash(); |
| 485 | } |
| 486 | |
| 487 | static GDExtensionInt gdextension_variant_recursive_hash(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count) { |
| 488 | const Variant *self = (const Variant *)p_self; |
| 489 | return self->recursive_hash(p_recursion_count); |
| 490 | } |
| 491 | |
| 492 | static GDExtensionBool gdextension_variant_hash_compare(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other) { |
| 493 | const Variant *self = (const Variant *)p_self; |
| 494 | const Variant *other = (const Variant *)p_other; |
| 495 | return self->hash_compare(*other); |
| 496 | } |
| 497 | |
| 498 | static GDExtensionBool gdextension_variant_booleanize(GDExtensionConstVariantPtr p_self) { |
| 499 | const Variant *self = (const Variant *)p_self; |
| 500 | return self->booleanize(); |
| 501 | } |
| 502 | |
| 503 | static void gdextension_variant_duplicate(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool p_deep) { |
| 504 | const Variant *self = (const Variant *)p_self; |
| 505 | memnew_placement(r_ret, Variant(self->duplicate(p_deep))); |
| 506 | } |
| 507 | |
| 508 | static void gdextension_variant_stringify(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_ret) { |
| 509 | const Variant *self = (const Variant *)p_self; |
| 510 | memnew_placement(r_ret, String(*self)); |
| 511 | } |
| 512 | |
| 513 | static GDExtensionVariantType gdextension_variant_get_type(GDExtensionConstVariantPtr p_self) { |
| 514 | const Variant *self = (const Variant *)p_self; |
| 515 | return (GDExtensionVariantType)self->get_type(); |
| 516 | } |
| 517 | |
| 518 | static GDExtensionBool gdextension_variant_has_method(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method) { |
| 519 | const Variant *self = (const Variant *)p_self; |
| 520 | const StringName *method = (const StringName *)p_method; |
| 521 | return self->has_method(*method); |
| 522 | } |
| 523 | |
| 524 | static GDExtensionBool gdextension_variant_has_member(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member) { |
| 525 | return Variant::has_member((Variant::Type)p_type, *((const StringName *)p_member)); |
| 526 | } |
| 527 | |
| 528 | static GDExtensionBool gdextension_variant_has_key(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid) { |
| 529 | const Variant *self = (const Variant *)p_self; |
| 530 | const Variant *key = (const Variant *)p_key; |
| 531 | bool valid; |
| 532 | bool ret = self->has_key(*key, valid); |
| 533 | *r_valid = valid; |
| 534 | return ret; |
| 535 | } |
| 536 | |
| 537 | static GDObjectInstanceID gdextension_variant_get_object_instance_id(GDExtensionConstVariantPtr p_self) { |
| 538 | const Variant *self = (const Variant *)p_self; |
| 539 | if (likely(self->get_type() == Variant::OBJECT)) { |
| 540 | return self->operator ObjectID(); |
| 541 | } |
| 542 | return 0; |
| 543 | } |
| 544 | |
| 545 | static void gdextension_variant_get_type_name(GDExtensionVariantType p_type, GDExtensionUninitializedVariantPtr r_ret) { |
| 546 | String name = Variant::get_type_name((Variant::Type)p_type); |
| 547 | memnew_placement(r_ret, String(name)); |
| 548 | } |
| 549 | |
| 550 | static GDExtensionBool gdextension_variant_can_convert(GDExtensionVariantType p_from, GDExtensionVariantType p_to) { |
| 551 | return Variant::can_convert((Variant::Type)p_from, (Variant::Type)p_to); |
| 552 | } |
| 553 | |
| 554 | static GDExtensionBool gdextension_variant_can_convert_strict(GDExtensionVariantType p_from, GDExtensionVariantType p_to) { |
| 555 | return Variant::can_convert_strict((Variant::Type)p_from, (Variant::Type)p_to); |
| 556 | } |
| 557 | |
| 558 | // Variant interaction. |
| 559 | static GDExtensionVariantFromTypeConstructorFunc gdextension_get_variant_from_type_constructor(GDExtensionVariantType p_type) { |
| 560 | switch (p_type) { |
| 561 | case GDEXTENSION_VARIANT_TYPE_BOOL: |
| 562 | return VariantTypeConstructor<bool>::variant_from_type; |
| 563 | case GDEXTENSION_VARIANT_TYPE_INT: |
| 564 | return VariantTypeConstructor<int64_t>::variant_from_type; |
| 565 | case GDEXTENSION_VARIANT_TYPE_FLOAT: |
| 566 | return VariantTypeConstructor<double>::variant_from_type; |
| 567 | case GDEXTENSION_VARIANT_TYPE_STRING: |
| 568 | return VariantTypeConstructor<String>::variant_from_type; |
| 569 | case GDEXTENSION_VARIANT_TYPE_VECTOR2: |
| 570 | return VariantTypeConstructor<Vector2>::variant_from_type; |
| 571 | case GDEXTENSION_VARIANT_TYPE_VECTOR2I: |
| 572 | return VariantTypeConstructor<Vector2i>::variant_from_type; |
| 573 | case GDEXTENSION_VARIANT_TYPE_RECT2: |
| 574 | return VariantTypeConstructor<Rect2>::variant_from_type; |
| 575 | case GDEXTENSION_VARIANT_TYPE_RECT2I: |
| 576 | return VariantTypeConstructor<Rect2i>::variant_from_type; |
| 577 | case GDEXTENSION_VARIANT_TYPE_VECTOR3: |
| 578 | return VariantTypeConstructor<Vector3>::variant_from_type; |
| 579 | case GDEXTENSION_VARIANT_TYPE_VECTOR3I: |
| 580 | return VariantTypeConstructor<Vector3i>::variant_from_type; |
| 581 | case GDEXTENSION_VARIANT_TYPE_TRANSFORM2D: |
| 582 | return VariantTypeConstructor<Transform2D>::variant_from_type; |
| 583 | case GDEXTENSION_VARIANT_TYPE_VECTOR4: |
| 584 | return VariantTypeConstructor<Vector4>::variant_from_type; |
| 585 | case GDEXTENSION_VARIANT_TYPE_VECTOR4I: |
| 586 | return VariantTypeConstructor<Vector4i>::variant_from_type; |
| 587 | case GDEXTENSION_VARIANT_TYPE_PLANE: |
| 588 | return VariantTypeConstructor<Plane>::variant_from_type; |
| 589 | case GDEXTENSION_VARIANT_TYPE_QUATERNION: |
| 590 | return VariantTypeConstructor<Quaternion>::variant_from_type; |
| 591 | case GDEXTENSION_VARIANT_TYPE_AABB: |
| 592 | return VariantTypeConstructor<AABB>::variant_from_type; |
| 593 | case GDEXTENSION_VARIANT_TYPE_BASIS: |
| 594 | return VariantTypeConstructor<Basis>::variant_from_type; |
| 595 | case GDEXTENSION_VARIANT_TYPE_TRANSFORM3D: |
| 596 | return VariantTypeConstructor<Transform3D>::variant_from_type; |
| 597 | case GDEXTENSION_VARIANT_TYPE_PROJECTION: |
| 598 | return VariantTypeConstructor<Projection>::variant_from_type; |
| 599 | case GDEXTENSION_VARIANT_TYPE_COLOR: |
| 600 | return VariantTypeConstructor<Color>::variant_from_type; |
| 601 | case GDEXTENSION_VARIANT_TYPE_STRING_NAME: |
| 602 | return VariantTypeConstructor<StringName>::variant_from_type; |
| 603 | case GDEXTENSION_VARIANT_TYPE_NODE_PATH: |
| 604 | return VariantTypeConstructor<NodePath>::variant_from_type; |
| 605 | case GDEXTENSION_VARIANT_TYPE_RID: |
| 606 | return VariantTypeConstructor<RID>::variant_from_type; |
| 607 | case GDEXTENSION_VARIANT_TYPE_OBJECT: |
| 608 | return VariantTypeConstructor<Object *>::variant_from_type; |
| 609 | case GDEXTENSION_VARIANT_TYPE_CALLABLE: |
| 610 | return VariantTypeConstructor<Callable>::variant_from_type; |
| 611 | case GDEXTENSION_VARIANT_TYPE_SIGNAL: |
| 612 | return VariantTypeConstructor<Signal>::variant_from_type; |
| 613 | case GDEXTENSION_VARIANT_TYPE_DICTIONARY: |
| 614 | return VariantTypeConstructor<Dictionary>::variant_from_type; |
| 615 | case GDEXTENSION_VARIANT_TYPE_ARRAY: |
| 616 | return VariantTypeConstructor<Array>::variant_from_type; |
| 617 | case GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY: |
| 618 | return VariantTypeConstructor<PackedByteArray>::variant_from_type; |
| 619 | case GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY: |
| 620 | return VariantTypeConstructor<PackedInt32Array>::variant_from_type; |
| 621 | case GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY: |
| 622 | return VariantTypeConstructor<PackedInt64Array>::variant_from_type; |
| 623 | case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY: |
| 624 | return VariantTypeConstructor<PackedFloat32Array>::variant_from_type; |
| 625 | case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY: |
| 626 | return VariantTypeConstructor<PackedFloat64Array>::variant_from_type; |
| 627 | case GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY: |
| 628 | return VariantTypeConstructor<PackedStringArray>::variant_from_type; |
| 629 | case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY: |
| 630 | return VariantTypeConstructor<PackedVector2Array>::variant_from_type; |
| 631 | case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY: |
| 632 | return VariantTypeConstructor<PackedVector3Array>::variant_from_type; |
| 633 | case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY: |
| 634 | return VariantTypeConstructor<PackedVector4Array>::variant_from_type; |
| 635 | case GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY: |
| 636 | return VariantTypeConstructor<PackedColorArray>::variant_from_type; |
| 637 | case GDEXTENSION_VARIANT_TYPE_NIL: |
| 638 | case GDEXTENSION_VARIANT_TYPE_VARIANT_MAX: |
| 639 | ERR_FAIL_V_MSG(nullptr, "Getting Variant conversion function with invalid type"); |
| 640 | } |
| 641 | ERR_FAIL_V_MSG(nullptr, "Getting Variant conversion function with invalid type"); |
| 642 | } |
| 643 | |
| 644 | static GDExtensionTypeFromVariantConstructorFunc gdextension_get_variant_to_type_constructor(GDExtensionVariantType p_type) { |
| 645 | switch (p_type) { |
| 646 | case GDEXTENSION_VARIANT_TYPE_BOOL: |
| 647 | return VariantTypeConstructor<bool>::type_from_variant; |
| 648 | case GDEXTENSION_VARIANT_TYPE_INT: |
| 649 | return VariantTypeConstructor<int64_t>::type_from_variant; |
| 650 | case GDEXTENSION_VARIANT_TYPE_FLOAT: |
| 651 | return VariantTypeConstructor<double>::type_from_variant; |
| 652 | case GDEXTENSION_VARIANT_TYPE_STRING: |
| 653 | return VariantTypeConstructor<String>::type_from_variant; |
| 654 | case GDEXTENSION_VARIANT_TYPE_VECTOR2: |
| 655 | return VariantTypeConstructor<Vector2>::type_from_variant; |
| 656 | case GDEXTENSION_VARIANT_TYPE_VECTOR2I: |
| 657 | return VariantTypeConstructor<Vector2i>::type_from_variant; |
| 658 | case GDEXTENSION_VARIANT_TYPE_RECT2: |
| 659 | return VariantTypeConstructor<Rect2>::type_from_variant; |
| 660 | case GDEXTENSION_VARIANT_TYPE_RECT2I: |
| 661 | return VariantTypeConstructor<Rect2i>::type_from_variant; |
| 662 | case GDEXTENSION_VARIANT_TYPE_VECTOR3: |
| 663 | return VariantTypeConstructor<Vector3>::type_from_variant; |
| 664 | case GDEXTENSION_VARIANT_TYPE_VECTOR3I: |
| 665 | return VariantTypeConstructor<Vector3i>::type_from_variant; |
| 666 | case GDEXTENSION_VARIANT_TYPE_TRANSFORM2D: |
| 667 | return VariantTypeConstructor<Transform2D>::type_from_variant; |
| 668 | case GDEXTENSION_VARIANT_TYPE_VECTOR4: |
| 669 | return VariantTypeConstructor<Vector4>::type_from_variant; |
| 670 | case GDEXTENSION_VARIANT_TYPE_VECTOR4I: |
| 671 | return VariantTypeConstructor<Vector4i>::type_from_variant; |
| 672 | case GDEXTENSION_VARIANT_TYPE_PLANE: |
| 673 | return VariantTypeConstructor<Plane>::type_from_variant; |
| 674 | case GDEXTENSION_VARIANT_TYPE_QUATERNION: |
| 675 | return VariantTypeConstructor<Quaternion>::type_from_variant; |
| 676 | case GDEXTENSION_VARIANT_TYPE_AABB: |
| 677 | return VariantTypeConstructor<AABB>::type_from_variant; |
| 678 | case GDEXTENSION_VARIANT_TYPE_BASIS: |
| 679 | return VariantTypeConstructor<Basis>::type_from_variant; |
| 680 | case GDEXTENSION_VARIANT_TYPE_TRANSFORM3D: |
| 681 | return VariantTypeConstructor<Transform3D>::type_from_variant; |
| 682 | case GDEXTENSION_VARIANT_TYPE_PROJECTION: |
| 683 | return VariantTypeConstructor<Projection>::type_from_variant; |
| 684 | case GDEXTENSION_VARIANT_TYPE_COLOR: |
| 685 | return VariantTypeConstructor<Color>::type_from_variant; |
| 686 | case GDEXTENSION_VARIANT_TYPE_STRING_NAME: |
| 687 | return VariantTypeConstructor<StringName>::type_from_variant; |
| 688 | case GDEXTENSION_VARIANT_TYPE_NODE_PATH: |
| 689 | return VariantTypeConstructor<NodePath>::type_from_variant; |
| 690 | case GDEXTENSION_VARIANT_TYPE_RID: |
| 691 | return VariantTypeConstructor<RID>::type_from_variant; |
| 692 | case GDEXTENSION_VARIANT_TYPE_OBJECT: |
| 693 | return VariantTypeConstructor<Object *>::type_from_variant; |
| 694 | case GDEXTENSION_VARIANT_TYPE_CALLABLE: |
| 695 | return VariantTypeConstructor<Callable>::type_from_variant; |
| 696 | case GDEXTENSION_VARIANT_TYPE_SIGNAL: |
| 697 | return VariantTypeConstructor<Signal>::type_from_variant; |
| 698 | case GDEXTENSION_VARIANT_TYPE_DICTIONARY: |
| 699 | return VariantTypeConstructor<Dictionary>::type_from_variant; |
| 700 | case GDEXTENSION_VARIANT_TYPE_ARRAY: |
| 701 | return VariantTypeConstructor<Array>::type_from_variant; |
| 702 | case GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY: |
| 703 | return VariantTypeConstructor<PackedByteArray>::type_from_variant; |
| 704 | case GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY: |
| 705 | return VariantTypeConstructor<PackedInt32Array>::type_from_variant; |
| 706 | case GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY: |
| 707 | return VariantTypeConstructor<PackedInt64Array>::type_from_variant; |
| 708 | case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY: |
| 709 | return VariantTypeConstructor<PackedFloat32Array>::type_from_variant; |
| 710 | case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY: |
| 711 | return VariantTypeConstructor<PackedFloat64Array>::type_from_variant; |
| 712 | case GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY: |
| 713 | return VariantTypeConstructor<PackedStringArray>::type_from_variant; |
| 714 | case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY: |
| 715 | return VariantTypeConstructor<PackedVector2Array>::type_from_variant; |
| 716 | case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY: |
| 717 | return VariantTypeConstructor<PackedVector3Array>::type_from_variant; |
| 718 | case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY: |
| 719 | return VariantTypeConstructor<PackedVector4Array>::type_from_variant; |
| 720 | case GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY: |
| 721 | return VariantTypeConstructor<PackedColorArray>::type_from_variant; |
| 722 | case GDEXTENSION_VARIANT_TYPE_NIL: |
| 723 | case GDEXTENSION_VARIANT_TYPE_VARIANT_MAX: |
| 724 | ERR_FAIL_V_MSG(nullptr, "Getting Variant conversion function with invalid type"); |
| 725 | } |
| 726 | ERR_FAIL_V_MSG(nullptr, "Getting Variant conversion function with invalid type"); |
| 727 | } |
| 728 | |
| 729 | static GDExtensionVariantGetInternalPtrFunc gdextension_variant_get_ptr_internal_getter(GDExtensionVariantType p_type) { |
| 730 | switch (p_type) { |
| 731 | case GDEXTENSION_VARIANT_TYPE_BOOL: |
| 732 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<bool *(*)(Variant *)>(VariantInternal::get_bool)); |
| 733 | case GDEXTENSION_VARIANT_TYPE_INT: |
| 734 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<int64_t *(*)(Variant *)>(VariantInternal::get_int)); |
| 735 | case GDEXTENSION_VARIANT_TYPE_FLOAT: |
| 736 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<double *(*)(Variant *)>(VariantInternal::get_float)); |
| 737 | case GDEXTENSION_VARIANT_TYPE_STRING: |
| 738 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<String *(*)(Variant *)>(VariantInternal::get_string)); |
| 739 | case GDEXTENSION_VARIANT_TYPE_VECTOR2: |
| 740 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Vector2 *(*)(Variant *)>(VariantInternal::get_vector2)); |
| 741 | case GDEXTENSION_VARIANT_TYPE_VECTOR2I: |
| 742 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Vector2i *(*)(Variant *)>(VariantInternal::get_vector2i)); |
| 743 | case GDEXTENSION_VARIANT_TYPE_RECT2: |
| 744 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Rect2 *(*)(Variant *)>(VariantInternal::get_rect2)); |
| 745 | case GDEXTENSION_VARIANT_TYPE_RECT2I: |
| 746 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Rect2i *(*)(Variant *)>(VariantInternal::get_rect2i)); |
| 747 | case GDEXTENSION_VARIANT_TYPE_VECTOR3: |
| 748 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Vector3 *(*)(Variant *)>(VariantInternal::get_vector3)); |
| 749 | case GDEXTENSION_VARIANT_TYPE_VECTOR3I: |
| 750 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Vector3i *(*)(Variant *)>(VariantInternal::get_vector3i)); |
| 751 | case GDEXTENSION_VARIANT_TYPE_TRANSFORM2D: |
| 752 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Transform2D *(*)(Variant *)>(VariantInternal::get_transform2d)); |
| 753 | case GDEXTENSION_VARIANT_TYPE_VECTOR4: |
| 754 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Vector4 *(*)(Variant *)>(VariantInternal::get_vector4)); |
| 755 | case GDEXTENSION_VARIANT_TYPE_VECTOR4I: |
| 756 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Vector4i *(*)(Variant *)>(VariantInternal::get_vector4i)); |
| 757 | case GDEXTENSION_VARIANT_TYPE_PLANE: |
| 758 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Plane *(*)(Variant *)>(VariantInternal::get_plane)); |
| 759 | case GDEXTENSION_VARIANT_TYPE_QUATERNION: |
| 760 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Quaternion *(*)(Variant *)>(VariantInternal::get_quaternion)); |
| 761 | case GDEXTENSION_VARIANT_TYPE_AABB: |
| 762 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<AABB *(*)(Variant *)>(VariantInternal::get_aabb)); |
| 763 | case GDEXTENSION_VARIANT_TYPE_BASIS: |
| 764 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Basis *(*)(Variant *)>(VariantInternal::get_basis)); |
| 765 | case GDEXTENSION_VARIANT_TYPE_TRANSFORM3D: |
| 766 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Transform3D *(*)(Variant *)>(VariantInternal::get_transform)); |
| 767 | case GDEXTENSION_VARIANT_TYPE_PROJECTION: |
| 768 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Projection *(*)(Variant *)>(VariantInternal::get_projection)); |
| 769 | case GDEXTENSION_VARIANT_TYPE_COLOR: |
| 770 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Color *(*)(Variant *)>(VariantInternal::get_color)); |
| 771 | case GDEXTENSION_VARIANT_TYPE_STRING_NAME: |
| 772 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<StringName *(*)(Variant *)>(VariantInternal::get_string_name)); |
| 773 | case GDEXTENSION_VARIANT_TYPE_NODE_PATH: |
| 774 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<NodePath *(*)(Variant *)>(VariantInternal::get_node_path)); |
| 775 | case GDEXTENSION_VARIANT_TYPE_RID: |
| 776 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<RID *(*)(Variant *)>(VariantInternal::get_rid)); |
| 777 | case GDEXTENSION_VARIANT_TYPE_OBJECT: |
| 778 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Object **(*)(Variant *)>(VariantInternal::get_object)); |
| 779 | case GDEXTENSION_VARIANT_TYPE_CALLABLE: |
| 780 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Callable *(*)(Variant *)>(VariantInternal::get_callable)); |
| 781 | case GDEXTENSION_VARIANT_TYPE_SIGNAL: |
| 782 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Signal *(*)(Variant *)>(VariantInternal::get_signal)); |
| 783 | case GDEXTENSION_VARIANT_TYPE_DICTIONARY: |
| 784 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Dictionary *(*)(Variant *)>(VariantInternal::get_dictionary)); |
| 785 | case GDEXTENSION_VARIANT_TYPE_ARRAY: |
| 786 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<Array *(*)(Variant *)>(VariantInternal::get_array)); |
| 787 | case GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY: |
| 788 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedByteArray *(*)(Variant *)>(VariantInternal::get_byte_array)); |
| 789 | case GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY: |
| 790 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedInt32Array *(*)(Variant *)>(VariantInternal::get_int32_array)); |
| 791 | case GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY: |
| 792 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedInt64Array *(*)(Variant *)>(VariantInternal::get_int64_array)); |
| 793 | case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY: |
| 794 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedFloat32Array *(*)(Variant *)>(VariantInternal::get_float32_array)); |
| 795 | case GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY: |
| 796 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedFloat64Array *(*)(Variant *)>(VariantInternal::get_float64_array)); |
| 797 | case GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY: |
| 798 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedStringArray *(*)(Variant *)>(VariantInternal::get_string_array)); |
| 799 | case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY: |
| 800 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedVector2Array *(*)(Variant *)>(VariantInternal::get_vector2_array)); |
| 801 | case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY: |
| 802 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedVector3Array *(*)(Variant *)>(VariantInternal::get_vector3_array)); |
| 803 | case GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY: |
| 804 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedColorArray *(*)(Variant *)>(VariantInternal::get_color_array)); |
| 805 | case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY: |
| 806 | return reinterpret_cast<GDExtensionVariantGetInternalPtrFunc>(static_cast<PackedVector4Array *(*)(Variant *)>(VariantInternal::get_vector4_array)); |
| 807 | case GDEXTENSION_VARIANT_TYPE_NIL: |
| 808 | case GDEXTENSION_VARIANT_TYPE_VARIANT_MAX: |
| 809 | ERR_FAIL_V_MSG(nullptr, "Getting Variant get internal pointer function with invalid type."); |
| 810 | } |
| 811 | ERR_FAIL_V_MSG(nullptr, "Getting Variant get internal pointer function with invalid type."); |
| 812 | } |
| 813 | |
| 814 | // ptrcalls |
| 815 | static GDExtensionPtrOperatorEvaluator gdextension_variant_get_ptr_operator_evaluator(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b) { |
| 816 | return (GDExtensionPtrOperatorEvaluator)Variant::get_ptr_operator_evaluator(Variant::Operator(p_operator), Variant::Type(p_type_a), Variant::Type(p_type_b)); |
| 817 | } |
| 818 | static GDExtensionPtrBuiltInMethod gdextension_variant_get_ptr_builtin_method(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash) { |
| 819 | const StringName method = *reinterpret_cast<const StringName *>(p_method); |
| 820 | GDExtensionPtrBuiltInMethod ptr = (GDExtensionPtrBuiltInMethod)Variant::get_ptr_builtin_method_with_compatibility(Variant::Type(p_type), method, p_hash); |
| 821 | if (!ptr) { |
| 822 | ERR_PRINT("Error getting method " + method + ", missing or hash mismatch."); |
| 823 | } |
| 824 | return ptr; |
| 825 | } |
| 826 | static GDExtensionPtrConstructor gdextension_variant_get_ptr_constructor(GDExtensionVariantType p_type, int32_t p_constructor) { |
| 827 | return (GDExtensionPtrConstructor)Variant::get_ptr_constructor(Variant::Type(p_type), p_constructor); |
| 828 | } |
| 829 | static GDExtensionPtrDestructor gdextension_variant_get_ptr_destructor(GDExtensionVariantType p_type) { |
| 830 | return (GDExtensionPtrDestructor)Variant::get_ptr_destructor(Variant::Type(p_type)); |
| 831 | } |
| 832 | static void gdextension_variant_construct(GDExtensionVariantType p_type, GDExtensionUninitializedVariantPtr r_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error) { |
| 833 | memnew_placement(r_base, Variant); |
| 834 | Variant *base = reinterpret_cast<Variant *>(r_base); |
| 835 | |
| 836 | Callable::CallError error; |
| 837 | Variant::construct(Variant::Type(p_type), *base, (const Variant **)p_args, p_argument_count, error); |
| 838 | |
| 839 | if (r_error) { |
| 840 | r_error->error = (GDExtensionCallErrorType)(error.error); |
| 841 | r_error->argument = error.argument; |
| 842 | r_error->expected = error.expected; |
| 843 | } |
| 844 | } |
| 845 | static GDExtensionPtrSetter gdextension_variant_get_ptr_setter(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member) { |
| 846 | const StringName member = *reinterpret_cast<const StringName *>(p_member); |
| 847 | return (GDExtensionPtrSetter)Variant::get_member_ptr_setter(Variant::Type(p_type), member); |
| 848 | } |
| 849 | static GDExtensionPtrGetter gdextension_variant_get_ptr_getter(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member) { |
| 850 | const StringName member = *reinterpret_cast<const StringName *>(p_member); |
| 851 | return (GDExtensionPtrGetter)Variant::get_member_ptr_getter(Variant::Type(p_type), member); |
| 852 | } |
| 853 | static GDExtensionPtrIndexedSetter gdextension_variant_get_ptr_indexed_setter(GDExtensionVariantType p_type) { |
| 854 | return (GDExtensionPtrIndexedSetter)Variant::get_member_ptr_indexed_setter(Variant::Type(p_type)); |
| 855 | } |
| 856 | static GDExtensionPtrIndexedGetter gdextension_variant_get_ptr_indexed_getter(GDExtensionVariantType p_type) { |
| 857 | return (GDExtensionPtrIndexedGetter)Variant::get_member_ptr_indexed_getter(Variant::Type(p_type)); |
| 858 | } |
| 859 | static GDExtensionPtrKeyedSetter gdextension_variant_get_ptr_keyed_setter(GDExtensionVariantType p_type) { |
| 860 | return (GDExtensionPtrKeyedSetter)Variant::get_member_ptr_keyed_setter(Variant::Type(p_type)); |
| 861 | } |
| 862 | static GDExtensionPtrKeyedGetter gdextension_variant_get_ptr_keyed_getter(GDExtensionVariantType p_type) { |
| 863 | return (GDExtensionPtrKeyedGetter)Variant::get_member_ptr_keyed_getter(Variant::Type(p_type)); |
| 864 | } |
| 865 | static GDExtensionPtrKeyedChecker gdextension_variant_get_ptr_keyed_checker(GDExtensionVariantType p_type) { |
| 866 | return (GDExtensionPtrKeyedChecker)Variant::get_member_ptr_keyed_checker(Variant::Type(p_type)); |
| 867 | } |
| 868 | static void gdextension_variant_get_constant_value(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionUninitializedVariantPtr r_ret) { |
| 869 | StringName constant = *reinterpret_cast<const StringName *>(p_constant); |
| 870 | memnew_placement(r_ret, Variant(Variant::get_constant_value(Variant::Type(p_type), constant))); |
| 871 | } |
| 872 | static GDExtensionPtrUtilityFunction gdextension_variant_get_ptr_utility_function(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash) { |
| 873 | StringName function = *reinterpret_cast<const StringName *>(p_function); |
| 874 | uint32_t hash = Variant::get_utility_function_hash(function); |
| 875 | if (hash != p_hash) { |
| 876 | ERR_PRINT_ONCE("Error getting utility function " + function + ", hash mismatch."); |
| 877 | return nullptr; |
| 878 | } |
| 879 | return (GDExtensionPtrUtilityFunction)Variant::get_ptr_utility_function(function); |
| 880 | } |
| 881 | |
| 882 | //string helpers |
| 883 | |
| 884 | static void gdextension_string_new_with_latin1_chars(GDExtensionUninitializedStringPtr r_dest, const char *p_contents) { |
| 885 | String *dest = memnew_placement(r_dest, String); |
| 886 | dest->append_latin1(Span<char>(p_contents, p_contents ? strlen(p_contents) : 0)); |
| 887 | } |
| 888 | |
| 889 | static void gdextension_string_new_with_utf8_chars(GDExtensionUninitializedStringPtr r_dest, const char *p_contents) { |
| 890 | String *dest = memnew_placement(r_dest, String); |
| 891 | dest->append_utf8(p_contents); |
| 892 | } |
| 893 | |
| 894 | static void gdextension_string_new_with_utf16_chars(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents) { |
| 895 | String *dest = memnew_placement(r_dest, String); |
| 896 | dest->append_utf16(p_contents); |
| 897 | } |
| 898 | |
| 899 | static void gdextension_string_new_with_utf32_chars(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents) { |
| 900 | String *dest = memnew_placement(r_dest, String); |
| 901 | dest->append_utf32(Span(p_contents, p_contents ? strlen(p_contents) : 0)); |
| 902 | } |
| 903 | |
| 904 | static void gdextension_string_new_with_wide_chars(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents) { |
| 905 | if constexpr (sizeof(wchar_t) == 2) { |
| 906 | // wchar_t is 16 bit (UTF-16). |
| 907 | String *dest = memnew_placement(r_dest, String); |
| 908 | dest->append_utf16((const char16_t *)p_contents); |
| 909 | } else { |
| 910 | // wchar_t is 32 bit (UTF-32). |
| 911 | String *string = memnew_placement(r_dest, String); |
| 912 | string->append_utf32(Span((const char32_t *)p_contents, p_contents ? strlen(p_contents) : 0)); |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | static void gdextension_string_new_with_latin1_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size) { |
| 917 | const size_t string_length = p_contents ? (p_size < 0 ? strlen(p_contents) : strnlen(p_contents, p_size)) : 0; |
| 918 | String *dest = memnew_placement(r_dest, String); |
| 919 | dest->append_latin1(Span(p_contents, string_length)); |
| 920 | } |
| 921 | |
| 922 | static void gdextension_string_new_with_utf8_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size) { |
| 923 | String *dest = memnew_placement(r_dest, String); |
| 924 | dest->append_utf8(p_contents, p_size); |
| 925 | } |
| 926 | |
| 927 | static GDExtensionInt gdextension_string_new_with_utf8_chars_and_len2(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size) { |
| 928 | String *dest = memnew_placement(r_dest, String); |
| 929 | return (GDExtensionInt)dest->append_utf8(p_contents, p_size); |
| 930 | } |
| 931 | |
| 932 | static void gdextension_string_new_with_utf16_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count) { |
| 933 | String *dest = memnew_placement(r_dest, String); |
| 934 | dest->append_utf16(p_contents, p_char_count); |
| 935 | } |
| 936 | |
| 937 | static GDExtensionInt gdextension_string_new_with_utf16_chars_and_len2(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count, GDExtensionBool p_default_little_endian) { |
| 938 | String *dest = memnew_placement(r_dest, String); |
| 939 | return (GDExtensionInt)dest->append_utf16(p_contents, p_char_count, p_default_little_endian); |
| 940 | } |
| 941 | |
| 942 | static void gdextension_string_new_with_utf32_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_char_count) { |
| 943 | const size_t string_length = p_contents ? (p_char_count < 0 ? strlen(p_contents) : strnlen(p_contents, p_char_count)) : 0; |
| 944 | String *string = memnew_placement(r_dest, String); |
| 945 | string->append_utf32(Span(p_contents, string_length)); |
| 946 | } |
| 947 | |
| 948 | static void gdextension_string_new_with_wide_chars_and_len(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_char_count) { |
| 949 | if constexpr (sizeof(wchar_t) == 2) { |
| 950 | // wchar_t is 16 bit (UTF-16). |
| 951 | String *dest = memnew_placement(r_dest, String); |
| 952 | dest->append_utf16((const char16_t *)p_contents, p_char_count); |
| 953 | } else { |
| 954 | // wchar_t is 32 bit (UTF-32). |
| 955 | const size_t string_length = p_contents ? (p_char_count < 0 ? strlen(p_contents) : strnlen((const char32_t *)p_contents, p_char_count)) : 0; |
| 956 | String *string = memnew_placement(r_dest, String); |
| 957 | string->append_utf32(Span((const char32_t *)p_contents, string_length)); |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | static GDExtensionInt gdextension_string_to_latin1_chars(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length) { |
| 962 | String *self = (String *)p_self; |
| 963 | CharString cs = self->latin1(); |
| 964 | GDExtensionInt len = cs.length(); |
| 965 | if (r_text) { |
| 966 | const char *s_text = cs.ptr(); |
| 967 | for (GDExtensionInt i = 0; i < MIN(len, p_max_write_length); i++) { |
| 968 | r_text[i] = s_text[i]; |
| 969 | } |
| 970 | } |
| 971 | return len; |
| 972 | } |
| 973 | static GDExtensionInt gdextension_string_to_utf8_chars(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length) { |
| 974 | String *self = (String *)p_self; |
| 975 | CharString cs = self->utf8(); |
| 976 | GDExtensionInt len = cs.length(); |
| 977 | if (r_text) { |
| 978 | const char *s_text = cs.ptr(); |
| 979 | for (GDExtensionInt i = 0; i < MIN(len, p_max_write_length); i++) { |
| 980 | r_text[i] = s_text[i]; |
| 981 | } |
| 982 | } |
| 983 | return len; |
| 984 | } |
| 985 | static GDExtensionInt gdextension_string_to_utf16_chars(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length) { |
| 986 | String *self = (String *)p_self; |
| 987 | Char16String cs = self->utf16(); |
| 988 | GDExtensionInt len = cs.length(); |
| 989 | if (r_text) { |
| 990 | const char16_t *s_text = cs.ptr(); |
| 991 | for (GDExtensionInt i = 0; i < MIN(len, p_max_write_length); i++) { |
| 992 | r_text[i] = s_text[i]; |
| 993 | } |
| 994 | } |
| 995 | return len; |
| 996 | } |
| 997 | static GDExtensionInt gdextension_string_to_utf32_chars(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length) { |
| 998 | String *self = (String *)p_self; |
| 999 | GDExtensionInt len = self->length(); |
| 1000 | if (r_text) { |
| 1001 | const char32_t *s_text = self->ptr(); |
| 1002 | for (GDExtensionInt i = 0; i < MIN(len, p_max_write_length); i++) { |
| 1003 | r_text[i] = s_text[i]; |
| 1004 | } |
| 1005 | } |
| 1006 | return len; |
| 1007 | } |
| 1008 | static GDExtensionInt gdextension_string_to_wide_chars(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length) { |
| 1009 | if constexpr (sizeof(wchar_t) == 4) { |
| 1010 | return gdextension_string_to_utf32_chars(p_self, (char32_t *)r_text, p_max_write_length); |
| 1011 | } else { |
| 1012 | return gdextension_string_to_utf16_chars(p_self, (char16_t *)r_text, p_max_write_length); |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | static char32_t *gdextension_string_operator_index(GDExtensionStringPtr p_self, GDExtensionInt p_index) { |
| 1017 | String *self = (String *)p_self; |
| 1018 | if (unlikely(p_index < 0 || p_index >= self->length() + 1)) { |
| 1019 | return nullptr; |
| 1020 | } |
| 1021 | return &self->ptrw()[p_index]; |
| 1022 | } |
| 1023 | |
| 1024 | static const char32_t *gdextension_string_operator_index_const(GDExtensionConstStringPtr p_self, GDExtensionInt p_index) { |
| 1025 | const String *self = (const String *)p_self; |
| 1026 | if (unlikely(p_index < 0 || p_index >= self->length() + 1)) { |
| 1027 | return nullptr; |
| 1028 | } |
| 1029 | return &self->ptr()[p_index]; |
| 1030 | } |
| 1031 | |
| 1032 | static void gdextension_string_operator_plus_eq_string(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b) { |
| 1033 | String *self = (String *)p_self; |
| 1034 | const String *b = (const String *)p_b; |
| 1035 | *self += *b; |
| 1036 | } |
| 1037 | |
| 1038 | static void gdextension_string_operator_plus_eq_char(GDExtensionStringPtr p_self, char32_t p_b) { |
| 1039 | String *self = (String *)p_self; |
| 1040 | *self += p_b; |
| 1041 | } |
| 1042 | |
| 1043 | static void gdextension_string_operator_plus_eq_cstr(GDExtensionStringPtr p_self, const char *p_b) { |
| 1044 | String *self = (String *)p_self; |
| 1045 | *self += p_b; |
| 1046 | } |
| 1047 | |
| 1048 | static void gdextension_string_operator_plus_eq_wcstr(GDExtensionStringPtr p_self, const wchar_t *p_b) { |
| 1049 | String *self = (String *)p_self; |
| 1050 | *self += p_b; |
| 1051 | } |
| 1052 | |
| 1053 | static void gdextension_string_operator_plus_eq_c32str(GDExtensionStringPtr p_self, const char32_t *p_b) { |
| 1054 | String *self = (String *)p_self; |
| 1055 | *self += p_b; |
| 1056 | } |
| 1057 | |
| 1058 | static GDExtensionInt gdextension_string_resize(GDExtensionStringPtr p_self, GDExtensionInt p_length) { |
| 1059 | String *self = (String *)p_self; |
| 1060 | return (*self).resize_uninitialized(p_length); |
| 1061 | } |
| 1062 | |
| 1063 | static void gdextension_string_name_new_with_latin1_chars(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionBool p_is_static) { |
| 1064 | memnew_placement(r_dest, StringName(p_contents, static_cast<bool>(p_is_static))); |
| 1065 | } |
| 1066 | |
| 1067 | static void gdextension_string_name_new_with_utf8_chars(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents) { |
| 1068 | String tmp = String::utf8(p_contents); |
| 1069 | memnew_placement(r_dest, StringName(tmp)); |
| 1070 | } |
| 1071 | |
| 1072 | static void gdextension_string_name_new_with_utf8_chars_and_len(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionInt p_size) { |
| 1073 | String tmp = String::utf8(p_contents, p_size); |
| 1074 | memnew_placement(r_dest, StringName(tmp)); |
| 1075 | } |
| 1076 | |
| 1077 | static GDExtensionInt gdextension_xml_parser_open_buffer(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size) { |
| 1078 | XMLParser *xml = (XMLParser *)p_instance; |
| 1079 | return (GDExtensionInt)xml->_open_buffer(p_buffer, p_size); |
| 1080 | } |
| 1081 | |
| 1082 | static void gdextension_file_access_store_buffer(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length) { |
| 1083 | FileAccess *fa = (FileAccess *)p_instance; |
| 1084 | fa->store_buffer(p_src, p_length); |
| 1085 | } |
| 1086 | |
| 1087 | static uint64_t gdextension_file_access_get_buffer(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length) { |
| 1088 | const FileAccess *fa = (FileAccess *)p_instance; |
| 1089 | return fa->get_buffer(p_dst, p_length); |
| 1090 | } |
| 1091 | |
| 1092 | static uint8_t *gdextension_image_ptrw(GDExtensionObjectPtr p_instance) { |
| 1093 | Image *img = (Image *)p_instance; |
| 1094 | return img->ptrw(); |
| 1095 | } |
| 1096 | |
| 1097 | static const uint8_t *gdextension_image_ptr(GDExtensionObjectPtr p_instance) { |
| 1098 | Image *img = (Image *)p_instance; |
| 1099 | return img->ptr(); |
| 1100 | } |
| 1101 | |
| 1102 | 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) { |
| 1103 | WorkerThreadPool *p = (WorkerThreadPool *)p_instance; |
| 1104 | const String *description = (const String *)p_description; |
| 1105 | return (int64_t)p->add_native_group_task(p_func, p_userdata, p_elements, p_tasks, static_cast<bool>(p_high_priority), *description); |
| 1106 | } |
| 1107 | |
| 1108 | 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) { |
| 1109 | WorkerThreadPool *p = (WorkerThreadPool *)p_instance; |
| 1110 | const String *description = (const String *)p_description; |
| 1111 | return (int64_t)p->add_native_task(p_func, p_userdata, static_cast<bool>(p_high_priority), *description); |
| 1112 | } |
| 1113 | |
| 1114 | /* Packed array functions */ |
| 1115 | |
| 1116 | static uint8_t *gdextension_packed_byte_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1117 | PackedByteArray *self = (PackedByteArray *)p_self; |
| 1118 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1119 | return nullptr; |
| 1120 | } |
| 1121 | return &self->ptrw()[p_index]; |
| 1122 | } |
| 1123 | |
| 1124 | static const uint8_t *gdextension_packed_byte_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1125 | const PackedByteArray *self = (const PackedByteArray *)p_self; |
| 1126 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1127 | return nullptr; |
| 1128 | } |
| 1129 | return &self->ptr()[p_index]; |
| 1130 | } |
| 1131 | |
| 1132 | static GDExtensionTypePtr gdextension_packed_color_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1133 | PackedColorArray *self = (PackedColorArray *)p_self; |
| 1134 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1135 | return nullptr; |
| 1136 | } |
| 1137 | return (GDExtensionTypePtr)&self->ptrw()[p_index]; |
| 1138 | } |
| 1139 | |
| 1140 | static GDExtensionTypePtr gdextension_packed_color_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1141 | const PackedColorArray *self = (const PackedColorArray *)p_self; |
| 1142 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1143 | return nullptr; |
| 1144 | } |
| 1145 | return (GDExtensionTypePtr)&self->ptr()[p_index]; |
| 1146 | } |
| 1147 | |
| 1148 | static float *gdextension_packed_float32_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1149 | PackedFloat32Array *self = (PackedFloat32Array *)p_self; |
| 1150 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1151 | return nullptr; |
| 1152 | } |
| 1153 | return &self->ptrw()[p_index]; |
| 1154 | } |
| 1155 | |
| 1156 | static const float *gdextension_packed_float32_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1157 | const PackedFloat32Array *self = (const PackedFloat32Array *)p_self; |
| 1158 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1159 | return nullptr; |
| 1160 | } |
| 1161 | return &self->ptr()[p_index]; |
| 1162 | } |
| 1163 | |
| 1164 | static double *gdextension_packed_float64_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1165 | PackedFloat64Array *self = (PackedFloat64Array *)p_self; |
| 1166 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1167 | return nullptr; |
| 1168 | } |
| 1169 | return &self->ptrw()[p_index]; |
| 1170 | } |
| 1171 | |
| 1172 | static const double *gdextension_packed_float64_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1173 | const PackedFloat64Array *self = (const PackedFloat64Array *)p_self; |
| 1174 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1175 | return nullptr; |
| 1176 | } |
| 1177 | return &self->ptr()[p_index]; |
| 1178 | } |
| 1179 | |
| 1180 | static int32_t *gdextension_packed_int32_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1181 | PackedInt32Array *self = (PackedInt32Array *)p_self; |
| 1182 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1183 | return nullptr; |
| 1184 | } |
| 1185 | return &self->ptrw()[p_index]; |
| 1186 | } |
| 1187 | |
| 1188 | static const int32_t *gdextension_packed_int32_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1189 | const PackedInt32Array *self = (const PackedInt32Array *)p_self; |
| 1190 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1191 | return nullptr; |
| 1192 | } |
| 1193 | return &self->ptr()[p_index]; |
| 1194 | } |
| 1195 | |
| 1196 | static int64_t *gdextension_packed_int64_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1197 | PackedInt64Array *self = (PackedInt64Array *)p_self; |
| 1198 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1199 | return nullptr; |
| 1200 | } |
| 1201 | return &self->ptrw()[p_index]; |
| 1202 | } |
| 1203 | |
| 1204 | static const int64_t *gdextension_packed_int64_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1205 | const PackedInt64Array *self = (const PackedInt64Array *)p_self; |
| 1206 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1207 | return nullptr; |
| 1208 | } |
| 1209 | return &self->ptr()[p_index]; |
| 1210 | } |
| 1211 | |
| 1212 | static GDExtensionStringPtr gdextension_packed_string_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1213 | PackedStringArray *self = (PackedStringArray *)p_self; |
| 1214 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1215 | return nullptr; |
| 1216 | } |
| 1217 | return (GDExtensionStringPtr)&self->ptrw()[p_index]; |
| 1218 | } |
| 1219 | |
| 1220 | static GDExtensionStringPtr gdextension_packed_string_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1221 | const PackedStringArray *self = (const PackedStringArray *)p_self; |
| 1222 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1223 | return nullptr; |
| 1224 | } |
| 1225 | return (GDExtensionStringPtr)&self->ptr()[p_index]; |
| 1226 | } |
| 1227 | |
| 1228 | static GDExtensionTypePtr gdextension_packed_vector2_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1229 | PackedVector2Array *self = (PackedVector2Array *)p_self; |
| 1230 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1231 | return nullptr; |
| 1232 | } |
| 1233 | return (GDExtensionTypePtr)&self->ptrw()[p_index]; |
| 1234 | } |
| 1235 | |
| 1236 | static GDExtensionTypePtr gdextension_packed_vector2_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1237 | const PackedVector2Array *self = (const PackedVector2Array *)p_self; |
| 1238 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1239 | return nullptr; |
| 1240 | } |
| 1241 | return (GDExtensionTypePtr)&self->ptr()[p_index]; |
| 1242 | } |
| 1243 | |
| 1244 | static GDExtensionTypePtr gdextension_packed_vector3_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1245 | PackedVector3Array *self = (PackedVector3Array *)p_self; |
| 1246 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1247 | return nullptr; |
| 1248 | } |
| 1249 | return (GDExtensionTypePtr)&self->ptrw()[p_index]; |
| 1250 | } |
| 1251 | |
| 1252 | static GDExtensionTypePtr gdextension_packed_vector3_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1253 | const PackedVector3Array *self = (const PackedVector3Array *)p_self; |
| 1254 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1255 | return nullptr; |
| 1256 | } |
| 1257 | return (GDExtensionTypePtr)&self->ptr()[p_index]; |
| 1258 | } |
| 1259 | |
| 1260 | static GDExtensionTypePtr gdextension_packed_vector4_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1261 | PackedVector4Array *self = (PackedVector4Array *)p_self; |
| 1262 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1263 | return nullptr; |
| 1264 | } |
| 1265 | return (GDExtensionTypePtr)&self->ptrw()[p_index]; |
| 1266 | } |
| 1267 | |
| 1268 | static GDExtensionTypePtr gdextension_packed_vector4_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1269 | const PackedVector4Array *self = (const PackedVector4Array *)p_self; |
| 1270 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1271 | return nullptr; |
| 1272 | } |
| 1273 | return (GDExtensionTypePtr)&self->ptr()[p_index]; |
| 1274 | } |
| 1275 | |
| 1276 | static GDExtensionVariantPtr gdextension_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { |
| 1277 | Array *self = (Array *)p_self; |
| 1278 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1279 | return nullptr; |
| 1280 | } |
| 1281 | return (GDExtensionVariantPtr)&self->operator[](p_index); |
| 1282 | } |
| 1283 | |
| 1284 | static GDExtensionVariantPtr gdextension_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { |
| 1285 | const Array *self = (const Array *)p_self; |
| 1286 | if (unlikely(p_index < 0 || p_index >= self->size())) { |
| 1287 | return nullptr; |
| 1288 | } |
| 1289 | return (GDExtensionVariantPtr)&self->operator[](p_index); |
| 1290 | } |
| 1291 | |
| 1292 | #ifndef DISABLE_DEPRECATED |
| 1293 | void gdextension_array_ref(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from) { |
| 1294 | Array *self = (Array *)p_self; |
| 1295 | const Array *from = (const Array *)p_from; |
| 1296 | self->Array::operator=(*from); |
| 1297 | } |
| 1298 | #endif // DISABLE_DEPRECATED |
| 1299 | |
| 1300 | void gdextension_array_set_typed(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script) { |
| 1301 | Array *self = reinterpret_cast<Array *>(p_self); |
| 1302 | const StringName *class_name = reinterpret_cast<const StringName *>(p_class_name); |
| 1303 | const Variant *script = reinterpret_cast<const Variant *>(p_script); |
| 1304 | self->set_typed((uint32_t)p_type, *class_name, *script); |
| 1305 | } |
| 1306 | |
| 1307 | /* Dictionary functions */ |
| 1308 | |
| 1309 | static GDExtensionVariantPtr gdextension_dictionary_operator_index(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key) { |
| 1310 | Dictionary *self = (Dictionary *)p_self; |
| 1311 | return (GDExtensionVariantPtr)&self->operator[](*(const Variant *)p_key); |
| 1312 | } |
| 1313 | |
| 1314 | static GDExtensionVariantPtr gdextension_dictionary_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key) { |
| 1315 | const Dictionary *self = (const Dictionary *)p_self; |
| 1316 | return (GDExtensionVariantPtr)&self->operator[](*(const Variant *)p_key); |
| 1317 | } |
| 1318 | |
| 1319 | void gdextension_dictionary_set_typed(GDExtensionTypePtr p_self, GDExtensionVariantType p_key_type, GDExtensionConstStringNamePtr p_key_class_name, GDExtensionConstVariantPtr p_key_script, GDExtensionVariantType p_value_type, GDExtensionConstStringNamePtr p_value_class_name, GDExtensionConstVariantPtr p_value_script) { |
| 1320 | Dictionary *self = reinterpret_cast<Dictionary *>(p_self); |
| 1321 | const StringName *key_class_name = reinterpret_cast<const StringName *>(p_key_class_name); |
| 1322 | const Variant *key_script = reinterpret_cast<const Variant *>(p_key_script); |
| 1323 | const StringName *value_class_name = reinterpret_cast<const StringName *>(p_value_class_name); |
| 1324 | const Variant *value_script = reinterpret_cast<const Variant *>(p_value_script); |
| 1325 | self->set_typed((uint32_t)p_key_type, *key_class_name, *key_script, (uint32_t)p_value_type, *value_class_name, *value_script); |
| 1326 | } |
| 1327 | |
| 1328 | /* OBJECT API */ |
| 1329 | |
| 1330 | 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) { |
| 1331 | const MethodBind *mb = reinterpret_cast<const MethodBind *>(p_method_bind); |
| 1332 | Object *o = (Object *)p_instance; |
| 1333 | const Variant **args = (const Variant **)p_args; |
| 1334 | Callable::CallError error; |
| 1335 | |
| 1336 | memnew_placement(r_return, Variant(mb->call(o, args, p_arg_count, error))); |
| 1337 | |
| 1338 | if (r_error) { |
| 1339 | r_error->error = (GDExtensionCallErrorType)(error.error); |
| 1340 | r_error->argument = error.argument; |
| 1341 | r_error->expected = error.expected; |
| 1342 | } |
| 1343 | } |
| 1344 | |
| 1345 | static void gdextension_object_method_bind_ptrcall(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr p_ret) { |
| 1346 | const MethodBind *mb = reinterpret_cast<const MethodBind *>(p_method_bind); |
| 1347 | Object *o = (Object *)p_instance; |
| 1348 | mb->ptrcall(o, (const void **)p_args, p_ret); |
| 1349 | } |
| 1350 | |
| 1351 | static void gdextension_object_destroy(GDExtensionObjectPtr p_o) { |
| 1352 | memdelete((Object *)p_o); |
| 1353 | } |
| 1354 | |
| 1355 | static GDExtensionObjectPtr gdextension_global_get_singleton(GDExtensionConstStringNamePtr p_name) { |
| 1356 | const StringName name = *reinterpret_cast<const StringName *>(p_name); |
| 1357 | return (GDExtensionObjectPtr)Engine::get_singleton()->get_singleton_object(name); |
| 1358 | } |
| 1359 | |
| 1360 | static void *gdextension_object_get_instance_binding(GDExtensionObjectPtr p_object, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks) { |
| 1361 | Object *o = (Object *)p_object; |
| 1362 | return o->get_instance_binding(p_token, p_callbacks); |
| 1363 | } |
| 1364 | |
| 1365 | static void gdextension_object_set_instance_binding(GDExtensionObjectPtr p_object, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks) { |
| 1366 | Object *o = (Object *)p_object; |
| 1367 | o->set_instance_binding(p_token, p_binding, p_callbacks); |
| 1368 | } |
| 1369 | |
| 1370 | static void gdextension_object_free_instance_binding(GDExtensionObjectPtr p_object, void *p_token) { |
| 1371 | Object *o = (Object *)p_object; |
| 1372 | o->free_instance_binding(p_token); |
| 1373 | } |
| 1374 | |
| 1375 | static void gdextension_object_set_instance(GDExtensionObjectPtr p_object, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance) { |
| 1376 | const StringName classname = *reinterpret_cast<const StringName *>(p_classname); |
| 1377 | Object *o = (Object *)p_object; |
| 1378 | ClassDB::set_object_extension_instance(o, classname, p_instance); |
| 1379 | } |
| 1380 | |
| 1381 | static GDExtensionObjectPtr gdextension_object_get_instance_from_id(GDObjectInstanceID p_instance_id) { |
| 1382 | return (GDExtensionObjectPtr)ObjectDB::get_instance(ObjectID(p_instance_id)); |
| 1383 | } |
| 1384 | |
| 1385 | static GDExtensionBool gdextension_object_get_class_name(GDExtensionConstObjectPtr p_object, GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringNamePtr r_class_name) { |
| 1386 | if (!p_object) { |
| 1387 | return false; |
| 1388 | } |
| 1389 | const Object *o = (const Object *)p_object; |
| 1390 | |
| 1391 | memnew_placement(r_class_name, StringName); |
| 1392 | StringName *class_name = reinterpret_cast<StringName *>(r_class_name); |
| 1393 | *class_name = o->get_class_name_for_extension((GDExtension *)p_library); |
| 1394 | |
| 1395 | return true; |
| 1396 | } |
| 1397 | |
| 1398 | static GDExtensionObjectPtr gdextension_object_cast_to(GDExtensionConstObjectPtr p_object, void *p_class_tag) { |
| 1399 | if (!p_object) { |
| 1400 | return nullptr; |
| 1401 | } |
| 1402 | Object *o = (Object *)p_object; |
| 1403 | |
| 1404 | return o->is_class_ptr(p_class_tag) ? (GDExtensionObjectPtr)o : (GDExtensionObjectPtr) nullptr; |
| 1405 | } |
| 1406 | |
| 1407 | static GDObjectInstanceID gdextension_object_get_instance_id(GDExtensionConstObjectPtr p_object) { |
| 1408 | const Object *o = (const Object *)p_object; |
| 1409 | return (GDObjectInstanceID)o->get_instance_id(); |
| 1410 | } |
| 1411 | |
| 1412 | static GDExtensionBool gdextension_object_has_script_method(GDExtensionConstObjectPtr p_object, GDExtensionConstStringNamePtr p_method) { |
| 1413 | Object *o = (Object *)p_object; |
| 1414 | const StringName method = *reinterpret_cast<const StringName *>(p_method); |
| 1415 | |
| 1416 | ScriptInstance *script_instance = o->get_script_instance(); |
| 1417 | if (script_instance) { |
| 1418 | return script_instance->has_method(method); |
| 1419 | } |
| 1420 | return false; |
| 1421 | } |
| 1422 | |
| 1423 | static void gdextension_object_call_script_method(GDExtensionObjectPtr p_object, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error) { |
| 1424 | Object *o = (Object *)p_object; |
| 1425 | const StringName method = *reinterpret_cast<const StringName *>(p_method); |
| 1426 | const Variant **args = (const Variant **)p_args; |
| 1427 | |
| 1428 | Callable::CallError error; // TODO: Check `error`? |
| 1429 | memnew_placement(r_return, Variant); |
| 1430 | *(Variant *)r_return = o->callp(method, args, p_argument_count, error); |
| 1431 | |
| 1432 | if (r_error) { |
| 1433 | r_error->error = (GDExtensionCallErrorType)(error.error); |
| 1434 | r_error->argument = error.argument; |
| 1435 | r_error->expected = error.expected; |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | static GDExtensionObjectPtr gdextension_ref_get_object(GDExtensionConstRefPtr p_ref) { |
| 1440 | const Ref<RefCounted> *ref = (const Ref<RefCounted> *)p_ref; |
| 1441 | if (ref == nullptr || ref->is_null()) { |
| 1442 | return (GDExtensionObjectPtr) nullptr; |
| 1443 | } else { |
| 1444 | return (GDExtensionObjectPtr)ref->ptr(); |
| 1445 | } |
| 1446 | } |
| 1447 | |
| 1448 | static void gdextension_ref_set_object(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object) { |
| 1449 | Ref<RefCounted> *ref = (Ref<RefCounted> *)p_ref; |
| 1450 | ERR_FAIL_NULL(ref); |
| 1451 | |
| 1452 | Object *o = (RefCounted *)p_object; |
| 1453 | ref->reference_ptr(o); |
| 1454 | } |
| 1455 | |
| 1456 | #ifndef DISABLE_DEPRECATED |
| 1457 | static GDExtensionScriptInstancePtr gdextension_script_instance_create(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data) { |
| 1458 | GDExtensionScriptInstanceInfo3 *info_3 = memnew(GDExtensionScriptInstanceInfo3); |
| 1459 | info_3->set_func = p_info->set_func; |
| 1460 | info_3->get_func = p_info->get_func; |
| 1461 | info_3->get_property_list_func = p_info->get_property_list_func; |
| 1462 | info_3->free_property_list_func = nullptr; |
| 1463 | info_3->get_class_category_func = nullptr; |
| 1464 | info_3->property_can_revert_func = p_info->property_can_revert_func; |
| 1465 | info_3->property_get_revert_func = p_info->property_get_revert_func; |
| 1466 | info_3->get_owner_func = p_info->get_owner_func; |
| 1467 | info_3->get_property_state_func = p_info->get_property_state_func; |
| 1468 | info_3->get_method_list_func = p_info->get_method_list_func; |
| 1469 | info_3->free_method_list_func = nullptr; |
| 1470 | info_3->get_property_type_func = p_info->get_property_type_func; |
| 1471 | info_3->validate_property_func = nullptr; |
| 1472 | info_3->has_method_func = p_info->has_method_func; |
| 1473 | info_3->get_method_argument_count_func = nullptr; |
| 1474 | info_3->call_func = p_info->call_func; |
| 1475 | info_3->notification_func = nullptr; |
| 1476 | info_3->to_string_func = p_info->to_string_func; |
| 1477 | info_3->refcount_incremented_func = p_info->refcount_incremented_func; |
| 1478 | info_3->refcount_decremented_func = p_info->refcount_decremented_func; |
| 1479 | info_3->get_script_func = p_info->get_script_func; |
| 1480 | info_3->is_placeholder_func = p_info->is_placeholder_func; |
| 1481 | info_3->set_fallback_func = p_info->set_fallback_func; |
| 1482 | info_3->get_fallback_func = p_info->get_fallback_func; |
| 1483 | info_3->get_language_func = p_info->get_language_func; |
| 1484 | info_3->free_func = p_info->free_func; |
| 1485 | |
| 1486 | ScriptInstanceExtension *script_instance_extension = memnew(ScriptInstanceExtension); |
| 1487 | script_instance_extension->instance = p_instance_data; |
| 1488 | script_instance_extension->native_info = info_3; |
| 1489 | script_instance_extension->free_native_info = true; |
| 1490 | script_instance_extension->deprecated_native_info = memnew(ScriptInstanceExtension::DeprecatedNativeInfo); |
| 1491 | script_instance_extension->deprecated_native_info->notification_func = p_info->notification_func; |
| 1492 | script_instance_extension->deprecated_native_info->free_property_list_func = p_info->free_property_list_func; |
| 1493 | script_instance_extension->deprecated_native_info->free_method_list_func = p_info->free_method_list_func; |
| 1494 | return reinterpret_cast<GDExtensionScriptInstancePtr>(script_instance_extension); |
| 1495 | } |
| 1496 | |
| 1497 | static GDExtensionScriptInstancePtr gdextension_script_instance_create2(const GDExtensionScriptInstanceInfo2 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data) { |
| 1498 | GDExtensionScriptInstanceInfo3 *info_3 = memnew(GDExtensionScriptInstanceInfo3); |
| 1499 | info_3->set_func = p_info->set_func; |
| 1500 | info_3->get_func = p_info->get_func; |
| 1501 | info_3->get_property_list_func = p_info->get_property_list_func; |
| 1502 | info_3->free_property_list_func = nullptr; |
| 1503 | info_3->get_class_category_func = nullptr; |
| 1504 | info_3->property_can_revert_func = p_info->property_can_revert_func; |
| 1505 | info_3->property_get_revert_func = p_info->property_get_revert_func; |
| 1506 | info_3->get_owner_func = p_info->get_owner_func; |
| 1507 | info_3->get_property_state_func = p_info->get_property_state_func; |
| 1508 | info_3->get_method_list_func = p_info->get_method_list_func; |
| 1509 | info_3->free_method_list_func = nullptr; |
| 1510 | info_3->get_property_type_func = p_info->get_property_type_func; |
| 1511 | info_3->validate_property_func = nullptr; |
| 1512 | info_3->has_method_func = p_info->has_method_func; |
| 1513 | info_3->get_method_argument_count_func = nullptr; |
| 1514 | info_3->call_func = p_info->call_func; |
| 1515 | info_3->notification_func = p_info->notification_func; |
| 1516 | info_3->to_string_func = p_info->to_string_func; |
| 1517 | info_3->refcount_incremented_func = p_info->refcount_incremented_func; |
| 1518 | info_3->refcount_decremented_func = p_info->refcount_decremented_func; |
| 1519 | info_3->get_script_func = p_info->get_script_func; |
| 1520 | info_3->is_placeholder_func = p_info->is_placeholder_func; |
| 1521 | info_3->set_fallback_func = p_info->set_fallback_func; |
| 1522 | info_3->get_fallback_func = p_info->get_fallback_func; |
| 1523 | info_3->get_language_func = p_info->get_language_func; |
| 1524 | info_3->free_func = p_info->free_func; |
| 1525 | |
| 1526 | ScriptInstanceExtension *script_instance_extension = memnew(ScriptInstanceExtension); |
| 1527 | script_instance_extension->instance = p_instance_data; |
| 1528 | script_instance_extension->native_info = info_3; |
| 1529 | script_instance_extension->free_native_info = true; |
| 1530 | script_instance_extension->deprecated_native_info = memnew(ScriptInstanceExtension::DeprecatedNativeInfo); |
| 1531 | script_instance_extension->deprecated_native_info->free_property_list_func = p_info->free_property_list_func; |
| 1532 | script_instance_extension->deprecated_native_info->free_method_list_func = p_info->free_method_list_func; |
| 1533 | return reinterpret_cast<GDExtensionScriptInstancePtr>(script_instance_extension); |
| 1534 | } |
| 1535 | #endif // DISABLE_DEPRECATED |
| 1536 | |
| 1537 | static GDExtensionScriptInstancePtr gdextension_script_instance_create3(const GDExtensionScriptInstanceInfo3 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data) { |
| 1538 | ScriptInstanceExtension *script_instance_extension = memnew(ScriptInstanceExtension); |
| 1539 | script_instance_extension->instance = p_instance_data; |
| 1540 | script_instance_extension->native_info = p_info; |
| 1541 | return reinterpret_cast<GDExtensionScriptInstancePtr>(script_instance_extension); |
| 1542 | } |
| 1543 | |
| 1544 | static GDExtensionScriptInstancePtr gdextension_placeholder_script_instance_create(GDExtensionObjectPtr p_language, GDExtensionObjectPtr p_script, GDExtensionObjectPtr p_owner) { |
| 1545 | ScriptLanguage *language = (ScriptLanguage *)p_language; |
| 1546 | Ref<Script> script; |
| 1547 | script.reference_ptr((Script *)p_script); |
| 1548 | Object *owner = (Object *)p_owner; |
| 1549 | |
| 1550 | PlaceHolderScriptInstance *placeholder = memnew(PlaceHolderScriptInstance(language, script, owner)); |
| 1551 | return reinterpret_cast<GDExtensionScriptInstancePtr>(placeholder); |
| 1552 | } |
| 1553 | |
| 1554 | static void gdextension_placeholder_script_instance_update(GDExtensionScriptInstancePtr p_placeholder, GDExtensionConstTypePtr p_properties, GDExtensionConstTypePtr p_values) { |
| 1555 | PlaceHolderScriptInstance *placeholder = dynamic_cast<PlaceHolderScriptInstance *>(reinterpret_cast<ScriptInstance *>(p_placeholder)); |
| 1556 | ERR_FAIL_NULL_MSG(placeholder, "Unable to update placeholder, expected a PlaceHolderScriptInstance but received an invalid type."); |
| 1557 | |
| 1558 | const Array &properties = *reinterpret_cast<const Array *>(p_properties); |
| 1559 | const Dictionary &values = *reinterpret_cast<const Dictionary *>(p_values); |
| 1560 | |
| 1561 | List<PropertyInfo> properties_list; |
| 1562 | HashMap<StringName, Variant> values_map; |
| 1563 | |
| 1564 | for (int i = 0; i < properties.size(); i++) { |
| 1565 | Dictionary d = properties[i]; |
| 1566 | properties_list.push_back(PropertyInfo::from_dict(d)); |
| 1567 | } |
| 1568 | |
| 1569 | for (const KeyValue<Variant, Variant> &kv : values) { |
| 1570 | values_map.insert(kv.key, kv.value); |
| 1571 | } |
| 1572 | |
| 1573 | placeholder->update(properties_list, values_map); |
| 1574 | } |
| 1575 | |
| 1576 | static GDExtensionScriptInstancePtr gdextension_object_get_script_instance(GDExtensionConstObjectPtr p_object, GDExtensionConstObjectPtr p_language) { |
| 1577 | if (!p_object || !p_language) { |
| 1578 | return nullptr; |
| 1579 | } |
| 1580 | |
| 1581 | const Object *o = (const Object *)p_object; |
| 1582 | ScriptInstanceExtension *script_instance_extension = reinterpret_cast<ScriptInstanceExtension *>(o->get_script_instance()); |
| 1583 | if (!script_instance_extension) { |
| 1584 | return nullptr; |
| 1585 | } |
| 1586 | |
| 1587 | const ScriptLanguage *language = script_instance_extension->get_language(); |
| 1588 | if (language != p_language) { |
| 1589 | return nullptr; |
| 1590 | } |
| 1591 | |
| 1592 | return script_instance_extension->instance; |
| 1593 | } |
| 1594 | |
| 1595 | static void gdextension_object_set_script_instance(GDExtensionObjectPtr p_object, GDExtensionScriptInstancePtr p_script_instance) { |
| 1596 | ERR_FAIL_NULL(p_object); |
| 1597 | |
| 1598 | Object *o = (Object *)p_object; |
| 1599 | ScriptInstance *script_instance = (ScriptInstanceExtension *)p_script_instance; |
| 1600 | |
| 1601 | o->set_script_instance(script_instance); |
| 1602 | } |
| 1603 | |
| 1604 | #ifndef DISABLE_DEPRECATED |
| 1605 | static void gdextension_callable_custom_create(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo *p_custom_callable_info) { |
| 1606 | memnew_placement(r_callable, Callable(memnew(CallableCustomExtension(p_custom_callable_info)))); |
| 1607 | } |
| 1608 | #endif |
| 1609 | |
| 1610 | static void gdextension_callable_custom_create2(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo2 *p_custom_callable_info) { |
| 1611 | memnew_placement(r_callable, Callable(memnew(CallableCustomExtension(p_custom_callable_info)))); |
| 1612 | } |
| 1613 | |
| 1614 | static void *gdextension_callable_custom_get_userdata(GDExtensionTypePtr p_callable, void *p_token) { |
| 1615 | const Callable &callable = *reinterpret_cast<const Callable *>(p_callable); |
| 1616 | if (!callable.is_custom()) { |
| 1617 | return nullptr; |
| 1618 | } |
| 1619 | const CallableCustomExtension *custom_callable = dynamic_cast<const CallableCustomExtension *>(callable.get_custom()); |
| 1620 | if (!custom_callable) { |
| 1621 | return nullptr; |
| 1622 | } |
| 1623 | return custom_callable->get_userdata(p_token); |
| 1624 | } |
| 1625 | |
| 1626 | static GDExtensionMethodBindPtr gdextension_classdb_get_method_bind(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash) { |
| 1627 | const StringName classname = *reinterpret_cast<const StringName *>(p_classname); |
| 1628 | const StringName methodname = *reinterpret_cast<const StringName *>(p_methodname); |
| 1629 | bool exists = false; |
| 1630 | MethodBind *mb = ClassDB::get_method_with_compatibility(classname, methodname, p_hash, &exists); |
| 1631 | |
| 1632 | #ifndef DISABLE_DEPRECATED |
| 1633 | // If lookup failed, see if this is one of the broken hashes from issue #81386. |
| 1634 | if (!mb && exists) { |
| 1635 | uint32_t mapped_hash; |
| 1636 | if (GDExtensionSpecialCompatHashes::lookup_current_hash(classname, methodname, p_hash, &mapped_hash)) { |
| 1637 | mb = ClassDB::get_method_with_compatibility(classname, methodname, mapped_hash, &exists); |
| 1638 | } |
| 1639 | } |
| 1640 | #endif |
| 1641 | |
| 1642 | if (!mb && exists) { |
| 1643 | ERR_PRINT(vformat("Method '%s.%s' has changed and no compatibility fallback has been provided. Please open an issue.", classname, methodname)); |
| 1644 | return nullptr; |
| 1645 | } |
| 1646 | ERR_FAIL_NULL_V(mb, nullptr); |
| 1647 | return (GDExtensionMethodBindPtr)mb; |
| 1648 | } |
| 1649 | |
| 1650 | #ifndef DISABLE_DEPRECATED |
| 1651 | static GDExtensionObjectPtr gdextension_classdb_construct_object(GDExtensionConstStringNamePtr p_classname) { |
| 1652 | const StringName classname = *reinterpret_cast<const StringName *>(p_classname); |
| 1653 | return (GDExtensionObjectPtr)ClassDB::instantiate_no_placeholders(classname); |
| 1654 | } |
| 1655 | #endif |
| 1656 | |
| 1657 | static GDExtensionObjectPtr gdextension_classdb_construct_object2(GDExtensionConstStringNamePtr p_classname) { |
| 1658 | const StringName classname = *reinterpret_cast<const StringName *>(p_classname); |
| 1659 | return (GDExtensionObjectPtr)ClassDB::instantiate_without_postinitialization(classname); |
| 1660 | } |
| 1661 | |
| 1662 | static void *gdextension_classdb_get_class_tag(GDExtensionConstStringNamePtr p_classname) { |
| 1663 | const StringName classname = *reinterpret_cast<const StringName *>(p_classname); |
| 1664 | ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(classname); |
| 1665 | return class_info ? class_info->class_ptr : nullptr; |
| 1666 | } |
| 1667 | |
| 1668 | static void gdextension_editor_add_plugin(GDExtensionConstStringNamePtr p_classname) { |
| 1669 | #ifdef TOOLS_ENABLED |
| 1670 | const StringName classname = *reinterpret_cast<const StringName *>(p_classname); |
| 1671 | GDExtensionEditorPlugins::add_extension_class(classname); |
| 1672 | #endif |
| 1673 | } |
| 1674 | |
| 1675 | static void gdextension_editor_remove_plugin(GDExtensionConstStringNamePtr p_classname) { |
| 1676 | #ifdef TOOLS_ENABLED |
| 1677 | const StringName classname = *reinterpret_cast<const StringName *>(p_classname); |
| 1678 | GDExtensionEditorPlugins::remove_extension_class(classname); |
| 1679 | #endif |
| 1680 | } |
| 1681 | |
| 1682 | static void gdextension_editor_help_load_xml_from_utf8_chars_and_len(const char *p_data, GDExtensionInt p_size) { |
| 1683 | #ifdef TOOLS_ENABLED |
| 1684 | GDExtensionEditorHelp::load_xml_buffer((const uint8_t *)p_data, p_size); |
| 1685 | #endif |
| 1686 | } |
| 1687 | |
| 1688 | static void gdextension_editor_help_load_xml_from_utf8_chars(const char *p_data) { |
| 1689 | #ifdef TOOLS_ENABLED |
| 1690 | size_t len = strlen(p_data); |
| 1691 | gdextension_editor_help_load_xml_from_utf8_chars_and_len(p_data, len); |
| 1692 | #endif |
| 1693 | } |
| 1694 | |
| 1695 | #define REGISTER_INTERFACE_FUNC(m_name) GDExtension::register_interface_function(#m_name, (GDExtensionInterfaceFunctionPtr) & gdextension_##m_name) |
| 1696 | |
| 1697 | void gdextension_setup_interface() { |
| 1698 | #ifndef DISABLE_DEPRECATED |
| 1699 | REGISTER_INTERFACE_FUNC(get_godot_version); |
| 1700 | #endif // DISABLE_DEPRECATED |
| 1701 | REGISTER_INTERFACE_FUNC(get_godot_version2); |
| 1702 | #ifndef DISABLE_DEPRECATED |
| 1703 | REGISTER_INTERFACE_FUNC(mem_alloc); |
| 1704 | REGISTER_INTERFACE_FUNC(mem_realloc); |
| 1705 | REGISTER_INTERFACE_FUNC(mem_free); |
| 1706 | #endif // DISABLE_DEPRECATED |
| 1707 | REGISTER_INTERFACE_FUNC(mem_alloc2); |
| 1708 | REGISTER_INTERFACE_FUNC(mem_realloc2); |
| 1709 | REGISTER_INTERFACE_FUNC(mem_free2); |
| 1710 | REGISTER_INTERFACE_FUNC(print_error); |
| 1711 | REGISTER_INTERFACE_FUNC(print_error_with_message); |
| 1712 | REGISTER_INTERFACE_FUNC(print_warning); |
| 1713 | REGISTER_INTERFACE_FUNC(print_warning_with_message); |
| 1714 | REGISTER_INTERFACE_FUNC(print_script_error); |
| 1715 | REGISTER_INTERFACE_FUNC(print_script_error_with_message); |
| 1716 | REGISTER_INTERFACE_FUNC(get_native_struct_size); |
| 1717 | REGISTER_INTERFACE_FUNC(variant_new_copy); |
| 1718 | REGISTER_INTERFACE_FUNC(variant_new_nil); |
| 1719 | REGISTER_INTERFACE_FUNC(variant_destroy); |
| 1720 | REGISTER_INTERFACE_FUNC(variant_call); |
| 1721 | REGISTER_INTERFACE_FUNC(variant_call_static); |
| 1722 | REGISTER_INTERFACE_FUNC(variant_evaluate); |
| 1723 | REGISTER_INTERFACE_FUNC(variant_set); |
| 1724 | REGISTER_INTERFACE_FUNC(variant_set_named); |
| 1725 | REGISTER_INTERFACE_FUNC(variant_set_keyed); |
| 1726 | REGISTER_INTERFACE_FUNC(variant_set_indexed); |
| 1727 | REGISTER_INTERFACE_FUNC(variant_get); |
| 1728 | REGISTER_INTERFACE_FUNC(variant_get_named); |
| 1729 | REGISTER_INTERFACE_FUNC(variant_get_keyed); |
| 1730 | REGISTER_INTERFACE_FUNC(variant_get_indexed); |
| 1731 | REGISTER_INTERFACE_FUNC(variant_iter_init); |
| 1732 | REGISTER_INTERFACE_FUNC(variant_iter_next); |
| 1733 | REGISTER_INTERFACE_FUNC(variant_iter_get); |
| 1734 | REGISTER_INTERFACE_FUNC(variant_hash); |
| 1735 | REGISTER_INTERFACE_FUNC(variant_recursive_hash); |
| 1736 | REGISTER_INTERFACE_FUNC(variant_hash_compare); |
| 1737 | REGISTER_INTERFACE_FUNC(variant_booleanize); |
| 1738 | REGISTER_INTERFACE_FUNC(variant_duplicate); |
| 1739 | REGISTER_INTERFACE_FUNC(variant_stringify); |
| 1740 | REGISTER_INTERFACE_FUNC(variant_get_type); |
| 1741 | REGISTER_INTERFACE_FUNC(variant_has_method); |
| 1742 | REGISTER_INTERFACE_FUNC(variant_has_member); |
| 1743 | REGISTER_INTERFACE_FUNC(variant_has_key); |
| 1744 | REGISTER_INTERFACE_FUNC(variant_get_object_instance_id); |
| 1745 | REGISTER_INTERFACE_FUNC(variant_get_type_name); |
| 1746 | REGISTER_INTERFACE_FUNC(variant_can_convert); |
| 1747 | REGISTER_INTERFACE_FUNC(variant_can_convert_strict); |
| 1748 | REGISTER_INTERFACE_FUNC(get_variant_from_type_constructor); |
| 1749 | REGISTER_INTERFACE_FUNC(get_variant_to_type_constructor); |
| 1750 | REGISTER_INTERFACE_FUNC(variant_get_ptr_internal_getter); |
| 1751 | REGISTER_INTERFACE_FUNC(variant_get_ptr_operator_evaluator); |
| 1752 | REGISTER_INTERFACE_FUNC(variant_get_ptr_builtin_method); |
| 1753 | REGISTER_INTERFACE_FUNC(variant_get_ptr_constructor); |
| 1754 | REGISTER_INTERFACE_FUNC(variant_get_ptr_destructor); |
| 1755 | REGISTER_INTERFACE_FUNC(variant_construct); |
| 1756 | REGISTER_INTERFACE_FUNC(variant_get_ptr_setter); |
| 1757 | REGISTER_INTERFACE_FUNC(variant_get_ptr_getter); |
| 1758 | REGISTER_INTERFACE_FUNC(variant_get_ptr_indexed_setter); |
| 1759 | REGISTER_INTERFACE_FUNC(variant_get_ptr_indexed_getter); |
| 1760 | REGISTER_INTERFACE_FUNC(variant_get_ptr_keyed_setter); |
| 1761 | REGISTER_INTERFACE_FUNC(variant_get_ptr_keyed_getter); |
| 1762 | REGISTER_INTERFACE_FUNC(variant_get_ptr_keyed_checker); |
| 1763 | REGISTER_INTERFACE_FUNC(variant_get_constant_value); |
| 1764 | REGISTER_INTERFACE_FUNC(variant_get_ptr_utility_function); |
| 1765 | REGISTER_INTERFACE_FUNC(string_new_with_latin1_chars); |
| 1766 | REGISTER_INTERFACE_FUNC(string_new_with_utf8_chars); |
| 1767 | REGISTER_INTERFACE_FUNC(string_new_with_utf16_chars); |
| 1768 | REGISTER_INTERFACE_FUNC(string_new_with_utf32_chars); |
| 1769 | REGISTER_INTERFACE_FUNC(string_new_with_wide_chars); |
| 1770 | REGISTER_INTERFACE_FUNC(string_new_with_latin1_chars_and_len); |
| 1771 | REGISTER_INTERFACE_FUNC(string_new_with_utf8_chars_and_len); |
| 1772 | REGISTER_INTERFACE_FUNC(string_new_with_utf8_chars_and_len2); |
| 1773 | REGISTER_INTERFACE_FUNC(string_new_with_utf16_chars_and_len); |
| 1774 | REGISTER_INTERFACE_FUNC(string_new_with_utf16_chars_and_len2); |
| 1775 | REGISTER_INTERFACE_FUNC(string_new_with_utf32_chars_and_len); |
| 1776 | REGISTER_INTERFACE_FUNC(string_new_with_wide_chars_and_len); |
| 1777 | REGISTER_INTERFACE_FUNC(string_to_latin1_chars); |
| 1778 | REGISTER_INTERFACE_FUNC(string_to_utf8_chars); |
| 1779 | REGISTER_INTERFACE_FUNC(string_to_utf16_chars); |
| 1780 | REGISTER_INTERFACE_FUNC(string_to_utf32_chars); |
| 1781 | REGISTER_INTERFACE_FUNC(string_to_wide_chars); |
| 1782 | REGISTER_INTERFACE_FUNC(string_operator_index); |
| 1783 | REGISTER_INTERFACE_FUNC(string_operator_index_const); |
| 1784 | REGISTER_INTERFACE_FUNC(string_operator_plus_eq_string); |
| 1785 | REGISTER_INTERFACE_FUNC(string_operator_plus_eq_char); |
| 1786 | REGISTER_INTERFACE_FUNC(string_operator_plus_eq_cstr); |
| 1787 | REGISTER_INTERFACE_FUNC(string_operator_plus_eq_wcstr); |
| 1788 | REGISTER_INTERFACE_FUNC(string_operator_plus_eq_c32str); |
| 1789 | REGISTER_INTERFACE_FUNC(string_resize); |
| 1790 | REGISTER_INTERFACE_FUNC(string_name_new_with_latin1_chars); |
| 1791 | REGISTER_INTERFACE_FUNC(string_name_new_with_utf8_chars); |
| 1792 | REGISTER_INTERFACE_FUNC(string_name_new_with_utf8_chars_and_len); |
| 1793 | REGISTER_INTERFACE_FUNC(xml_parser_open_buffer); |
| 1794 | REGISTER_INTERFACE_FUNC(file_access_store_buffer); |
| 1795 | REGISTER_INTERFACE_FUNC(file_access_get_buffer); |
| 1796 | REGISTER_INTERFACE_FUNC(worker_thread_pool_add_native_group_task); |
| 1797 | REGISTER_INTERFACE_FUNC(worker_thread_pool_add_native_task); |
| 1798 | REGISTER_INTERFACE_FUNC(packed_byte_array_operator_index); |
| 1799 | REGISTER_INTERFACE_FUNC(packed_byte_array_operator_index_const); |
| 1800 | REGISTER_INTERFACE_FUNC(packed_color_array_operator_index); |
| 1801 | REGISTER_INTERFACE_FUNC(packed_color_array_operator_index_const); |
| 1802 | REGISTER_INTERFACE_FUNC(packed_float32_array_operator_index); |
| 1803 | REGISTER_INTERFACE_FUNC(packed_float32_array_operator_index_const); |
| 1804 | REGISTER_INTERFACE_FUNC(packed_float64_array_operator_index); |
| 1805 | REGISTER_INTERFACE_FUNC(packed_float64_array_operator_index_const); |
| 1806 | REGISTER_INTERFACE_FUNC(packed_int32_array_operator_index); |
| 1807 | REGISTER_INTERFACE_FUNC(packed_int32_array_operator_index_const); |
| 1808 | REGISTER_INTERFACE_FUNC(packed_int64_array_operator_index); |
| 1809 | REGISTER_INTERFACE_FUNC(packed_int64_array_operator_index_const); |
| 1810 | REGISTER_INTERFACE_FUNC(packed_string_array_operator_index); |
| 1811 | REGISTER_INTERFACE_FUNC(packed_string_array_operator_index_const); |
| 1812 | REGISTER_INTERFACE_FUNC(packed_vector2_array_operator_index); |
| 1813 | REGISTER_INTERFACE_FUNC(packed_vector2_array_operator_index_const); |
| 1814 | REGISTER_INTERFACE_FUNC(packed_vector3_array_operator_index); |
| 1815 | REGISTER_INTERFACE_FUNC(packed_vector3_array_operator_index_const); |
| 1816 | REGISTER_INTERFACE_FUNC(packed_vector4_array_operator_index); |
| 1817 | REGISTER_INTERFACE_FUNC(packed_vector4_array_operator_index_const); |
| 1818 | REGISTER_INTERFACE_FUNC(array_operator_index); |
| 1819 | REGISTER_INTERFACE_FUNC(array_operator_index_const); |
| 1820 | #ifndef DISABLE_DEPRECATED |
| 1821 | REGISTER_INTERFACE_FUNC(array_ref); |
| 1822 | #endif // DISABLE_DEPRECATED |
| 1823 | REGISTER_INTERFACE_FUNC(array_set_typed); |
| 1824 | REGISTER_INTERFACE_FUNC(dictionary_operator_index); |
| 1825 | REGISTER_INTERFACE_FUNC(dictionary_operator_index_const); |
| 1826 | REGISTER_INTERFACE_FUNC(dictionary_set_typed); |
| 1827 | REGISTER_INTERFACE_FUNC(object_method_bind_call); |
| 1828 | REGISTER_INTERFACE_FUNC(object_method_bind_ptrcall); |
| 1829 | REGISTER_INTERFACE_FUNC(object_destroy); |
| 1830 | REGISTER_INTERFACE_FUNC(global_get_singleton); |
| 1831 | REGISTER_INTERFACE_FUNC(object_get_instance_binding); |
| 1832 | REGISTER_INTERFACE_FUNC(object_set_instance_binding); |
| 1833 | REGISTER_INTERFACE_FUNC(object_free_instance_binding); |
| 1834 | REGISTER_INTERFACE_FUNC(object_set_instance); |
| 1835 | REGISTER_INTERFACE_FUNC(object_get_class_name); |
| 1836 | REGISTER_INTERFACE_FUNC(object_cast_to); |
| 1837 | REGISTER_INTERFACE_FUNC(object_get_instance_from_id); |
| 1838 | REGISTER_INTERFACE_FUNC(object_get_instance_id); |
| 1839 | REGISTER_INTERFACE_FUNC(object_has_script_method); |
| 1840 | REGISTER_INTERFACE_FUNC(object_call_script_method); |
| 1841 | REGISTER_INTERFACE_FUNC(ref_get_object); |
| 1842 | REGISTER_INTERFACE_FUNC(ref_set_object); |
| 1843 | #ifndef DISABLE_DEPRECATED |
| 1844 | REGISTER_INTERFACE_FUNC(script_instance_create); |
| 1845 | REGISTER_INTERFACE_FUNC(script_instance_create2); |
| 1846 | #endif // DISABLE_DEPRECATED |
| 1847 | REGISTER_INTERFACE_FUNC(script_instance_create3); |
| 1848 | REGISTER_INTERFACE_FUNC(placeholder_script_instance_create); |
| 1849 | REGISTER_INTERFACE_FUNC(placeholder_script_instance_update); |
| 1850 | REGISTER_INTERFACE_FUNC(object_get_script_instance); |
| 1851 | REGISTER_INTERFACE_FUNC(object_set_script_instance); |
| 1852 | #ifndef DISABLE_DEPRECATED |
| 1853 | REGISTER_INTERFACE_FUNC(callable_custom_create); |
| 1854 | #endif // DISABLE_DEPRECATED |
| 1855 | REGISTER_INTERFACE_FUNC(callable_custom_create2); |
| 1856 | REGISTER_INTERFACE_FUNC(callable_custom_get_userdata); |
| 1857 | #ifndef DISABLE_DEPRECATED |
| 1858 | REGISTER_INTERFACE_FUNC(classdb_construct_object); |
| 1859 | #endif // DISABLE_DEPRECATED |
| 1860 | REGISTER_INTERFACE_FUNC(classdb_construct_object2); |
| 1861 | REGISTER_INTERFACE_FUNC(classdb_get_method_bind); |
| 1862 | REGISTER_INTERFACE_FUNC(classdb_get_class_tag); |
| 1863 | REGISTER_INTERFACE_FUNC(editor_add_plugin); |
| 1864 | REGISTER_INTERFACE_FUNC(editor_remove_plugin); |
| 1865 | REGISTER_INTERFACE_FUNC(editor_help_load_xml_from_utf8_chars); |
| 1866 | REGISTER_INTERFACE_FUNC(editor_help_load_xml_from_utf8_chars_and_len); |
| 1867 | REGISTER_INTERFACE_FUNC(image_ptrw); |
| 1868 | REGISTER_INTERFACE_FUNC(image_ptr); |
| 1869 | } |
| 1870 | |
| 1871 | #undef REGISTER_INTERFACE_FUNCTION |