diff options
author | chai <chaifix@163.com> | 2018-10-25 10:38:31 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-25 10:38:31 +0800 |
commit | 9aaffab5721e0b2e850d6ffe9cf6c1e1367fc8ca (patch) | |
tree | abae6d9751fc412c0fb55da8d1547021e0ef5fde /src/jin/main.cpp | |
parent | 7322a090355af1989d7a1de0de431b6c89844fe2 (diff) |
*修改目录结构,将lua binding独立出来一个工程
Diffstat (limited to 'src/jin/main.cpp')
-rw-r--r-- | src/jin/main.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
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 <SDL2/SDL_Main.h> + #include <direct.h> +#endif + +#include "lua/luax.h" +#include "lua/jin.h" +#include "libjin/jin.h" +#include <Windows.h> + +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 |