From 3dc7957528e6d2ef84ffdc53262b91ecfa4ecb9b Mon Sep 17 00:00:00 2001 From: AdventureT Date: Sun, 12 Nov 2023 14:53:15 +0100 Subject: [PATCH] Fix TClass not copying class tree --- Tools/UnitTests/Source/TKernel/TObject_Tests.cpp | 14 +++++++++++++- Toshi/Include/TKernel/TObject.h | 2 ++ Toshi/Source/TKernel/TObject.cpp | 5 ++--- Toshi/Source/TKernel/TSystem.cpp | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Tools/UnitTests/Source/TKernel/TObject_Tests.cpp b/Tools/UnitTests/Source/TKernel/TObject_Tests.cpp index 64b9392..16d9cc4 100644 --- a/Tools/UnitTests/Source/TKernel/TObject_Tests.cpp +++ b/Tools/UnitTests/Source/TKernel/TObject_Tests.cpp @@ -24,7 +24,7 @@ class Test3 : public TObject IMPLEMENT_DYNAMIC(Test3, TObject); -TEST_CASE("TObject Creation", "[TObject]") +TEST_CASE("IsA", "[TObject]") { Test test; REQUIRE(test.IsA(TGetClass(TObject))); @@ -32,4 +32,16 @@ TEST_CASE("TObject Creation", "[TObject]") 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))); } \ No newline at end of file diff --git a/Toshi/Include/TKernel/TObject.h b/Toshi/Include/TKernel/TObject.h index 3345d1c..0f3ff08 100644 --- a/Toshi/Include/TKernel/TObject.h +++ b/Toshi/Include/TKernel/TObject.h @@ -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; diff --git a/Toshi/Source/TKernel/TObject.cpp b/Toshi/Source/TKernel/TObject.cpp index 04a326a..a99d121 100644 --- a/Toshi/Source/TKernel/TObject.cpp +++ b/Toshi/Source/TKernel/TObject.cpp @@ -1,5 +1,4 @@ #include "TObject.h" -#include "TDebug.h" #include "TSystem.h" TOSHI_NAMESPACE_USING @@ -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; } @@ -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); } } diff --git a/Toshi/Source/TKernel/TSystem.cpp b/Toshi/Source/TKernel/TSystem.cpp index fa2648a..39738d8 100644 --- a/Toshi/Source/TKernel/TSystem.cpp +++ b/Toshi/Source/TKernel/TSystem.cpp @@ -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)