From c7c412f6458f5aceeb02e9bfc292dc7aac0852d3 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 25 Jul 2024 00:54:13 +0800 Subject: move autogen tests --- .../hello/modules/shared/foo/src/foo.c | 26 ++++++++++++++++++++++ .../hello/modules/shared/foo/xmake.lua | 6 +++++ 2 files changed, 32 insertions(+) create mode 100644 tests/projects/other/native_module/hello/modules/shared/foo/src/foo.c create mode 100644 tests/projects/other/native_module/hello/modules/shared/foo/xmake.lua (limited to 'tests/projects/other/native_module/hello/modules/shared/foo') diff --git a/tests/projects/other/native_module/hello/modules/shared/foo/src/foo.c b/tests/projects/other/native_module/hello/modules/shared/foo/src/foo.c new file mode 100644 index 000000000..0555b071f --- /dev/null +++ b/tests/projects/other/native_module/hello/modules/shared/foo/src/foo.c @@ -0,0 +1,26 @@ +#include + +static int add(lua_State* lua) { + int a = lua_tointeger(lua, 1); + int b = lua_tointeger(lua, 2); + lua_pushinteger(lua, a + b); + return 1; +} + +static int sub(lua_State* lua) { + int a = lua_tointeger(lua, 1); + int b = lua_tointeger(lua, 2); + lua_pushinteger(lua, a - b); + return 1; +} + +int luaopen(foo, lua_State* lua) { + static const luaL_Reg funcs[] = { + {"add", add}, + {"sub", sub}, + {NULL, NULL} + }; + lua_newtable(lua); + luaL_setfuncs(lua, funcs, 0); + return 1; +} diff --git a/tests/projects/other/native_module/hello/modules/shared/foo/xmake.lua b/tests/projects/other/native_module/hello/modules/shared/foo/xmake.lua new file mode 100644 index 000000000..035573d9f --- /dev/null +++ b/tests/projects/other/native_module/hello/modules/shared/foo/xmake.lua @@ -0,0 +1,6 @@ +add_rules("mode.debug", "mode.release") + +target("foo") + add_rules("module.shared") + add_files("src/foo.c") + -- cgit v1.3.1