From f55e5a9edca4033f32a9dfa6549bdb20e65e4282 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 19 Oct 2023 10:06:53 -0700 Subject: [PATCH] Fix IObjectStore vtable shenanigans Former-commit-id: 53c632b5a9744922da38b5df09d4cdedb79f7793 --- include/Kyoto/CSimplePool.hpp | 4 ++-- src/Kyoto/CFactoryStore.cpp | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/Kyoto/CSimplePool.hpp b/include/Kyoto/CSimplePool.hpp index 5cd60592..874acd19 100644 --- a/include/Kyoto/CSimplePool.hpp +++ b/include/Kyoto/CSimplePool.hpp @@ -12,9 +12,9 @@ class IFactory; class CSimplePool : public IObjectStore { public: - CSimplePool(IFactory& factory) : x18_factory(factory) {} + CSimplePool(IFactory& factory); ~CSimplePool(); - + void DumpDebugPool() const; virtual CToken GetObj(const SObjectTag& tag, CVParamTransfer xfer); virtual CToken GetObj(const SObjectTag& tag); virtual CToken GetObj(const char* name); diff --git a/src/Kyoto/CFactoryStore.cpp b/src/Kyoto/CFactoryStore.cpp index fcb2a3c3..7b5bce24 100644 --- a/src/Kyoto/CFactoryStore.cpp +++ b/src/Kyoto/CFactoryStore.cpp @@ -1,8 +1,25 @@ -#include "Kyoto/CSimplePool.hpp" #include "Kyoto/CResFactory.hpp" +#include "Kyoto/IObjectStore.hpp" -TObjOwnerParam DumbTest() { +struct CDummyFactory : public IObjectStore { +public: + CDummyFactory(IFactory& factory) : mFactory(factory){}; + CToken GetObj(const SObjectTag& tag, CVParamTransfer xfer) { return CToken(); } + CToken GetObj(const SObjectTag& tag) { return CToken(); }; + CToken GetObj(const char* name){}; + CToken GetObj(const char* name, CVParamTransfer xfer){}; + bool HasObject(const SObjectTag& tag) { return false; } + bool ObjectIsLive(const SObjectTag& tag) { return false; } + IFactory& GetFactory() { return mFactory; } + void Flush(){}; + void ObjectUnreferenced(const SObjectTag& tag){}; + +private: + IFactory& mFactory; +}; + +TObjOwnerParam< IObjectStore* > DumbTest() { CResFactory tmp; - CSimplePool pool(tmp); - return TObjOwnerParam(&pool); + CDummyFactory pool(tmp); + return TObjOwnerParam< IObjectStore* >(&pool); }