summaryrefslogtreecommitdiff
path: root/tests/projects/swig/lua_c/src/example.c
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-27 22:35:24 +0800
committerruki <[email protected]>2021-09-27 22:35:24 +0800
commit9128fe7d5b84a27831ae2535a16547bb0b9b7d8e (patch)
tree299f6a0ff0c871ca149cf327ef9665bae55e6f31 /tests/projects/swig/lua_c/src/example.c
parentd00138d98064b84db0c76dde99587b5ea425fdf4 (diff)
add lua_c swig test
Diffstat (limited to 'tests/projects/swig/lua_c/src/example.c')
-rw-r--r--tests/projects/swig/lua_c/src/example.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/projects/swig/lua_c/src/example.c b/tests/projects/swig/lua_c/src/example.c
new file mode 100644
index 000000000..c4afe9779
--- /dev/null
+++ b/tests/projects/swig/lua_c/src/example.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+
+extern int luaopen_example(lua_State* L); // declare the wrapped module
+
+int main(int argc,char* argv[])
+{
+ lua_State *L;
+ if (argc<2)
+ {
+ printf("%s: <filename.lua>\n",argv[0]);
+ return 0;
+ }
+ L=lua_open();
+ luaopen_base(L); // load basic libs (eg. print)
+ luaopen_example(L); // load the wrappered module
+ if (luaL_loadfile(L,argv[1])==0) // load and run the file
+ lua_pcall(L,0,0,0);
+ else
+ printf("unable to load %s\n",argv[1]);
+ lua_close(L);
+ return 0;
+}