diff options
| author | ruki <[email protected]> | 2024-04-04 21:06:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-04-04 21:06:19 +0800 |
| commit | 110401c47b1afd744876825c6219d4b311da7863 (patch) | |
| tree | c47b2c956ffe590b091a5f04074d6dead7a476e8 /xmake/scripts/module | |
| parent | 6142965eb16020eb23f704a273f0b78502e02333 (diff) | |
update xmi.h
Diffstat (limited to 'xmake/scripts/module')
| -rw-r--r-- | xmake/scripts/module/xmi.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/xmake/scripts/module/xmi.h b/xmake/scripts/module/xmi.h index f8b74585a..e763d479b 100644 --- a/xmake/scripts/module/xmi.h +++ b/xmake/scripts/module/xmi.h @@ -50,8 +50,6 @@ #define xmi_lua_tointegerx(lua, idx, isnum) (g_lua_ops)->_lua_tointegerx(lua, idx, isnum) #define xmi_lua_touserdata(lua, idx) (g_lua_ops)->_lua_touserdata(lua, idx) #define xmi_lua_pushinteger(lua, n) (g_lua_ops)->_lua_pushinteger(lua, n) -#define xmi_lua_newtable(lua) xmi_lua_createtable(lua, 0, 0) -#define xmi_lua_tointeger(lua, i) lua_tointegerx(lua, (i), NULL) // luaL interfaces #define xmi_luaL_setfuncs(lua, narr, nrec) (g_lua_ops)->_luaL_setfuncs(lua, narr, nrec) @@ -61,6 +59,40 @@ # define xmi_luaL_error(lua, fmt, arg ...) (g_lua_ops)->_luaL_error(lua, fmt, ## arg) #endif +// helper interfaces +#define xmi_lua_newtable(lua) xmi_lua_createtable(lua, 0, 0) +#define xmi_lua_tointeger(lua, i) xmi_lua_tointegerx(lua, (i), NULL) +#define luaL_newlibtable(lua, l) xml_lua_createtable(lua, 0, sizeof(l)/sizeof((l)[0]) - 1) +//#define luaL_newlib(lua, l) (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) + +#if 0 +#define xmi_luaL_argcheck(lua, cond, arg, extramsg) \ + ((void)(luai_likely(cond) || luaL_argerror(L, (arg), (extramsg)))) + +#define luaL_argexpected(L,cond,arg,tname) \ + ((void)(luai_likely(cond) || luaL_typeerror(L, (arg), (tname)))) + +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) + +#define luaL_pushfail(L) lua_pushnil(L) + +#endif + /* we cannot redefine lua functions in loadxmi.c, * because original lua.h has been included */ |
