6#include <unordered_map>
16 static void expose(ssq::Table& table); \
17 static void expose(ssq::Class& vm);
19#define Module_REG(ModuleName) \
21 virtual std::string getName() const override { return name; } \
\
28 [[nodiscard("module instance ownership must be retained or explicitly handled")]] static ModuleName* create(); \
29 static const char* name
31#define Module_IMPL(ModuleName, newExpr) \
32 ModuleRegister ModuleName##_register(ModuleName::name, \
33 (ModuleManager::creator_t)(ModuleName::create), ModuleName::expose); \
34 ModuleName* ModuleName::create() { \
35 auto* p = ModuleManager::find(name); \
36 if (p) return static_cast<ModuleName*>(p); \
37 ModuleName* n = newExpr; \
38 ModuleManager::insert(name, n); \
41 const char* ModuleName::name = #ModuleName
43#define getModInst(N,T) eve::ModuleManager::getInstance<N::T>(#T)
44#define requireModInst(N,T) eve::ModuleManager::requireInstance<N::T>(#T)
56 virtual std::string getName()
const = 0;
62 typedef Module* (*creator_t)();
63 typedef void (*exposer_t)(ssq::Table&);
77 [[nodiscard(
"module lookup result must be checked before use")]]
static Module* find(
const char*
name);
79 static void insert(
const char*
name,
Module* inst);
82 static void register_module(
const char*
name, creator_t
c, exposer_t e);
84 [[nodiscard(
"plugin registration outcome must be checked")]]
static eve::Result<void> beginPluginRegistration();
90 [[nodiscard(
"plugin registration outcome must be checked")]]
static eve::Result<void> finishPluginRegistration(
101 static void expose(
Runtime& runtime);
104 static void expose(ssq::VM&
vm);
107 static int expose_pending();
125 static ssq::VM*
vm();
127 static void detach(
Runtime* runtime);
137 template <
typename T>
138 [[nodiscard(
"module lookup result must be checked before use")]]
static T* getInstance(
const char*
name) {
139 return static_cast<T*
>(getInstanceRaw(
name));
150 template <
typename T>
151 [[nodiscard(
"module instance ownership must be retained or explicitly handled")]]
static T* requireInstance(
153 return static_cast<T*
>(requireInstanceRaw(
name));
162 static void requireAll();
166 static void exposeVM(ssq::VM&
vm);
169 static int ensureScriptEcs();
170 static int exposeAllForCompatibility();
180 static Module* getInstanceRaw(
const char*
name);
191 creator_t creator =
nullptr;
192 exposer_t exposer =
nullptr;
194 bool exposed =
false;
197 std::unordered_map<std::string, ModuleInfo> registered_modules;
198 bool plugin_registration_active_ =
false;
199 std::vector<std::string> plugin_registration_added_;
200 std::string plugin_registration_error_;
201 Runtime* active_runtime_ =
nullptr;
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Move-only, checked operation results for the common layer.
EVENGINE_API_FOUNDATION public API.
EVENGINE_API_FOUNDATION public API.
Move-only operation result carrying either a value or Status.
EVENGINE_API_FOUNDATION public API.
Build metadata (engine git commit, build time, third-party version).
enum EVENGINE_API_FOUNDATION Table
OT_TABLE (editable via Runtime table APIs / ReflectedPropertyModel).
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
EVENGINE_API_FOUNDATION public API.