Skip to content

Commit

Permalink
Fix hint_string for C# enum arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
raulsntos committed Oct 15, 2021
1 parent f6784e1 commit 9778987
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions modules/mono/mono_gd/gd_mono_marshal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,39 +107,42 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) {

case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
MonoArrayType *array_type = mono_type_get_array_type(p_type.type_class->get_mono_type());
MonoClass *elem_class = mono_class_get_element_class(p_type.type_class->get_mono_ptr());

if (array_type->eklass == CACHED_CLASS_RAW(MonoObject))
if (elem_class == CACHED_CLASS_RAW(MonoObject))
return Variant::ARRAY;

if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
if (elem_class == CACHED_CLASS_RAW(uint8_t))
return Variant::POOL_BYTE_ARRAY;

if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
if (elem_class == CACHED_CLASS_RAW(int32_t))
return Variant::POOL_INT_ARRAY;

if (array_type->eklass == REAL_T_MONOCLASS)
if (elem_class == REAL_T_MONOCLASS)
return Variant::POOL_REAL_ARRAY;

if (array_type->eklass == CACHED_CLASS_RAW(String))
if (elem_class == CACHED_CLASS_RAW(String))
return Variant::POOL_STRING_ARRAY;

if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
if (elem_class == CACHED_CLASS_RAW(Vector2))
return Variant::POOL_VECTOR2_ARRAY;

if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
if (elem_class == CACHED_CLASS_RAW(Vector3))
return Variant::POOL_VECTOR3_ARRAY;

if (array_type->eklass == CACHED_CLASS_RAW(Color))
if (elem_class == CACHED_CLASS_RAW(Color))
return Variant::POOL_COLOR_ARRAY;

if (array_type->eklass == CACHED_CLASS_RAW(NodePath))
if (elem_class == CACHED_CLASS_RAW(NodePath))
return Variant::ARRAY;

if (array_type->eklass == CACHED_CLASS_RAW(RID))
if (elem_class == CACHED_CLASS_RAW(RID))
return Variant::ARRAY;

GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
if (mono_class_is_enum(elem_class))
return Variant::ARRAY;

GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(elem_class);
if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class))
return Variant::ARRAY;
} break;
Expand Down Expand Up @@ -232,9 +235,8 @@ bool try_get_array_element_type(const ManagedType &p_array_type, ManagedType &r_
switch (p_array_type.type_encoding) {
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
MonoArrayType *array_type = mono_type_get_array_type(p_array_type.type_class->get_mono_type());
GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
r_elem_type = ManagedType::from_class(array_type_class);
MonoClass *elem_class = mono_class_get_element_class(p_array_type.type_class->get_mono_ptr());
r_elem_type = ManagedType::from_class(elem_class);
return true;
} break;
case MONO_TYPE_GENERICINST: {
Expand Down

0 comments on commit 9778987

Please sign in to comment.