Fix naming convention in scripting backend for klass

This commit is contained in:
Wojtek Figat
2024-09-22 12:30:34 +02:00
parent da5570e89f
commit aba46cb2c6
9 changed files with 77 additions and 77 deletions

View File

@@ -305,9 +305,9 @@ public:
/// <summary>
/// Checks if class has an attribute of the specified type.
/// </summary>
/// <param name="monoClass">The attribute class to check.</param>
/// <param name="klass">The attribute class to check.</param>
/// <returns>True if has attribute of that class type, otherwise false.</returns>
bool HasAttribute(const MClass* monoClass) const;
bool HasAttribute(const MClass* klass) const;
/// <summary>
/// Checks if class has an attribute of any type.
@@ -318,9 +318,9 @@ public:
/// <summary>
/// Returns an instance of an attribute of the specified type. Returns null if the class doesn't have such an attribute.
/// </summary>
/// <param name="monoClass">The attribute class to take.</param>
/// <param name="klass">The attribute class to take.</param>
/// <returns>The attribute object.</returns>
MObject* GetAttribute(const MClass* monoClass) const;
MObject* GetAttribute(const MClass* klass) const;
/// <summary>
/// Returns an instance of all attributes connected with given class. Returns null if the class doesn't have any attributes.

View File

@@ -99,9 +99,9 @@ public:
/// <summary>
/// Checks if event has an attribute of the specified type.
/// </summary>
/// <param name="monoClass">The attribute class to check.</param>
/// <param name="klass">The attribute class to check.</param>
/// <returns>True if has attribute of that class type, otherwise false.</returns>
bool HasAttribute(MClass* monoClass) const;
bool HasAttribute(const MClass* klass) const;
/// <summary>
/// Checks if event has an attribute of any type.
@@ -112,9 +112,9 @@ public:
/// <summary>
/// Returns an instance of an attribute of the specified type. Returns null if the event doesn't have such an attribute.
/// </summary>
/// <param name="monoClass">The attribute class to take.</param>
/// <param name="klass">The attribute class to take.</param>
/// <returns>The attribute object.</returns>
MObject* GetAttribute(MClass* monoClass) const;
MObject* GetAttribute(const MClass* klass) const;
/// <summary>
/// Returns an instance of all attributes connected with given event. Returns null if the event doesn't have any attributes.

View File

@@ -134,9 +134,9 @@ public:
/// <summary>
/// Checks if field has an attribute of the specified type.
/// </summary>
/// <param name="monoClass">The attribute class to check.</param>
/// <param name="klass">The attribute class to check.</param>
/// <returns>True if has attribute of that class type, otherwise false.</returns>
bool HasAttribute(MClass* monoClass) const;
bool HasAttribute(const MClass* klass) const;
/// <summary>
/// Checks if field has an attribute of any type.
@@ -147,9 +147,9 @@ public:
/// <summary>
/// Returns an instance of an attribute of the specified type. Returns null if the field doesn't have such an attribute.
/// </summary>
/// <param name="monoClass">The attribute class to take.</param>
/// <param name="klass">The attribute class to take.</param>
/// <returns>The attribute object.</returns>
MObject* GetAttribute(MClass* monoClass) const;
MObject* GetAttribute(const MClass* klass) const;
/// <summary>
/// Returns an instance of all attributes connected with given field. Returns null if the field doesn't have any attributes.

View File

@@ -175,9 +175,9 @@ public:
/// <summary>
/// Checks if method has an attribute of the specified type.
/// </summary>
/// <param name="monoClass">The attribute class to check.</param>
/// <param name="klass">The attribute class to check.</param>
/// <returns>True if has attribute of that class type, otherwise false.</returns>
bool HasAttribute(MClass* monoClass) const;
bool HasAttribute(const MClass* klass) const;
/// <summary>
/// Checks if method has an attribute of any type.
@@ -188,9 +188,9 @@ public:
/// <summary>
/// Returns an instance of an attribute of the specified type. Returns null if the method doesn't have such an attribute.
/// </summary>
/// <param name="monoClass">The attribute Class to take.</param>
/// <param name="klass">The attribute Class to take.</param>
/// <returns>The attribute object.</returns>
MObject* GetAttribute(MClass* monoClass) const;
MObject* GetAttribute(const MClass* klass) const;
/// <summary>
/// Returns an instance of all attributes connected with given method. Returns null if the method doesn't have any attributes.

View File

@@ -111,9 +111,9 @@ public:
/// <summary>
/// Checks if property has an attribute of the specified type.
/// </summary>
/// <param name="monoClass">The attribute class to check.</param>
/// <param name="klass">The attribute class to check.</param>
/// <returns>True if has attribute of that class type, otherwise false.</returns>
bool HasAttribute(MClass* monoClass) const;
bool HasAttribute(const MClass* klass) const;
/// <summary>
/// Checks if property has an attribute of any type.
@@ -124,9 +124,9 @@ public:
/// <summary>
/// Returns an instance of an attribute of the specified type. Returns null if the property doesn't have such an attribute.
/// </summary>
/// <param name="monoClass">The attribute class to take.</param>
/// <param name="klass">The attribute class to take.</param>
/// <returns>The attribute object.</returns>
MObject* GetAttribute(MClass* monoClass) const;
MObject* GetAttribute(const MClass* klass) const;
/// <summary>
/// Returns an instance of all attributes connected with given property. Returns null if the property doesn't have any attributes.

View File

@@ -1119,9 +1119,9 @@ const Array<MClass*>& 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<MObject*>& 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<void, void*, void*, void*>(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<bool, void*, int>(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;

View File

@@ -1517,10 +1517,10 @@ const Array<MClass*>& 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<MObject*>& 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;
}

View File

@@ -388,7 +388,7 @@ const Array<MProperty*>& 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;
}

View File

@@ -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())