blob: d4f08a07059c443cb31f9123d0143f0d8239e255 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#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::Filesystem;
using namespace JinEngine::Lua;
static void setParamters(lua_State* L, int argc, char* args[])
{
// Add args to field.
luax_newtable(L);
for (int i = 0; i < argc; ++i)
luax_setrawstring(L, -2, i + 1, args[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);
}
int main(int argc, char* args[])
{
// Global lua runtime.
lua_State* L = luax_newstate();
// Open lua standard module.
luax_openlibs(L);
// Open jin module.
luaopen_jin(L);
// Set parameters.
setParamters(L, argc, args);
// Clear lua stack.
luax_clearstack(L);
// Boot jin and run it.
boot(L);
// Close lua lib.
luax_close(L);
return 0;
}
|