| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  collections_glue.cpp                                                 */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							|  |  |  | /*                      https://godotengine.org                          */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2021-01-01 20:13:46 +01:00
										 |  |  | /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							|  |  |  | /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md).   */ | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the       */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including   */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,   */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to    */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to */ | 
					
						
							|  |  |  | /* the following conditions:                                             */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be        */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.       */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 05:40:41 +02:00
										 |  |  | #ifdef MONO_GLUE_ENABLED
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | #include <mono/metadata/exception.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-07 19:33:38 -03:00
										 |  |  | #include "core/variant/array.h"
 | 
					
						
							| 
									
										
										
										
											2020-07-05 19:19:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-10 17:10:38 +01:00
										 |  |  | #include "../mono_gd/gd_mono_cache.h"
 | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | #include "../mono_gd/gd_mono_class.h"
 | 
					
						
							| 
									
										
										
										
											2020-07-05 19:19:36 +02:00
										 |  |  | #include "../mono_gd/gd_mono_marshal.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-04 05:40:41 +02:00
										 |  |  | #include "../mono_gd/gd_mono_utils.h"
 | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | Array *godot_icall_Array_Ctor() { | 
					
						
							|  |  |  | 	return memnew(Array); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void godot_icall_Array_Dtor(Array *ptr) { | 
					
						
							|  |  |  | 	memdelete(ptr); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | MonoObject *godot_icall_Array_At(Array *ptr, int32_t index) { | 
					
						
							| 
									
										
										
										
											2019-07-03 17:56:08 +02:00
										 |  |  | 	if (index < 0 || index >= ptr->size()) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 		GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 		return nullptr; | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | MonoObject *godot_icall_Array_At_Generic(Array *ptr, int32_t index, uint32_t type_encoding, GDMonoClass *type_class) { | 
					
						
							| 
									
										
										
										
											2019-07-03 17:56:08 +02:00
										 |  |  | 	if (index < 0 || index >= ptr->size()) { | 
					
						
							| 
									
										
										
										
											2018-09-27 00:11:31 +02:00
										 |  |  | 		GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 		return nullptr; | 
					
						
							| 
									
										
										
										
											2018-09-27 00:11:31 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index), ManagedType(type_encoding, type_class)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | void godot_icall_Array_SetAt(Array *ptr, int32_t index, MonoObject *value) { | 
					
						
							| 
									
										
										
										
											2019-07-03 17:56:08 +02:00
										 |  |  | 	if (index < 0 || index >= ptr->size()) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 		GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ptr->operator[](index) = GDMonoMarshal::mono_object_to_variant(value); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | int32_t godot_icall_Array_Count(Array *ptr) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	return ptr->size(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | int32_t godot_icall_Array_Add(Array *ptr, MonoObject *item) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	ptr->append(GDMonoMarshal::mono_object_to_variant(item)); | 
					
						
							| 
									
										
										
										
											2019-03-04 21:31:04 +01:00
										 |  |  | 	return ptr->size(); | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void godot_icall_Array_Clear(Array *ptr) { | 
					
						
							|  |  |  | 	ptr->clear(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-28 20:01:54 +01:00
										 |  |  | MonoBoolean godot_icall_Array_Contains(Array *ptr, MonoObject *item) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	return ptr->find(GDMonoMarshal::mono_object_to_variant(item)) != -1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | void godot_icall_Array_CopyTo(Array *ptr, MonoArray *array, int32_t array_index) { | 
					
						
							| 
									
										
										
										
											2019-02-21 20:57:39 +01:00
										 |  |  | 	unsigned int count = ptr->size(); | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (mono_array_length(array) < (array_index + count)) { | 
					
						
							|  |  |  | 		MonoException *exc = mono_get_exception_argument("", "Destination array was not long enough. Check destIndex and length, and the array's lower bounds."); | 
					
						
							|  |  |  | 		GDMonoUtils::set_pending_exception(exc); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-21 20:57:39 +01:00
										 |  |  | 	for (unsigned int i = 0; i < count; i++) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 		MonoObject *boxed = GDMonoMarshal::variant_to_mono_object(ptr->operator[](i)); | 
					
						
							|  |  |  | 		mono_array_setref(array, array_index, boxed); | 
					
						
							|  |  |  | 		array_index++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-12 17:40:08 -04:00
										 |  |  | Array *godot_icall_Array_Ctor_MonoArray(MonoArray *mono_array) { | 
					
						
							|  |  |  | 	Array *godot_array = memnew(Array); | 
					
						
							|  |  |  | 	unsigned int count = mono_array_length(mono_array); | 
					
						
							|  |  |  | 	godot_array->resize(count); | 
					
						
							|  |  |  | 	for (unsigned int i = 0; i < count; i++) { | 
					
						
							|  |  |  | 		MonoObject *item = mono_array_get(mono_array, MonoObject *, i); | 
					
						
							|  |  |  | 		godot_icall_Array_SetAt(godot_array, i, item); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return godot_array; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-04 14:54:33 +01:00
										 |  |  | Array *godot_icall_Array_Duplicate(Array *ptr, MonoBoolean deep) { | 
					
						
							|  |  |  | 	return memnew(Array(ptr->duplicate(deep))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-12 17:40:08 -04:00
										 |  |  | Array *godot_icall_Array_Concatenate(Array *left, Array *right) { | 
					
						
							|  |  |  | 	int count = left->size() + right->size(); | 
					
						
							|  |  |  | 	Array *new_array = memnew(Array(left->duplicate(false))); | 
					
						
							|  |  |  | 	new_array->resize(count); | 
					
						
							|  |  |  | 	for (unsigned int i = 0; i < (unsigned int)right->size(); i++) { | 
					
						
							|  |  |  | 		new_array->operator[](i + left->size()) = right->operator[](i); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return new_array; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | int32_t godot_icall_Array_IndexOf(Array *ptr, MonoObject *item) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	return ptr->find(GDMonoMarshal::mono_object_to_variant(item)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | void godot_icall_Array_Insert(Array *ptr, int32_t index, MonoObject *item) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	if (index < 0 || index > ptr->size()) { | 
					
						
							|  |  |  | 		GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ptr->insert(index, GDMonoMarshal::mono_object_to_variant(item)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-28 20:01:54 +01:00
										 |  |  | MonoBoolean godot_icall_Array_Remove(Array *ptr, MonoObject *item) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	int idx = ptr->find(GDMonoMarshal::mono_object_to_variant(item)); | 
					
						
							|  |  |  | 	if (idx >= 0) { | 
					
						
							|  |  |  | 		ptr->remove(idx); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | void godot_icall_Array_RemoveAt(Array *ptr, int32_t index) { | 
					
						
							| 
									
										
										
										
											2019-07-03 17:56:08 +02:00
										 |  |  | 	if (index < 0 || index >= ptr->size()) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 		GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ptr->remove(index); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | int32_t godot_icall_Array_Resize(Array *ptr, int32_t new_size) { | 
					
						
							|  |  |  | 	return (int32_t)ptr->resize(new_size); | 
					
						
							| 
									
										
										
										
											2019-02-28 18:33:42 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-07 11:19:23 +03:00
										 |  |  | void godot_icall_Array_Shuffle(Array *ptr) { | 
					
						
							|  |  |  | 	ptr->shuffle(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 00:11:31 +02:00
										 |  |  | void godot_icall_Array_Generic_GetElementTypeInfo(MonoReflectionType *refltype, uint32_t *type_encoding, GDMonoClass **type_class) { | 
					
						
							|  |  |  | 	MonoType *elem_type = mono_reflection_type_get_type(refltype); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	*type_encoding = mono_type_get_type(elem_type); | 
					
						
							|  |  |  | 	MonoClass *type_class_raw = mono_class_from_mono_type(elem_type); | 
					
						
							|  |  |  | 	*type_class = GDMono::get_singleton()->get_class(type_class_raw); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-18 14:48:10 +02:00
										 |  |  | MonoString *godot_icall_Array_ToString(Array *ptr) { | 
					
						
							|  |  |  | 	return GDMonoMarshal::mono_string_from_godot(Variant(*ptr).operator String()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | Dictionary *godot_icall_Dictionary_Ctor() { | 
					
						
							|  |  |  | 	return memnew(Dictionary); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void godot_icall_Dictionary_Dtor(Dictionary *ptr) { | 
					
						
							|  |  |  | 	memdelete(ptr); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MonoObject *godot_icall_Dictionary_GetValue(Dictionary *ptr, MonoObject *key) { | 
					
						
							|  |  |  | 	Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	if (ret == nullptr) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 		MonoObject *exc = mono_object_new(mono_domain_get(), CACHED_CLASS(KeyNotFoundException)->get_mono_ptr()); | 
					
						
							|  |  |  | #ifdef DEBUG_ENABLED
 | 
					
						
							|  |  |  | 		CRASH_COND(!exc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-05-21 00:06:04 +02:00
										 |  |  | 		GDMonoUtils::runtime_object_init(exc, CACHED_CLASS(KeyNotFoundException)); | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 		GDMonoUtils::set_pending_exception((MonoException *)exc); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 		return nullptr; | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return GDMonoMarshal::variant_to_mono_object(ret); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 00:11:31 +02:00
										 |  |  | MonoObject *godot_icall_Dictionary_GetValue_Generic(Dictionary *ptr, MonoObject *key, uint32_t type_encoding, GDMonoClass *type_class) { | 
					
						
							|  |  |  | 	Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	if (ret == nullptr) { | 
					
						
							| 
									
										
										
										
											2018-09-27 00:11:31 +02:00
										 |  |  | 		MonoObject *exc = mono_object_new(mono_domain_get(), CACHED_CLASS(KeyNotFoundException)->get_mono_ptr()); | 
					
						
							|  |  |  | #ifdef DEBUG_ENABLED
 | 
					
						
							|  |  |  | 		CRASH_COND(!exc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-05-21 00:06:04 +02:00
										 |  |  | 		GDMonoUtils::runtime_object_init(exc, CACHED_CLASS(KeyNotFoundException)); | 
					
						
							| 
									
										
										
										
											2018-09-27 00:11:31 +02:00
										 |  |  | 		GDMonoUtils::set_pending_exception((MonoException *)exc); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 		return nullptr; | 
					
						
							| 
									
										
										
										
											2018-09-27 00:11:31 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return GDMonoMarshal::variant_to_mono_object(ret, ManagedType(type_encoding, type_class)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | void godot_icall_Dictionary_SetValue(Dictionary *ptr, MonoObject *key, MonoObject *value) { | 
					
						
							|  |  |  | 	ptr->operator[](GDMonoMarshal::mono_object_to_variant(key)) = GDMonoMarshal::mono_object_to_variant(value); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Array *godot_icall_Dictionary_Keys(Dictionary *ptr) { | 
					
						
							|  |  |  | 	return memnew(Array(ptr->keys())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Array *godot_icall_Dictionary_Values(Dictionary *ptr) { | 
					
						
							|  |  |  | 	return memnew(Array(ptr->values())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | int32_t godot_icall_Dictionary_Count(Dictionary *ptr) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	return ptr->size(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void godot_icall_Dictionary_Add(Dictionary *ptr, MonoObject *key, MonoObject *value) { | 
					
						
							|  |  |  | 	Variant varKey = GDMonoMarshal::mono_object_to_variant(key); | 
					
						
							|  |  |  | 	Variant *ret = ptr->getptr(varKey); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	if (ret != nullptr) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 		GDMonoUtils::set_pending_exception(mono_get_exception_argument("key", "An element with the same key already exists")); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ptr->operator[](varKey) = GDMonoMarshal::mono_object_to_variant(value); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void godot_icall_Dictionary_Clear(Dictionary *ptr) { | 
					
						
							|  |  |  | 	ptr->clear(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-28 20:01:54 +01:00
										 |  |  | MonoBoolean godot_icall_Dictionary_Contains(Dictionary *ptr, MonoObject *key, MonoObject *value) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	// no dupes
 | 
					
						
							|  |  |  | 	Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	return ret != nullptr && *ret == GDMonoMarshal::mono_object_to_variant(value); | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-28 20:01:54 +01:00
										 |  |  | MonoBoolean godot_icall_Dictionary_ContainsKey(Dictionary *ptr, MonoObject *key) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	return ptr->has(GDMonoMarshal::mono_object_to_variant(key)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-04 14:54:33 +01:00
										 |  |  | Dictionary *godot_icall_Dictionary_Duplicate(Dictionary *ptr, MonoBoolean deep) { | 
					
						
							|  |  |  | 	return memnew(Dictionary(ptr->duplicate(deep))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-28 20:01:54 +01:00
										 |  |  | MonoBoolean godot_icall_Dictionary_RemoveKey(Dictionary *ptr, MonoObject *key) { | 
					
						
							| 
									
										
										
										
											2018-08-14 19:19:05 +02:00
										 |  |  | 	return ptr->erase(GDMonoMarshal::mono_object_to_variant(key)); | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-28 20:01:54 +01:00
										 |  |  | MonoBoolean godot_icall_Dictionary_Remove(Dictionary *ptr, MonoObject *key, MonoObject *value) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	Variant varKey = GDMonoMarshal::mono_object_to_variant(key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// no dupes
 | 
					
						
							|  |  |  | 	Variant *ret = ptr->getptr(varKey); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	if (ret != nullptr && *ret == GDMonoMarshal::mono_object_to_variant(value)) { | 
					
						
							| 
									
										
										
										
											2018-08-14 19:19:05 +02:00
										 |  |  | 		ptr->erase(varKey); | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-28 20:01:54 +01:00
										 |  |  | MonoBoolean godot_icall_Dictionary_TryGetValue(Dictionary *ptr, MonoObject *key, MonoObject **value) { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 	Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	if (ret == nullptr) { | 
					
						
							|  |  |  | 		*value = nullptr; | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	*value = GDMonoMarshal::variant_to_mono_object(ret); | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-28 20:01:54 +01:00
										 |  |  | MonoBoolean godot_icall_Dictionary_TryGetValue_Generic(Dictionary *ptr, MonoObject *key, MonoObject **value, uint32_t type_encoding, GDMonoClass *type_class) { | 
					
						
							| 
									
										
										
										
											2018-09-27 00:11:31 +02:00
										 |  |  | 	Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	if (ret == nullptr) { | 
					
						
							|  |  |  | 		*value = nullptr; | 
					
						
							| 
									
										
										
										
											2018-09-27 00:11:31 +02:00
										 |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	*value = GDMonoMarshal::variant_to_mono_object(ret, ManagedType(type_encoding, type_class)); | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void godot_icall_Dictionary_Generic_GetValueTypeInfo(MonoReflectionType *refltype, uint32_t *type_encoding, GDMonoClass **type_class) { | 
					
						
							|  |  |  | 	MonoType *value_type = mono_reflection_type_get_type(refltype); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	*type_encoding = mono_type_get_type(value_type); | 
					
						
							|  |  |  | 	MonoClass *type_class_raw = mono_class_from_mono_type(value_type); | 
					
						
							|  |  |  | 	*type_class = GDMono::get_singleton()->get_class(type_class_raw); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-18 14:48:10 +02:00
										 |  |  | MonoString *godot_icall_Dictionary_ToString(Dictionary *ptr) { | 
					
						
							|  |  |  | 	return GDMonoMarshal::mono_string_from_godot(Variant(*ptr).operator String()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | void godot_register_collections_icalls() { | 
					
						
							| 
									
										
										
										
											2020-12-05 00:05:01 +01:00
										 |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Ctor", godot_icall_Array_Ctor); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Ctor_MonoArray", godot_icall_Array_Ctor_MonoArray); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Dtor", godot_icall_Array_Dtor); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_At", godot_icall_Array_At); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_At_Generic", godot_icall_Array_At_Generic); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_SetAt", godot_icall_Array_SetAt); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Count", godot_icall_Array_Count); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Add", godot_icall_Array_Add); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Clear", godot_icall_Array_Clear); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Concatenate", godot_icall_Array_Concatenate); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Contains", godot_icall_Array_Contains); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_CopyTo", godot_icall_Array_CopyTo); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Duplicate", godot_icall_Array_Duplicate); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_IndexOf", godot_icall_Array_IndexOf); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Insert", godot_icall_Array_Insert); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Remove", godot_icall_Array_Remove); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_RemoveAt", godot_icall_Array_RemoveAt); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Resize", godot_icall_Array_Resize); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Shuffle", godot_icall_Array_Shuffle); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_Generic_GetElementTypeInfo", godot_icall_Array_Generic_GetElementTypeInfo); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Array::godot_icall_Array_ToString", godot_icall_Array_ToString); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Ctor", godot_icall_Dictionary_Ctor); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Dtor", godot_icall_Dictionary_Dtor); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_GetValue", godot_icall_Dictionary_GetValue); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_GetValue_Generic", godot_icall_Dictionary_GetValue_Generic); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_SetValue", godot_icall_Dictionary_SetValue); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Keys", godot_icall_Dictionary_Keys); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Values", godot_icall_Dictionary_Values); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Count", godot_icall_Dictionary_Count); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Add", godot_icall_Dictionary_Add); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Clear", godot_icall_Dictionary_Clear); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Contains", godot_icall_Dictionary_Contains); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_ContainsKey", godot_icall_Dictionary_ContainsKey); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Duplicate", godot_icall_Dictionary_Duplicate); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_RemoveKey", godot_icall_Dictionary_RemoveKey); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Remove", godot_icall_Dictionary_Remove); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_TryGetValue", godot_icall_Dictionary_TryGetValue); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_TryGetValue_Generic", godot_icall_Dictionary_TryGetValue_Generic); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Generic_GetValueTypeInfo", godot_icall_Dictionary_Generic_GetValueTypeInfo); | 
					
						
							|  |  |  | 	GDMonoUtils::add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_ToString", godot_icall_Dictionary_ToString); | 
					
						
							| 
									
										
										
										
											2018-07-18 23:07:57 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-09-04 05:40:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif // MONO_GLUE_ENABLED
 |