forked from enlightenment/efl
elua lib: add elua_state_dirs_set
This commit is contained in:
parent
098f2ad4cd
commit
ed3f24943f
|
@ -402,6 +402,8 @@ elua_main(lua_State *L)
|
|||
|
||||
INF("arguments parsed");
|
||||
|
||||
elua_state_dirs_set(es, coredir, moddir, appsdir);
|
||||
|
||||
lua_gc(L, LUA_GCSTOP, 0);
|
||||
|
||||
elua_prefix = eina_prefix_new(elua_progname, elua_main, "ELUA", "elua", "checkme",
|
||||
|
|
|
@ -54,6 +54,8 @@ extern "C" {
|
|||
|
||||
#ifdef EFL_BETA_API_SUPPORT
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
|
@ -61,6 +63,9 @@ extern "C" {
|
|||
typedef struct _Elua_State
|
||||
{
|
||||
lua_State *luastate;
|
||||
Eina_Stringshare *coredir;
|
||||
Eina_Stringshare *moddir;
|
||||
Eina_Stringshare *appsdir;
|
||||
} Elua_State;
|
||||
|
||||
EAPI int elua_init(void);
|
||||
|
@ -69,6 +74,9 @@ EAPI int elua_shutdown(void);
|
|||
EAPI Elua_State *elua_state_new(void);
|
||||
EAPI void elua_state_free(Elua_State *es);
|
||||
|
||||
EAPI void elua_state_dirs_set(Elua_State *es, const char *core,
|
||||
const char *mods, const char *apps);
|
||||
|
||||
EAPI Elua_State *elua_state_from_lua_get(lua_State *L);
|
||||
|
||||
EAPI int elua_report_error(Elua_State *es, const char *pname, int status);
|
||||
|
|
|
@ -69,7 +69,7 @@ elua_state_new(void)
|
|||
lua_State *L = luaL_newstate();
|
||||
if (!L)
|
||||
return NULL;
|
||||
ret = malloc(sizeof(Elua_State));
|
||||
ret = calloc(1, sizeof(Elua_State));
|
||||
ret->luastate = L;
|
||||
luaL_openlibs(L);
|
||||
lua_pushlightuserdata(L, ret);
|
||||
|
@ -82,9 +82,22 @@ elua_state_free(Elua_State *es)
|
|||
{
|
||||
if (!es) return;
|
||||
if (es->luastate) lua_close(es->luastate);
|
||||
eina_stringshare_del(es->coredir);
|
||||
eina_stringshare_del(es->moddir);
|
||||
eina_stringshare_del(es->appsdir);
|
||||
free(es);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elua_state_dirs_set(Elua_State *es, const char *core, const char *mods,
|
||||
const char *apps)
|
||||
{
|
||||
if (!es) return;
|
||||
if (core) es->coredir = eina_stringshare_add(core);
|
||||
if (mods) es->moddir = eina_stringshare_add(mods);
|
||||
if (apps) es->appsdir = eina_stringshare_add(apps);
|
||||
}
|
||||
|
||||
EAPI Elua_State *
|
||||
elua_state_from_lua_get(lua_State *L)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue