From 9aaffab5721e0b2e850d6ffe9cf6c1e1367fc8ca Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 25 Oct 2018 10:38:31 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84?= =?UTF-8?q?=EF=BC=8C=E5=B0=86lua=20binding=E7=8B=AC=E7=AB=8B=E5=87=BA?= =?UTF-8?q?=E6=9D=A5=E4=B8=80=E4=B8=AA=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jin/main.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/jin/main.cpp (limited to 'src/jin/main.cpp') diff --git a/src/jin/main.cpp b/src/jin/main.cpp new file mode 100644 index 0000000..2d65064 --- /dev/null +++ b/src/jin/main.cpp @@ -0,0 +1,44 @@ +#ifdef _WIN32 + #include + #include +#endif + +#include "lua/luax.h" +#include "lua/jin.h" +#include "libjin/jin.h" +#include + +using namespace JinEngine::Lua; +using namespace JinEngine::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, cwd.size()); +#elif defined __unix__ +#elif defined __APPLE__ +#endif + luax_setfieldstring(L, "cwd", (char*)&cwd); + 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