From 70228ca3552f57f5371e229d92f3d1e307ecbd2a Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 17 Aug 2023 15:29:11 +0200 Subject: [PATCH] Various improvements to Variant --- Source/Engine/Core/Types/Variant.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Source/Engine/Core/Types/Variant.cpp b/Source/Engine/Core/Types/Variant.cpp index f1c27fe5c..0012913a3 100644 --- a/Source/Engine/Core/Types/Variant.cpp +++ b/Source/Engine/Core/Types/Variant.cpp @@ -124,13 +124,6 @@ VariantType::VariantType(Types type, MClass* klass) VariantType::VariantType(const StringAnsiView& typeName) { - // Check case for array - if (typeName.EndsWith(StringAnsiView("[]"), StringSearchCase::CaseSensitive)) - { - new(this) VariantType(Array, StringAnsiView(typeName.Get(), typeName.Length() - 2)); - return; - } - // Try using in-built type for (uint32 i = 0; i < ARRAY_COUNT(InBuiltTypesTypeNames); i++) { @@ -141,6 +134,13 @@ VariantType::VariantType(const StringAnsiView& typeName) } } + // Check case for array + if (typeName.EndsWith(StringAnsiView("[]"), StringSearchCase::CaseSensitive)) + { + new(this) VariantType(Array, StringAnsiView(typeName.Get(), typeName.Length() - 2)); + return; + } + // Try using scripting type const ScriptingTypeHandle typeHandle = Scripting::FindScriptingType(typeName); if (typeHandle) @@ -166,7 +166,10 @@ VariantType::VariantType(const StringAnsiView& typeName) #if USE_CSHARP if (const auto mclass = Scripting::FindClass(typeName)) { - new(this) VariantType(ManagedObject, typeName); + if (mclass->IsEnum()) + new(this) VariantType(Enum, typeName); + else + new(this) VariantType(ManagedObject, typeName); return; } #endif @@ -2922,6 +2925,7 @@ Variant Variant::NewValue(const StringAnsiView& typeName) switch (type.Type) { case ScriptingTypes::Script: + case ScriptingTypes::Class: v.SetType(VariantType(VariantType::Object, typeName)); break; case ScriptingTypes::Structure: