aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-09-14 04:56:50 +1000
committerDavid Walter Seikel2014-09-14 04:56:50 +1000
commit611af992cede0bb980ac350e93874b6168b46b40 (patch)
tree482694b6b4c6a05e3b8713b267cc7ffe39ced45e
parentDon't generate the lemon .out file, we are not using it. (diff)
downloadSledjHamr-611af992cede0bb980ac350e93874b6168b46b40.zip
SledjHamr-611af992cede0bb980ac350e93874b6168b46b40.tar.gz
SledjHamr-611af992cede0bb980ac350e93874b6168b46b40.tar.bz2
SledjHamr-611af992cede0bb980ac350e93874b6168b46b40.tar.xz
Now we can pass LSL scripts to LuaSL on the command line. Plus some white space clean ups.
-rw-r--r--src/LuaSL/LuaSL_compile.c4
-rw-r--r--src/LuaSL/LuaSL_main.c145
2 files changed, 95 insertions, 54 deletions
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c
index a2b2bca..9d6834d 100644
--- a/src/LuaSL/LuaSL_compile.c
+++ b/src/LuaSL/LuaSL_compile.c
@@ -2219,7 +2219,7 @@ boolean compilerSetup(gameGlobals *ourGlobals)
2219 compiler->SID = strdup("FAKE_SID"); 2219 compiler->SID = strdup("FAKE_SID");
2220 compiler->doConstants = TRUE; 2220 compiler->doConstants = TRUE;
2221 compiler->parser = (compileCb) compileLSL; 2221 compiler->parser = (compileCb) compileLSL;
2222 compileScript(compiler, COMPILE_THREADED); 2222 compileScript(compiler, FALSE);
2223 2223
2224 return TRUE; 2224 return TRUE;
2225 } 2225 }
@@ -2252,7 +2252,7 @@ void compileLSL(LuaCompiler *compiler)
2252 lcompiler->ignorable = eina_strbuf_new(); 2252 lcompiler->ignorable = eina_strbuf_new();
2253#endif 2253#endif
2254 2254
2255// PI("Compiling %s.", lcompiler->compiler->file); 2255 PI("Compiling %s.", lcompiler->compiler->file);
2256 2256
2257 in = fopen(lcompiler->compiler->file, "r"); 2257 in = fopen(lcompiler->compiler->file, "r");
2258 if (NULL == in) 2258 if (NULL == in)
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c
index 0ffc679..052bc55 100644
--- a/src/LuaSL/LuaSL_main.c
+++ b/src/LuaSL/LuaSL_main.c
@@ -202,6 +202,28 @@ static void _compileCb(LuaCompiler *compiler)
202 sendBack(compiler->client, compiler->SID, "compiled(false)"); 202 sendBack(compiler->client, compiler->SID, "compiled(false)");
203} 203}
204 204
205static void _compileCbSingle(LuaCompiler *compiler)
206{
207 compileMessage *message = NULL, *safe = NULL;
208
209 EINA_CLIST_FOR_EACH_ENTRY_SAFE(message, safe, &(compiler->messages), compileMessage, node)
210 {
211#if COMPILE_OUTPUT
212 if (message->type)
213 printf("compilerError(%d,%d,%s)\n", message->line, message->column, message->message);
214 else
215 printf("compilerWarning(%d,%d,%s)\n", message->line, message->column, message->message);
216#endif
217 eina_clist_remove(&(message->node));
218 free(message);
219 }
220
221 if (0 == compiler->bugCount)
222 printf("Compiled.\n");
223 else
224 printf("Compile failed!\n");
225}
226
205static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev) 227static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev)
206{ 228{
207 gameGlobals *ourGlobals = data; 229 gameGlobals *ourGlobals = data;
@@ -309,68 +331,87 @@ int main(int argc, char **argv)
309 gameGlobals ourGlobals; 331 gameGlobals ourGlobals;
310 int result = EXIT_FAILURE; 332 int result = EXIT_FAILURE;
311 333
312 memset(&ourGlobals, 0, sizeof(gameGlobals)); 334 memset(&ourGlobals, 0, sizeof(gameGlobals));
313 ourGlobals.address = "127.0.0.1"; 335 ourGlobals.address = "127.0.0.1";
314 ourGlobals.port = 8211; 336 ourGlobals.port = 8211;
315 337
316 if (eina_init()) 338 if (eina_init())
339 {
340 logDom = HamrTime(argv[0], main, logDom);
341 ourGlobals.names = eina_hash_string_superfast_new(NULL);
342 if (ecore_init())
317 { 343 {
318 logDom = HamrTime(argv[0], main, logDom); 344// ecore_thread_max_set(4);
319 ourGlobals.names = eina_hash_string_superfast_new(NULL); 345
320 if (ecore_init()) 346 if (argc > 1)
347 {
348 result = 0;
349 compilerSetup(&ourGlobals);
350 // get the arguments passed in
351 while (--argc > 0 && *++argv != '\0')
352 {
353 LuaCompiler *compiler = calloc(1, sizeof(LuaCompiler));
354
355 eina_clist_init(&(compiler->messages));
356 compiler->file = strdup(*argv);
357 compiler->SID = strdup("0");
358 compiler->doConstants = FALSE;
359 compiler->parser = (compileCb) compileLSL;
360 compiler->cb = _compileCbSingle;
361 compileScript(compiler, FALSE);
362 }
363 }
364 else if (ecore_con_init())
365 {
366 if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals)))
321 { 367 {
322// ecore_thread_max_set(4); 368// int i;
323 if (ecore_con_init()) 369 Eina_Iterator *scripts;
370 script *me;
371
372 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals);
373 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals);
374 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals);
375 ecore_con_server_timeout_set(ourGlobals.server, 0);
376 ecore_con_server_client_limit_set(ourGlobals.server, -1, 0);
377// ecore_con_server_timeout_set(ourGlobals.server, 10);
378// ecore_con_server_client_limit_set(ourGlobals.server, 3, 0);
379 clientStream = eina_strbuf_new();
380
381 result = 0;
382 compilerSetup(&ourGlobals);
383
384// ecore_timer_add(3.0, _statusTimer, &ourGlobals);
385
386 ecore_main_loop_begin();
387 PD("Fell out of the main loop.");
388
389 scripts = eina_hash_iterator_data_new(ourGlobals.names);
390 while(eina_iterator_next(scripts, (void **) &me))
324 { 391 {
325 if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) 392 if (me->SID[0])
326 { 393 send2script(me->SID, "quit()");
327// int i;
328 Eina_Iterator *scripts;
329 script *me;
330
331 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals);
332 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals);
333 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals);
334 ecore_con_server_timeout_set(ourGlobals.server, 0);
335 ecore_con_server_client_limit_set(ourGlobals.server, -1, 0);
336// ecore_con_server_timeout_set(ourGlobals.server, 10);
337// ecore_con_server_client_limit_set(ourGlobals.server, 3, 0);
338 clientStream = eina_strbuf_new();
339
340 result = 0;
341 compilerSetup(&ourGlobals);
342
343// ecore_timer_add(3.0, _statusTimer, &ourGlobals);
344
345 ecore_main_loop_begin();
346 PD("Fell out of the main loop.");
347
348 scripts = eina_hash_iterator_data_new(ourGlobals.names);
349 while(eina_iterator_next(scripts, (void **) &me))
350 {
351 if (me->SID[0])
352 send2script(me->SID, "quit()");
353 }
354
355 PD("Finished quitting scripts.");
356 }
357 else
358 PC("Failed to add server!");
359 ecore_con_shutdown();
360 } 394 }
361 else 395
362 PC("Failed to init ecore_con!"); 396 PD("Finished quitting scripts.");
363 ecore_shutdown();
364 } 397 }
365 else 398 else
366 PC("Failed to init ecore!"); 399 PC("Failed to add server!");
367 pantsOff(logDom); 400 ecore_con_shutdown();
401 }
402 else
403 PC("Failed to init ecore_con!");
404 ecore_shutdown();
368 } 405 }
369 else 406 else
370 fprintf(stderr, "Failed to init eina!"); 407 PC("Failed to init ecore!");
408 pantsOff(logDom);
409 }
410 else
411 fprintf(stderr, "Failed to init eina!");
371 412
372 PD("Falling out of main()"); 413 PD("Falling out of main()");
373 return result; 414 return result;
374} 415}
375 416
376 417