diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-06-03 17:28:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-03 17:28:12 +0200 |
commit | 027c38e97fec19999ffedc05c797045ea5e4b8d8 (patch) | |
tree | 80bfd0929fd0e83c7dbd88aa6fc7c6b574eb5658 /modules/mono/csharp_script.cpp | |
parent | 361a401fbb1d35206f594be86dd4f5a1010c763a (diff) | |
parent | 329818f20b455bd5026878ee4ed15df4d50abc62 (diff) |
Merge pull request #59327 from raulsntos/csharp-flag-enums
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r-- | modules/mono/csharp_script.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index bee4e0e1fb..622838b308 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2807,7 +2807,8 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage GD_MONO_ASSERT_THREAD_ATTACHED; if (p_variant_type == Variant::INT && p_type.type_encoding == MONO_TYPE_VALUETYPE && mono_class_is_enum(p_type.type_class->get_mono_ptr())) { - r_hint = PROPERTY_HINT_ENUM; + MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), p_type.type_class->get_mono_type()); + r_hint = GDMonoUtils::Marshal::type_has_flags_attribute(reftype) ? PROPERTY_HINT_FLAGS : PROPERTY_HINT_ENUM; Vector<MonoClassField *> fields = p_type.type_class->get_enum_fields(); @@ -2844,7 +2845,8 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage uint64_t val = GDMonoUtils::unbox_enum_value(val_obj, enum_basetype, r_error); ERR_FAIL_COND_V_MSG(r_error, -1, "Failed to unbox '" + enum_field_name + "' constant enum value."); - if (val != (unsigned int)i) { + unsigned int expected_val = r_hint == PROPERTY_HINT_FLAGS ? 1 << i : i; + if (val != expected_val) { uses_default_values = false; } |