From 2389b605fcf7927fe0ff34122069b23cbdc8ffe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=BB?= <119668441+Jiga228@users.noreply.github.com> Date: Fri, 11 Apr 2025 20:54:19 +0700 Subject: [PATCH] Fix bugs and refactor --- RTTI/RTTI.cpp | 6 ++++++ RTTI/RTTI.h | 13 ++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/RTTI/RTTI.cpp b/RTTI/RTTI.cpp index 48f5855..fe252b0 100644 --- a/RTTI/RTTI.cpp +++ b/RTTI/RTTI.cpp @@ -51,6 +51,12 @@ bool IRTTI::FastContainer::find(const Classes& Type) const return false; } +IRTTI::FastContainer::~FastContainer() +{ + _size = 0; + delete[] array; +} + void IRTTI::SetType(const Classes Type) { this->type = Type; diff --git a/RTTI/RTTI.h b/RTTI/RTTI.h index f61d16d..e6ad22d 100644 --- a/RTTI/RTTI.h +++ b/RTTI/RTTI.h @@ -15,6 +15,8 @@ class IRTTI long long constexpr size() const { return _size; } void push_back(const Classes object); bool find(const Classes& Type) const; + + ~FastContainer(); }; FastContainer Tree; Classes type; @@ -33,18 +35,11 @@ class RTTI final { RTTI() = default; - - // That method allow compare given type with real type object - template - static bool IsA(const Classes type) - { - return Meta::Type == type; - } public: template static bool IsA(const IRTTI* object) { - return IsA(object->type); + return Meta::Type == object->type; } // That method realized dynamic_cast @@ -52,7 +47,7 @@ public: static To* dyn_cast(From* object) { IRTTI* InterfaceOfObject = static_cast(object); - if (IsA(InterfaceOfObject->type)) + if (IsA(object)) return reinterpret_cast(object); if (InterfaceOfObject->Tree.find(Meta::Type))