Skip to content

Commit

Permalink
add call functions
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Apr 5, 2024
1 parent 1aeccb9 commit 05f7602
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/xmake/package/loadxmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions xmake/scripts/module/xmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 05f7602

Please sign in to comment.