| 1 | /**************************************************************************/ |
| 2 | /* runtime_interop.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 "runtime_interop.h" |
| 32 | |
| 33 | #include "../csharp_script.h" |
| 34 | #include "../interop_types.h" |
| 35 | #include "../managed_callable.h" |
| 36 | #include "../mono_gd/gd_mono_cache.h" |
| 37 | #include "../signal_awaiter_utils.h" |
| 38 | #include "../utils/path_utils.h" |
| 39 | |
| 40 | #include "core/config/engine.h" |
| 41 | #include "core/config/project_settings.h" |
| 42 | #include "core/debugger/engine_debugger.h" |
| 43 | #include "core/debugger/script_debugger.h" |
| 44 | #include "core/io/marshalls.h" |
| 45 | #include "core/object/class_db.h" |
| 46 | #include "core/object/method_bind.h" |
| 47 | #include "core/os/os.h" |
| 48 | #include "core/string/string_name.h" |
| 49 | |
| 50 | #ifdef TOOLS_ENABLED |
| 51 | #include "editor/file_system/editor_file_system.h" |
| 52 | #endif |
| 53 | |
| 54 | #ifdef __cplusplus |
| 55 | extern "C" { |
| 56 | #endif |
| 57 | |
| 58 | // For ArrayPrivate and DictionaryPrivate |
| 59 | static_assert(sizeof(SafeRefCount) == sizeof(uint32_t)); |
| 60 | |
| 61 | typedef Object *(*godotsharp_class_creation_func)(bool); |
| 62 | |
| 63 | bool godotsharp_dotnet_module_is_initialized() { |
| 64 | return GDMono::get_singleton()->is_initialized(); |
| 65 | } |
| 66 | |
| 67 | MethodBind *godotsharp_method_bind_get_method(const StringName *p_classname, const StringName *p_methodname) { |
| 68 | return ClassDB::get_method(*p_classname, *p_methodname); |
| 69 | } |
| 70 | |
| 71 | MethodBind *godotsharp_method_bind_get_method_with_compatibility(const StringName *p_classname, const StringName *p_methodname, uint64_t p_hash) { |
| 72 | return ClassDB::get_method_with_compatibility(*p_classname, *p_methodname, p_hash); |
| 73 | } |
| 74 | |
| 75 | godotsharp_class_creation_func godotsharp_get_class_constructor(const StringName *p_classname) { |
| 76 | ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(*p_classname); |
| 77 | if (class_info) { |
| 78 | return class_info->creation_func; |
| 79 | } |
| 80 | return nullptr; |
| 81 | } |
| 82 | |
| 83 | Object *godotsharp_engine_get_singleton(const String *p_name) { |
| 84 | return Engine::get_singleton()->get_singleton_object(*p_name); |
| 85 | } |
| 86 | |
| 87 | int32_t godotsharp_stack_info_vector_resize( |
| 88 | Vector<ScriptLanguage::StackInfo> *p_stack_info_vector, int p_size) { |
| 89 | return (int32_t)p_stack_info_vector->resize(p_size); |
| 90 | } |
| 91 | |
| 92 | void godotsharp_stack_info_vector_destroy( |
| 93 | Vector<ScriptLanguage::StackInfo> *p_stack_info_vector) { |
| 94 | p_stack_info_vector->~Vector(); |
| 95 | } |
| 96 | |
| 97 | void godotsharp_internal_script_debugger_send_error(const String *p_func, |
| 98 | const String *p_file, int32_t p_line, const String *p_err, const String *p_descr, |
| 99 | ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> *p_stack_info_vector) { |
| 100 | const String file = ProjectSettings::get_singleton()->localize_path(p_file->simplify_path()); |
| 101 | EngineDebugger::get_script_debugger()->send_error(*p_func, file, p_line, *p_err, *p_descr, |
| 102 | true, p_type, *p_stack_info_vector); |
| 103 | } |
| 104 | |
| 105 | bool godotsharp_internal_script_debugger_is_active() { |
| 106 | return EngineDebugger::is_active(); |
| 107 | } |
| 108 | |
| 109 | GCHandleIntPtr godotsharp_internal_object_get_associated_gchandle(Object *p_ptr) { |
| 110 | #ifdef DEBUG_ENABLED |
| 111 | CRASH_COND(p_ptr == nullptr); |
| 112 | #endif |
| 113 | |
| 114 | if (p_ptr->get_script_instance()) { |
| 115 | CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(p_ptr->get_script_instance()); |
| 116 | if (cs_instance) { |
| 117 | if (!cs_instance->is_destructing_script_instance()) { |
| 118 | return cs_instance->get_gchandle_intptr(); |
| 119 | } |
| 120 | return { nullptr }; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | void *data = CSharpLanguage::get_existing_instance_binding(p_ptr); |
| 125 | |
| 126 | if (data) { |
| 127 | CSharpScriptBinding &script_binding = ((RBMap<Object *, CSharpScriptBinding>::Element *)data)->get(); |
| 128 | if (script_binding.inited) { |
| 129 | MonoGCHandleData &gchandle = script_binding.gchandle; |
| 130 | return !gchandle.is_released() ? gchandle.get_intptr() : GCHandleIntPtr{ nullptr }; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | return { nullptr }; |
| 135 | } |
| 136 | |
| 137 | void godotsharp_internal_object_disposed(Object *p_ptr, GCHandleIntPtr p_gchandle_to_free) { |
| 138 | #ifdef DEBUG_ENABLED |
| 139 | CRASH_COND(p_ptr == nullptr); |
| 140 | #endif |
| 141 | |
| 142 | if (p_ptr->get_script_instance()) { |
| 143 | CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(p_ptr->get_script_instance()); |
| 144 | if (cs_instance) { |
| 145 | if (!cs_instance->is_destructing_script_instance()) { |
| 146 | cs_instance->mono_object_disposed(p_gchandle_to_free); |
| 147 | p_ptr->set_script_instance(nullptr); |
| 148 | } |
| 149 | return; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | void *data = CSharpLanguage::get_existing_instance_binding(p_ptr); |
| 154 | |
| 155 | if (data) { |
| 156 | CSharpScriptBinding &script_binding = ((RBMap<Object *, CSharpScriptBinding>::Element *)data)->get(); |
| 157 | if (script_binding.inited) { |
| 158 | if (!script_binding.gchandle.is_released()) { |
| 159 | CSharpLanguage::release_binding_gchandle_thread_safe(p_gchandle_to_free, script_binding); |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | void godotsharp_internal_refcounted_disposed(Object *p_ptr, GCHandleIntPtr p_gchandle_to_free, bool p_is_finalizer) { |
| 166 | #ifdef DEBUG_ENABLED |
| 167 | CRASH_COND(p_ptr == nullptr); |
| 168 | // This is only called with RefCounted derived classes |
| 169 | CRASH_COND(!Object::cast_to<RefCounted>(p_ptr)); |
| 170 | #endif |
| 171 | |
| 172 | RefCounted *rc = static_cast<RefCounted *>(p_ptr); |
| 173 | |
| 174 | if (rc->get_script_instance()) { |
| 175 | CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(rc->get_script_instance()); |
| 176 | if (cs_instance) { |
| 177 | if (!cs_instance->is_destructing_script_instance()) { |
| 178 | bool delete_owner; |
| 179 | bool remove_script_instance; |
| 180 | |
| 181 | cs_instance->mono_object_disposed_baseref(p_gchandle_to_free, p_is_finalizer, |
| 182 | delete_owner, remove_script_instance); |
| 183 | |
| 184 | if (delete_owner) { |
| 185 | memdelete(rc); |
| 186 | } else if (remove_script_instance) { |
| 187 | rc->set_script_instance(nullptr); |
| 188 | } |
| 189 | } |
| 190 | return; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | // Unsafe refcount decrement. The managed instance also counts as a reference. |
| 195 | // See: CSharpLanguage::alloc_instance_binding_data(Object *p_object) |
| 196 | CSharpLanguage::get_singleton()->pre_unsafe_unreference(rc); |
| 197 | if (rc->unreference()) { |
| 198 | memdelete(rc); |
| 199 | } else { |
| 200 | void *data = CSharpLanguage::get_existing_instance_binding(rc); |
| 201 | |
| 202 | if (data) { |
| 203 | CSharpScriptBinding &script_binding = ((RBMap<Object *, CSharpScriptBinding>::Element *)data)->get(); |
| 204 | if (script_binding.inited) { |
| 205 | if (!script_binding.gchandle.is_released()) { |
| 206 | if (rc->get_reference_count() == 1 && script_binding.gchandle.is_weak()) { |
| 207 | // The GCHandle is just swapped, so get the swapped handle to release |
| 208 | // See: CSharpLanguage::_instance_binding_reference_callback(void *p_token, void *p_binding, GDExtensionBool p_reference) |
| 209 | p_gchandle_to_free = script_binding.gchandle.get_intptr(); |
| 210 | } |
| 211 | CSharpLanguage::release_binding_gchandle_thread_safe(p_gchandle_to_free, script_binding); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | int32_t godotsharp_internal_signal_awaiter_connect(Object *p_source, StringName *p_signal, Object *p_target, GCHandleIntPtr p_awaiter_handle_ptr) { |
| 219 | StringName signal = p_signal ? *p_signal : StringName(); |
| 220 | return (int32_t)gd_mono_connect_signal_awaiter(p_source, signal, p_target, p_awaiter_handle_ptr); |
| 221 | } |
| 222 | |
| 223 | GCHandleIntPtr godotsharp_internal_unmanaged_get_script_instance_managed(Object *p_unmanaged, bool *r_has_cs_script_instance) { |
| 224 | #ifdef DEBUG_ENABLED |
| 225 | CRASH_COND(!p_unmanaged); |
| 226 | CRASH_COND(!r_has_cs_script_instance); |
| 227 | #endif |
| 228 | |
| 229 | if (p_unmanaged->get_script_instance()) { |
| 230 | CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(p_unmanaged->get_script_instance()); |
| 231 | |
| 232 | if (cs_instance) { |
| 233 | *r_has_cs_script_instance = true; |
| 234 | return cs_instance->get_gchandle_intptr(); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | *r_has_cs_script_instance = false; |
| 239 | return { nullptr }; |
| 240 | } |
| 241 | |
| 242 | GCHandleIntPtr godotsharp_internal_unmanaged_get_instance_binding_managed(Object *p_unmanaged) { |
| 243 | #ifdef DEBUG_ENABLED |
| 244 | CRASH_COND(!p_unmanaged); |
| 245 | #endif |
| 246 | |
| 247 | void *data = CSharpLanguage::get_instance_binding_with_setup(p_unmanaged); |
| 248 | ERR_FAIL_NULL_V(data, { nullptr }); |
| 249 | CSharpScriptBinding &script_binding = ((RBMap<Object *, CSharpScriptBinding>::Element *)data)->value(); |
| 250 | ERR_FAIL_COND_V(!script_binding.inited, { nullptr }); |
| 251 | |
| 252 | return script_binding.gchandle.get_intptr(); |
| 253 | } |
| 254 | |
| 255 | GCHandleIntPtr godotsharp_internal_unmanaged_instance_binding_create_managed(Object *p_unmanaged, GCHandleIntPtr p_old_gchandle) { |
| 256 | #ifdef DEBUG_ENABLED |
| 257 | CRASH_COND(!p_unmanaged); |
| 258 | #endif |
| 259 | |
| 260 | void *data = CSharpLanguage::get_instance_binding_with_setup(p_unmanaged); |
| 261 | ERR_FAIL_NULL_V(data, { nullptr }); |
| 262 | CSharpScriptBinding &script_binding = ((RBMap<Object *, CSharpScriptBinding>::Element *)data)->value(); |
| 263 | ERR_FAIL_COND_V(!script_binding.inited, { nullptr }); |
| 264 | |
| 265 | MonoGCHandleData &gchandle = script_binding.gchandle; |
| 266 | |
| 267 | // TODO: Possible data race? |
| 268 | CRASH_COND(gchandle.get_intptr().value != p_old_gchandle.value); |
| 269 | |
| 270 | CSharpLanguage::get_singleton()->release_script_gchandle(gchandle); |
| 271 | script_binding.inited = false; |
| 272 | |
| 273 | // Create a new one |
| 274 | |
| 275 | #ifdef DEBUG_ENABLED |
| 276 | CRASH_COND(script_binding.type_name == StringName()); |
| 277 | #endif |
| 278 | |
| 279 | bool parent_is_object_class = ClassDB::is_parent_class(p_unmanaged->get_class_name(), script_binding.type_name); |
| 280 | ERR_FAIL_COND_V_MSG(!parent_is_object_class, { nullptr }, |
| 281 | "Type inherits from native type '" + script_binding.type_name + "', so it can't be instantiated in object of type: '" + p_unmanaged->get_class() + "'."); |
| 282 | |
| 283 | GCHandleIntPtr strong_gchandle = |
| 284 | GDMonoCache::managed_callbacks.ScriptManagerBridge_CreateManagedForGodotObjectBinding( |
| 285 | &script_binding.type_name, p_unmanaged); |
| 286 | |
| 287 | ERR_FAIL_NULL_V(strong_gchandle.value, { nullptr }); |
| 288 | |
| 289 | gchandle = MonoGCHandleData(strong_gchandle, gdmono::GCHandleType::STRONG_HANDLE); |
| 290 | script_binding.inited = true; |
| 291 | |
| 292 | // Tie managed to unmanaged |
| 293 | RefCounted *rc = Object::cast_to<RefCounted>(p_unmanaged); |
| 294 | |
| 295 | if (rc) { |
| 296 | // Unsafe refcount increment. The managed instance also counts as a reference. |
| 297 | // This way if the unmanaged world has no references to our owner |
| 298 | // but the managed instance is alive, the refcount will be 1 instead of 0. |
| 299 | // See: godot_icall_RefCounted_Dtor(MonoObject *p_obj, Object *p_ptr) |
| 300 | rc->reference(); |
| 301 | CSharpLanguage::get_singleton()->post_unsafe_reference(rc); |
| 302 | } |
| 303 | |
| 304 | return gchandle.get_intptr(); |
| 305 | } |
| 306 | |
| 307 | void godotsharp_internal_tie_native_managed_to_unmanaged(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged, const StringName *p_native_name, bool p_ref_counted) { |
| 308 | CSharpLanguage::tie_native_managed_to_unmanaged(p_gchandle_intptr, p_unmanaged, p_native_name, p_ref_counted); |
| 309 | } |
| 310 | |
| 311 | void godotsharp_internal_tie_user_managed_to_unmanaged(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged, Ref<CSharpScript> *p_script, bool p_ref_counted) { |
| 312 | CSharpLanguage::tie_user_managed_to_unmanaged(p_gchandle_intptr, p_unmanaged, p_script, p_ref_counted); |
| 313 | } |
| 314 | |
| 315 | void godotsharp_internal_tie_managed_to_unmanaged_with_pre_setup(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged) { |
| 316 | CSharpLanguage::tie_managed_to_unmanaged_with_pre_setup(p_gchandle_intptr, p_unmanaged); |
| 317 | } |
| 318 | |
| 319 | void godotsharp_internal_new_csharp_script(Ref<CSharpScript> *r_dest) { |
| 320 | memnew_placement(r_dest, Ref<CSharpScript>(memnew(CSharpScript))); |
| 321 | } |
| 322 | |
| 323 | void godotsharp_internal_editor_file_system_update_files(const PackedStringArray &p_script_paths) { |
| 324 | #ifdef TOOLS_ENABLED |
| 325 | // If the EditorFileSystem singleton is available, update the file; |
| 326 | // otherwise, the file will be updated when the singleton becomes available. |
| 327 | EditorFileSystem *efs = EditorFileSystem::get_singleton(); |
| 328 | if (efs) { |
| 329 | efs->update_files(p_script_paths); |
| 330 | } |
| 331 | #else |
| 332 | // EditorFileSystem is only available when running in the Godot editor. |
| 333 | DEV_ASSERT(false); |
| 334 | #endif |
| 335 | } |
| 336 | |
| 337 | bool godotsharp_internal_script_load(const String *p_path, Ref<CSharpScript> *r_dest) { |
| 338 | Ref<Resource> res = ResourceLoader::load(*p_path); |
| 339 | if (res.is_valid()) { |
| 340 | memnew_placement(r_dest, Ref<CSharpScript>(res)); |
| 341 | return true; |
| 342 | } else { |
| 343 | memnew_placement(r_dest, Ref<CSharpScript>()); |
| 344 | return false; |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | void godotsharp_internal_reload_registered_script(CSharpScript *p_script) { |
| 349 | CRASH_COND(!p_script); |
| 350 | CSharpScript::reload_registered_script(Ref<CSharpScript>(p_script)); |
| 351 | } |
| 352 | |
| 353 | void godotsharp_array_filter_godot_objects_by_native(StringName *p_native_name, const Array *p_input, Array *r_output) { |
| 354 | memnew_placement(r_output, Array); |
| 355 | |
| 356 | for (int i = 0; i < p_input->size(); ++i) { |
| 357 | if (ClassDB::is_parent_class(((Object *)(*p_input)[i])->get_class(), *p_native_name)) { |
| 358 | r_output->push_back(p_input[i]); |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | void godotsharp_array_filter_godot_objects_by_non_native(const Array *p_input, Array *r_output) { |
| 364 | memnew_placement(r_output, Array); |
| 365 | |
| 366 | for (int i = 0; i < p_input->size(); ++i) { |
| 367 | CSharpInstance *si = CAST_CSHARP_INSTANCE(((Object *)(*p_input)[i])->get_script_instance()); |
| 368 | |
| 369 | if (si != nullptr) { |
| 370 | r_output->push_back(p_input[i]); |
| 371 | } |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | void godotsharp_ref_new_from_ref_counted_ptr(Ref<RefCounted> *r_dest, RefCounted *p_ref_counted_ptr) { |
| 376 | memnew_placement(r_dest, Ref<RefCounted>(p_ref_counted_ptr)); |
| 377 | } |
| 378 | |
| 379 | void godotsharp_ref_destroy(Ref<RefCounted> *p_instance) { |
| 380 | p_instance->~Ref(); |
| 381 | } |
| 382 | |
| 383 | void godotsharp_string_name_new_from_string(StringName *r_dest, const String *p_name) { |
| 384 | memnew_placement(r_dest, StringName(*p_name)); |
| 385 | } |
| 386 | |
| 387 | void godotsharp_node_path_new_from_string(NodePath *r_dest, const String *p_name) { |
| 388 | memnew_placement(r_dest, NodePath(*p_name)); |
| 389 | } |
| 390 | |
| 391 | void godotsharp_string_name_as_string(String *r_dest, const StringName *p_name) { |
| 392 | memnew_placement(r_dest, String(p_name->operator String())); |
| 393 | } |
| 394 | |
| 395 | void godotsharp_node_path_as_string(String *r_dest, const NodePath *p_np) { |
| 396 | memnew_placement(r_dest, String(p_np->operator String())); |
| 397 | } |
| 398 | |
| 399 | godot_packed_array godotsharp_packed_byte_array_new_mem_copy(const uint8_t *p_src, int32_t p_length) { |
| 400 | godot_packed_array ret; |
| 401 | memnew_placement(&ret, PackedByteArray); |
| 402 | PackedByteArray *array = reinterpret_cast<PackedByteArray *>(&ret); |
| 403 | array->resize(p_length); |
| 404 | uint8_t *dst = array->ptrw(); |
| 405 | memcpy(dst, p_src, p_length * sizeof(uint8_t)); |
| 406 | return ret; |
| 407 | } |
| 408 | |
| 409 | godot_packed_array godotsharp_packed_int32_array_new_mem_copy(const int32_t *p_src, int32_t p_length) { |
| 410 | godot_packed_array ret; |
| 411 | memnew_placement(&ret, PackedInt32Array); |
| 412 | PackedInt32Array *array = reinterpret_cast<PackedInt32Array *>(&ret); |
| 413 | array->resize(p_length); |
| 414 | int32_t *dst = array->ptrw(); |
| 415 | memcpy(dst, p_src, p_length * sizeof(int32_t)); |
| 416 | return ret; |
| 417 | } |
| 418 | |
| 419 | godot_packed_array godotsharp_packed_int64_array_new_mem_copy(const int64_t *p_src, int32_t p_length) { |
| 420 | godot_packed_array ret; |
| 421 | memnew_placement(&ret, PackedInt64Array); |
| 422 | PackedInt64Array *array = reinterpret_cast<PackedInt64Array *>(&ret); |
| 423 | array->resize(p_length); |
| 424 | int64_t *dst = array->ptrw(); |
| 425 | memcpy(dst, p_src, p_length * sizeof(int64_t)); |
| 426 | return ret; |
| 427 | } |
| 428 | |
| 429 | godot_packed_array godotsharp_packed_float32_array_new_mem_copy(const float *p_src, int32_t p_length) { |
| 430 | godot_packed_array ret; |
| 431 | memnew_placement(&ret, PackedFloat32Array); |
| 432 | PackedFloat32Array *array = reinterpret_cast<PackedFloat32Array *>(&ret); |
| 433 | array->resize(p_length); |
| 434 | float *dst = array->ptrw(); |
| 435 | memcpy(dst, p_src, p_length * sizeof(float)); |
| 436 | return ret; |
| 437 | } |
| 438 | |
| 439 | godot_packed_array godotsharp_packed_float64_array_new_mem_copy(const double *p_src, int32_t p_length) { |
| 440 | godot_packed_array ret; |
| 441 | memnew_placement(&ret, PackedFloat64Array); |
| 442 | PackedFloat64Array *array = reinterpret_cast<PackedFloat64Array *>(&ret); |
| 443 | array->resize(p_length); |
| 444 | double *dst = array->ptrw(); |
| 445 | memcpy(dst, p_src, p_length * sizeof(double)); |
| 446 | return ret; |
| 447 | } |
| 448 | |
| 449 | godot_packed_array godotsharp_packed_vector2_array_new_mem_copy(const Vector2 *p_src, int32_t p_length) { |
| 450 | godot_packed_array ret; |
| 451 | memnew_placement(&ret, PackedVector2Array); |
| 452 | PackedVector2Array *array = reinterpret_cast<PackedVector2Array *>(&ret); |
| 453 | array->resize(p_length); |
| 454 | Vector2 *dst = array->ptrw(); |
| 455 | memcpy(dst, p_src, p_length * sizeof(Vector2)); |
| 456 | return ret; |
| 457 | } |
| 458 | |
| 459 | godot_packed_array godotsharp_packed_vector3_array_new_mem_copy(const Vector3 *p_src, int32_t p_length) { |
| 460 | godot_packed_array ret; |
| 461 | memnew_placement(&ret, PackedVector3Array); |
| 462 | PackedVector3Array *array = reinterpret_cast<PackedVector3Array *>(&ret); |
| 463 | array->resize(p_length); |
| 464 | Vector3 *dst = array->ptrw(); |
| 465 | memcpy(dst, p_src, p_length * sizeof(Vector3)); |
| 466 | return ret; |
| 467 | } |
| 468 | |
| 469 | godot_packed_array godotsharp_packed_vector4_array_new_mem_copy(const Vector4 *p_src, int32_t p_length) { |
| 470 | godot_packed_array ret; |
| 471 | memnew_placement(&ret, PackedVector4Array); |
| 472 | PackedVector4Array *array = reinterpret_cast<PackedVector4Array *>(&ret); |
| 473 | array->resize(p_length); |
| 474 | Vector4 *dst = array->ptrw(); |
| 475 | memcpy(dst, p_src, p_length * sizeof(Vector4)); |
| 476 | return ret; |
| 477 | } |
| 478 | |
| 479 | godot_packed_array godotsharp_packed_color_array_new_mem_copy(const Color *p_src, int32_t p_length) { |
| 480 | godot_packed_array ret; |
| 481 | memnew_placement(&ret, PackedColorArray); |
| 482 | PackedColorArray *array = reinterpret_cast<PackedColorArray *>(&ret); |
| 483 | array->resize(p_length); |
| 484 | Color *dst = array->ptrw(); |
| 485 | memcpy(dst, p_src, p_length * sizeof(Color)); |
| 486 | return ret; |
| 487 | } |
| 488 | |
| 489 | void godotsharp_packed_string_array_add(PackedStringArray *r_dest, const String *p_element) { |
| 490 | r_dest->append(*p_element); |
| 491 | } |
| 492 | |
| 493 | void godotsharp_callable_new_with_delegate(GCHandleIntPtr p_delegate_handle, void *p_trampoline, |
| 494 | const Object *p_object, Callable *r_callable) { |
| 495 | // TODO: Use pooling for ManagedCallable instances. |
| 496 | ObjectID objid = p_object ? p_object->get_instance_id() : ObjectID(); |
| 497 | CallableCustom *managed_callable = memnew(ManagedCallable(p_delegate_handle, p_trampoline, objid)); |
| 498 | memnew_placement(r_callable, Callable(managed_callable)); |
| 499 | } |
| 500 | |
| 501 | bool godotsharp_callable_get_data_for_marshalling(const Callable *p_callable, |
| 502 | GCHandleIntPtr *r_delegate_handle, void **r_trampoline, Object **r_object, StringName *r_name) { |
| 503 | if (p_callable->is_custom()) { |
| 504 | CallableCustom *custom = p_callable->get_custom(); |
| 505 | CallableCustom::CompareEqualFunc compare_equal_func = custom->get_compare_equal_func(); |
| 506 | |
| 507 | if (compare_equal_func == ManagedCallable::compare_equal_func_ptr) { |
| 508 | ManagedCallable *managed_callable = static_cast<ManagedCallable *>(custom); |
| 509 | *r_delegate_handle = managed_callable->get_delegate(); |
| 510 | *r_trampoline = managed_callable->get_trampoline(); |
| 511 | *r_object = nullptr; |
| 512 | memnew_placement(r_name, StringName()); |
| 513 | return true; |
| 514 | } else if (compare_equal_func == SignalAwaiterCallable::compare_equal_func_ptr) { |
| 515 | SignalAwaiterCallable *signal_awaiter_callable = static_cast<SignalAwaiterCallable *>(custom); |
| 516 | *r_delegate_handle = { nullptr }; |
| 517 | *r_trampoline = nullptr; |
| 518 | *r_object = ObjectDB::get_instance(signal_awaiter_callable->get_object()); |
| 519 | memnew_placement(r_name, StringName(signal_awaiter_callable->get_signal())); |
| 520 | return true; |
| 521 | } else if (compare_equal_func == EventSignalCallable::compare_equal_func_ptr) { |
| 522 | EventSignalCallable *event_signal_callable = static_cast<EventSignalCallable *>(custom); |
| 523 | *r_delegate_handle = { nullptr }; |
| 524 | *r_trampoline = nullptr; |
| 525 | *r_object = ObjectDB::get_instance(event_signal_callable->get_object()); |
| 526 | memnew_placement(r_name, StringName(event_signal_callable->get_signal())); |
| 527 | return true; |
| 528 | } |
| 529 | |
| 530 | // Some other CallableCustom. We only support ManagedCallable. |
| 531 | *r_delegate_handle = { nullptr }; |
| 532 | *r_trampoline = nullptr; |
| 533 | *r_object = nullptr; |
| 534 | memnew_placement(r_name, StringName()); |
| 535 | return false; |
| 536 | } else { |
| 537 | *r_delegate_handle = { nullptr }; |
| 538 | *r_trampoline = nullptr; |
| 539 | *r_object = ObjectDB::get_instance(p_callable->get_object_id()); |
| 540 | memnew_placement(r_name, StringName(p_callable->get_method())); |
| 541 | return true; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | godot_variant godotsharp_callable_call(Callable *p_callable, const Variant **p_args, const int32_t p_arg_count, Callable::CallError *p_call_error) { |
| 546 | godot_variant ret; |
| 547 | memnew_placement(&ret, Variant); |
| 548 | |
| 549 | Variant *ret_val = (Variant *)&ret; |
| 550 | |
| 551 | p_callable->callp(p_args, p_arg_count, *ret_val, *p_call_error); |
| 552 | |
| 553 | return ret; |
| 554 | } |
| 555 | |
| 556 | void godotsharp_callable_call_deferred(Callable *p_callable, const Variant **p_args, const int32_t p_arg_count) { |
| 557 | p_callable->call_deferredp(p_args, p_arg_count); |
| 558 | } |
| 559 | |
| 560 | godot_color godotsharp_color_from_ok_hsl(float p_h, float p_s, float p_l, float p_alpha) { |
| 561 | godot_color ret; |
| 562 | Color *dest = (Color *)&ret; |
| 563 | memnew_placement(dest, Color(Color::from_ok_hsl(p_h, p_s, p_l, p_alpha))); |
| 564 | return ret; |
| 565 | } |
| 566 | |
| 567 | float godotsharp_color_get_ok_hsl_h(const Color *p_self) { |
| 568 | return p_self->get_ok_hsl_h(); |
| 569 | } |
| 570 | |
| 571 | float godotsharp_color_get_ok_hsl_s(const Color *p_self) { |
| 572 | return p_self->get_ok_hsl_s(); |
| 573 | } |
| 574 | |
| 575 | float godotsharp_color_get_ok_hsl_l(const Color *p_self) { |
| 576 | return p_self->get_ok_hsl_l(); |
| 577 | } |
| 578 | |
| 579 | // GDNative functions |
| 580 | |
| 581 | // gdnative.h |
| 582 | |
| 583 | void godotsharp_method_bind_ptrcall(MethodBind *p_method_bind, Object *p_instance, const void **p_args, void *p_ret) { |
| 584 | p_method_bind->ptrcall(p_instance, p_args, p_ret); |
| 585 | } |
| 586 | |
| 587 | godot_variant godotsharp_method_bind_call(MethodBind *p_method_bind, Object *p_instance, const godot_variant **p_args, const int32_t p_arg_count, Callable::CallError *p_call_error) { |
| 588 | godot_variant ret; |
| 589 | memnew_placement(&ret, Variant()); |
| 590 | |
| 591 | Variant *ret_val = (Variant *)&ret; |
| 592 | |
| 593 | *ret_val = p_method_bind->call(p_instance, (const Variant **)p_args, p_arg_count, *p_call_error); |
| 594 | |
| 595 | return ret; |
| 596 | } |
| 597 | |
| 598 | // variant.h |
| 599 | |
| 600 | void godotsharp_variant_new_copy(godot_variant *r_dest, const Variant *p_src) { |
| 601 | memnew_placement(r_dest, Variant(*p_src)); |
| 602 | } |
| 603 | |
| 604 | void godotsharp_variant_new_string_name(godot_variant *r_dest, const StringName *p_s) { |
| 605 | memnew_placement(r_dest, Variant(*p_s)); |
| 606 | } |
| 607 | |
| 608 | void godotsharp_variant_new_node_path(godot_variant *r_dest, const NodePath *p_np) { |
| 609 | memnew_placement(r_dest, Variant(*p_np)); |
| 610 | } |
| 611 | |
| 612 | void godotsharp_variant_new_object(godot_variant *r_dest, const Object *p_obj) { |
| 613 | memnew_placement(r_dest, Variant(p_obj)); |
| 614 | } |
| 615 | |
| 616 | void godotsharp_variant_new_transform2d(godot_variant *r_dest, const Transform2D *p_t2d) { |
| 617 | memnew_placement(r_dest, Variant(*p_t2d)); |
| 618 | } |
| 619 | |
| 620 | void godotsharp_variant_new_basis(godot_variant *r_dest, const Basis *p_basis) { |
| 621 | memnew_placement(r_dest, Variant(*p_basis)); |
| 622 | } |
| 623 | |
| 624 | void godotsharp_variant_new_transform3d(godot_variant *r_dest, const Transform3D *p_trans) { |
| 625 | memnew_placement(r_dest, Variant(*p_trans)); |
| 626 | } |
| 627 | |
| 628 | void godotsharp_variant_new_projection(godot_variant *r_dest, const Projection *p_proj) { |
| 629 | memnew_placement(r_dest, Variant(*p_proj)); |
| 630 | } |
| 631 | |
| 632 | void godotsharp_variant_new_aabb(godot_variant *r_dest, const AABB *p_aabb) { |
| 633 | memnew_placement(r_dest, Variant(*p_aabb)); |
| 634 | } |
| 635 | |
| 636 | void godotsharp_variant_new_dictionary(godot_variant *r_dest, const Dictionary *p_dict) { |
| 637 | memnew_placement(r_dest, Variant(*p_dict)); |
| 638 | } |
| 639 | |
| 640 | void godotsharp_variant_new_array(godot_variant *r_dest, const Array *p_arr) { |
| 641 | memnew_placement(r_dest, Variant(*p_arr)); |
| 642 | } |
| 643 | |
| 644 | void godotsharp_variant_new_packed_byte_array(godot_variant *r_dest, const PackedByteArray *p_pba) { |
| 645 | memnew_placement(r_dest, Variant(*p_pba)); |
| 646 | } |
| 647 | |
| 648 | void godotsharp_variant_new_packed_int32_array(godot_variant *r_dest, const PackedInt32Array *p_pia) { |
| 649 | memnew_placement(r_dest, Variant(*p_pia)); |
| 650 | } |
| 651 | |
| 652 | void godotsharp_variant_new_packed_int64_array(godot_variant *r_dest, const PackedInt64Array *p_pia) { |
| 653 | memnew_placement(r_dest, Variant(*p_pia)); |
| 654 | } |
| 655 | |
| 656 | void godotsharp_variant_new_packed_float32_array(godot_variant *r_dest, const PackedFloat32Array *p_pra) { |
| 657 | memnew_placement(r_dest, Variant(*p_pra)); |
| 658 | } |
| 659 | |
| 660 | void godotsharp_variant_new_packed_float64_array(godot_variant *r_dest, const PackedFloat64Array *p_pra) { |
| 661 | memnew_placement(r_dest, Variant(*p_pra)); |
| 662 | } |
| 663 | |
| 664 | void godotsharp_variant_new_packed_string_array(godot_variant *r_dest, const PackedStringArray *p_psa) { |
| 665 | memnew_placement(r_dest, Variant(*p_psa)); |
| 666 | } |
| 667 | |
| 668 | void godotsharp_variant_new_packed_vector2_array(godot_variant *r_dest, const PackedVector2Array *p_pv2a) { |
| 669 | memnew_placement(r_dest, Variant(*p_pv2a)); |
| 670 | } |
| 671 | |
| 672 | void godotsharp_variant_new_packed_vector3_array(godot_variant *r_dest, const PackedVector3Array *p_pv3a) { |
| 673 | memnew_placement(r_dest, Variant(*p_pv3a)); |
| 674 | } |
| 675 | |
| 676 | void godotsharp_variant_new_packed_vector4_array(godot_variant *r_dest, const PackedVector4Array *p_pv4a) { |
| 677 | memnew_placement(r_dest, Variant(*p_pv4a)); |
| 678 | } |
| 679 | |
| 680 | void godotsharp_variant_new_packed_color_array(godot_variant *r_dest, const PackedColorArray *p_pca) { |
| 681 | memnew_placement(r_dest, Variant(*p_pca)); |
| 682 | } |
| 683 | |
| 684 | bool godotsharp_variant_as_bool(const Variant *p_self) { |
| 685 | return p_self->operator bool(); |
| 686 | } |
| 687 | |
| 688 | int64_t godotsharp_variant_as_int(const Variant *p_self) { |
| 689 | return p_self->operator int64_t(); |
| 690 | } |
| 691 | |
| 692 | double godotsharp_variant_as_float(const Variant *p_self) { |
| 693 | return p_self->operator double(); |
| 694 | } |
| 695 | |
| 696 | godot_string godotsharp_variant_as_string(const Variant *p_self) { |
| 697 | godot_string raw_dest; |
| 698 | String *dest = (String *)&raw_dest; |
| 699 | memnew_placement(dest, String(p_self->operator String())); |
| 700 | return raw_dest; |
| 701 | } |
| 702 | |
| 703 | godot_vector2 godotsharp_variant_as_vector2(const Variant *p_self) { |
| 704 | godot_vector2 raw_dest; |
| 705 | Vector2 *dest = (Vector2 *)&raw_dest; |
| 706 | memnew_placement(dest, Vector2(p_self->operator Vector2())); |
| 707 | return raw_dest; |
| 708 | } |
| 709 | |
| 710 | godot_vector2i godotsharp_variant_as_vector2i(const Variant *p_self) { |
| 711 | godot_vector2i raw_dest; |
| 712 | Vector2i *dest = (Vector2i *)&raw_dest; |
| 713 | memnew_placement(dest, Vector2i(p_self->operator Vector2i())); |
| 714 | return raw_dest; |
| 715 | } |
| 716 | |
| 717 | godot_rect2 godotsharp_variant_as_rect2(const Variant *p_self) { |
| 718 | godot_rect2 raw_dest; |
| 719 | Rect2 *dest = (Rect2 *)&raw_dest; |
| 720 | memnew_placement(dest, Rect2(p_self->operator Rect2())); |
| 721 | return raw_dest; |
| 722 | } |
| 723 | |
| 724 | godot_rect2i godotsharp_variant_as_rect2i(const Variant *p_self) { |
| 725 | godot_rect2i raw_dest; |
| 726 | Rect2i *dest = (Rect2i *)&raw_dest; |
| 727 | memnew_placement(dest, Rect2i(p_self->operator Rect2i())); |
| 728 | return raw_dest; |
| 729 | } |
| 730 | |
| 731 | godot_vector3 godotsharp_variant_as_vector3(const Variant *p_self) { |
| 732 | godot_vector3 raw_dest; |
| 733 | Vector3 *dest = (Vector3 *)&raw_dest; |
| 734 | memnew_placement(dest, Vector3(p_self->operator Vector3())); |
| 735 | return raw_dest; |
| 736 | } |
| 737 | |
| 738 | godot_vector3i godotsharp_variant_as_vector3i(const Variant *p_self) { |
| 739 | godot_vector3i raw_dest; |
| 740 | Vector3i *dest = (Vector3i *)&raw_dest; |
| 741 | memnew_placement(dest, Vector3i(p_self->operator Vector3i())); |
| 742 | return raw_dest; |
| 743 | } |
| 744 | |
| 745 | godot_transform2d godotsharp_variant_as_transform2d(const Variant *p_self) { |
| 746 | godot_transform2d raw_dest; |
| 747 | Transform2D *dest = (Transform2D *)&raw_dest; |
| 748 | memnew_placement(dest, Transform2D(p_self->operator Transform2D())); |
| 749 | return raw_dest; |
| 750 | } |
| 751 | |
| 752 | godot_vector4 godotsharp_variant_as_vector4(const Variant *p_self) { |
| 753 | godot_vector4 raw_dest; |
| 754 | Vector4 *dest = (Vector4 *)&raw_dest; |
| 755 | memnew_placement(dest, Vector4(p_self->operator Vector4())); |
| 756 | return raw_dest; |
| 757 | } |
| 758 | |
| 759 | godot_vector4i godotsharp_variant_as_vector4i(const Variant *p_self) { |
| 760 | godot_vector4i raw_dest; |
| 761 | Vector4i *dest = (Vector4i *)&raw_dest; |
| 762 | memnew_placement(dest, Vector4i(p_self->operator Vector4i())); |
| 763 | return raw_dest; |
| 764 | } |
| 765 | |
| 766 | godot_plane godotsharp_variant_as_plane(const Variant *p_self) { |
| 767 | godot_plane raw_dest; |
| 768 | Plane *dest = (Plane *)&raw_dest; |
| 769 | memnew_placement(dest, Plane(p_self->operator Plane())); |
| 770 | return raw_dest; |
| 771 | } |
| 772 | |
| 773 | godot_quaternion godotsharp_variant_as_quaternion(const Variant *p_self) { |
| 774 | godot_quaternion raw_dest; |
| 775 | Quaternion *dest = (Quaternion *)&raw_dest; |
| 776 | memnew_placement(dest, Quaternion(p_self->operator Quaternion())); |
| 777 | return raw_dest; |
| 778 | } |
| 779 | |
| 780 | godot_aabb godotsharp_variant_as_aabb(const Variant *p_self) { |
| 781 | godot_aabb raw_dest; |
| 782 | AABB *dest = (AABB *)&raw_dest; |
| 783 | memnew_placement(dest, AABB(p_self->operator ::AABB())); |
| 784 | return raw_dest; |
| 785 | } |
| 786 | |
| 787 | godot_basis godotsharp_variant_as_basis(const Variant *p_self) { |
| 788 | godot_basis raw_dest; |
| 789 | Basis *dest = (Basis *)&raw_dest; |
| 790 | memnew_placement(dest, Basis(p_self->operator Basis())); |
| 791 | return raw_dest; |
| 792 | } |
| 793 | |
| 794 | godot_transform3d godotsharp_variant_as_transform3d(const Variant *p_self) { |
| 795 | godot_transform3d raw_dest; |
| 796 | Transform3D *dest = (Transform3D *)&raw_dest; |
| 797 | memnew_placement(dest, Transform3D(p_self->operator Transform3D())); |
| 798 | return raw_dest; |
| 799 | } |
| 800 | |
| 801 | godot_projection godotsharp_variant_as_projection(const Variant *p_self) { |
| 802 | godot_projection raw_dest; |
| 803 | Projection *dest = (Projection *)&raw_dest; |
| 804 | memnew_placement(dest, Projection(p_self->operator Projection())); |
| 805 | return raw_dest; |
| 806 | } |
| 807 | |
| 808 | godot_color godotsharp_variant_as_color(const Variant *p_self) { |
| 809 | godot_color raw_dest; |
| 810 | Color *dest = (Color *)&raw_dest; |
| 811 | memnew_placement(dest, Color(p_self->operator Color())); |
| 812 | return raw_dest; |
| 813 | } |
| 814 | |
| 815 | godot_string_name godotsharp_variant_as_string_name(const Variant *p_self) { |
| 816 | godot_string_name raw_dest; |
| 817 | StringName *dest = (StringName *)&raw_dest; |
| 818 | memnew_placement(dest, StringName(p_self->operator StringName())); |
| 819 | return raw_dest; |
| 820 | } |
| 821 | |
| 822 | godot_node_path godotsharp_variant_as_node_path(const Variant *p_self) { |
| 823 | godot_node_path raw_dest; |
| 824 | NodePath *dest = (NodePath *)&raw_dest; |
| 825 | memnew_placement(dest, NodePath(p_self->operator NodePath())); |
| 826 | return raw_dest; |
| 827 | } |
| 828 | |
| 829 | godot_rid godotsharp_variant_as_rid(const Variant *p_self) { |
| 830 | godot_rid raw_dest; |
| 831 | RID *dest = (RID *)&raw_dest; |
| 832 | memnew_placement(dest, RID(p_self->operator ::RID())); |
| 833 | return raw_dest; |
| 834 | } |
| 835 | |
| 836 | godot_callable godotsharp_variant_as_callable(const Variant *p_self) { |
| 837 | godot_callable raw_dest; |
| 838 | Callable *dest = (Callable *)&raw_dest; |
| 839 | memnew_placement(dest, Callable(p_self->operator Callable())); |
| 840 | return raw_dest; |
| 841 | } |
| 842 | |
| 843 | godot_signal godotsharp_variant_as_signal(const Variant *p_self) { |
| 844 | godot_signal raw_dest; |
| 845 | Signal *dest = (Signal *)&raw_dest; |
| 846 | memnew_placement(dest, Signal(p_self->operator Signal())); |
| 847 | return raw_dest; |
| 848 | } |
| 849 | |
| 850 | godot_dictionary godotsharp_variant_as_dictionary(const Variant *p_self) { |
| 851 | godot_dictionary raw_dest; |
| 852 | Dictionary *dest = (Dictionary *)&raw_dest; |
| 853 | memnew_placement(dest, Dictionary(p_self->operator Dictionary())); |
| 854 | return raw_dest; |
| 855 | } |
| 856 | |
| 857 | godot_array godotsharp_variant_as_array(const Variant *p_self) { |
| 858 | godot_array raw_dest; |
| 859 | Array *dest = (Array *)&raw_dest; |
| 860 | memnew_placement(dest, Array(p_self->operator Array())); |
| 861 | return raw_dest; |
| 862 | } |
| 863 | |
| 864 | godot_packed_array godotsharp_variant_as_packed_byte_array(const Variant *p_self) { |
| 865 | godot_packed_array raw_dest; |
| 866 | PackedByteArray *dest = (PackedByteArray *)&raw_dest; |
| 867 | memnew_placement(dest, PackedByteArray(p_self->operator PackedByteArray())); |
| 868 | return raw_dest; |
| 869 | } |
| 870 | |
| 871 | godot_packed_array godotsharp_variant_as_packed_int32_array(const Variant *p_self) { |
| 872 | godot_packed_array raw_dest; |
| 873 | PackedInt32Array *dest = (PackedInt32Array *)&raw_dest; |
| 874 | memnew_placement(dest, PackedInt32Array(p_self->operator PackedInt32Array())); |
| 875 | return raw_dest; |
| 876 | } |
| 877 | |
| 878 | godot_packed_array godotsharp_variant_as_packed_int64_array(const Variant *p_self) { |
| 879 | godot_packed_array raw_dest; |
| 880 | PackedInt64Array *dest = (PackedInt64Array *)&raw_dest; |
| 881 | memnew_placement(dest, PackedInt64Array(p_self->operator PackedInt64Array())); |
| 882 | return raw_dest; |
| 883 | } |
| 884 | |
| 885 | godot_packed_array godotsharp_variant_as_packed_float32_array(const Variant *p_self) { |
| 886 | godot_packed_array raw_dest; |
| 887 | PackedFloat32Array *dest = (PackedFloat32Array *)&raw_dest; |
| 888 | memnew_placement(dest, PackedFloat32Array(p_self->operator PackedFloat32Array())); |
| 889 | return raw_dest; |
| 890 | } |
| 891 | |
| 892 | godot_packed_array godotsharp_variant_as_packed_float64_array(const Variant *p_self) { |
| 893 | godot_packed_array raw_dest; |
| 894 | PackedFloat64Array *dest = (PackedFloat64Array *)&raw_dest; |
| 895 | memnew_placement(dest, PackedFloat64Array(p_self->operator PackedFloat64Array())); |
| 896 | return raw_dest; |
| 897 | } |
| 898 | |
| 899 | godot_packed_array godotsharp_variant_as_packed_string_array(const Variant *p_self) { |
| 900 | godot_packed_array raw_dest; |
| 901 | PackedStringArray *dest = (PackedStringArray *)&raw_dest; |
| 902 | memnew_placement(dest, PackedStringArray(p_self->operator PackedStringArray())); |
| 903 | return raw_dest; |
| 904 | } |
| 905 | |
| 906 | godot_packed_array godotsharp_variant_as_packed_vector2_array(const Variant *p_self) { |
| 907 | godot_packed_array raw_dest; |
| 908 | PackedVector2Array *dest = (PackedVector2Array *)&raw_dest; |
| 909 | memnew_placement(dest, PackedVector2Array(p_self->operator PackedVector2Array())); |
| 910 | return raw_dest; |
| 911 | } |
| 912 | |
| 913 | godot_packed_array godotsharp_variant_as_packed_vector3_array(const Variant *p_self) { |
| 914 | godot_packed_array raw_dest; |
| 915 | PackedVector3Array *dest = (PackedVector3Array *)&raw_dest; |
| 916 | memnew_placement(dest, PackedVector3Array(p_self->operator PackedVector3Array())); |
| 917 | return raw_dest; |
| 918 | } |
| 919 | |
| 920 | godot_packed_array godotsharp_variant_as_packed_vector4_array(const Variant *p_self) { |
| 921 | godot_packed_array raw_dest; |
| 922 | PackedVector4Array *dest = (PackedVector4Array *)&raw_dest; |
| 923 | memnew_placement(dest, PackedVector4Array(p_self->operator PackedVector4Array())); |
| 924 | return raw_dest; |
| 925 | } |
| 926 | |
| 927 | godot_packed_array godotsharp_variant_as_packed_color_array(const Variant *p_self) { |
| 928 | godot_packed_array raw_dest; |
| 929 | PackedColorArray *dest = (PackedColorArray *)&raw_dest; |
| 930 | memnew_placement(dest, PackedColorArray(p_self->operator PackedColorArray())); |
| 931 | return raw_dest; |
| 932 | } |
| 933 | |
| 934 | bool godotsharp_variant_equals(const godot_variant *p_a, const godot_variant *p_b) { |
| 935 | return *reinterpret_cast<const Variant *>(p_a) == *reinterpret_cast<const Variant *>(p_b); |
| 936 | } |
| 937 | |
| 938 | // string.h |
| 939 | |
| 940 | void godotsharp_string_new_with_utf16_chars(String *r_dest, const char16_t *p_contents) { |
| 941 | memnew_placement(r_dest, String()); |
| 942 | r_dest->append_utf16(p_contents); |
| 943 | } |
| 944 | |
| 945 | // string_name.h |
| 946 | |
| 947 | void godotsharp_string_name_new_copy(StringName *r_dest, const StringName *p_src) { |
| 948 | memnew_placement(r_dest, StringName(*p_src)); |
| 949 | } |
| 950 | |
| 951 | // node_path.h |
| 952 | |
| 953 | void godotsharp_node_path_new_copy(NodePath *r_dest, const NodePath *p_src) { |
| 954 | memnew_placement(r_dest, NodePath(*p_src)); |
| 955 | } |
| 956 | |
| 957 | // array.h |
| 958 | |
| 959 | void godotsharp_array_new(Array *r_dest) { |
| 960 | memnew_placement(r_dest, Array); |
| 961 | } |
| 962 | |
| 963 | void godotsharp_array_new_copy(Array *r_dest, const Array *p_src) { |
| 964 | memnew_placement(r_dest, Array(*p_src)); |
| 965 | } |
| 966 | |
| 967 | godot_variant *godotsharp_array_ptrw(godot_array *p_self) { |
| 968 | return reinterpret_cast<godot_variant *>(&reinterpret_cast<Array *>(p_self)->operator[](0)); |
| 969 | } |
| 970 | |
| 971 | // dictionary.h |
| 972 | |
| 973 | void godotsharp_dictionary_new(Dictionary *r_dest) { |
| 974 | memnew_placement(r_dest, Dictionary); |
| 975 | } |
| 976 | |
| 977 | void godotsharp_dictionary_new_copy(Dictionary *r_dest, const Dictionary *p_src) { |
| 978 | memnew_placement(r_dest, Dictionary(*p_src)); |
| 979 | } |
| 980 | |
| 981 | // destroy functions |
| 982 | |
| 983 | void godotsharp_packed_byte_array_destroy(PackedByteArray *p_self) { |
| 984 | p_self->~PackedByteArray(); |
| 985 | } |
| 986 | |
| 987 | void godotsharp_packed_int32_array_destroy(PackedInt32Array *p_self) { |
| 988 | p_self->~PackedInt32Array(); |
| 989 | } |
| 990 | |
| 991 | void godotsharp_packed_int64_array_destroy(PackedInt64Array *p_self) { |
| 992 | p_self->~PackedInt64Array(); |
| 993 | } |
| 994 | |
| 995 | void godotsharp_packed_float32_array_destroy(PackedFloat32Array *p_self) { |
| 996 | p_self->~PackedFloat32Array(); |
| 997 | } |
| 998 | |
| 999 | void godotsharp_packed_float64_array_destroy(PackedFloat64Array *p_self) { |
| 1000 | p_self->~PackedFloat64Array(); |
| 1001 | } |
| 1002 | |
| 1003 | void godotsharp_packed_string_array_destroy(PackedStringArray *p_self) { |
| 1004 | p_self->~PackedStringArray(); |
| 1005 | } |
| 1006 | |
| 1007 | void godotsharp_packed_vector2_array_destroy(PackedVector2Array *p_self) { |
| 1008 | p_self->~PackedVector2Array(); |
| 1009 | } |
| 1010 | |
| 1011 | void godotsharp_packed_vector3_array_destroy(PackedVector3Array *p_self) { |
| 1012 | p_self->~PackedVector3Array(); |
| 1013 | } |
| 1014 | |
| 1015 | void godotsharp_packed_vector4_array_destroy(PackedVector4Array *p_self) { |
| 1016 | p_self->~PackedVector4Array(); |
| 1017 | } |
| 1018 | |
| 1019 | void godotsharp_packed_color_array_destroy(PackedColorArray *p_self) { |
| 1020 | p_self->~PackedColorArray(); |
| 1021 | } |
| 1022 | |
| 1023 | void godotsharp_variant_destroy(Variant *p_self) { |
| 1024 | p_self->~Variant(); |
| 1025 | } |
| 1026 | |
| 1027 | void godotsharp_string_destroy(String *p_self) { |
| 1028 | p_self->~String(); |
| 1029 | } |
| 1030 | |
| 1031 | void godotsharp_string_name_destroy(StringName *p_self) { |
| 1032 | p_self->~StringName(); |
| 1033 | } |
| 1034 | |
| 1035 | void godotsharp_node_path_destroy(NodePath *p_self) { |
| 1036 | p_self->~NodePath(); |
| 1037 | } |
| 1038 | |
| 1039 | void godotsharp_signal_destroy(Signal *p_self) { |
| 1040 | p_self->~Signal(); |
| 1041 | } |
| 1042 | |
| 1043 | void godotsharp_callable_destroy(Callable *p_self) { |
| 1044 | p_self->~Callable(); |
| 1045 | } |
| 1046 | |
| 1047 | void godotsharp_array_destroy(Array *p_self) { |
| 1048 | p_self->~Array(); |
| 1049 | } |
| 1050 | |
| 1051 | void godotsharp_dictionary_destroy(Dictionary *p_self) { |
| 1052 | p_self->~Dictionary(); |
| 1053 | } |
| 1054 | |
| 1055 | // Array |
| 1056 | |
| 1057 | int32_t godotsharp_array_add(Array *p_self, const Variant *p_item) { |
| 1058 | p_self->append(*p_item); |
| 1059 | return p_self->size(); |
| 1060 | } |
| 1061 | |
| 1062 | int32_t godotsharp_array_add_range(Array *p_self, const Array *p_collection) { |
| 1063 | p_self->append_array(*p_collection); |
| 1064 | return p_self->size(); |
| 1065 | } |
| 1066 | |
| 1067 | int32_t godotsharp_array_binary_search(const Array *p_self, int32_t p_index, int32_t p_length, const Variant *p_value) { |
| 1068 | ERR_FAIL_COND_V(p_index < 0, -1); |
| 1069 | ERR_FAIL_COND_V(p_length < 0, -1); |
| 1070 | ERR_FAIL_COND_V(p_self->size() - p_index < p_length, -1); |
| 1071 | |
| 1072 | const Variant &value = *p_value; |
| 1073 | const Array &array = *p_self; |
| 1074 | |
| 1075 | int lo = p_index; |
| 1076 | int hi = p_index + p_length - 1; |
| 1077 | while (lo <= hi) { |
| 1078 | int mid = lo + ((hi - lo) >> 1); |
| 1079 | const Variant &mid_item = array[mid]; |
| 1080 | |
| 1081 | if (mid_item == value) { |
| 1082 | return mid; |
| 1083 | } |
| 1084 | if (mid_item < value) { |
| 1085 | lo = mid + 1; |
| 1086 | } else { |
| 1087 | hi = mid - 1; |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | return ~lo; |
| 1092 | } |
| 1093 | |
| 1094 | void godotsharp_array_duplicate(const Array *p_self, bool p_deep, Array *r_dest) { |
| 1095 | memnew_placement(r_dest, Array(p_self->duplicate(p_deep))); |
| 1096 | } |
| 1097 | |
| 1098 | void godotsharp_array_fill(Array *p_self, const Variant *p_value) { |
| 1099 | p_self->fill(*p_value); |
| 1100 | } |
| 1101 | |
| 1102 | int32_t godotsharp_array_index_of(const Array *p_self, const Variant *p_item, int32_t p_index = 0) { |
| 1103 | return p_self->find(*p_item, p_index); |
| 1104 | } |
| 1105 | |
| 1106 | void godotsharp_array_insert(Array *p_self, int32_t p_index, const Variant *p_item) { |
| 1107 | p_self->insert(p_index, *p_item); |
| 1108 | } |
| 1109 | |
| 1110 | int32_t godotsharp_array_last_index_of(const Array *p_self, const Variant *p_item, int32_t p_index) { |
| 1111 | return p_self->rfind(*p_item, p_index); |
| 1112 | } |
| 1113 | |
| 1114 | void godotsharp_array_make_read_only(Array *p_self) { |
| 1115 | p_self->make_read_only(); |
| 1116 | } |
| 1117 | |
| 1118 | void godotsharp_array_set_typed(Array *p_self, uint32_t p_elem_type, const StringName *p_elem_class_name, const Ref<CSharpScript> *p_elem_script) { |
| 1119 | Variant elem_script_variant; |
| 1120 | StringName elem_class_name = *p_elem_class_name; |
| 1121 | if (p_elem_script && p_elem_script->is_valid()) { |
| 1122 | elem_script_variant = Variant(p_elem_script->ptr()); |
| 1123 | elem_class_name = p_elem_script->ptr()->get_instance_base_type(); |
| 1124 | } |
| 1125 | p_self->set_typed(p_elem_type, elem_class_name, p_elem_script->ptr()); |
| 1126 | } |
| 1127 | |
| 1128 | bool godotsharp_array_is_typed(const Array *p_self) { |
| 1129 | return p_self->is_typed(); |
| 1130 | } |
| 1131 | |
| 1132 | void godotsharp_array_max(const Array *p_self, Variant *r_value) { |
| 1133 | *r_value = p_self->max(); |
| 1134 | } |
| 1135 | |
| 1136 | void godotsharp_array_min(const Array *p_self, Variant *r_value) { |
| 1137 | *r_value = p_self->min(); |
| 1138 | } |
| 1139 | |
| 1140 | void godotsharp_array_pick_random(const Array *p_self, Variant *r_value) { |
| 1141 | *r_value = p_self->pick_random(); |
| 1142 | } |
| 1143 | |
| 1144 | bool godotsharp_array_recursive_equal(const Array *p_self, const Array *p_other) { |
| 1145 | return p_self->recursive_equal(*p_other, 0); |
| 1146 | } |
| 1147 | |
| 1148 | void godotsharp_array_remove_at(Array *p_self, int32_t p_index) { |
| 1149 | p_self->remove_at(p_index); |
| 1150 | } |
| 1151 | |
| 1152 | int32_t godotsharp_array_resize(Array *p_self, int32_t p_new_size) { |
| 1153 | return (int32_t)p_self->resize(p_new_size); |
| 1154 | } |
| 1155 | |
| 1156 | void godotsharp_array_reverse(Array *p_self) { |
| 1157 | p_self->reverse(); |
| 1158 | } |
| 1159 | |
| 1160 | void godotsharp_array_shuffle(Array *p_self) { |
| 1161 | p_self->shuffle(); |
| 1162 | } |
| 1163 | |
| 1164 | void godotsharp_array_slice(Array *p_self, int32_t p_start, int32_t p_end, int32_t p_step, bool p_deep, Array *r_dest) { |
| 1165 | memnew_placement(r_dest, Array(p_self->slice(p_start, p_end, p_step, p_deep))); |
| 1166 | } |
| 1167 | |
| 1168 | void godotsharp_array_sort(Array *p_self) { |
| 1169 | p_self->sort(); |
| 1170 | } |
| 1171 | |
| 1172 | void godotsharp_array_to_string(const Array *p_self, String *r_str) { |
| 1173 | *r_str = Variant(*p_self).operator String(); |
| 1174 | } |
| 1175 | |
| 1176 | void godotsharp_packed_byte_array_compress(const PackedByteArray *p_src, int p_mode, PackedByteArray *r_dst) { |
| 1177 | if (p_src->size() > 0) { |
| 1178 | Compression::Mode mode = (Compression::Mode)(p_mode); |
| 1179 | r_dst->resize(Compression::get_max_compressed_buffer_size(p_src->size(), mode)); |
| 1180 | int result = Compression::compress(r_dst->ptrw(), p_src->ptr(), p_src->size(), mode); |
| 1181 | |
| 1182 | result = result >= 0 ? result : 0; |
| 1183 | r_dst->resize(result); |
| 1184 | } |
| 1185 | } |
| 1186 | |
| 1187 | void godotsharp_packed_byte_array_decompress(const PackedByteArray *p_src, int64_t p_buffer_size, int p_mode, PackedByteArray *r_dst) { |
| 1188 | int64_t buffer_size = p_buffer_size; |
| 1189 | Compression::Mode mode = (Compression::Mode)(p_mode); |
| 1190 | |
| 1191 | if (buffer_size <= 0) { |
| 1192 | ERR_FAIL_MSG("Decompression buffer size must be greater than zero."); |
| 1193 | } |
| 1194 | if (p_src->size() == 0) { |
| 1195 | ERR_FAIL_MSG("Compressed buffer size must be greater than zero."); |
| 1196 | } |
| 1197 | |
| 1198 | r_dst->resize(buffer_size); |
| 1199 | int result = Compression::decompress(r_dst->ptrw(), buffer_size, p_src->ptr(), p_src->size(), mode); |
| 1200 | |
| 1201 | result = result >= 0 ? result : 0; |
| 1202 | r_dst->resize(result); |
| 1203 | } |
| 1204 | |
| 1205 | void godotsharp_packed_byte_array_decompress_dynamic(const PackedByteArray *p_src, int64_t p_max_output_size, int p_mode, PackedByteArray *r_dst) { |
| 1206 | int64_t max_output_size = p_max_output_size; |
| 1207 | Compression::Mode mode = (Compression::Mode)(p_mode); |
| 1208 | |
| 1209 | int result = Compression::decompress_dynamic(r_dst, max_output_size, p_src->ptr(), p_src->size(), mode); |
| 1210 | |
| 1211 | if (result != OK) { |
| 1212 | r_dst->clear(); |
| 1213 | ERR_FAIL_MSG("Decompression failed."); |
| 1214 | } |
| 1215 | } |
| 1216 | |
| 1217 | // Dictionary |
| 1218 | |
| 1219 | bool godotsharp_dictionary_try_get_value(const Dictionary *p_self, const Variant *p_key, Variant *r_value) { |
| 1220 | const Variant *ret = p_self->getptr(*p_key); |
| 1221 | if (ret == nullptr) { |
| 1222 | memnew_placement(r_value, Variant()); |
| 1223 | return false; |
| 1224 | } |
| 1225 | memnew_placement(r_value, Variant(*ret)); |
| 1226 | return true; |
| 1227 | } |
| 1228 | |
| 1229 | void godotsharp_dictionary_set_value(Dictionary *p_self, const Variant *p_key, const Variant *p_value) { |
| 1230 | p_self->operator[](*p_key) = *p_value; |
| 1231 | } |
| 1232 | |
| 1233 | void godotsharp_dictionary_keys(const Dictionary *p_self, Array *r_dest) { |
| 1234 | memnew_placement(r_dest, Array(p_self->keys())); |
| 1235 | } |
| 1236 | |
| 1237 | void godotsharp_dictionary_values(const Dictionary *p_self, Array *r_dest) { |
| 1238 | memnew_placement(r_dest, Array(p_self->values())); |
| 1239 | } |
| 1240 | |
| 1241 | int32_t godotsharp_dictionary_count(const Dictionary *p_self) { |
| 1242 | return p_self->size(); |
| 1243 | } |
| 1244 | |
| 1245 | void godotsharp_dictionary_key_value_pair_at(const Dictionary *p_self, int32_t p_index, Variant *r_key, Variant *r_value) { |
| 1246 | memnew_placement(r_key, Variant(p_self->get_key_at_index(p_index))); |
| 1247 | memnew_placement(r_value, Variant(p_self->get_value_at_index(p_index))); |
| 1248 | } |
| 1249 | |
| 1250 | void godotsharp_dictionary_add(Dictionary *p_self, const Variant *p_key, const Variant *p_value) { |
| 1251 | p_self->operator[](*p_key) = *p_value; |
| 1252 | } |
| 1253 | |
| 1254 | void godotsharp_dictionary_clear(Dictionary *p_self) { |
| 1255 | p_self->clear(); |
| 1256 | } |
| 1257 | |
| 1258 | bool godotsharp_dictionary_contains_key(const Dictionary *p_self, const Variant *p_key) { |
| 1259 | return p_self->has(*p_key); |
| 1260 | } |
| 1261 | |
| 1262 | void godotsharp_dictionary_duplicate(const Dictionary *p_self, bool p_deep, Dictionary *r_dest) { |
| 1263 | memnew_placement(r_dest, Dictionary(p_self->duplicate(p_deep))); |
| 1264 | } |
| 1265 | |
| 1266 | void godotsharp_dictionary_merge(Dictionary *p_self, const Dictionary *p_dictionary, bool p_overwrite) { |
| 1267 | p_self->merge(*p_dictionary, p_overwrite); |
| 1268 | } |
| 1269 | |
| 1270 | bool godotsharp_dictionary_recursive_equal(const Dictionary *p_self, const Dictionary *p_other) { |
| 1271 | return p_self->recursive_equal(*p_other, 0); |
| 1272 | } |
| 1273 | |
| 1274 | bool godotsharp_dictionary_remove_key(Dictionary *p_self, const Variant *p_key) { |
| 1275 | return p_self->erase(*p_key); |
| 1276 | } |
| 1277 | |
| 1278 | void godotsharp_dictionary_make_read_only(Dictionary *p_self) { |
| 1279 | p_self->make_read_only(); |
| 1280 | } |
| 1281 | |
| 1282 | void godotsharp_dictionary_set_typed(Dictionary *p_self, uint32_t p_key_type, const StringName *p_key_class_name, const Ref<CSharpScript> *p_key_script, uint32_t p_value_type, const StringName *p_value_class_name, const Ref<CSharpScript> *p_value_script) { |
| 1283 | Variant key_script_variant; |
| 1284 | StringName key_class_name = *p_key_class_name; |
| 1285 | if (p_key_script && p_key_script->is_valid()) { |
| 1286 | key_script_variant = Variant(p_key_script->ptr()); |
| 1287 | key_class_name = p_key_script->ptr()->get_instance_base_type(); |
| 1288 | } |
| 1289 | Variant value_script_variant; |
| 1290 | StringName value_class_name = *p_value_class_name; |
| 1291 | if (p_value_script && p_value_script->is_valid()) { |
| 1292 | value_script_variant = Variant(p_value_script->ptr()); |
| 1293 | value_class_name = p_value_script->ptr()->get_instance_base_type(); |
| 1294 | } |
| 1295 | p_self->set_typed(p_key_type, key_class_name, p_key_script->ptr(), p_value_type, value_class_name, p_value_script->ptr()); |
| 1296 | } |
| 1297 | |
| 1298 | bool godotsharp_dictionary_is_typed_key(const Dictionary *p_self) { |
| 1299 | return p_self->is_typed_key(); |
| 1300 | } |
| 1301 | |
| 1302 | bool godotsharp_dictionary_is_typed_value(const Dictionary *p_self) { |
| 1303 | return p_self->is_typed_value(); |
| 1304 | } |
| 1305 | |
| 1306 | uint32_t godotsharp_dictionary_get_typed_key_builtin(const Dictionary *p_self) { |
| 1307 | return p_self->get_typed_key_builtin(); |
| 1308 | } |
| 1309 | |
| 1310 | uint32_t godotsharp_dictionary_get_typed_value_builtin(const Dictionary *p_self) { |
| 1311 | return p_self->get_typed_value_builtin(); |
| 1312 | } |
| 1313 | |
| 1314 | void godotsharp_dictionary_get_typed_key_class_name(const Dictionary *p_self, StringName *r_dest) { |
| 1315 | memnew_placement(r_dest, StringName(p_self->get_typed_key_class_name())); |
| 1316 | } |
| 1317 | |
| 1318 | void godotsharp_dictionary_get_typed_value_class_name(const Dictionary *p_self, StringName *r_dest) { |
| 1319 | memnew_placement(r_dest, StringName(p_self->get_typed_value_class_name())); |
| 1320 | } |
| 1321 | |
| 1322 | void godotsharp_dictionary_get_typed_key_script(const Dictionary *p_self, Variant *r_dest) { |
| 1323 | memnew_placement(r_dest, Variant(p_self->get_typed_key_script())); |
| 1324 | } |
| 1325 | |
| 1326 | void godotsharp_dictionary_get_typed_value_script(const Dictionary *p_self, Variant *r_dest) { |
| 1327 | memnew_placement(r_dest, Variant(p_self->get_typed_value_script())); |
| 1328 | } |
| 1329 | |
| 1330 | void godotsharp_dictionary_to_string(const Dictionary *p_self, String *r_str) { |
| 1331 | *r_str = Variant(*p_self).operator String(); |
| 1332 | } |
| 1333 | |
| 1334 | void godotsharp_string_simplify_path(const String *p_self, String *r_simplified_path) { |
| 1335 | memnew_placement(r_simplified_path, String(p_self->simplify_path())); |
| 1336 | } |
| 1337 | |
| 1338 | void godotsharp_string_capitalize(const String *p_self, String *r_capitalized) { |
| 1339 | memnew_placement(r_capitalized, String(p_self->capitalize())); |
| 1340 | } |
| 1341 | |
| 1342 | void godotsharp_string_to_camel_case(const String *p_self, String *r_camel_case) { |
| 1343 | memnew_placement(r_camel_case, String(p_self->to_camel_case())); |
| 1344 | } |
| 1345 | |
| 1346 | void godotsharp_string_to_pascal_case(const String *p_self, String *r_pascal_case) { |
| 1347 | memnew_placement(r_pascal_case, String(p_self->to_pascal_case())); |
| 1348 | } |
| 1349 | |
| 1350 | void godotsharp_string_to_snake_case(const String *p_self, String *r_snake_case) { |
| 1351 | memnew_placement(r_snake_case, String(p_self->to_snake_case())); |
| 1352 | } |
| 1353 | |
| 1354 | void godotsharp_string_to_kebab_case(const String *p_self, String *r_kebab_case) { |
| 1355 | memnew_placement(r_kebab_case, String(p_self->to_kebab_case())); |
| 1356 | } |
| 1357 | |
| 1358 | void godotsharp_node_path_get_as_property_path(const NodePath *p_ptr, NodePath *r_dest) { |
| 1359 | memnew_placement(r_dest, NodePath(p_ptr->get_as_property_path())); |
| 1360 | } |
| 1361 | |
| 1362 | void godotsharp_node_path_get_concatenated_names(const NodePath *p_self, String *r_subnames) { |
| 1363 | memnew_placement(r_subnames, String(p_self->get_concatenated_names())); |
| 1364 | } |
| 1365 | |
| 1366 | void godotsharp_node_path_get_concatenated_subnames(const NodePath *p_self, String *r_subnames) { |
| 1367 | memnew_placement(r_subnames, String(p_self->get_concatenated_subnames())); |
| 1368 | } |
| 1369 | |
| 1370 | void godotsharp_node_path_get_name(const NodePath *p_self, uint32_t p_idx, String *r_name) { |
| 1371 | memnew_placement(r_name, String(p_self->get_name(p_idx))); |
| 1372 | } |
| 1373 | |
| 1374 | int32_t godotsharp_node_path_get_name_count(const NodePath *p_self) { |
| 1375 | return p_self->get_name_count(); |
| 1376 | } |
| 1377 | |
| 1378 | void godotsharp_node_path_get_subname(const NodePath *p_self, uint32_t p_idx, String *r_subname) { |
| 1379 | memnew_placement(r_subname, String(p_self->get_subname(p_idx))); |
| 1380 | } |
| 1381 | |
| 1382 | int32_t godotsharp_node_path_get_subname_count(const NodePath *p_self) { |
| 1383 | return p_self->get_subname_count(); |
| 1384 | } |
| 1385 | |
| 1386 | bool godotsharp_node_path_is_absolute(const NodePath *p_self) { |
| 1387 | return p_self->is_absolute(); |
| 1388 | } |
| 1389 | |
| 1390 | bool godotsharp_node_path_equals(const NodePath *p_self, const NodePath *p_other) { |
| 1391 | return *p_self == *p_other; |
| 1392 | } |
| 1393 | |
| 1394 | int godotsharp_node_path_hash(const NodePath *p_self) { |
| 1395 | return p_self->hash(); |
| 1396 | } |
| 1397 | |
| 1398 | void godotsharp_randomize() { |
| 1399 | Math::randomize(); |
| 1400 | } |
| 1401 | |
| 1402 | uint32_t godotsharp_randi() { |
| 1403 | return Math::rand(); |
| 1404 | } |
| 1405 | |
| 1406 | float godotsharp_randf() { |
| 1407 | return Math::randf(); |
| 1408 | } |
| 1409 | |
| 1410 | int32_t godotsharp_randi_range(int32_t p_from, int32_t p_to) { |
| 1411 | return Math::random(p_from, p_to); |
| 1412 | } |
| 1413 | |
| 1414 | double godotsharp_randf_range(double p_from, double p_to) { |
| 1415 | return Math::random(p_from, p_to); |
| 1416 | } |
| 1417 | |
| 1418 | double godotsharp_randfn(double p_mean, double p_deviation) { |
| 1419 | return Math::randfn(p_mean, p_deviation); |
| 1420 | } |
| 1421 | |
| 1422 | void godotsharp_seed(uint64_t p_seed) { |
| 1423 | Math::seed(p_seed); |
| 1424 | } |
| 1425 | |
| 1426 | uint32_t godotsharp_rand_from_seed(uint64_t p_seed, uint64_t *r_new_seed) { |
| 1427 | uint32_t ret = Math::rand_from_seed(&p_seed); |
| 1428 | *r_new_seed = p_seed; |
| 1429 | return ret; |
| 1430 | } |
| 1431 | |
| 1432 | void godotsharp_weakref(Object *p_ptr, Ref<RefCounted> *r_weak_ref) { |
| 1433 | if (!p_ptr) { |
| 1434 | return; |
| 1435 | } |
| 1436 | |
| 1437 | Ref<WeakRef> wref; |
| 1438 | RefCounted *rc = Object::cast_to<RefCounted>(p_ptr); |
| 1439 | |
| 1440 | if (rc) { |
| 1441 | Ref<RefCounted> r = rc; |
| 1442 | if (r.is_null()) { |
| 1443 | return; |
| 1444 | } |
| 1445 | |
| 1446 | wref.instantiate(); |
| 1447 | wref->set_ref(r); |
| 1448 | } else { |
| 1449 | wref.instantiate(); |
| 1450 | wref->set_obj(p_ptr); |
| 1451 | } |
| 1452 | |
| 1453 | memnew_placement(r_weak_ref, Ref<RefCounted>(wref)); |
| 1454 | } |
| 1455 | |
| 1456 | void godotsharp_print(const godot_string *p_what) { |
| 1457 | print_line(*reinterpret_cast<const String *>(p_what)); |
| 1458 | } |
| 1459 | |
| 1460 | void godotsharp_print_rich(const godot_string *p_what) { |
| 1461 | print_line_rich(*reinterpret_cast<const String *>(p_what)); |
| 1462 | } |
| 1463 | |
| 1464 | void godotsharp_printerr(const godot_string *p_what) { |
| 1465 | print_error(*reinterpret_cast<const String *>(p_what)); |
| 1466 | } |
| 1467 | |
| 1468 | void godotsharp_printt(const godot_string *p_what) { |
| 1469 | print_line(*reinterpret_cast<const String *>(p_what)); |
| 1470 | } |
| 1471 | |
| 1472 | void godotsharp_prints(const godot_string *p_what) { |
| 1473 | print_line(*reinterpret_cast<const String *>(p_what)); |
| 1474 | } |
| 1475 | |
| 1476 | void godotsharp_printraw(const godot_string *p_what) { |
| 1477 | OS::get_singleton()->print("%s", reinterpret_cast<const String *>(p_what)->utf8().get_data()); |
| 1478 | } |
| 1479 | |
| 1480 | void godotsharp_err_print_error(const godot_string *p_function, const godot_string *p_file, int32_t p_line, const godot_string *p_error, const godot_string *p_message, bool p_editor_notify, ErrorHandlerType p_type) { |
| 1481 | _err_print_error( |
| 1482 | reinterpret_cast<const String *>(p_function)->utf8().get_data(), |
| 1483 | reinterpret_cast<const String *>(p_file)->utf8().get_data(), |
| 1484 | p_line, |
| 1485 | reinterpret_cast<const String *>(p_error)->utf8().get_data(), |
| 1486 | reinterpret_cast<const String *>(p_message)->utf8().get_data(), |
| 1487 | p_editor_notify, p_type); |
| 1488 | } |
| 1489 | |
| 1490 | void godotsharp_var_to_str(const godot_variant *p_var, godot_string *r_ret) { |
| 1491 | const Variant &var = *reinterpret_cast<const Variant *>(p_var); |
| 1492 | String &vars = *memnew_placement(r_ret, String); |
| 1493 | VariantWriter::write_to_string(var, vars); |
| 1494 | } |
| 1495 | |
| 1496 | void godotsharp_str_to_var(const godot_string *p_str, godot_variant *r_ret) { |
| 1497 | Variant ret; |
| 1498 | |
| 1499 | VariantParser::StreamString ss; |
| 1500 | ss.s = *reinterpret_cast<const String *>(p_str); |
| 1501 | |
| 1502 | String errs; |
| 1503 | int line; |
| 1504 | Error err = VariantParser::parse(&ss, ret, errs, line); |
| 1505 | if (err != OK) { |
| 1506 | String err_str = "Parse error at line " + itos(line) + ": " + errs + "."; |
| 1507 | ERR_PRINT(err_str); |
| 1508 | ret = err_str; |
| 1509 | } |
| 1510 | memnew_placement(r_ret, Variant(ret)); |
| 1511 | } |
| 1512 | |
| 1513 | void godotsharp_var_to_bytes(const godot_variant *p_var, bool p_full_objects, godot_packed_array *r_bytes) { |
| 1514 | const Variant &var = *reinterpret_cast<const Variant *>(p_var); |
| 1515 | PackedByteArray &bytes = *memnew_placement(r_bytes, PackedByteArray); |
| 1516 | |
| 1517 | int len; |
| 1518 | Error err = encode_variant(var, nullptr, len, p_full_objects); |
| 1519 | ERR_FAIL_COND_MSG(err != OK, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID)."); |
| 1520 | |
| 1521 | bytes.resize(len); |
| 1522 | encode_variant(var, bytes.ptrw(), len, p_full_objects); |
| 1523 | } |
| 1524 | |
| 1525 | void godotsharp_bytes_to_var(const godot_packed_array *p_bytes, bool p_allow_objects, godot_variant *r_ret) { |
| 1526 | const PackedByteArray *bytes = reinterpret_cast<const PackedByteArray *>(p_bytes); |
| 1527 | Variant ret; |
| 1528 | Error err = decode_variant(ret, bytes->ptr(), bytes->size(), nullptr, p_allow_objects); |
| 1529 | if (err != OK) { |
| 1530 | ret = RTR("Not enough bytes for decoding bytes, or invalid format."); |
| 1531 | } |
| 1532 | memnew_placement(r_ret, Variant(ret)); |
| 1533 | } |
| 1534 | |
| 1535 | int godotsharp_hash(const godot_variant *p_var) { |
| 1536 | return reinterpret_cast<const Variant *>(p_var)->hash(); |
| 1537 | } |
| 1538 | |
| 1539 | void godotsharp_convert(const godot_variant *p_what, int32_t p_type, godot_variant *r_ret) { |
| 1540 | const Variant *args[1] = { reinterpret_cast<const Variant *>(p_what) }; |
| 1541 | Callable::CallError ce; |
| 1542 | Variant ret; |
| 1543 | Variant::construct(Variant::Type(p_type), ret, args, 1, ce); |
| 1544 | if (ce.error != Callable::CallError::CALL_OK) { |
| 1545 | memnew_placement(r_ret, Variant); |
| 1546 | ERR_FAIL_MSG("Unable to convert parameter from '" + |
| 1547 | Variant::get_type_name(reinterpret_cast<const Variant *>(p_what)->get_type()) + |
| 1548 | "' to '" + Variant::get_type_name(Variant::Type(p_type)) + "'."); |
| 1549 | } |
| 1550 | memnew_placement(r_ret, Variant(ret)); |
| 1551 | } |
| 1552 | |
| 1553 | Object *godotsharp_instance_from_id(uint64_t p_instance_id) { |
| 1554 | return ObjectDB::get_instance(ObjectID(p_instance_id)); |
| 1555 | } |
| 1556 | |
| 1557 | void godotsharp_object_to_string(Object *p_ptr, godot_string *r_str) { |
| 1558 | #ifdef DEBUG_ENABLED |
| 1559 | // Cannot happen in C#; would get an ObjectDisposedException instead. |
| 1560 | CRASH_COND(p_ptr == nullptr); |
| 1561 | #endif |
| 1562 | // Can't call 'Object::to_string()' here, as that can end up calling 'ToString' again resulting in an endless circular loop. |
| 1563 | memnew_placement(r_str, |
| 1564 | String("<" + p_ptr->get_class() + "#" + itos(p_ptr->get_instance_id()) + ">")); |
| 1565 | } |
| 1566 | |
| 1567 | #ifdef __cplusplus |
| 1568 | } |
| 1569 | #endif |
| 1570 | |
| 1571 | int64_t godotsharp_string_size(const String *p_self) { |
| 1572 | return p_self->size(); |
| 1573 | } |
| 1574 | |
| 1575 | int64_t godotsharp_packed_byte_array_size(const PackedByteArray *p_self) { |
| 1576 | return p_self->size(); |
| 1577 | } |
| 1578 | |
| 1579 | int64_t godotsharp_packed_int32_array_size(const PackedInt32Array *p_self) { |
| 1580 | return p_self->size(); |
| 1581 | } |
| 1582 | |
| 1583 | int64_t godotsharp_packed_int64_array_size(const PackedInt64Array *p_self) { |
| 1584 | return p_self->size(); |
| 1585 | } |
| 1586 | |
| 1587 | int64_t godotsharp_packed_float32_array_size(const PackedFloat32Array *p_self) { |
| 1588 | return p_self->size(); |
| 1589 | } |
| 1590 | |
| 1591 | int64_t godotsharp_packed_float64_array_size(const PackedFloat64Array *p_self) { |
| 1592 | return p_self->size(); |
| 1593 | } |
| 1594 | |
| 1595 | int64_t godotsharp_packed_string_array_size(const PackedStringArray *p_self) { |
| 1596 | return p_self->size(); |
| 1597 | } |
| 1598 | |
| 1599 | int64_t godotsharp_packed_vector2_array_size(const PackedVector2Array *p_self) { |
| 1600 | return p_self->size(); |
| 1601 | } |
| 1602 | |
| 1603 | int64_t godotsharp_packed_vector3_array_size(const PackedVector3Array *p_self) { |
| 1604 | return p_self->size(); |
| 1605 | } |
| 1606 | |
| 1607 | int64_t godotsharp_packed_vector4_array_size(const PackedVector4Array *p_self) { |
| 1608 | return p_self->size(); |
| 1609 | } |
| 1610 | |
| 1611 | int64_t godotsharp_packed_color_array_size(const PackedColorArray *p_self) { |
| 1612 | return p_self->size(); |
| 1613 | } |
| 1614 | |
| 1615 | int64_t godotsharp_array_size(const Array *p_self) { |
| 1616 | return p_self->size(); |
| 1617 | } |
| 1618 | |
| 1619 | // The order in this array must match the declaration order of |
| 1620 | // the methods in 'GodotSharp/Core/NativeInterop/NativeFuncs.cs'. |
| 1621 | static const void *unmanaged_callbacks[]{ |
| 1622 | (void *)godotsharp_dotnet_module_is_initialized, |
| 1623 | (void *)godotsharp_method_bind_get_method, |
| 1624 | (void *)godotsharp_method_bind_get_method_with_compatibility, |
| 1625 | (void *)godotsharp_get_class_constructor, |
| 1626 | (void *)godotsharp_engine_get_singleton, |
| 1627 | (void *)godotsharp_stack_info_vector_resize, |
| 1628 | (void *)godotsharp_stack_info_vector_destroy, |
| 1629 | (void *)godotsharp_internal_editor_file_system_update_files, |
| 1630 | (void *)godotsharp_internal_script_debugger_send_error, |
| 1631 | (void *)godotsharp_internal_script_debugger_is_active, |
| 1632 | (void *)godotsharp_internal_object_get_associated_gchandle, |
| 1633 | (void *)godotsharp_internal_object_disposed, |
| 1634 | (void *)godotsharp_internal_refcounted_disposed, |
| 1635 | (void *)godotsharp_internal_signal_awaiter_connect, |
| 1636 | (void *)godotsharp_internal_tie_native_managed_to_unmanaged, |
| 1637 | (void *)godotsharp_internal_tie_user_managed_to_unmanaged, |
| 1638 | (void *)godotsharp_internal_tie_managed_to_unmanaged_with_pre_setup, |
| 1639 | (void *)godotsharp_internal_unmanaged_get_script_instance_managed, |
| 1640 | (void *)godotsharp_internal_unmanaged_get_instance_binding_managed, |
| 1641 | (void *)godotsharp_internal_unmanaged_instance_binding_create_managed, |
| 1642 | (void *)godotsharp_internal_new_csharp_script, |
| 1643 | (void *)godotsharp_internal_script_load, |
| 1644 | (void *)godotsharp_internal_reload_registered_script, |
| 1645 | (void *)godotsharp_array_filter_godot_objects_by_native, |
| 1646 | (void *)godotsharp_array_filter_godot_objects_by_non_native, |
| 1647 | (void *)godotsharp_ref_new_from_ref_counted_ptr, |
| 1648 | (void *)godotsharp_ref_destroy, |
| 1649 | (void *)godotsharp_string_name_new_from_string, |
| 1650 | (void *)godotsharp_node_path_new_from_string, |
| 1651 | (void *)godotsharp_string_name_as_string, |
| 1652 | (void *)godotsharp_node_path_as_string, |
| 1653 | (void *)godotsharp_packed_byte_array_new_mem_copy, |
| 1654 | (void *)godotsharp_packed_int32_array_new_mem_copy, |
| 1655 | (void *)godotsharp_packed_int64_array_new_mem_copy, |
| 1656 | (void *)godotsharp_packed_float32_array_new_mem_copy, |
| 1657 | (void *)godotsharp_packed_float64_array_new_mem_copy, |
| 1658 | (void *)godotsharp_packed_vector2_array_new_mem_copy, |
| 1659 | (void *)godotsharp_packed_vector3_array_new_mem_copy, |
| 1660 | (void *)godotsharp_packed_vector4_array_new_mem_copy, |
| 1661 | (void *)godotsharp_packed_color_array_new_mem_copy, |
| 1662 | (void *)godotsharp_packed_string_array_add, |
| 1663 | (void *)godotsharp_callable_new_with_delegate, |
| 1664 | (void *)godotsharp_callable_get_data_for_marshalling, |
| 1665 | (void *)godotsharp_callable_call, |
| 1666 | (void *)godotsharp_callable_call_deferred, |
| 1667 | (void *)godotsharp_color_from_ok_hsl, |
| 1668 | (void *)godotsharp_color_get_ok_hsl_h, |
| 1669 | (void *)godotsharp_color_get_ok_hsl_s, |
| 1670 | (void *)godotsharp_color_get_ok_hsl_l, |
| 1671 | (void *)godotsharp_method_bind_ptrcall, |
| 1672 | (void *)godotsharp_method_bind_call, |
| 1673 | (void *)godotsharp_variant_new_string_name, |
| 1674 | (void *)godotsharp_variant_new_copy, |
| 1675 | (void *)godotsharp_variant_new_node_path, |
| 1676 | (void *)godotsharp_variant_new_object, |
| 1677 | (void *)godotsharp_variant_new_transform2d, |
| 1678 | (void *)godotsharp_variant_new_basis, |
| 1679 | (void *)godotsharp_variant_new_transform3d, |
| 1680 | (void *)godotsharp_variant_new_projection, |
| 1681 | (void *)godotsharp_variant_new_aabb, |
| 1682 | (void *)godotsharp_variant_new_dictionary, |
| 1683 | (void *)godotsharp_variant_new_array, |
| 1684 | (void *)godotsharp_variant_new_packed_byte_array, |
| 1685 | (void *)godotsharp_variant_new_packed_int32_array, |
| 1686 | (void *)godotsharp_variant_new_packed_int64_array, |
| 1687 | (void *)godotsharp_variant_new_packed_float32_array, |
| 1688 | (void *)godotsharp_variant_new_packed_float64_array, |
| 1689 | (void *)godotsharp_variant_new_packed_string_array, |
| 1690 | (void *)godotsharp_variant_new_packed_vector2_array, |
| 1691 | (void *)godotsharp_variant_new_packed_vector3_array, |
| 1692 | (void *)godotsharp_variant_new_packed_vector4_array, |
| 1693 | (void *)godotsharp_variant_new_packed_color_array, |
| 1694 | (void *)godotsharp_variant_as_bool, |
| 1695 | (void *)godotsharp_variant_as_int, |
| 1696 | (void *)godotsharp_variant_as_float, |
| 1697 | (void *)godotsharp_variant_as_string, |
| 1698 | (void *)godotsharp_variant_as_vector2, |
| 1699 | (void *)godotsharp_variant_as_vector2i, |
| 1700 | (void *)godotsharp_variant_as_rect2, |
| 1701 | (void *)godotsharp_variant_as_rect2i, |
| 1702 | (void *)godotsharp_variant_as_vector3, |
| 1703 | (void *)godotsharp_variant_as_vector3i, |
| 1704 | (void *)godotsharp_variant_as_transform2d, |
| 1705 | (void *)godotsharp_variant_as_vector4, |
| 1706 | (void *)godotsharp_variant_as_vector4i, |
| 1707 | (void *)godotsharp_variant_as_plane, |
| 1708 | (void *)godotsharp_variant_as_quaternion, |
| 1709 | (void *)godotsharp_variant_as_aabb, |
| 1710 | (void *)godotsharp_variant_as_basis, |
| 1711 | (void *)godotsharp_variant_as_transform3d, |
| 1712 | (void *)godotsharp_variant_as_projection, |
| 1713 | (void *)godotsharp_variant_as_color, |
| 1714 | (void *)godotsharp_variant_as_string_name, |
| 1715 | (void *)godotsharp_variant_as_node_path, |
| 1716 | (void *)godotsharp_variant_as_rid, |
| 1717 | (void *)godotsharp_variant_as_callable, |
| 1718 | (void *)godotsharp_variant_as_signal, |
| 1719 | (void *)godotsharp_variant_as_dictionary, |
| 1720 | (void *)godotsharp_variant_as_array, |
| 1721 | (void *)godotsharp_variant_as_packed_byte_array, |
| 1722 | (void *)godotsharp_variant_as_packed_int32_array, |
| 1723 | (void *)godotsharp_variant_as_packed_int64_array, |
| 1724 | (void *)godotsharp_variant_as_packed_float32_array, |
| 1725 | (void *)godotsharp_variant_as_packed_float64_array, |
| 1726 | (void *)godotsharp_variant_as_packed_string_array, |
| 1727 | (void *)godotsharp_variant_as_packed_vector2_array, |
| 1728 | (void *)godotsharp_variant_as_packed_vector3_array, |
| 1729 | (void *)godotsharp_variant_as_packed_vector4_array, |
| 1730 | (void *)godotsharp_variant_as_packed_color_array, |
| 1731 | (void *)godotsharp_variant_equals, |
| 1732 | (void *)godotsharp_string_new_with_utf16_chars, |
| 1733 | (void *)godotsharp_string_name_new_copy, |
| 1734 | (void *)godotsharp_node_path_new_copy, |
| 1735 | (void *)godotsharp_array_new, |
| 1736 | (void *)godotsharp_array_new_copy, |
| 1737 | (void *)godotsharp_array_ptrw, |
| 1738 | (void *)godotsharp_dictionary_new, |
| 1739 | (void *)godotsharp_dictionary_new_copy, |
| 1740 | (void *)godotsharp_packed_byte_array_destroy, |
| 1741 | (void *)godotsharp_packed_int32_array_destroy, |
| 1742 | (void *)godotsharp_packed_int64_array_destroy, |
| 1743 | (void *)godotsharp_packed_float32_array_destroy, |
| 1744 | (void *)godotsharp_packed_float64_array_destroy, |
| 1745 | (void *)godotsharp_packed_string_array_destroy, |
| 1746 | (void *)godotsharp_packed_vector2_array_destroy, |
| 1747 | (void *)godotsharp_packed_vector3_array_destroy, |
| 1748 | (void *)godotsharp_packed_vector4_array_destroy, |
| 1749 | (void *)godotsharp_packed_color_array_destroy, |
| 1750 | (void *)godotsharp_variant_destroy, |
| 1751 | (void *)godotsharp_string_destroy, |
| 1752 | (void *)godotsharp_string_name_destroy, |
| 1753 | (void *)godotsharp_node_path_destroy, |
| 1754 | (void *)godotsharp_signal_destroy, |
| 1755 | (void *)godotsharp_callable_destroy, |
| 1756 | (void *)godotsharp_array_destroy, |
| 1757 | (void *)godotsharp_dictionary_destroy, |
| 1758 | (void *)godotsharp_array_add, |
| 1759 | (void *)godotsharp_array_add_range, |
| 1760 | (void *)godotsharp_array_binary_search, |
| 1761 | (void *)godotsharp_array_duplicate, |
| 1762 | (void *)godotsharp_array_fill, |
| 1763 | (void *)godotsharp_array_index_of, |
| 1764 | (void *)godotsharp_array_insert, |
| 1765 | (void *)godotsharp_array_last_index_of, |
| 1766 | (void *)godotsharp_array_make_read_only, |
| 1767 | (void *)godotsharp_array_set_typed, |
| 1768 | (void *)godotsharp_array_is_typed, |
| 1769 | (void *)godotsharp_array_max, |
| 1770 | (void *)godotsharp_array_min, |
| 1771 | (void *)godotsharp_array_pick_random, |
| 1772 | (void *)godotsharp_array_recursive_equal, |
| 1773 | (void *)godotsharp_array_remove_at, |
| 1774 | (void *)godotsharp_array_resize, |
| 1775 | (void *)godotsharp_array_reverse, |
| 1776 | (void *)godotsharp_array_shuffle, |
| 1777 | (void *)godotsharp_array_slice, |
| 1778 | (void *)godotsharp_array_sort, |
| 1779 | (void *)godotsharp_array_to_string, |
| 1780 | (void *)godotsharp_packed_byte_array_compress, |
| 1781 | (void *)godotsharp_packed_byte_array_decompress, |
| 1782 | (void *)godotsharp_packed_byte_array_decompress_dynamic, |
| 1783 | (void *)godotsharp_dictionary_try_get_value, |
| 1784 | (void *)godotsharp_dictionary_set_value, |
| 1785 | (void *)godotsharp_dictionary_keys, |
| 1786 | (void *)godotsharp_dictionary_values, |
| 1787 | (void *)godotsharp_dictionary_count, |
| 1788 | (void *)godotsharp_dictionary_key_value_pair_at, |
| 1789 | (void *)godotsharp_dictionary_add, |
| 1790 | (void *)godotsharp_dictionary_clear, |
| 1791 | (void *)godotsharp_dictionary_contains_key, |
| 1792 | (void *)godotsharp_dictionary_duplicate, |
| 1793 | (void *)godotsharp_dictionary_merge, |
| 1794 | (void *)godotsharp_dictionary_recursive_equal, |
| 1795 | (void *)godotsharp_dictionary_remove_key, |
| 1796 | (void *)godotsharp_dictionary_make_read_only, |
| 1797 | (void *)godotsharp_dictionary_set_typed, |
| 1798 | (void *)godotsharp_dictionary_is_typed_key, |
| 1799 | (void *)godotsharp_dictionary_is_typed_value, |
| 1800 | (void *)godotsharp_dictionary_get_typed_key_builtin, |
| 1801 | (void *)godotsharp_dictionary_get_typed_value_builtin, |
| 1802 | (void *)godotsharp_dictionary_get_typed_key_class_name, |
| 1803 | (void *)godotsharp_dictionary_get_typed_value_class_name, |
| 1804 | (void *)godotsharp_dictionary_get_typed_key_script, |
| 1805 | (void *)godotsharp_dictionary_get_typed_value_script, |
| 1806 | (void *)godotsharp_dictionary_to_string, |
| 1807 | (void *)godotsharp_string_simplify_path, |
| 1808 | (void *)godotsharp_string_capitalize, |
| 1809 | (void *)godotsharp_string_to_camel_case, |
| 1810 | (void *)godotsharp_string_to_pascal_case, |
| 1811 | (void *)godotsharp_string_to_snake_case, |
| 1812 | (void *)godotsharp_string_to_kebab_case, |
| 1813 | (void *)godotsharp_node_path_get_as_property_path, |
| 1814 | (void *)godotsharp_node_path_get_concatenated_names, |
| 1815 | (void *)godotsharp_node_path_get_concatenated_subnames, |
| 1816 | (void *)godotsharp_node_path_get_name, |
| 1817 | (void *)godotsharp_node_path_get_name_count, |
| 1818 | (void *)godotsharp_node_path_get_subname, |
| 1819 | (void *)godotsharp_node_path_get_subname_count, |
| 1820 | (void *)godotsharp_node_path_is_absolute, |
| 1821 | (void *)godotsharp_node_path_equals, |
| 1822 | (void *)godotsharp_node_path_hash, |
| 1823 | (void *)godotsharp_bytes_to_var, |
| 1824 | (void *)godotsharp_convert, |
| 1825 | (void *)godotsharp_hash, |
| 1826 | (void *)godotsharp_instance_from_id, |
| 1827 | (void *)godotsharp_print, |
| 1828 | (void *)godotsharp_print_rich, |
| 1829 | (void *)godotsharp_printerr, |
| 1830 | (void *)godotsharp_printraw, |
| 1831 | (void *)godotsharp_prints, |
| 1832 | (void *)godotsharp_printt, |
| 1833 | (void *)godotsharp_randf, |
| 1834 | (void *)godotsharp_randi, |
| 1835 | (void *)godotsharp_randomize, |
| 1836 | (void *)godotsharp_randf_range, |
| 1837 | (void *)godotsharp_randfn, |
| 1838 | (void *)godotsharp_randi_range, |
| 1839 | (void *)godotsharp_rand_from_seed, |
| 1840 | (void *)godotsharp_seed, |
| 1841 | (void *)godotsharp_weakref, |
| 1842 | (void *)godotsharp_str_to_var, |
| 1843 | (void *)godotsharp_var_to_bytes, |
| 1844 | (void *)godotsharp_var_to_str, |
| 1845 | (void *)godotsharp_err_print_error, |
| 1846 | (void *)godotsharp_object_to_string, |
| 1847 | (void *)godotsharp_string_size, |
| 1848 | (void *)godotsharp_packed_byte_array_size, |
| 1849 | (void *)godotsharp_packed_int32_array_size, |
| 1850 | (void *)godotsharp_packed_int64_array_size, |
| 1851 | (void *)godotsharp_packed_float32_array_size, |
| 1852 | (void *)godotsharp_packed_float64_array_size, |
| 1853 | (void *)godotsharp_packed_string_array_size, |
| 1854 | (void *)godotsharp_packed_vector2_array_size, |
| 1855 | (void *)godotsharp_packed_vector3_array_size, |
| 1856 | (void *)godotsharp_packed_vector4_array_size, |
| 1857 | (void *)godotsharp_packed_color_array_size, |
| 1858 | (void *)godotsharp_array_size, |
| 1859 | }; |
| 1860 | |
| 1861 | const void **godotsharp::get_runtime_interop_funcs(int32_t &r_size) { |
| 1862 | r_size = sizeof(unmanaged_callbacks); |
| 1863 | return unmanaged_callbacks; |
| 1864 | } |