aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-05 14:10:25 +1000
committerDavid Walter Seikel2012-02-05 14:10:25 +1000
commit8beba4fbb8a66f2a328f83245a1c14ccc8976752 (patch)
tree61a56d861e21c40378ebf9337664ee7001274127
parentUse the internal Lua compile function instead of the external compile program... (diff)
downloadSledjHamr-8beba4fbb8a66f2a328f83245a1c14ccc8976752.zip
SledjHamr-8beba4fbb8a66f2a328f83245a1c14ccc8976752.tar.gz
SledjHamr-8beba4fbb8a66f2a328f83245a1c14ccc8976752.tar.bz2
SledjHamr-8beba4fbb8a66f2a328f83245a1c14ccc8976752.tar.xz
Loop through the compiled scripts and run them using luaproc + LuaJIT.
-rw-r--r--LuaSL/src/LuaSL_main.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c
index 247b360..24626fb 100644
--- a/LuaSL/src/LuaSL_main.c
+++ b/LuaSL/src/LuaSL_main.c
@@ -69,7 +69,7 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
69 ecore_main_loop_quit(); 69 ecore_main_loop_quit();
70} 70}
71 71
72static void dirList_cb(const char *name, const char *path, void *data) 72static void dirList_compile(const char *name, const char *path, void *data)
73{ 73{
74 gameGlobals *game = data; 74 gameGlobals *game = data;
75 char buf[PATH_MAX]; 75 char buf[PATH_MAX];
@@ -90,6 +90,22 @@ static void dirList_cb(const char *name, const char *path, void *data)
90 } 90 }
91} 91}
92 92
93static void dirList_run(const char *name, const char *path, void *data)
94{
95 gameGlobals *game = data;
96 char buf[PATH_MAX];
97 char *ext = rindex(name, '.');
98
99 if (ext)
100 {
101 if (0 == strcmp(ext, ".out"))
102 {
103 snprintf(buf, sizeof(buf), "%s/%s", path, name);
104// PD("Running Lua script %s", buf);
105 runLuaFile(game, buf);
106 }
107 }
108}
93 109
94int 110int
95main(int argc, char **argv) 111main(int argc, char **argv)
@@ -229,9 +245,10 @@ main(int argc, char **argv)
229 runnerSetup(&game); 245 runnerSetup(&game);
230 gettimeofday(&lastTime2, 0); 246 gettimeofday(&lastTime2, 0);
231 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR); 247 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR);
232 eina_file_dir_list(buf, EINA_TRUE, dirList_cb, &game); 248 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, &game);
233 diff = timeDiff(&thisTime2, &lastTime2); 249 diff = timeDiff(&thisTime2, &lastTime2);
234 printf("Compiling %d LSL scripts took %f seconds, that's %f scripts per second.\n", scriptCount, diff, scriptCount / diff); 250 printf("Compiling %d LSL scripts took %f seconds, that's %f scripts per second.\n", scriptCount, diff, scriptCount / diff);
251 eina_file_dir_list(buf, EINA_TRUE, dirList_run, &game);
235 252
236 if (game.ui) 253 if (game.ui)
237 { 254 {