2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-13 20:21:48 +00:00

test: add test for KeyValuePairsCompilerT6

This commit is contained in:
Jan
2025-01-03 17:51:56 +01:00
parent 16e82f68ca
commit fc9e6ce14d
9 changed files with 307 additions and 90 deletions

View File

@@ -6,6 +6,33 @@
class MemoryManager
{
public:
MemoryManager();
virtual ~MemoryManager();
MemoryManager(const MemoryManager& other) = delete;
MemoryManager(MemoryManager&& other) noexcept = default;
MemoryManager& operator=(const MemoryManager& other) = delete;
MemoryManager& operator=(MemoryManager&& other) noexcept = default;
void* AllocRaw(size_t size);
char* Dup(const char* str);
template<typename T> std::add_pointer_t<T> Alloc(const size_t count = 1u)
{
return static_cast<std::add_pointer_t<T>>(AllocRaw(sizeof(T) * count));
}
template<class T, class... ValType> std::add_pointer_t<T> Create(ValType&&... val)
{
Allocation<T>* allocation = new Allocation<T>(std::forward<ValType>(val)...);
m_destructible.emplace_back(allocation, &allocation->m_entry);
return &allocation->m_entry;
}
void Free(const void* data);
void Delete(const void* data);
protected:
class IDestructible
{
public:
@@ -47,30 +74,4 @@ class MemoryManager
std::vector<void*> m_allocations;
std::vector<AllocationInfo> m_destructible;
public:
MemoryManager();
virtual ~MemoryManager();
MemoryManager(const MemoryManager& other) = delete;
MemoryManager(MemoryManager&& other) noexcept = default;
MemoryManager& operator=(const MemoryManager& other) = delete;
MemoryManager& operator=(MemoryManager&& other) noexcept = default;
void* AllocRaw(size_t size);
char* Dup(const char* str);
template<typename T> std::add_pointer_t<T> Alloc(const size_t count = 1u)
{
return static_cast<std::add_pointer_t<T>>(AllocRaw(sizeof(T) * count));
}
template<class T, class... ValType> std::add_pointer_t<T> Create(ValType&&... val)
{
Allocation<T>* allocation = new Allocation<T>(std::forward<ValType>(val)...);
m_destructible.emplace_back(allocation, &allocation->m_entry);
return &allocation->m_entry;
}
void Free(const void* data);
void Delete(const void* data);
};