From 05f7602a1d195308e8c220faee6f18cbf65e6781 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 5 Apr 2024 21:05:07 +0800 Subject: [PATCH] add call functions --- core/src/xmake/package/loadxmi.c | 6 ++++++ xmake/scripts/module/xmi.h | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/core/src/xmake/package/loadxmi.c b/core/src/xmake/package/loadxmi.c index 78fba0c762f..b9572d58d24 100644 --- a/core/src/xmake/package/loadxmi.c +++ b/core/src/xmake/package/loadxmi.c @@ -163,6 +163,12 @@ tb_int_t xm_package_loadxmi(lua_State* lua) s_luaops._lua_toclose = &lua_toclose; s_luaops._lua_closeslot = &lua_closeslot; + // 'load' and 'call' functions + s_luaops._lua_callk = &lua_callk; + s_luaops._lua_pcallk = &lua_pcallk; + s_luaops._lua_load = &lua_load; + s_luaops._lua_dump = &lua_dump; + // luaL functions s_luaops._luaL_getmetafield = &luaL_getmetafield; s_luaops._luaL_callmeta = &luaL_callmeta; diff --git a/xmake/scripts/module/xmi.h b/xmake/scripts/module/xmi.h index 1398bdc51b5..c07058487c2 100644 --- a/xmake/scripts/module/xmi.h +++ b/xmake/scripts/module/xmi.h @@ -160,6 +160,12 @@ #define xmi_lua_toclose(lua, idx) (g_lua_ops)->_lua_toclose(lua, idx) #define xmi_lua_closeslot(lua, idx) (g_lua_ops)->_lua_closeslot(lua, idx) +// 'load' and 'call' functions +#define xmi_lua_callk(lua, nargs, nr, ctx, k) (g_lua_ops)->_lua_callk(lua, nargs, nr, ctx, k) +#define xmi_lua_pcallk(lua, nargs, nr, ef, ctx, k) (g_lua_ops)->_lua_pcallk(lua, nargs, nr, ef, ctx, k) +#define xmi_lua_load(lua, r, dt, ch, mode) (g_lua_ops)->_lua_load(lua, r, dt, ch, mode) +#define xmi_lua_dump(lua, w, d, strip) (g_lua_ops)->_lua_dump(lua, r, d, strip) + // compatibility macros #define xmi_lua_newuserdata(lua, s) xmi_lua_newuserdatauv(lua, s, 1) #define xmi_lua_getuservalue(lua, idx) xmi_lua_getiuservalue(lua, idx, 1) @@ -330,6 +336,12 @@ # define lua_toclose xmi_lua_toclose # define lua_closeslot xmi_lua_closeslot +// 'load' and 'call' functions +# define lua_callk xmi_lua_callk +# define lua_pcallk xmi_lua_pcallk +# define lua_load xmi_lua_load +# define lua_dump xmi_lua_dump + // luaL macros # define luaL_getmetafield xmi_luaL_getmetafield # define luaL_callmeta xmi_luaL_callmeta @@ -510,6 +522,12 @@ typedef struct xmi_lua_ops_t_ { void (*_lua_toclose)(lua_State* lua, int idx); void (*_lua_closeslot)(lua_State* lua, int idx); + // 'load' and 'call' functions + void (*_lua_callk)(lua_State* lua, int nargs, int nresults, lua_KContext ctx, lua_KFunction k); + int (*_lua_pcallk)(lua_State* lua, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k); + int (*_lua_load)(lua_State* lua, lua_Reader reader, void* dt, const char* chunkname, const char* mode); + int (*_lua_dump)(lua_State* lua, lua_Writer writer, void* data, int strip); + // luaL functions int (*_luaL_getmetafield)(lua_State* lua, int obj, const char* e); int (*_luaL_callmeta)(lua_State* lua, int obj, const char* e);