Add C#-only types for Variant value storage from 0cb049167b

This commit is contained in:
2023-08-16 22:27:03 +02:00
parent 0cb049167b
commit dd8e05ed49
+20
View File
@@ -2933,10 +2933,30 @@ Variant Variant::NewValue(const StringAnsiView& typeName)
break;
}
}
#if USE_CSHARP
else if (const auto mclass = Scripting::FindClass(typeName))
{
// Fallback to C#-only types
if (mclass->IsEnum())
{
v.SetType(VariantType(VariantType::Enum, typeName));
v.AsUint64 = 0;
}
else if (mclass->IsValueType())
{
v.SetType(VariantType(VariantType::Structure, typeName));
}
else
{
v.SetType(VariantType(VariantType::ManagedObject, typeName));
}
}
#endif
else if (typeName.HasChars())
{
LOG(Warning, "Missing scripting type \'{0}\'", String(typeName));
}
v.Inline(); // Wrap in-built types
return MoveTemp(v);
}