aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-09-09 18:03:05 +0800
committerchai <chaifix@163.com>2018-09-09 18:03:05 +0800
commite3ddc74a36e4336d28e9e09586b5194c2e6e6dc6 (patch)
tree979992cd174fe5b488b58ffc831c6d7a67491fd4 /src/main.cpp
parent090bd8229421073305e5e202ac3347e95bbea36d (diff)
*update
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp25
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