From f716446fa869ef4dc9663d69a3e4364ef2dcbb6b Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 3 Apr 2024 23:55:17 +0800 Subject: use xmi.h --- xmake/scripts/module/xmi.h | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'xmake/scripts/module') diff --git a/xmake/scripts/module/xmi.h b/xmake/scripts/module/xmi.h index 598d23ef3..c9a2d0a6f 100644 --- a/xmake/scripts/module/xmi.h +++ b/xmake/scripts/module/xmi.h @@ -26,19 +26,35 @@ */ #include +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ +#define xmi_lua_createtable(lua, narr, nrec) lua->_lua_createtable(lua->_lua, narr, nrec) +#define xmi_lua_newtable(lua) xmi_lua_createtable(lua, 0, 0) + +#ifndef LUA_VERSION +# define lua_createtable xmi_lua_createtable +# define lua_newtable xmi_lua_newtable + +# define luaL_Reg xmi_luaL_Reg +# define lua_State struct xmi_lua_State_ +#endif + /* ////////////////////////////////////////////////////////////////////////////////////// * types */ -struct lua_State_; -typedef struct luaL_Reg_ { +struct xmi_lua_State_; +typedef struct xmi_luaL_Reg_ { char const* name; - int (*func)(struct lua_State_* lua); -}luaL_Reg; + int (*func)(struct xmi_lua_State_* lua); +}xmi_luaL_Reg; + +typedef struct xmi_lua_State_ { + void* _lua; + void (*_lua_createtable)(lua_State* lua, int narr, int nrec); +}xmi_lua_State; -typedef struct lua_State_ { - void* ctx; -}lua_State; #endif -- cgit v1.3.1