summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-12-12 13:39:57 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2014-12-12 13:39:57 +0000
commit09869589c9528afef7544753b7229d2cd944cbec (patch)
treea8b656ed25561ded5102a437ced93e046fef1ff3 /src
parent4a1bfdeb4d771f39c49f9d8fc65aa0cde2700de0 (diff)
elua: move caching into the library
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Elua.am4
-rw-r--r--src/bin/elua/main.c12
-rw-r--r--src/bin/elua/main.h3
-rw-r--r--src/lib/elua/Elua.h2
-rw-r--r--src/lib/elua/cache.c (renamed from src/bin/elua/cache.c)17
5 files changed, 17 insertions, 21 deletions
diff --git a/src/Makefile_Elua.am b/src/Makefile_Elua.am
index 65792b6..dd9bf06 100644
--- a/src/Makefile_Elua.am
+++ b/src/Makefile_Elua.am
@@ -9,7 +9,8 @@ lib/elua/Elua.h
9lib_elua_libelua_la_SOURCES = \ 9lib_elua_libelua_la_SOURCES = \
10 lib/elua/elua_private.h \ 10 lib/elua/elua_private.h \
11 lib/elua/elua.c \ 11 lib/elua/elua.c \
12 lib/elua/io.c 12 lib/elua/io.c \
13 lib/elua/cache.c
13 14
14lib_elua_libelua_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ELUA_CFLAGS@ \ 15lib_elua_libelua_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ELUA_CFLAGS@ \
15 -DLOCALE_DIR=\"@LOCALE_DIR@\" \ 16 -DLOCALE_DIR=\"@LOCALE_DIR@\" \
@@ -29,7 +30,6 @@ bin_PROGRAMS += bin/elua/elua
29 30
30bin_elua_elua_SOURCES = \ 31bin_elua_elua_SOURCES = \
31 bin/elua/main.h \ 32 bin/elua/main.h \
32 bin/elua/cache.c \
33 bin/elua/main.c 33 bin/elua/main.c
34 34
35bin_elua_elua_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ELUA_CFLAGS@ \ 35bin_elua_elua_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ELUA_CFLAGS@ \
diff --git a/src/bin/elua/main.c b/src/bin/elua/main.c
index 5ff7487..1eb2a75 100644
--- a/src/bin/elua/main.c
+++ b/src/bin/elua/main.c
@@ -195,7 +195,7 @@ elua_dolib(lua_State *L, const char *libname)
195static int 195static int
196elua_dofile(lua_State *L, const char *fname) 196elua_dofile(lua_State *L, const char *fname)
197{ 197{
198 return elua_report(L, elua_loadfile(L, fname) || elua_docall(L, 0, 1)); 198 return elua_report(L, elua_io_loadfile(L, fname) || elua_docall(L, 0, 1));
199} 199}
200 200
201static int 201static int
@@ -238,14 +238,14 @@ elua_doscript(lua_State *L, int argc, char **argv, int n, int *quit)
238 if (f) 238 if (f)
239 { 239 {
240 fclose(f); 240 fclose(f);
241 status = elua_loadfile(L, fname); 241 status = elua_io_loadfile(L, fname);
242 } 242 }
243 else 243 else
244 status = !elua_loadapp(L, fname); 244 status = !elua_loadapp(L, fname);
245 } 245 }
246 else 246 else
247 { 247 {
248 status = elua_loadfile(L, fname); 248 status = elua_io_loadfile(L, fname);
249 } 249 }
250 lua_insert(L, -(narg + 1)); 250 lua_insert(L, -(narg + 1));
251 if (!status) 251 if (!status)
@@ -444,7 +444,7 @@ elua_main(lua_State *L)
444 } 444 }
445 } 445 }
446 snprintf(modfile, sizeof(modfile), "%s/module.lua", coref); 446 snprintf(modfile, sizeof(modfile), "%s/module.lua", coref);
447 if (elua_report(L, elua_loadfile(L, modfile))) 447 if (elua_report(L, elua_io_loadfile(L, modfile)))
448 { 448 {
449 m->status = 1; 449 m->status = 1;
450 return 0; 450 return 0;
@@ -460,7 +460,7 @@ elua_main(lua_State *L)
460 lua_call(L, 2, 0); 460 lua_call(L, 2, 0);
461 461
462 snprintf(modfile, sizeof(modfile), "%s/gettext.lua", coref); 462 snprintf(modfile, sizeof(modfile), "%s/gettext.lua", coref);
463 if (elua_report(L, elua_loadfile(L, modfile))) 463 if (elua_report(L, elua_io_loadfile(L, modfile)))
464 { 464 {
465 m->status = 1; 465 m->status = 1;
466 return 0; 466 return 0;
@@ -468,7 +468,7 @@ elua_main(lua_State *L)
468 elua_state_setup_i18n(L); 468 elua_state_setup_i18n(L);
469 lua_call(L, 1, 0); 469 lua_call(L, 1, 0);
470 470
471 elua_register_cache(L); 471 elua_io_register(L);
472 lua_gc(L, LUA_GCRESTART, 0); 472 lua_gc(L, LUA_GCRESTART, 0);
473 473
474 INF("elua lua state initialized"); 474 INF("elua lua state initialized");
diff --git a/src/bin/elua/main.h b/src/bin/elua/main.h
index c66b3d6..29f7a42 100644
--- a/src/bin/elua/main.h
+++ b/src/bin/elua/main.h
@@ -37,7 +37,4 @@ extern int el_log_domain;
37#define ERR(...) EINA_LOG_DOM_ERR(el_log_domain, __VA_ARGS__) 37#define ERR(...) EINA_LOG_DOM_ERR(el_log_domain, __VA_ARGS__)
38#define CRT(...) EINA_LOG_DOM_CRITICAL(el_log_domain, __VA_ARGS__) 38#define CRT(...) EINA_LOG_DOM_CRITICAL(el_log_domain, __VA_ARGS__)
39 39
40int elua_loadfile(lua_State *L, const char *fname);
41void elua_register_cache(lua_State *L);
42
43#endif 40#endif
diff --git a/src/lib/elua/Elua.h b/src/lib/elua/Elua.h
index bba00e9..80a8a89 100644
--- a/src/lib/elua/Elua.h
+++ b/src/lib/elua/Elua.h
@@ -64,6 +64,8 @@ EAPI int elua_shutdown(void);
64EAPI void elua_state_setup_i18n(lua_State *L); 64EAPI void elua_state_setup_i18n(lua_State *L);
65 65
66EAPI int elua_io_popen(lua_State *L); 66EAPI int elua_io_popen(lua_State *L);
67EAPI int elua_io_loadfile(lua_State *L, const char *fname);
68EAPI void elua_io_register(lua_State *L);
67 69
68#endif 70#endif
69 71
diff --git a/src/bin/elua/cache.c b/src/lib/elua/cache.c
index c71fd04..e272843 100644
--- a/src/bin/elua/cache.c
+++ b/src/lib/elua/cache.c
@@ -1,6 +1,5 @@
1#include "config.h" 1#include "Elua.h"
2 2#include "elua_private.h"
3/* elua bytecode caching */
4 3
5#include <sys/types.h> 4#include <sys/types.h>
6#include <sys/stat.h> 5#include <sys/stat.h>
@@ -8,8 +7,6 @@
8#include <fcntl.h> 7#include <fcntl.h>
9#include <unistd.h> 8#include <unistd.h>
10 9
11#include "main.h"
12
13/* bytecode caching */ 10/* bytecode caching */
14 11
15static Eina_File * 12static Eina_File *
@@ -152,8 +149,8 @@ getf_map(lua_State *L EINA_UNUSED, void *ud, size_t *size)
152 return fmap; 149 return fmap;
153} 150}
154 151
155int 152EAPI int
156elua_loadfile(lua_State *L, const char *fname) 153elua_io_loadfile(lua_State *L, const char *fname)
157{ 154{
158 Map_Stream s; 155 Map_Stream s;
159 int status; 156 int status;
@@ -191,7 +188,7 @@ static int
191loadfile(lua_State *L) 188loadfile(lua_State *L)
192{ 189{
193 const char *fname = luaL_optstring(L, 1, NULL); 190 const char *fname = luaL_optstring(L, 1, NULL);
194 int status = elua_loadfile(L, fname), 191 int status = elua_io_loadfile(L, fname),
195 hasenv = (lua_gettop(L) >= 3); 192 hasenv = (lua_gettop(L) >= 3);
196 if (!status) 193 if (!status)
197 { 194 {
@@ -207,8 +204,8 @@ loadfile(lua_State *L)
207 return 2; 204 return 2;
208} 205}
209 206
210void 207EAPI void
211elua_register_cache(lua_State *L) 208elua_io_register(lua_State *L)
212{ 209{
213 lua_pushcfunction(L, loadfile); 210 lua_pushcfunction(L, loadfile);
214 lua_setglobal(L, "loadfile"); 211 lua_setglobal(L, "loadfile");