diff options
author | uniboi <64006268+uniboi@users.noreply.github.com> | 2024-02-04 02:14:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-04 02:14:46 +0100 |
commit | edf013952ca2d110f190dc8cd16e5529846656e4 (patch) | |
tree | ca219c17665810d94f2cb23b27f58fa9c82f3a62 /primedev/plugins/interfaces/interface.cpp | |
parent | 6ad955ae0aab8b79910cb4a12777419a78a42a90 (diff) | |
download | NorthstarLauncher-edf013952ca2d110f190dc8cd16e5529846656e4.tar.gz NorthstarLauncher-edf013952ca2d110f190dc8cd16e5529846656e4.zip |
Plugin interfaces (plugins v4) (#615)v1.23.1-rc2v1.23.1-rc1v1.23.1v1.23.0-rc2v1.23.0-rc1v1.23.0
Replaces the current plugin api with source interfaces.
- backwards compatible
- no more json in binaries (wtf)
- does not rely on structs from third party libraries (wtf)
- actually initializes variables
- no more basically unused classes
The launcher exposes almost everything required by plugins in interfaces that allow for backwards compatibility.
The only thing that's passed to a plugin directly is the northstar dll HWND and a struct of data that's different for each plugin.
Diffstat (limited to 'primedev/plugins/interfaces/interface.cpp')
-rw-r--r-- | primedev/plugins/interfaces/interface.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/primedev/plugins/interfaces/interface.cpp b/primedev/plugins/interfaces/interface.cpp new file mode 100644 index 00000000..4c006f2c --- /dev/null +++ b/primedev/plugins/interfaces/interface.cpp @@ -0,0 +1,36 @@ +#include <string.h> +#include "interface.h" + +InterfaceReg* s_pInterfaceRegs; + +InterfaceReg::InterfaceReg(InstantiateInterfaceFn fn, const char* pName) : m_pName(pName) +{ + m_CreateFn = fn; + m_pNext = s_pInterfaceRegs; + s_pInterfaceRegs = this; +} + +void* CreateInterface(const char* pName, InterfaceStatus* pReturnCode) +{ + for (InterfaceReg* pCur = s_pInterfaceRegs; pCur; pCur = pCur->m_pNext) + { + if (strcmp(pCur->m_pName, pName) == 0) + { + if (pReturnCode) + { + *pReturnCode = InterfaceStatus::IFACE_OK; + } + + NS::log::PLUGINSYS->info("creating interface {}", pName); + return pCur->m_CreateFn(); + } + } + + if (pReturnCode) + { + *pReturnCode = InterfaceStatus::IFACE_FAILED; + } + + NS::log::PLUGINSYS->error("could not find interface {}", pName); + return NULL; +} |