diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index 5b6309a..18d873d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,30 +9,35 @@ #include <Windows.h> 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 global field + /* add args to field */ luax_newtable(L); for (int i = 0; i < argc; ++i) - luax_setraw_string(L, -2, i + 1, argv[i]); - luax_setfield(L, -2, "_argv"); - - const int BUFFER_SIZE = 512; - char buffer[BUFFER_SIZE]; + 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(buffer, BUFFER_SIZE); + _getcwd((char*)cwd.data, cwd.size); #elif defined __unix__ #elif defined __APPLE__ #endif - luax_setfield_string(L, "_dir", buffer); + luax_setfieldstring(L, "cwd", (char*)cwd.data); + luax_clear(L); + + /* boot jin and run it */ boot(L); - luax_close(L); + luax_close(L); return 0; }
\ No newline at end of file |