Skip to content

Commit

Permalink
Fix TClass not copying class tree
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Nov 12, 2023
1 parent 303f495 commit 3dc7957
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
14 changes: 13 additions & 1 deletion Tools/UnitTests/Source/TKernel/TObject_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@ class Test3 : public TObject

IMPLEMENT_DYNAMIC(Test3, TObject);

TEST_CASE("TObject Creation", "[TObject]")
TEST_CASE("IsA", "[TObject]")
{
Test test;
REQUIRE(test.IsA(TGetClass(TObject)));
Test2 test2;
REQUIRE(test.IsA(TGetClass(Test)));
REQUIRE(test.IsA(TGetClass(TObject)));
REQUIRE_FALSE(test.IsA(TGetClass(Test3)));
}

TEST_CASE("DumpObjectClassHierachie", "[TObject]")
{
TClass::DumpObjectClassTree();
}

TEST_CASE("Create Object", "[TObject]")
{
TObject* obj = TGetClass(Test2).CreateObject();
REQUIRE(obj != TNULL);
REQUIRE(obj->IsA(TGetClass(Test2)));
}
2 changes: 2 additions & 0 deletions Toshi/Include/TKernel/TObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class TOSHI_EXPORT TClass
m_Initialize = a_rClass.m_Initialize;
m_Uninitialize = a_rClass.m_Uninitialize;
m_pParent = a_rClass.m_pParent;
m_pPrevious = a_rClass.m_pPrevious;
m_pLastAttached = a_rClass.m_pLastAttached;
m_uiVersion = a_rClass.m_uiVersion;
m_bInitialised = TFALSE;
return *this;
Expand Down
5 changes: 2 additions & 3 deletions Toshi/Source/TKernel/TObject.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "TObject.h"
#include "TDebug.h"
#include "TSystem.h"

TOSHI_NAMESPACE_USING
Expand Down Expand Up @@ -53,7 +52,7 @@ TBOOL DumpObjectClassTree_BaseEnd(TClass*, TPCVOID)

TBOOL DumpObjectClassTree_Check(TClass*, TPCVOID)
{
TDPRINTF("DumpObjectClassTree_Check() Not Implemented");
TDPRINTF("DumpObjectClassTree_Check() Not Implemented\n");
return TTRUE;
}

Expand Down Expand Up @@ -124,7 +123,7 @@ void TClass::RecurseTree2(t_RecurceTreeBaseBeginCb a_BaseBegin, t_RecurceTreeBas
if (a_Check) a_Check(pClass, a_pMem);
if (pClass->m_pLastAttached) {
if (a_BaseBegin) a_BaseBegin(pClass, a_pMem);
RecurseTree2(a_BaseBegin, a_BaseEnd, a_Check, a_pMem);
pClass->RecurseTree2(a_BaseBegin, a_BaseEnd, a_Check, a_pMem);
if (a_BaseEnd) a_BaseEnd(pClass, a_pMem);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Toshi/Source/TKernel/TSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TINT __stdcall TSystem::StringLength(TPCCHAR a_String)
TINT __stdcall TSystem::StringCompareNoCase(TPCCHAR a_String1, TPCCHAR a_String2, TINT a_uiSize)
{
TASSERT((a_String1!=TNULL) && (a_String2!=TNULL));
return a_uiSize == -1 ? _strnicmp(a_String1, a_String2, a_uiSize) : _stricmp(a_String1, a_String2);
return a_uiSize != -1 ? _strnicmp(a_String1, a_String2, a_uiSize) : _stricmp(a_String1, a_String2);
}

TPVOID __stdcall TSystem::MemCopy(TPVOID a_dest, TPCVOID a_src, TUINT a_iSize)
Expand Down

0 comments on commit 3dc7957

Please sign in to comment.