4#include "../Foundation/Memory.h"
5#include "../Foundation/PrimitiveTypes.h"
6#include "../Strings/StringHashFNV.h"
13#define SC_PLUGIN_EXPORT __declspec(dllexport)
15#define SC_PLUGIN_EXPORT __attribute__((visibility("default")))
19#define SC_PLUGIN_LINKER_OPERATORS \
20 void* operator new(SC::size_t len) \
22 return SC::Memory::allocate(len); \
24 void* operator new[](SC::size_t len) \
26 return SC::Memory::allocate(len); \
28 void operator delete(void* p, SC::size_t) noexcept \
32 SC::Memory::release(p); \
35 void operator delete(void* p) noexcept \
39 SC::Memory::release(p); \
44#define SC_PLUGIN_LINKER_DEFINITIONS \
45 SC_PLUGIN_LINKER_OPERATORS \
46 extern "C" void __CxxFrameHandler4() \
49 extern "C" void __CxxFrameHandler3() \
52 int __stdcall DllMain(void*, unsigned int, void*) \
56 extern "C" int _fltused = 0;
62#define SC_PLUGIN_LINKER_DEFINITIONS \
63 SC_PLUGIN_LINKER_OPERATORS \
64 extern "C" void bzero(void* s, SC::size_t n) \
66 unsigned char* p = reinterpret_cast<unsigned char*>(s); \
72 extern "C" int memcmp(const void* s1, const void* s2, SC::size_t n) \
74 const unsigned char* p1 = reinterpret_cast<const unsigned char*>(s1); \
75 const unsigned char* p2 = reinterpret_cast<const unsigned char*>(s2); \
92#define SC_PLUGIN_LINKER_DEFINITIONS
98#define SC_PLUGIN_DEFINE(PluginName) \
99 SC_PLUGIN_LINKER_DEFINITIONS \
100 extern "C" SC_PLUGIN_EXPORT bool PluginName##Init(PluginName*& instance) \
102 instance = new PluginName(); \
103 return instance->init(); \
106 extern "C" SC_PLUGIN_EXPORT bool PluginName##Close(PluginName* instance) \
108 auto res = instance->close(); \
113#define SC_PLUGIN_EXPORT_INTERFACES(PluginName, ...) \
114 extern "C" SC_PLUGIN_EXPORT bool PluginName##QueryInterface(PluginName* plugin, SC::uint32_t hash, \
115 void** pluginInterface) \
117 return SC::PluginCastInterface<PluginName, __VA_ARGS__>()(plugin, hash, pluginInterface); \
122template <
typename PluginClass,
typename... InterfaceClasses>
125template <
typename PluginClass>
128 bool operator()(PluginClass*,
uint32_t,
void**) {
return false; }
131template <
typename PluginClass,
typename InterfaceClass,
typename... InterfaceClasses>
134 bool operator()(PluginClass* plugin,
uint32_t hash,
void** pluginInterface)
136 if (hash == InterfaceClass::InterfaceHash)
138 *pluginInterface =
static_cast<InterfaceClass*
>(plugin);
141 return PluginCastInterface<PluginClass, InterfaceClasses...>()(plugin, hash, pluginInterface);
unsigned int uint32_t
Platform independent (4) bytes unsigned int.
Definition: PrimitiveTypes.h:38
Definition: PluginMacros.h:123