Skip to content

Commit

Permalink
Rename and reorder types in PPropertyValue to the original
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Sep 5, 2024
1 parent 8a42d8c commit b69de6d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 45 deletions.
20 changes: 11 additions & 9 deletions Toshi/Plugins/Include/PPropertyParser/PPropertyValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ class PPROPERTYPARSER_EXPORTS PPropertyValue
Toshi::TManagedPtr<PProperties> &GetPropertiesMP()
{
TASSERT(TYPE_PROPS == m_type);
return *(Toshi::TManagedPtr<PProperties> *)m_valueProps;
Toshi::TManagedPtr<PProperties> value(m_valueProps);
return value;
}
Toshi::TManagedPtr<PPropertyValueArray> &GetPropArrayMP()
{
TASSERT(TYPE_ARRAY == m_type);
return *(Toshi::TManagedPtr<PPropertyValueArray> *)m_valueArray;
Toshi::TManagedPtr<PPropertyValueArray> value(m_valueArray);
return value;
}

public:
Expand All @@ -105,16 +107,16 @@ class PPROPERTYPARSER_EXPORTS PPropertyValue
}

public:
static const Toshi::TClass *TYPE_ARRAY;
static const Toshi::TClass *TYPE_BOOL;
static const Toshi::TClass *TYPE_FLOAT;
static const Toshi::TClass *TYPE_INT;
static const Toshi::TClass *TYPE_PROPNAME;
static const Toshi::TClass *TYPE_PROPS;
static const Toshi::TClass *TYPE_TLSTRING;
static const Toshi::TClass *TYPE_UINT32;
static const Toshi::TClass *TYPE_FLOAT;
static const Toshi::TClass *TYPE_BOOL;
static const Toshi::TClass *TYPE_TPCSTRING;
static const Toshi::TClass *TYPE_TPWSTRING;
static const Toshi::TClass *TYPE_UINT32;
static const Toshi::TClass *TYPE_TLSTRING;
static const Toshi::TClass *TYPE_PROPNAME;
static const Toshi::TClass *TYPE_ARRAY;
static const Toshi::TClass *TYPE_PROPS;
static const Toshi::TClass *TYPE_UNDEF;

private:
Expand Down
95 changes: 59 additions & 36 deletions Toshi/Plugins/Source/PPropertyParser/PPropertyValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,74 @@

TOSHI_NAMESPACE_USING

class PArray : TObject
namespace ValueType {

class INT : TObject
{
DECLARE_DYNAMIC(PArray);
DECLARE_DYNAMIC(INT);
};
IMPLEMENT_DYNCREATE(PArray, TObject);
IMPLEMENT_DYNCREATE(INT, TObject);

class PBool : TObject
class UINT32 : TObject
{
DECLARE_DYNAMIC(PBool);
DECLARE_DYNAMIC(UINT32);
};
IMPLEMENT_DYNCREATE(PBool, TObject);
IMPLEMENT_DYNCREATE(UINT32, TObject);

class PFloat : TObject
class FLOAT : TObject
{
DECLARE_DYNAMIC(PFloat);
DECLARE_DYNAMIC(FLOAT);
};
IMPLEMENT_DYNCREATE(PFloat, TObject);
IMPLEMENT_DYNCREATE(FLOAT, TObject);

class PInt : TObject
class BOOL : TObject
{
DECLARE_DYNAMIC(PInt);
DECLARE_DYNAMIC(BOOL);
};
IMPLEMENT_DYNCREATE(PInt, TObject);
IMPLEMENT_DYNCREATE(BOOL, TObject);

class PPropName : TObject
class TPCString : TObject
{
DECLARE_DYNAMIC(PPropName);
DECLARE_DYNAMIC(TPCString);
};
IMPLEMENT_DYNCREATE(PPropName, TObject);
IMPLEMENT_DYNCREATE(TPCString, TObject);

class PLString : TObject
class TPWString : TObject
{
DECLARE_DYNAMIC(PLString);
DECLARE_DYNAMIC(TPWString);
};
IMPLEMENT_DYNCREATE(PLString, TObject);
IMPLEMENT_DYNCREATE(TPWString, TObject);

class PCString : TObject
class TLString : TObject
{
DECLARE_DYNAMIC(PCString);
DECLARE_DYNAMIC(TLString);
};
IMPLEMENT_DYNCREATE(PCString, TObject);
IMPLEMENT_DYNCREATE(TLString, TObject);

class PWString : TObject
class PPropertyName : TObject
{
DECLARE_DYNAMIC(PWString);
DECLARE_DYNAMIC(PPropertyName);
};
IMPLEMENT_DYNCREATE(PWString, TObject);
IMPLEMENT_DYNCREATE(PPropertyName, TObject);

class PPUINT32 : TObject
class PPropertyValueArray : TObject
{
DECLARE_DYNAMIC(PPUINT32);
DECLARE_DYNAMIC(PPropertyValueArray);
};
IMPLEMENT_DYNCREATE(PPUINT32, TObject);
IMPLEMENT_DYNCREATE(PPropertyValueArray, TObject);

}

