diff --git a/Source/Engine/Core/Types/StringView.cpp b/Source/Engine/Core/Types/StringView.cpp
index 39404179b..24a3978f8 100644
--- a/Source/Engine/Core/Types/StringView.cpp
+++ b/Source/Engine/Core/Types/StringView.cpp
@@ -35,7 +35,7 @@ StringView StringView::Left(int32 count) const
StringView StringView::Right(int32 count) const
{
const int32 countClamped = count < 0 ? 0 : count < Length() ? count : Length();
- return StringView(**this + Length() - countClamped);
+ return StringView(**this + countClamped, Length() - countClamped);
}
StringView StringView::Substring(int32 startIndex) const
diff --git a/Source/Engine/Core/Types/Variant.cpp b/Source/Engine/Core/Types/Variant.cpp
index 3dd403d5f..3aea34368 100644
--- a/Source/Engine/Core/Types/Variant.cpp
+++ b/Source/Engine/Core/Types/Variant.cpp
@@ -2449,7 +2449,9 @@ void Variant::SetType(const VariantType& type)
case VariantType::Structure:
AllocStructure();
break;
- default: ;
+ default:
+ AsUint64 = 0;
+ break;
}
}
@@ -3065,6 +3067,69 @@ void Variant::DeleteValue()
SetType(VariantType(VariantType::Null));
}
+Variant Variant::Parse(const StringView& text, const VariantType& type)
+{
+ Variant result;
+ result.SetType(type);
+ if (text.IsEmpty())
+ return result;
+ if (type != VariantType())
+ {
+ switch (type.Type)
+ {
+ case VariantType::Bool:
+ if (text == TEXT("1") || text.Compare(StringView(TEXT("true"), 4), StringSearchCase::IgnoreCase) == 0)
+ result.AsBool = true;
+ break;
+ case VariantType::Int16:
+ StringUtils::Parse(text.Get(), &result.AsInt16);
+ break;
+ case VariantType::Uint16:
+ StringUtils::Parse(text.Get(), &result.AsUint16);
+ break;
+ case VariantType::Int:
+ StringUtils::Parse(text.Get(), &result.AsInt);
+ break;
+ case VariantType::Uint:
+ StringUtils::Parse(text.Get(), &result.AsUint);
+ break;
+ case VariantType::Int64:
+ StringUtils::Parse(text.Get(), &result.AsInt64);
+ break;
+ case VariantType::Uint64:
+ case VariantType::Enum:
+ StringUtils::Parse(text.Get(), &result.AsUint64);
+ break;
+ case VariantType::Float:
+ StringUtils::Parse(text.Get(), &result.AsFloat);
+ break;
+ case VariantType::Double:
+ StringUtils::Parse(text.Get(), &result.AsFloat);
+ result.AsDouble = (float)result.AsFloat;
+ break;
+ case VariantType::String:
+ result.SetString(text);
+ default:
+ break;
+ }
+ }
+ else
+ {
+ // Parse as number
+ int32 valueInt;
+ if (!StringUtils::Parse(text.Get(), text.Length(), &valueInt))
+ {
+ result = valueInt;
+ }
+ else
+ {
+ // Fallback to string
+ result.SetString(text);
+ }
+ }
+ return result;
+}
+
bool Variant::CanCast(const Variant& v, const VariantType& to)
{
if (v.Type == to)
diff --git a/Source/Engine/Core/Types/Variant.h b/Source/Engine/Core/Types/Variant.h
index fa7f748fe..cd05fc038 100644
--- a/Source/Engine/Core/Types/Variant.h
+++ b/Source/Engine/Core/Types/Variant.h
@@ -381,6 +381,9 @@ public:
// Frees the object or data owned by this Variant container (eg. structure or object).
void DeleteValue();
+ // Parses the text into the Variant value. Allows to specify explicit value type.
+ static Variant Parse(const StringView& text, const VariantType& type = VariantType());
+
FORCE_INLINE Variant Cast(const VariantType& to) const
{
return Cast(*this, to);
diff --git a/Source/Engine/Scripting/ManagedCLR/MClass.h b/Source/Engine/Scripting/ManagedCLR/MClass.h
index 258ea9b08..7d25c4069 100644
--- a/Source/Engine/Scripting/ManagedCLR/MClass.h
+++ b/Source/Engine/Scripting/ManagedCLR/MClass.h
@@ -305,9 +305,9 @@ public:
///
/// Checks if class has an attribute of the specified type.
///
- /// The attribute class to check.
+ /// The attribute class to check.
/// True if has attribute of that class type, otherwise false.
- bool HasAttribute(const MClass* monoClass) const;
+ bool HasAttribute(const MClass* klass) const;
///
/// Checks if class has an attribute of any type.
@@ -318,9 +318,9 @@ public:
///
/// Returns an instance of an attribute of the specified type. Returns null if the class doesn't have such an attribute.
///
- /// The attribute class to take.
+ /// The attribute class to take.
/// The attribute object.
- MObject* GetAttribute(const MClass* monoClass) const;
+ MObject* GetAttribute(const MClass* klass) const;
///
/// Returns an instance of all attributes connected with given class. Returns null if the class doesn't have any attributes.
diff --git a/Source/Engine/Scripting/ManagedCLR/MEvent.h b/Source/Engine/Scripting/ManagedCLR/MEvent.h
index 03779344c..5692f3dc6 100644
--- a/Source/Engine/Scripting/ManagedCLR/MEvent.h
+++ b/Source/Engine/Scripting/ManagedCLR/MEvent.h
@@ -99,9 +99,9 @@ public:
///
/// Checks if event has an attribute of the specified type.
///
- /// The attribute class to check.
+ /// The attribute class to check.
/// True if has attribute of that class type, otherwise false.
- bool HasAttribute(MClass* monoClass) const;
+ bool HasAttribute(const MClass* klass) const;
///
/// Checks if event has an attribute of any type.
@@ -112,9 +112,9 @@ public:
///
/// Returns an instance of an attribute of the specified type. Returns null if the event doesn't have such an attribute.
///
- /// The attribute class to take.
+ /// The attribute class to take.
/// The attribute object.
- MObject* GetAttribute(MClass* monoClass) const;
+ MObject* GetAttribute(const MClass* klass) const;
///
/// Returns an instance of all attributes connected with given event. Returns null if the event doesn't have any attributes.
diff --git a/Source/Engine/Scripting/ManagedCLR/MField.h b/Source/Engine/Scripting/ManagedCLR/MField.h
index 8d4eb6a12..5475f4535 100644
--- a/Source/Engine/Scripting/ManagedCLR/MField.h
+++ b/Source/Engine/Scripting/ManagedCLR/MField.h
@@ -134,9 +134,9 @@ public:
///
/// Checks if field has an attribute of the specified type.
///
- /// The attribute class to check.
+ /// The attribute class to check.
/// True if has attribute of that class type, otherwise false.
- bool HasAttribute(MClass* monoClass) const;
+ bool HasAttribute(const MClass* klass) const;
///
/// Checks if field has an attribute of any type.
@@ -147,9 +147,9 @@ public:
///
/// Returns an instance of an attribute of the specified type. Returns null if the field doesn't have such an attribute.
///
- /// The attribute class to take.
+ /// The attribute class to take.
/// The attribute object.
- MObject* GetAttribute(MClass* monoClass) const;
+ MObject* GetAttribute(const MClass* klass) const;
///
/// Returns an instance of all attributes connected with given field. Returns null if the field doesn't have any attributes.
diff --git a/Source/Engine/Scripting/ManagedCLR/MMethod.h b/Source/Engine/Scripting/ManagedCLR/MMethod.h
index 249c71e4e..f2b127871 100644
--- a/Source/Engine/Scripting/ManagedCLR/MMethod.h
+++ b/Source/Engine/Scripting/ManagedCLR/MMethod.h
@@ -175,9 +175,9 @@ public:
///
/// Checks if method has an attribute of the specified type.
///
- /// The attribute class to check.
+ /// The attribute class to check.
/// True if has attribute of that class type, otherwise false.
- bool HasAttribute(MClass* monoClass) const;
+ bool HasAttribute(const MClass* klass) const;
///
/// Checks if method has an attribute of any type.
@@ -188,9 +188,9 @@ public:
///
/// Returns an instance of an attribute of the specified type. Returns null if the method doesn't have such an attribute.
///
- /// The attribute Class to take.
+ /// The attribute Class to take.
/// The attribute object.
- MObject* GetAttribute(MClass* monoClass) const;
+ MObject* GetAttribute(const MClass* klass) const;
///
/// Returns an instance of all attributes connected with given method. Returns null if the method doesn't have any attributes.
diff --git a/Source/Engine/Scripting/ManagedCLR/MProperty.h b/Source/Engine/Scripting/ManagedCLR/MProperty.h
index bd3bebddf..a9ce918f8 100644
--- a/Source/Engine/Scripting/ManagedCLR/MProperty.h
+++ b/Source/Engine/Scripting/ManagedCLR/MProperty.h
@@ -111,9 +111,9 @@ public:
///
/// Checks if property has an attribute of the specified type.
///
- /// The attribute class to check.
+ /// The attribute class to check.
/// True if has attribute of that class type, otherwise false.
- bool HasAttribute(MClass* monoClass) const;
+ bool HasAttribute(const MClass* klass) const;
///
/// Checks if property has an attribute of any type.
@@ -124,9 +124,9 @@ public:
///
/// Returns an instance of an attribute of the specified type. Returns null if the property doesn't have such an attribute.
///
- /// The attribute class to take.
+ /// The attribute class to take.
/// The attribute object.
- MObject* GetAttribute(MClass* monoClass) const;
+ MObject* GetAttribute(const MClass* klass) const;
///
/// Returns an instance of all attributes connected with given property. Returns null if the property doesn't have any attributes.
diff --git a/Source/Engine/Scripting/Runtime/DotNet.cpp b/Source/Engine/Scripting/Runtime/DotNet.cpp
index 25213ec46..26b011855 100644
--- a/Source/Engine/Scripting/Runtime/DotNet.cpp
+++ b/Source/Engine/Scripting/Runtime/DotNet.cpp
@@ -1119,9 +1119,9 @@ const Array& MClass::GetInterfaces() const
return _interfaces;
}
-bool MClass::HasAttribute(const MClass* monoClass) const
+bool MClass::HasAttribute(const MClass* klass) const
{
- return GetCustomAttribute(this, monoClass) != nullptr;
+ return GetCustomAttribute(this, klass) != nullptr;
}
bool MClass::HasAttribute() const
@@ -1129,9 +1129,9 @@ bool MClass::HasAttribute() const
return !GetAttributes().IsEmpty();
}
-MObject* MClass::GetAttribute(const MClass* monoClass) const
+MObject* MClass::GetAttribute(const MClass* klass) const
{
- return (MObject*)GetCustomAttribute(this, monoClass);
+ return (MObject*)GetCustomAttribute(this, klass);
}
const Array& MClass::GetAttributes() const
@@ -1185,7 +1185,7 @@ MMethod* MEvent::GetRemoveMethod() const
return nullptr; // TODO: implement MEvent in .NET
}
-bool MEvent::HasAttribute(MClass* monoClass) const
+bool MEvent::HasAttribute(const MClass* klass) const
{
return false; // TODO: implement MEvent in .NET
}
@@ -1195,7 +1195,7 @@ bool MEvent::HasAttribute() const
return false; // TODO: implement MEvent in .NET
}
-MObject* MEvent::GetAttribute(MClass* monoClass) const
+MObject* MEvent::GetAttribute(const MClass* klass) const
{
return nullptr; // TODO: implement MEvent in .NET
}
@@ -1307,7 +1307,7 @@ void MField::SetValue(MObject* instance, void* value) const
CallStaticMethod(FieldSetValuePtr, instance, _handle, value);
}
-bool MField::HasAttribute(MClass* monoClass) const
+bool MField::HasAttribute(const MClass* klass) const
{
// TODO: implement MField attributes in .NET
return false;
@@ -1319,7 +1319,7 @@ bool MField::HasAttribute() const
return false;
}
-MObject* MField::GetAttribute(MClass* monoClass) const
+MObject* MField::GetAttribute(const MClass* klass) const
{
// TODO: implement MField attributes in .NET
return nullptr;
@@ -1469,7 +1469,7 @@ bool MMethod::GetParameterIsOut(int32 paramIdx) const
return CallStaticMethod(GetMethodParameterIsOutPtr, _handle, paramIdx);
}
-bool MMethod::HasAttribute(MClass* monoClass) const
+bool MMethod::HasAttribute(const MClass* klass) const
{
// TODO: implement MMethod attributes in .NET
return false;
@@ -1481,7 +1481,7 @@ bool MMethod::HasAttribute() const
return false;
}
-MObject* MMethod::GetAttribute(MClass* monoClass) const
+MObject* MMethod::GetAttribute(const MClass* klass) const
{
// TODO: implement MMethod attributes in .NET
return nullptr;
@@ -1546,7 +1546,7 @@ void MProperty::SetValue(MObject* instance, void* value, MObject** exception) co
_setMethod->Invoke(instance, params, exception);
}
-bool MProperty::HasAttribute(MClass* monoClass) const
+bool MProperty::HasAttribute(const MClass* klass) const
{
// TODO: implement MProperty attributes in .NET
return false;
@@ -1558,7 +1558,7 @@ bool MProperty::HasAttribute() const
return false;
}
-MObject* MProperty::GetAttribute(MClass* monoClass) const
+MObject* MProperty::GetAttribute(const MClass* klass) const
{
// TODO: implement MProperty attributes in .NET
return nullptr;
diff --git a/Source/Engine/Scripting/Runtime/Mono.cpp b/Source/Engine/Scripting/Runtime/Mono.cpp
index 40fa8f4bf..351e1569b 100644
--- a/Source/Engine/Scripting/Runtime/Mono.cpp
+++ b/Source/Engine/Scripting/Runtime/Mono.cpp
@@ -1517,10 +1517,10 @@ const Array& MClass::GetInterfaces() const
return _interfaces;
}
-bool MClass::HasAttribute(const MClass* monoClass) const
+bool MClass::HasAttribute(const MClass* klass) const
{
MonoCustomAttrInfo* attrInfo = GET_CUSTOM_ATTR();
- return attrInfo != nullptr && mono_custom_attrs_has_attr(attrInfo, monoClass->GetNative()) != 0;
+ return attrInfo != nullptr && mono_custom_attrs_has_attr(attrInfo, klass->GetNative()) != 0;
}
bool MClass::HasAttribute() const
@@ -1529,10 +1529,10 @@ bool MClass::HasAttribute() const
return attrInfo && attrInfo->num_attrs > 0;
}
-MObject* MClass::GetAttribute(const MClass* monoClass) const
+MObject* MClass::GetAttribute(const MClass* klass) const
{
MonoCustomAttrInfo* attrInfo = GET_CUSTOM_ATTR();
- return attrInfo ? mono_custom_attrs_get_attr(attrInfo, monoClass->GetNative()) : nullptr;
+ return attrInfo ? mono_custom_attrs_get_attr(attrInfo, klass->GetNative()) : nullptr;
}
const Array& MClass::GetAttributes() const
@@ -1618,14 +1618,14 @@ MMethod* MEvent::GetRemoveMethod() const
return _removeMethod;
}
-bool MEvent::HasAttribute(MClass* monoClass) const
+bool MEvent::HasAttribute(const MClass* klass) const
{
MonoClass* parentClass = mono_event_get_parent(_monoEvent);
MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_event(parentClass, _monoEvent);
if (attrInfo == nullptr)
return false;
- const bool hasAttr = mono_custom_attrs_has_attr(attrInfo, monoClass->GetNative()) != 0;
+ const bool hasAttr = mono_custom_attrs_has_attr(attrInfo, klass->GetNative()) != 0;
mono_custom_attrs_free(attrInfo);
return hasAttr;
}
@@ -1646,14 +1646,14 @@ bool MEvent::HasAttribute() const
return false;
}
-MObject* MEvent::GetAttribute(MClass* monoClass) const
+MObject* MEvent::GetAttribute(const MClass* klass) const
{
MonoClass* parentClass = mono_event_get_parent(_monoEvent);
MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_event(parentClass, _monoEvent);
if (attrInfo == nullptr)
return nullptr;
- MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, monoClass->GetNative());
+ MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, klass->GetNative());
mono_custom_attrs_free(attrInfo);
return foundAttr;
}
@@ -1771,14 +1771,14 @@ void MField::SetValue(MObject* instance, void* value) const
mono_field_set_value(instance, _monoField, value);
}
-bool MField::HasAttribute(MClass* monoClass) const
+bool MField::HasAttribute(const MClass* klass) const
{
MonoClass* parentClass = mono_field_get_parent(_monoField);
MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_field(parentClass, _monoField);
if (attrInfo == nullptr)
return false;
- const bool hasAttr = mono_custom_attrs_has_attr(attrInfo, monoClass->GetNative()) != 0;
+ const bool hasAttr = mono_custom_attrs_has_attr(attrInfo, klass->GetNative()) != 0;
mono_custom_attrs_free(attrInfo);
return hasAttr;
}
@@ -1799,14 +1799,14 @@ bool MField::HasAttribute() const
return false;
}
-MObject* MField::GetAttribute(MClass* monoClass) const
+MObject* MField::GetAttribute(const MClass* klass) const
{
MonoClass* parentClass = mono_field_get_parent(_monoField);
MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_field(parentClass, _monoField);
if (attrInfo == nullptr)
return nullptr;
- MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, monoClass->GetNative());
+ MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, klass->GetNative());
mono_custom_attrs_free(attrInfo);
return foundAttr;
}
@@ -1947,13 +1947,13 @@ bool MMethod::GetParameterIsOut(int32 paramIdx) const
return mono_signature_param_is_out(sig, paramIdx) != 0;
}
-bool MMethod::HasAttribute(MClass* monoClass) const
+bool MMethod::HasAttribute(const MClass* klass) const
{
MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_method(_monoMethod);
if (attrInfo == nullptr)
return false;
- const bool hasAttr = mono_custom_attrs_has_attr(attrInfo, monoClass->GetNative()) != 0;
+ const bool hasAttr = mono_custom_attrs_has_attr(attrInfo, klass->GetNative()) != 0;
mono_custom_attrs_free(attrInfo);
return hasAttr;
}
@@ -1973,13 +1973,13 @@ bool MMethod::HasAttribute() const
return false;
}
-MObject* MMethod::GetAttribute(MClass* monoClass) const
+MObject* MMethod::GetAttribute(const MClass* klass) const
{
MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_method(_monoMethod);
if (attrInfo == nullptr)
return nullptr;
- MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, monoClass->GetNative());
+ MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, klass->GetNative());
mono_custom_attrs_free(attrInfo);
return foundAttr;
}
@@ -2074,14 +2074,14 @@ void MProperty::SetValue(MObject* instance, void* value, MObject** exception) co
mono_property_set_value(_monoProperty, instance, params, exception);
}
-bool MProperty::HasAttribute(MClass* monoClass) const
+bool MProperty::HasAttribute(const MClass* klass) const
{
MonoClass* parentClass = mono_property_get_parent(_monoProperty);
MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_property(parentClass, _monoProperty);
if (attrInfo == nullptr)
return false;
- const bool hasAttr = mono_custom_attrs_has_attr(attrInfo, monoClass->GetNative()) != 0;
+ const bool hasAttr = mono_custom_attrs_has_attr(attrInfo, klass->GetNative()) != 0;
mono_custom_attrs_free(attrInfo);
return hasAttr;
}
@@ -2102,14 +2102,14 @@ bool MProperty::HasAttribute() const
return false;
}
-MObject* MProperty::GetAttribute(MClass* monoClass) const
+MObject* MProperty::GetAttribute(const MClass* klass) const
{
MonoClass* parentClass = mono_property_get_parent(_monoProperty);
MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_property(parentClass, _monoProperty);
if (attrInfo == nullptr)
return nullptr;
- MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, monoClass->GetNative());
+ MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, klass->GetNative());
mono_custom_attrs_free(attrInfo);
return foundAttr;
}
diff --git a/Source/Engine/Scripting/Runtime/None.cpp b/Source/Engine/Scripting/Runtime/None.cpp
index f4cdd92e2..8731ed00d 100644
--- a/Source/Engine/Scripting/Runtime/None.cpp
+++ b/Source/Engine/Scripting/Runtime/None.cpp
@@ -388,7 +388,7 @@ const Array& MClass::GetProperties() const
return _properties;
}
-bool MClass::HasAttribute(const MClass* monoClass) const
+bool MClass::HasAttribute(const MClass* klass) const
{
return false;
}
@@ -398,7 +398,7 @@ bool MClass::HasAttribute() const
return false;
}
-MObject* MClass::GetAttribute(const MClass* monoClass) const
+MObject* MClass::GetAttribute(const MClass* klass) const
{
return nullptr;
}
@@ -430,7 +430,7 @@ MMethod* MEvent::GetRemoveMethod() const
return _removeMethod;
}
-bool MEvent::HasAttribute(MClass* monoClass) const
+bool MEvent::HasAttribute(const MClass* klass) const
{
return false;
}
@@ -440,7 +440,7 @@ bool MEvent::HasAttribute() const
return false;
}
-MObject* MEvent::GetAttribute(MClass* monoClass) const
+MObject* MEvent::GetAttribute(const MClass* klass) const
{
return nullptr;
}
@@ -482,7 +482,7 @@ void MField::SetValue(MObject* instance, void* value) const
{
}
-bool MField::HasAttribute(MClass* monoClass) const
+bool MField::HasAttribute(const MClass* klass) const
{
return false;
}
@@ -492,7 +492,7 @@ bool MField::HasAttribute() const
return false;
}
-MObject* MField::GetAttribute(MClass* monoClass) const
+MObject* MField::GetAttribute(const MClass* klass) const
{
return nullptr;
}
@@ -537,7 +537,7 @@ bool MMethod::GetParameterIsOut(int32 paramIdx) const
return false;
}
-bool MMethod::HasAttribute(MClass* monoClass) const
+bool MMethod::HasAttribute(const MClass* klass) const
{
return false;
}
@@ -547,7 +547,7 @@ bool MMethod::HasAttribute() const
return false;
}
-MObject* MMethod::GetAttribute(MClass* monoClass) const
+MObject* MMethod::GetAttribute(const MClass* klass) const
{
return nullptr;
}
@@ -584,7 +584,7 @@ void MProperty::SetValue(MObject* instance, void* value, MObject** exception) co
{
}
-bool MProperty::HasAttribute(MClass* monoClass) const
+bool MProperty::HasAttribute(const MClass* klass) const
{
return false;
}
@@ -594,7 +594,7 @@ bool MProperty::HasAttribute() const
return false;
}
-MObject* MProperty::GetAttribute(MClass* monoClass) const
+MObject* MProperty::GetAttribute(const MClass* klass) const
{
return nullptr;
}
diff --git a/Source/Engine/Scripting/ScriptingObject.cpp b/Source/Engine/Scripting/ScriptingObject.cpp
index dfb89fadc..7f9d92369 100644
--- a/Source/Engine/Scripting/ScriptingObject.cpp
+++ b/Source/Engine/Scripting/ScriptingObject.cpp
@@ -277,10 +277,10 @@ void ScriptingObject::ChangeID(const Guid& newId)
// Update managed instance
const auto managedInstance = GetManagedInstance();
- const auto monoClass = GetClass();
- if (managedInstance && monoClass)
+ const auto klass = GetClass();
+ if (managedInstance && klass)
{
- const MField* monoIdField = monoClass->GetField(ScriptingObject_id);
+ const MField* monoIdField = klass->GetField(ScriptingObject_id);
if (monoIdField)
monoIdField->SetValue(managedInstance, &_id);
}
@@ -344,10 +344,10 @@ bool ScriptingObject::CreateManaged()
#endif
{
// Other thread already created the object before
- if (const auto monoClass = GetClass())
+ if (const auto klass = GetClass())
{
// Reset managed to unmanaged pointer
- MCore::ScriptingObject::SetInternalValues(monoClass, managedInstance, nullptr, nullptr);
+ MCore::ScriptingObject::SetInternalValues(klass, managedInstance, nullptr, nullptr);
}
MCore::GCHandle::Free(handle);
return true;
@@ -366,17 +366,17 @@ bool ScriptingObject::CreateManaged()
MObject* ScriptingObject::CreateManagedInternal()
{
// Get class
- MClass* monoClass = GetClass();
- if (monoClass == nullptr)
+ MClass* klass = GetClass();
+ if (klass == nullptr)
{
LOG(Warning, "Missing managed class for object with id {0}", GetID());
return nullptr;
}
- MObject* managedInstance = MCore::ScriptingObject::CreateScriptingObject(monoClass, this, &_id);
+ MObject* managedInstance = MCore::ScriptingObject::CreateScriptingObject(klass, this, &_id);
if (managedInstance == nullptr)
{
- LOG(Warning, "Failed to create new instance of the object of type {0}", String(monoClass->GetFullName()));
+ LOG(Warning, "Failed to create new instance of the object of type {0}", String(klass->GetFullName()));
}
return managedInstance;
@@ -393,9 +393,9 @@ void ScriptingObject::DestroyManaged()
// Reset managed to unmanaged pointer
if (managedInstance)
{
- if (const auto monoClass = GetClass())
+ if (const auto klass = GetClass())
{
- MCore::ScriptingObject::SetInternalValues(monoClass, managedInstance, nullptr, nullptr);
+ MCore::ScriptingObject::SetInternalValues(klass, managedInstance, nullptr, nullptr);
}
}
@@ -522,10 +522,10 @@ bool ManagedScriptingObject::CreateManaged()
#endif
{
// Other thread already created the object before
- if (const auto monoClass = GetClass())
+ if (const auto klass = GetClass())
{
// Reset managed to unmanaged pointer
- MCore::ScriptingObject::SetInternalValues(monoClass, managedInstance, nullptr, nullptr);
+ MCore::ScriptingObject::SetInternalValues(klass, managedInstance, nullptr, nullptr);
}
MCore::GCHandle::Free(handle);
return true;
@@ -684,9 +684,9 @@ DEFINE_INTERNAL_CALL(void) ObjectInternal_ManagedInstanceCreated(MObject* manage
actor->SetName(String(typeClass->GetName()));
}
- MClass* monoClass = obj->GetClass();
+ MClass* klass = obj->GetClass();
const Guid id = obj->GetID();
- MCore::ScriptingObject::SetInternalValues(monoClass, managedInstance, obj, &id);
+ MCore::ScriptingObject::SetInternalValues(klass, managedInstance, obj, &id);
// Register object
if (!obj->IsRegistered())