summaryrefslogtreecommitdiff
path: root/core/src/xmake/package
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-04 00:22:19 +0800
committerruki <[email protected]>2024-04-04 00:22:19 +0800
commitfee2d1b5106761728134c179375c73f9283a7ba1 (patch)
tree5aecd901ed3691dfe9b2fc75c5c2739b5442d004 /core/src/xmake/package
parentf716446fa869ef4dc9663d69a3e4364ef2dcbb6b (diff)
improve xmiopen
Diffstat (limited to 'core/src/xmake/package')
-rw-r--r--core/src/xmake/package/loadxmi.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/core/src/xmake/package/loadxmi.c b/core/src/xmake/package/loadxmi.c
index db4091431..b79e8cee4 100644
--- a/core/src/xmake/package/loadxmi.c
+++ b/core/src/xmake/package/loadxmi.c
@@ -34,7 +34,8 @@
/* //////////////////////////////////////////////////////////////////////////////////////
* types
*/
-typedef int (*xm_open_func_t)(xmi_lua_State* lua);
+typedef int (*xm_open_func_t)(lua_State* lua);
+typedef int (*xm_setup_func_t)(xmi_lua_ops_t* ops);
/* //////////////////////////////////////////////////////////////////////////////////////
* implementation
@@ -60,17 +61,28 @@ tb_int_t xm_package_loadxmi(lua_State* lua)
}
// get xmiopen_xxx function
- xm_open_func_t func = (xm_open_func_t)tb_dynamic_func(lib, name);
- if (!func)
+ xm_open_func_t luaopen = (xm_open_func_t)tb_dynamic_func(lib, name);
+ if (!luaopen)
{
lua_pushnil(lua);
lua_pushfstring(lua, "cannot get symbol %s failed", name);
return 2;
}
+ // get xmisetup function
+ xm_setup_func_t xmisetup = (xm_setup_func_t)tb_dynamic_func(lib, "xmisetup");
+ if (!xmisetup)
+ {
+ lua_pushnil(lua);
+ lua_pushfstring(lua, "cannot get symbol xmisetup failed");
+ return 2;
+ }
+
+ // setup lua interfaces
+ xmi_lua_ops_t luaops = {0};
+ luaops._lua_createtable = &lua_createtable;
+ xmisetup(&luaops);
+
// load module
- xmi_lua_State xmi_lua = {0};
- xmi_lua._lua = lua;
- xmi_lua._lua_createtable = &lua_createtable;
- return func(&xmi_lua);
+ return luaopen(lua);
}