const TClass *PPropertyValue::TYPE_ARRAY = &TGetClass(PArray);
const TClass *PPropertyValue::TYPE_BOOL = &TGetClass(PBool);
const TClass *PPropertyValue::TYPE_FLOAT = &TGetClass(PFloat);
const TClass *PPropertyValue::TYPE_INT = &TGetClass(PInt);
const TClass *PPropertyValue::TYPE_PROPNAME = &TGetClass(PPropName);
const TClass *PPropertyValue::TYPE_INT = &TGetClass(ValueType::INT);
const TClass *PPropertyValue::TYPE_UINT32 = &TGetClass(ValueType::UINT32);
const TClass *PPropertyValue::TYPE_FLOAT = &TGetClass(ValueType::FLOAT);
const TClass *PPropertyValue::TYPE_BOOL = &TGetClass(ValueType::BOOL);
const TClass *PPropertyValue::TYPE_TPCSTRING = &TGetClass(ValueType::TPCString);
const TClass *PPropertyValue::TYPE_TPWSTRING = &TGetClass(ValueType::TPWString);
const TClass *PPropertyValue::TYPE_TLSTRING = &TGetClass(ValueType::TLString);
const TClass *PPropertyValue::TYPE_PROPNAME = &TGetClass(ValueType::PPropertyName);
const TClass *PPropertyValue::TYPE_ARRAY = &TGetClass(ValueType::PPropertyValueArray);
const TClass *PPropertyValue::TYPE_PROPS = &TGetClass(PProperties);
const TClass *PPropertyValue::TYPE_TLSTRING = &TGetClass(PLString);
const TClass *PPropertyValue::TYPE_TPCSTRING = &TGetClass(PCString);
const TClass *PPropertyValue::TYPE_TPWSTRING = &TGetClass(PWString);
const TClass *PPropertyValue::TYPE_UINT32 = &TGetClass(PPUINT32);
const TClass *PPropertyValue::TYPE_UNDEF = TNULL;

PPropertyValue::PPropertyValue()
Expand Down Expand Up @@ -108,6 +112,7 @@ PPropertyValue::PPropertyValue(const PPropertyName &a_rPropname)
PPropertyValue::PPropertyValue(PProperties *props)
{
m_type = TYPE_PROPS;
m_valueProps = TNULL;
GetPropertiesMP() = props;
}

Expand Down Expand Up @@ -178,9 +183,27 @@ TBOOL PPropertyValue::ChangeType(const TClass *a_pType)
if (m_type == TYPE_TPCSTRING) {
GetTPCString().~TPCString();
}
else if (m_type == TYPE_PROPS) {
GetPropertiesMP().~TManagedPtr();
}
else if (m_type == TYPE_ARRAY) {
GetPropArrayMP().~TManagedPtr();
}
else if (m_type == TYPE_PROPNAME) {
delete m_valueName;
}
if (a_pType == TYPE_TPCSTRING) {
m_valueInt = 0;
}
else if (a_pType == TYPE_PROPS) {
m_valueProps = TNULL;
}
else if (a_pType == TYPE_ARRAY) {
m_valueArray = TNULL;
}
else if (a_pType == TYPE_PROPNAME) {
m_valueName = TNULL;
}
// TODO implement all types
m_type = a_pType;
return TTRUE;
Expand Down

0 comments on commit b69de6d

Please sign in to comment.