aboutsummaryrefslogtreecommitdiff
path: root/primedev/plugins/interfaces/interface.h
diff options
context:
space:
mode:
authoruniboi <64006268+uniboi@users.noreply.github.com>2024-02-04 02:14:46 +0100
committerGitHub <noreply@github.com>2024-02-04 02:14:46 +0100
commitedf013952ca2d110f190dc8cd16e5529846656e4 (patch)
treeca219c17665810d94f2cb23b27f58fa9c82f3a62 /primedev/plugins/interfaces/interface.h
parent6ad955ae0aab8b79910cb4a12777419a78a42a90 (diff)
downloadNorthstarLauncher-1.23.0-rc1.tar.gz
NorthstarLauncher-1.23.0-rc1.zip
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.h')
-rw-r--r--primedev/plugins/interfaces/interface.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/primedev/plugins/interfaces/interface.h b/primedev/plugins/interfaces/interface.h
new file mode 100644
index 00000000..440db5b2
--- /dev/null
+++ b/primedev/plugins/interfaces/interface.h
@@ -0,0 +1,39 @@
+#ifndef INTERFACE_H
+#define INTERFACE_H
+
+typedef void* (*InstantiateInterfaceFn)();
+
+// Used internally to register classes.
+class InterfaceReg
+{
+public:
+ InterfaceReg(InstantiateInterfaceFn fn, const char* pName);
+
+ InstantiateInterfaceFn m_CreateFn;
+ const char* m_pName;
+ InterfaceReg* m_pNext;
+};
+
+// Use this to expose an interface that can have multiple instances.
+#define EXPOSE_INTERFACE(className, interfaceName, versionName) \
+ static void* __Create##className##_interface() \
+ { \
+ return static_cast<interfaceName*>(new className); \
+ } \
+ static InterfaceReg __g_Create##className##_reg(__Create##className##_interface, versionName);
+
+#define EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, globalVarName) \
+ static void* __Create##className##interfaceName##_interface() \
+ { \
+ return static_cast<interfaceName*>(&globalVarName); \
+ } \
+ static InterfaceReg __g_Create##className##interfaceName##_reg(__Create##className##interfaceName##_interface, versionName);
+
+// Use this to expose a singleton interface. This creates the global variable for you automatically.
+#define EXPOSE_SINGLE_INTERFACE(className, interfaceName, versionName) \
+ static className __g_##className##_singleton; \
+ EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton)
+
+EXPORT void* CreateInterface(const char* pName, InterfaceStatus* pReturnCode);
+
+#endif