Dictionary mono_object_to_Dictionary(MonoObject *p_dict) { Dictionary ret; GDMonoUtils::MarshalUtils_DictToArrays dict_to_arrays = CACHED_METHOD_THUNK(MarshalUtils, DictionaryToArrays); MonoArray *keys = NULL; MonoArray *values = NULL; MonoObject *ex = NULL; dict_to_arrays(p_dict, &keys, &values, &ex); if (ex) { mono_print_unhandled_exception(ex); ERR_FAIL_V(Dictionary()); } int length = mono_array_length(keys); for (int i = 0; i < length; i++) { MonoObject *key_obj = mono_array_get(keys, MonoObject *, i); MonoObject *value_obj = mono_array_get(values, MonoObject *, i); Variant key = key_obj ? mono_object_to_variant(key_obj) : Variant(); Variant value = value_obj ? mono_object_to_variant(value_obj) : Variant(); ret[key] = value; } return ret; }
Array mono_array_to_Array(MonoArray *p_array) { Array ret; int length = mono_array_length(p_array); for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_array, MonoObject *, i); ret.push_back(mono_object_to_variant(elem)); } return ret; }
Array mono_array_to_Array(MonoArray *p_array) { Array ret; if (!p_array) return ret; int length = mono_array_length(p_array); ret.resize(length); for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_array, MonoObject *, i); ret[i] = mono_object_to_variant(elem); } return ret; }
Variant mono_object_to_variant(MonoObject *p_obj) { if (!p_obj) return Variant(); GDMonoClass *tclass = GDMono::get_singleton()->get_class(mono_object_get_class(p_obj)); ERR_FAIL_COND_V(!tclass, Variant()); MonoType *raw_type = tclass->get_raw_type(tclass); ManagedType type; type.type_encoding = mono_type_get_type(raw_type); type.type_class = tclass; return mono_object_to_variant(p_obj, type); }