summaryrefslogtreecommitdiff
path: root/src/lib/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-08 14:00:57 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:18 +0100
commitbf4837dbbfdb300372b9fe7a57378e580e4dad23 (patch)
tree2d4b9b94f5ff227431a79f6f08a74444c188b063 /src/lib/elua
parente0917331f63d06805708243ab9e02958ab4b620f (diff)
elua lib: add elua_state_new and elua_state_free
Diffstat (limited to 'src/lib/elua')
-rw-r--r--src/lib/elua/Elua.h3
-rw-r--r--src/lib/elua/elua.c21
2 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/elua/Elua.h b/src/lib/elua/Elua.h
index 7fdd19fa85..69c72b05b9 100644
--- a/src/lib/elua/Elua.h
+++ b/src/lib/elua/Elua.h
@@ -66,6 +66,9 @@ typedef struct _Elua_State
66EAPI int elua_init(void); 66EAPI int elua_init(void);
67EAPI int elua_shutdown(void); 67EAPI int elua_shutdown(void);
68 68
69EAPI Elua_State *elua_state_new(void);
70EAPI void elua_state_free(Elua_State *state);
71
69EAPI int elua_report_error(lua_State *L, const char *pname, int status); 72EAPI int elua_report_error(lua_State *L, const char *pname, int status);
70 73
71EAPI void elua_state_setup_i18n(lua_State *L); 74EAPI void elua_state_setup_i18n(lua_State *L);
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index 2f88e7be02..a6bb3914cd 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -62,6 +62,27 @@ elua_shutdown(void)
62 return _elua_init_counter; 62 return _elua_init_counter;
63} 63}
64 64
65EAPI Elua_State *
66elua_state_new(void)
67{
68 Elua_State *ret = NULL;
69 lua_State *L = luaL_newstate();
70 if (!L)
71 return NULL;
72 ret = malloc(sizeof(Elua_State));
73 ret->luastate = L;
74 luaL_openlibs(L);
75 return ret;
76}
77
78EAPI void
79elua_state_free(Elua_State *state)
80{
81 if (!state) return;
82 if (state->luastate) lua_close(state->luastate);
83 free(state);
84}
85
65static void 86static void
66_elua_errmsg(const char *pname, const char *msg) 87_elua_errmsg(const char *pname, const char *msg)
67{ 88{