From 8339939b7fce5236b1a933eef46e1dd4284a24aa Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 10 Sep 2018 07:17:50 +0800 Subject: *update --- src/lua/main.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/lua/main.cpp (limited to 'src/lua/main.cpp') diff --git a/src/lua/main.cpp b/src/lua/main.cpp new file mode 100644 index 0000000..f7a5c06 --- /dev/null +++ b/src/lua/main.cpp @@ -0,0 +1,43 @@ +#ifdef _WIN32 +#include +#include +#endif + +#include "luax.h" +#include "jin.h" +#include "libjin/jin.h" +#include + +using namespace jin::lua; +using namespace jin::filesystem; + +int main(int argc, char* argv[]) +{ + lua_State* L = luax_newstate(); + + /* open lua standard module */ + luax_openlibs(L); + /* open jin module */ + luaopen_jin(L); + /* add args to field */ + luax_newtable(L); + for (int i = 0; i < argc; ++i) + luax_setrawstring(L, -2, i + 1, argv[i]); + luax_setfield(L, -2, "args"); + /* push current working directory */ + /* absolute directory */ + Buffer cwd = Buffer(1024); +#ifdef _WIN32 + _getcwd((char*)cwd.data, cwd.size); +#elif defined __unix__ +#elif defined __APPLE__ +#endif + luax_setfieldstring(L, "cwd", (char*)cwd.data); + luax_clear(L); + + /* boot jin and run it */ + boot(L); + + luax_close(L); + return 0; +} \ No newline at end of file -- cgit v1.1-26-g67d0