blob: a0704735c657d068696dfa4115495b3a31266072 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include "deimos/core/api_registry.h"
#include "deimos/core/allocator.h"
static deimos::AllocatorApi* g_allocator_api;
namespace deimos
{
AllocatorApi* BootstrapAllocatorApi();
struct ApiEntry
{
const ApiEntry* next{};
IdName name;
void* impl;
ApiEntry(const IdName& name_, void* impl_) :
name{name_}, impl{impl_}
{}
};
class ApiRegistryImpl: public ApiRegistry
{
Allocator* m_allocator;
public:
explicit ApiRegistryImpl(Allocator* allocator) :
m_allocator{allocator}
{}
void Set(const IdName& name, void* impl) final
{
(void)name;
(void)impl;
(void)m_allocator;
}
};
ApiRegistry* InitializeGlobalApiRegistry()
{
g_allocator_api = BootstrapAllocatorApi();
Allocator* allocator = g_allocator_api->system;
ApiRegistry* api_registry = allocator->New<ApiRegistryImpl>(allocator);
api_registry->Set(g_allocator_api);
return api_registry;
}
} // namespace deimos
|