summaryrefslogtreecommitdiff
path: root/src/lib/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-08 16:43:14 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:19 +0100
commited3f24943f17dbc2459572ccdde34e62eaf945eb (patch)
tree1e2e9786c2d3981f8b1b66ed87eea462ee5023f8 /src/lib/elua
parent098f2ad4cd53c13d52e9496de98ed30966479aad (diff)
elua lib: add elua_state_dirs_set
Diffstat (limited to 'src/lib/elua')
-rw-r--r--src/lib/elua/Elua.h8
-rw-r--r--src/lib/elua/elua.c15
2 files changed, 22 insertions, 1 deletions
diff --git a/src/lib/elua/Elua.h b/src/lib/elua/Elua.h
index 2b06a805c0..e4df8afdb1 100644
--- a/src/lib/elua/Elua.h
+++ b/src/lib/elua/Elua.h
@@ -54,6 +54,8 @@ extern "C" {
54 54
55#ifdef EFL_BETA_API_SUPPORT 55#ifdef EFL_BETA_API_SUPPORT
56 56
57#include <Eina.h>
58
57#include <lua.h> 59#include <lua.h>
58#include <lualib.h> 60#include <lualib.h>
59#include <lauxlib.h> 61#include <lauxlib.h>
@@ -61,6 +63,9 @@ extern "C" {
61typedef struct _Elua_State 63typedef struct _Elua_State
62{ 64{
63 lua_State *luastate; 65 lua_State *luastate;
66 Eina_Stringshare *coredir;
67 Eina_Stringshare *moddir;
68 Eina_Stringshare *appsdir;
64} Elua_State; 69} Elua_State;
65 70
66EAPI int elua_init(void); 71EAPI int elua_init(void);
@@ -69,6 +74,9 @@ EAPI int elua_shutdown(void);
69EAPI Elua_State *elua_state_new(void); 74EAPI Elua_State *elua_state_new(void);
70EAPI void elua_state_free(Elua_State *es); 75EAPI void elua_state_free(Elua_State *es);
71 76
77EAPI void elua_state_dirs_set(Elua_State *es, const char *core,
78 const char *mods, const char *apps);
79
72EAPI Elua_State *elua_state_from_lua_get(lua_State *L); 80EAPI Elua_State *elua_state_from_lua_get(lua_State *L);
73 81
74EAPI int elua_report_error(Elua_State *es, const char *pname, int status); 82EAPI int elua_report_error(Elua_State *es, const char *pname, int status);
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index 6601953f27..3446ac4cd2 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -69,7 +69,7 @@ elua_state_new(void)
69 lua_State *L = luaL_newstate(); 69 lua_State *L = luaL_newstate();
70 if (!L) 70 if (!L)
71 return NULL; 71 return NULL;
72 ret = malloc(sizeof(Elua_State)); 72 ret = calloc(1, sizeof(Elua_State));
73 ret->luastate = L; 73 ret->luastate = L;
74 luaL_openlibs(L); 74 luaL_openlibs(L);
75 lua_pushlightuserdata(L, ret); 75 lua_pushlightuserdata(L, ret);
@@ -82,9 +82,22 @@ elua_state_free(Elua_State *es)
82{ 82{
83 if (!es) return; 83 if (!es) return;
84 if (es->luastate) lua_close(es->luastate); 84 if (es->luastate) lua_close(es->luastate);
85 eina_stringshare_del(es->coredir);
86 eina_stringshare_del(es->moddir);
87 eina_stringshare_del(es->appsdir);
85 free(es); 88 free(es);
86} 89}
87 90
91EAPI void
92elua_state_dirs_set(Elua_State *es, const char *core, const char *mods,
93 const char *apps)
94{
95 if (!es) return;
96 if (core) es->coredir = eina_stringshare_add(core);
97 if (mods) es->moddir = eina_stringshare_add(mods);
98 if (apps) es->appsdir = eina_stringshare_add(apps);
99}
100
88EAPI Elua_State * 101EAPI Elua_State *
89elua_state_from_lua_get(lua_State *L) 102elua_state_from_lua_get(lua_State *L)
90{ 103{