summaryrefslogtreecommitdiff
path: root/deimos/core/api_registry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'deimos/core/api_registry.cpp')
-rw-r--r--deimos/core/api_registry.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/deimos/core/api_registry.cpp b/deimos/core/api_registry.cpp
index 873d72d..1489484 100644
--- a/deimos/core/api_registry.cpp
+++ b/deimos/core/api_registry.cpp
@@ -7,6 +7,7 @@ namespace deimos
{
AllocatorApi* BootstrapAllocatorApi();
+void RegisterOsApi(ApiRegistry*);
struct ApiEntry
{
@@ -22,6 +23,7 @@ struct ApiEntry
class ApiRegistryImpl: public ApiRegistry
{
Allocator* m_allocator;
+ const ApiEntry* m_head{};
public:
explicit ApiRegistryImpl(Allocator* allocator) :
@@ -30,9 +32,17 @@ public:
void Set(const IdName& name, void* impl) final
{
- (void)name;
- (void)impl;
- (void)m_allocator;
+ auto* entry = m_allocator->New<ApiEntry>(name, impl);
+ entry->next = std::exchange(m_head, entry);
+ }
+
+ void* Get(const IdName& name) final
+ {
+ for (const ApiEntry* it = m_head; it != nullptr; it = it->next)
+ {
+ if (it->name == name) { return it->impl; }
+ }
+ return nullptr;
}
};
@@ -45,6 +55,8 @@ ApiRegistry* InitializeGlobalApiRegistry()
api_registry->Set(g_allocator_api);
+ RegisterOsApi(api_registry);
+
return api_registry;
}