forked from enlightenment/efl
elua lib: add elua_state_new and elua_state_free
This commit is contained in:
parent
e0917331f6
commit
bf4837dbbf
|
@ -66,6 +66,9 @@ typedef struct _Elua_State
|
|||
EAPI int elua_init(void);
|
||||
EAPI int elua_shutdown(void);
|
||||
|
||||
EAPI Elua_State *elua_state_new(void);
|
||||
EAPI void elua_state_free(Elua_State *state);
|
||||
|
||||
EAPI int elua_report_error(lua_State *L, const char *pname, int status);
|
||||
|
||||
EAPI void elua_state_setup_i18n(lua_State *L);
|
||||
|
|
|
@ -62,6 +62,27 @@ elua_shutdown(void)
|
|||
return _elua_init_counter;
|
||||
}
|
||||
|
||||
EAPI Elua_State *
|
||||
elua_state_new(void)
|
||||
{
|
||||
Elua_State *ret = NULL;
|
||||
lua_State *L = luaL_newstate();
|
||||
if (!L)
|
||||
return NULL;
|
||||
ret = malloc(sizeof(Elua_State));
|
||||
ret->luastate = L;
|
||||
luaL_openlibs(L);
|
||||
return ret;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elua_state_free(Elua_State *state)
|
||||
{
|
||||
if (!state) return;
|
||||
if (state->luastate) lua_close(state->luastate);
|
||||
free(state);
|
||||
}
|
||||
|
||||
static void
|
||||
_elua_errmsg(const char *pname, const char *msg)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue