diff options
| author | ruki <[email protected]> | 2020-04-22 23:23:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-04-22 14:21:42 +0800 |
| commit | 9407f3893ca3f71578febcabdf6a022a80dae209 (patch) | |
| tree | ed5e08bf206b406028b840a7f036af4c9a4d96c7 /tests | |
| parent | 8567065df7d23e7c51880d1e36a9895a13cd4b89 (diff) | |
add lni module
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/projects/xmake_cli/hello/src/lni/main.c | 16 | ||||
| -rw-r--r-- | tests/projects/xmake_cli/hello/src/lua/main.lua | 3 |
2 files changed, 18 insertions, 1 deletions
diff --git a/tests/projects/xmake_cli/hello/src/lni/main.c b/tests/projects/xmake_cli/hello/src/lni/main.c index dfef99794..1d574dc1b 100644 --- a/tests/projects/xmake_cli/hello/src/lni/main.c +++ b/tests/projects/xmake_cli/hello/src/lni/main.c @@ -1,11 +1,25 @@ #include <xmake/xmake.h> +static tb_int_t lni_test_hello(lua_State* lua) +{ + lua_pushliteral(lua, "hello xmake!"); + return 1; +} +static tb_void_t lni_initalizer(xm_engine_ref_t engine, lua_State* lua) +{ + static luaL_Reg const lni_test_funcs[] = + { + {"hello", lni_test_hello} + , {tb_null, tb_null} + }; + xm_engine_register(engine, "test", lni_test_funcs); +} tb_int_t main(tb_int_t argc, tb_char_t** argv) { tb_int_t ok = -1; if (xm_init()) { - xm_engine_ref_t engine = xm_engine_init(tb_null); + xm_engine_ref_t engine = xm_engine_init(lni_initalizer); if (engine) { tb_int_t argc2 = argc + 2; diff --git a/tests/projects/xmake_cli/hello/src/lua/main.lua b/tests/projects/xmake_cli/hello/src/lua/main.lua index 1ce83e728..26ba586a2 100644 --- a/tests/projects/xmake_cli/hello/src/lua/main.lua +++ b/tests/projects/xmake_cli/hello/src/lua/main.lua @@ -1,5 +1,8 @@ import("core.base.option") +import("lib.lni.test") + function main () + print(test) print("hello xmake!") local argv = option.get("arguments") if argv then |
