summaryrefslogtreecommitdiff
path: root/deimos/core/api_registry.cpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-03-25 23:28:26 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-03-25 23:28:26 +0100
commite1229e05aba7554363b2aa9874bd383b5923ee8b (patch)
treeadc8a8bc65942cc0c8e2cc69faa60fee29dbea8a /deimos/core/api_registry.cpp
parente3675d4d75c708f35f8041f493fde2fbfbea55b2 (diff)
Basic console API & API registry implementation
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;
}