aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-13 13:15:42 +1000
committerDavid Walter Seikel2014-05-13 13:15:42 +1000
commitafd126e1d207c8fe7933562227f16684b00bfc7c (patch)
tree0f34168d20e485738fcfd1b5d67cf5e0d1bb8113 /src/LuaSL
parentDedicating my lifes work to my girl Boots. (diff)
downloadSledjHamr-afd126e1d207c8fe7933562227f16684b00bfc7c.zip
SledjHamr-afd126e1d207c8fe7933562227f16684b00bfc7c.tar.gz
SledjHamr-afd126e1d207c8fe7933562227f16684b00bfc7c.tar.bz2
SledjHamr-afd126e1d207c8fe7933562227f16684b00bfc7c.tar.xz
Finish separating out love.
Diffstat (limited to 'src/LuaSL')
-rw-r--r--src/LuaSL/LuaSL.h23
-rw-r--r--src/LuaSL/LuaSL_compile.c15
-rw-r--r--src/LuaSL/LuaSL_main.c37
-rw-r--r--src/LuaSL/LuaSL_utilities.c60
-rwxr-xr-xsrc/LuaSL/build.lua2
5 files changed, 24 insertions, 113 deletions
diff --git a/src/LuaSL/LuaSL.h b/src/LuaSL/LuaSL.h
index d1f448e..175cebf 100644
--- a/src/LuaSL/LuaSL.h
+++ b/src/LuaSL/LuaSL.h
@@ -8,9 +8,7 @@
8#include <Eet.h> 8#include <Eet.h>
9#include <Ecore.h> 9#include <Ecore.h>
10#include <Ecore_Con.h> 10#include <Ecore_Con.h>
11#include <Ecore_Evas.h>
12#include <Ecore_File.h> 11#include <Ecore_File.h>
13#include <Edje.h>
14#include <stdio.h> 12#include <stdio.h>
15#include <ctype.h> 13#include <ctype.h>
16 14
@@ -26,26 +24,12 @@ typedef struct _gameGlobals gameGlobals; // Define this here, so LuaSL_threads.h
26#include "LumbrJack.h" 24#include "LumbrJack.h"
27 25
28 26
29#define WIDTH (512)
30#define HEIGHT (384)
31
32
33#define TABLE_WIDTH 7
34#define TABLE_HEIGHT 42
35
36
37struct _gameGlobals 27struct _gameGlobals
38{ 28{
39 Ecore_Evas *ee; // Our window.
40 Evas *canvas; // The canvas for drawing directly onto.
41 Evas_Object *bg; // Our background edje, also the game specific stuff.
42 Evas_Object *edje; // The edje of the background.
43 Ecore_Con_Server *server; 29 Ecore_Con_Server *server;
44 Eina_Hash *scripts, *names; 30 Eina_Hash *scripts, *names;
45 int logDom;
46 const char *address; 31 const char *address;
47 int port; 32 int port;
48 boolean ui; // Wether we actually start up the UI.
49}; 33};
50 34
51struct _script 35struct _script
@@ -56,9 +40,7 @@ struct _script
56 char fileName[PATH_MAX]; 40 char fileName[PATH_MAX];
57 lua_State *L; 41 lua_State *L;
58 struct timeval startTime; 42 struct timeval startTime;
59 float compileTime, timerTime; 43 float timerTime;
60 int bugs, warnings;
61 boolean running;
62 int status; 44 int status;
63 int args; 45 int args;
64 Eina_Clist messages; 46 Eina_Clist messages;
@@ -75,8 +57,5 @@ typedef struct
75 57
76 58
77void scriptSendBack(void * data); 59void scriptSendBack(void * data);
78void sendBack(gameGlobals *ourGlobals, Ecore_Con_Client *client, const char *SID, const char *message, ...);
79void sendForth(gameGlobals *ourGlobals, const char *SID, const char *message, ...);
80float timeDiff(struct timeval *now, struct timeval *then);
81 60
82#include "LuaSL_LSL_tree.h" 61#include "LuaSL_LSL_tree.h"
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c
index 3265acf..0c398b9 100644
--- a/src/LuaSL/LuaSL_compile.c
+++ b/src/LuaSL/LuaSL_compile.c
@@ -1,5 +1,6 @@
1 1
2#include "LuaSL.h" 2#include "LuaSL.h"
3#include "Runnr.h"
3 4
4/* TODO - problem de jour 5/* TODO - problem de jour
5*/ 6*/
@@ -316,7 +317,6 @@ static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name)
316 317
317LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *dot, LSL_Leaf *sub) 318LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *dot, LSL_Leaf *sub)
318{ 319{
319 gameGlobals *ourGlobals = compiler->game;
320 const char *search; 320 const char *search;
321 321
322 if (dot) 322 if (dot)
@@ -358,7 +358,7 @@ LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf
358 else 358 else
359 { 359 {
360 compiler->script.bugCount++; 360 compiler->script.bugCount++;
361 sendBack(ourGlobals, compiler->client, compiler->SID, "compilerError(%d,%d,NOT found %s)", identifier->line, identifier->column, identifier->value.stringValue); 361 sendBack(compiler->client, compiler->SID, "compilerError(%d,%d,NOT found %s)", identifier->line, identifier->column, identifier->value.stringValue);
362 } 362 }
363 } 363 }
364 364
@@ -367,8 +367,6 @@ LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf
367 367
368LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) 368LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right)
369{ 369{
370 gameGlobals *ourGlobals = compiler->game;
371
372 if (lval) 370 if (lval)
373 { 371 {
374 opType lType, rType; 372 opType lType, rType;
@@ -402,7 +400,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
402 if (OT_undeclared == lType) 400 if (OT_undeclared == lType)
403 { 401 {
404 compiler->script.warningCount++; 402 compiler->script.warningCount++;
405 sendBack(ourGlobals, compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); 403 sendBack(compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column);
406 lval->basicType = OT_undeclared; 404 lval->basicType = OT_undeclared;
407 return lval; 405 return lval;
408 } 406 }
@@ -430,7 +428,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
430 if (OT_undeclared == rType) 428 if (OT_undeclared == rType)
431 { 429 {
432 compiler->script.warningCount++; 430 compiler->script.warningCount++;
433 sendBack(ourGlobals, compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); 431 sendBack(compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column);
434 lval->basicType = OT_undeclared; 432 lval->basicType = OT_undeclared;
435 return lval; 433 return lval;
436 } 434 }
@@ -587,7 +585,7 @@ else
587 } 585 }
588 586
589 compiler->script.bugCount++; 587 compiler->script.bugCount++;
590 sendBack(ourGlobals, compiler->client, compiler->SID, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken); 588 sendBack(compiler->client, compiler->SID, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken);
591 } 589 }
592 } 590 }
593 591
@@ -991,7 +989,6 @@ LSL_Leaf *addFor(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_L
991 989
992LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier) 990LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier)
993{ 991{
994// gameGlobals *ourGlobals = compiler->game;
995 LSL_Statement *stat = calloc(1, sizeof(LSL_Statement)); 992 LSL_Statement *stat = calloc(1, sizeof(LSL_Statement));
996 boolean justOne = FALSE; 993 boolean justOne = FALSE;
997 994
@@ -2220,7 +2217,7 @@ boolean compileLSL(gameGlobals *ourGlobals, Ecore_Con_Client *client, char *SID,
2220 call->call->basicType = func->basicType; 2217 call->call->basicType = func->basicType;
2221 } 2218 }
2222 else 2219 else
2223 sendBack(ourGlobals, compiler.client, compiler.SID, "compilerError(%d,%d,Undeclared function %s called)", call->call->line, call->call->column, call->call->value.stringValue); 2220 sendBack(compiler.client, compiler.SID, "compilerError(%d,%d,Undeclared function %s called)", call->call->line, call->call->column, call->call->value.stringValue);
2224 } 2221 }
2225 } 2222 }
2226 secondPass(&compiler, compiler.ast); 2223 secondPass(&compiler, compiler.ast);
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c
index f4c94ac..0d8a6db 100644
--- a/src/LuaSL/LuaSL_main.c
+++ b/src/LuaSL/LuaSL_main.c
@@ -1,5 +1,6 @@
1 1
2#include "LuaSL.h" 2#include "LuaSL.h"
3#include "Runnr.h"
3 4
4 5
5int logDom; // Our logging domain. 6int logDom; // Our logging domain.
@@ -110,7 +111,7 @@ void scriptSendBack(void * data)
110 else if (0 == strncmp(message->message, "llResetScript(", 14)) 111 else if (0 == strncmp(message->message, "llResetScript(", 14))
111 resetScript(message->script); 112 resetScript(message->script);
112 else 113 else
113 sendBack(ourGlobals, message->script->client, message->script->SID, message->message); 114 sendBack(message->script->client, message->script->SID, message->message);
114 free(message); 115 free(message);
115} 116}
116 117
@@ -166,10 +167,10 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
166 me->client = ev->client; 167 me->client = ev->client;
167 eina_hash_add(ourGlobals->scripts, me->SID, me); 168 eina_hash_add(ourGlobals->scripts, me->SID, me);
168 eina_hash_add(ourGlobals->names, me->fileName, me); 169 eina_hash_add(ourGlobals->names, me->fileName, me);
169 sendBack(ourGlobals, ev->client, SID, "compiled(true)"); 170 sendBack(ev->client, SID, "compiled(true)");
170 } 171 }
171 else 172 else
172 sendBack(ourGlobals, ev->client, SID, "compiled(false)"); 173 sendBack(ev->client, SID, "compiled(false)");
173 } 174 }
174 else if (0 == strcmp(command, "run()")) 175 else if (0 == strcmp(command, "run()"))
175 { 176 {
@@ -238,6 +239,8 @@ int main(int argc, char **argv)
238 { 239 {
239 if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) 240 if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals)))
240 { 241 {
242 int i;
243
241 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals); 244 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals);
242 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals); 245 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals);
243 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals); 246 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals);
@@ -247,26 +250,18 @@ int main(int argc, char **argv)
247 ecore_con_server_client_limit_set(ourGlobals.server, 3, 0); 250 ecore_con_server_client_limit_set(ourGlobals.server, 3, 0);
248 clientStream = eina_strbuf_new(); 251 clientStream = eina_strbuf_new();
249 252
250 if (edje_init()) 253 result = 0;
254 compilerSetup(&ourGlobals);
255 luaprocInit();
256 for (i = 0; i < CPUs; i++)
251 { 257 {
252 int i; 258 if ( sched_create_worker( ) != LUAPROC_SCHED_OK )
253 259 PE("Error creating luaproc worker thread.");
254 result = 0;
255 compilerSetup(&ourGlobals);
256 luaprocInit();
257 for (i = 0; i < CPUs; i++)
258 {
259 if ( sched_create_worker( ) != LUAPROC_SCHED_OK )
260 PE("Error creating luaproc worker thread.");
261 }
262 ecore_main_loop_begin();
263
264 // TODO - this is what hangs the system, should change from raw pthreads to ecore threads.
265 sched_join_workerthreads();
266 edje_shutdown();
267 } 260 }
268 else 261 ecore_main_loop_begin();
269 PC("Failed to init edje!"); 262
263 // TODO - this is what hangs the system, should change from raw pthreads to ecore threads.
264 sched_join_workerthreads();
270 } 265 }
271 else 266 else
272 PC("Failed to add server!"); 267 PC("Failed to add server!");
diff --git a/src/LuaSL/LuaSL_utilities.c b/src/LuaSL/LuaSL_utilities.c
deleted file mode 100644
index 40263df..0000000
--- a/src/LuaSL/LuaSL_utilities.c
+++ /dev/null
@@ -1,60 +0,0 @@
1#include "LuaSL.h"
2
3
4void sendBack(gameGlobals *ourGlobals, Ecore_Con_Client *client, const char *SID, const char *message, ...)
5{
6 va_list args;
7 char buf[PATH_MAX];
8 int length = strlen(SID);
9
10 strncpy(buf, SID, length);
11 buf[length++] = '.';
12 va_start(args, message);
13 length += vsprintf(&buf[length], message, args);
14 va_end(args);
15 buf[length++] = '\n';
16 buf[length++] = '\0';
17 ecore_con_client_send(client, buf, strlen(buf));
18 ecore_con_client_flush(client);
19}
20
21void sendForth(gameGlobals *ourGlobals, const char *SID, const char *message, ...)
22{
23 va_list args;
24 char buf[PATH_MAX];
25 int length = strlen(SID);
26
27 strncpy(buf, SID, length);
28 buf[length++] = '.';
29 va_start(args, message);
30 length += vsprintf(&buf[length], message, args);
31 va_end(args);
32 buf[length++] = '\n';
33 buf[length++] = '\0';
34 ecore_con_server_send(ourGlobals->server, buf, strlen(buf));
35 ecore_con_server_flush(ourGlobals->server);
36}
37
38float timeDiff(struct timeval *now, struct timeval *then)
39{
40 if (0 == gettimeofday(now, 0))
41 {
42 struct timeval thisTime = { 0, 0 };
43 double result = 0.0;
44
45 thisTime.tv_sec = now->tv_sec;
46 thisTime.tv_usec = now->tv_usec;
47 if (thisTime.tv_usec < then->tv_usec)
48 {
49 thisTime.tv_sec--;
50 thisTime.tv_usec += 1000000;
51 }
52 thisTime.tv_usec -= then->tv_usec;
53 thisTime.tv_sec -= then->tv_sec;
54 result = ((double) thisTime.tv_usec) / ((double) 1000000.0);
55 result += thisTime.tv_sec;
56 return result;
57 }
58 else
59 return 0.0;
60}
diff --git a/src/LuaSL/build.lua b/src/LuaSL/build.lua
index 0efcca3..084a39c 100755
--- a/src/LuaSL/build.lua
+++ b/src/LuaSL/build.lua
@@ -26,4 +26,4 @@ CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. lib_d .. '\\"'
26CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"' 26CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"'
27CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"' 27CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"'
28 28
29compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_utilities', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '') 29compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '')