elua: use the dir paths from Elua_State

This commit is contained in:
Daniel Kolesa 2015-04-08 16:46:30 +01:00 committed by Daniel Kolesa
parent ed3f24943f
commit 01aecbe273
1 changed files with 7 additions and 11 deletions

View File

@ -39,6 +39,7 @@ static int elua_require_ref = LUA_REFNIL;
static int elua_appload_ref = LUA_REFNIL; static int elua_appload_ref = LUA_REFNIL;
static const char *elua_progname = NULL; static const char *elua_progname = NULL;
static Eina_Prefix *elua_prefix = NULL; static Eina_Prefix *elua_prefix = NULL;
static Elua_State *elua_state = NULL;
static int _el_log_domain = -1; static int _el_log_domain = -1;
@ -124,11 +125,11 @@ elua_init_module(lua_State *L)
static int static int
elua_register_require(lua_State *L) elua_register_require(lua_State *L)
{ {
const char *corepath = lua_touserdata(L, lua_upvalueindex(1)); const char *corepath = elua_state->coredir;
const char *modpath = lua_touserdata(L, lua_upvalueindex(2)); const char *modpath = elua_state->moddir;
const char *appspath = lua_touserdata(L, lua_upvalueindex(3)); const char *appspath = elua_state->appsdir;
Eina_List *largs = lua_touserdata(L, lua_upvalueindex(4)), *l = NULL; Eina_List *largs = lua_touserdata(L, lua_upvalueindex(1)), *l = NULL;
Eina_Bool noenv = lua_toboolean (L, lua_upvalueindex(5)); Eina_Bool noenv = lua_toboolean (L, lua_upvalueindex(2));
Arg_Data *data = NULL; Arg_Data *data = NULL;
char corepathbuf[PATH_MAX], modpathbuf[PATH_MAX], appspathbuf[PATH_MAX]; char corepathbuf[PATH_MAX], modpathbuf[PATH_MAX], appspathbuf[PATH_MAX];
int n = 3; int n = 3;
@ -297,8 +298,6 @@ elua_bin_shutdown(Elua_State *es, int c)
exit(c); exit(c);
} }
static Elua_State *elua_state = NULL;
struct Main_Data struct Main_Data
{ {
Elua_State *es; Elua_State *es;
@ -440,12 +439,9 @@ elua_main(lua_State *L)
m->status = 1; m->status = 1;
return 0; return 0;
} }
lua_pushlightuserdata(L, coredir);
lua_pushlightuserdata(L, moddir);
lua_pushlightuserdata(L, appsdir);
lua_pushlightuserdata(L, largs); lua_pushlightuserdata(L, largs);
lua_pushboolean (L, noenv); lua_pushboolean (L, noenv);
lua_pushcclosure(L, elua_register_require, 5); lua_pushcclosure(L, elua_register_require, 2);
lua_createtable(L, 0, 0); lua_createtable(L, 0, 0);
luaL_register(L, NULL, cutillib); luaL_register(L, NULL, cutillib);
lua_call(L, 2, 0); lua_call(L, 2, 0);