aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-21 18:28:19 +1000
committerDavid Walter Seikel2014-04-21 18:28:19 +1000
commit26df7205616dbcf80b60c1ed3c04ebea26975fe9 (patch)
tree7bc3851bf7eb3232367cdf8dc6894acf6cb51780 /LuaSL/src
parentGuiLua uses LumbrJack and Runnr from the shared libraries directory at run ti... (diff)
downloadSledjHamr-26df7205616dbcf80b60c1ed3c04ebea26975fe9.zip
SledjHamr-26df7205616dbcf80b60c1ed3c04ebea26975fe9.tar.gz
SledjHamr-26df7205616dbcf80b60c1ed3c04ebea26975fe9.tar.bz2
SledjHamr-26df7205616dbcf80b60c1ed3c04ebea26975fe9.tar.xz
Convert LuaSL to use LumbrJack.
Diffstat (limited to 'LuaSL/src')
-rw-r--r--LuaSL/src/LuaSL.h31
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h4
-rw-r--r--LuaSL/src/LuaSL_compile.c24
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y8
-rw-r--r--LuaSL/src/LuaSL_main.c80
-rw-r--r--LuaSL/src/LuaSL_test.c162
-rw-r--r--LuaSL/src/LuaSL_threads.c4
-rw-r--r--LuaSL/src/LuaSL_threads.h2
-rw-r--r--LuaSL/src/LuaSL_utilities.c84
9 files changed, 149 insertions, 250 deletions
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h
index 086d1b7..5dfa0eb 100644
--- a/LuaSL/src/LuaSL.h
+++ b/LuaSL/src/LuaSL.h
@@ -23,39 +23,16 @@ typedef struct _script script; // Define this here, so LuaSL_threads.h can use
23typedef struct _gameGlobals gameGlobals; // Define this here, so LuaSL_threads.h can use it. 23typedef struct _gameGlobals gameGlobals; // Define this here, so LuaSL_threads.h can use it.
24 24
25#include "LuaSL_threads.h" 25#include "LuaSL_threads.h"
26#include "LumbrJack.h"
26 27
27 28
28#define WIDTH (1024) 29#define WIDTH (1024)
29#define HEIGHT (768) 30#define HEIGHT (768)
30 31
31#define PC(...) EINA_LOG_DOM_CRIT(game->logDom, __VA_ARGS__)
32#define PE(...) EINA_LOG_DOM_ERR(game->logDom, __VA_ARGS__)
33#define PW(...) EINA_LOG_DOM_WARN(game->logDom, __VA_ARGS__)
34#define PD(...) EINA_LOG_DOM_DBG(game->logDom, __VA_ARGS__)
35#define PI(...) EINA_LOG_DOM_INFO(game->logDom, __VA_ARGS__)
36
37#define PCm(...) EINA_LOG_DOM_CRIT(game.logDom, __VA_ARGS__)
38#define PEm(...) EINA_LOG_DOM_ERR(game.logDom, __VA_ARGS__)
39#define PWm(...) EINA_LOG_DOM_WARN(game.logDom, __VA_ARGS__)
40#define PDm(...) EINA_LOG_DOM_DBG(game.logDom, __VA_ARGS__)
41#define PIm(...) EINA_LOG_DOM_INFO(game.logDom, __VA_ARGS__)
42
43#define D() PD("DEBUG")
44
45// "01:03:52 01-01-1973\n\0"
46#define DATE_TIME_LEN 21
47 32
48#define TABLE_WIDTH 7 33#define TABLE_WIDTH 7
49#define TABLE_HEIGHT 42 34#define TABLE_HEIGHT 42
50 35
51#ifndef FALSE
52// NEVER change this
53typedef enum
54{
55 FALSE = 0,
56 TRUE = 1
57} boolean;
58#endif
59 36
60struct _gameGlobals 37struct _gameGlobals
61{ 38{
@@ -97,11 +74,9 @@ typedef struct
97} scriptMessage; 74} scriptMessage;
98 75
99 76
100void loggingStartup(gameGlobals *game);
101char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut);
102void scriptSendBack(void * data); 77void scriptSendBack(void * data);
103void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message, ...); 78void sendBack(gameGlobals *ourGlobals, Ecore_Con_Client *client, const char *SID, const char *message, ...);
104void sendForth(gameGlobals *game, const char *SID, const char *message, ...); 79void sendForth(gameGlobals *ourGlobals, const char *SID, const char *message, ...);
105float timeDiff(struct timeval *now, struct timeval *then); 80float timeDiff(struct timeval *now, struct timeval *then);
106 81
107#include "LuaSL_LSL_tree.h" 82#include "LuaSL_LSL_tree.h"
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index f172110..5415228 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -406,8 +406,8 @@ typedef struct
406 406
407 407
408 408
409boolean compilerSetup(gameGlobals *game); 409boolean compilerSetup(gameGlobals *ourGlobals);
410boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *SID, char *script, boolean doConstants); 410boolean compileLSL(gameGlobals *ourGlobals, Ecore_Con_Client *client, char *SID, char *script, boolean doConstants);
411void burnLeaf(void *data); 411void burnLeaf(void *data);
412 412
413LSL_Leaf *addBlock(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); 413LSL_Leaf *addBlock(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right);
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 2a4c503..afff67f 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -316,7 +316,7 @@ static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name)
316 316
317LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *dot, LSL_Leaf *sub) 317LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *dot, LSL_Leaf *sub)
318{ 318{
319 gameGlobals *game = compiler->game; 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(game, compiler->client, compiler->SID, "compilerError(%d,%d,NOT found %s)", identifier->line, identifier->column, identifier->value.stringValue); 361 sendBack(ourGlobals, compiler->client, compiler->SID, "compilerError(%d,%d,NOT found %s)", identifier->line, identifier->column, identifier->value.stringValue);
362 } 362 }
363 } 363 }
364 364
@@ -367,7 +367,7 @@ 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 *game = compiler->game; 370 gameGlobals *ourGlobals = compiler->game;
371 371
372 if (lval) 372 if (lval)
373 { 373 {
@@ -402,7 +402,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
402 if (OT_undeclared == lType) 402 if (OT_undeclared == lType)
403 { 403 {
404 compiler->script.warningCount++; 404 compiler->script.warningCount++;
405 sendBack(game, compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); 405 sendBack(ourGlobals, 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; 406 lval->basicType = OT_undeclared;
407 return lval; 407 return lval;
408 } 408 }
@@ -430,7 +430,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
430 if (OT_undeclared == rType) 430 if (OT_undeclared == rType)
431 { 431 {
432 compiler->script.warningCount++; 432 compiler->script.warningCount++;
433 sendBack(game, compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); 433 sendBack(ourGlobals, 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; 434 lval->basicType = OT_undeclared;
435 return lval; 435 return lval;
436 } 436 }
@@ -587,7 +587,7 @@ else
587 } 587 }
588 588
589 compiler->script.bugCount++; 589 compiler->script.bugCount++;
590 sendBack(game, 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); 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);
591 } 591 }
592 } 592 }
593 593
@@ -991,7 +991,7 @@ LSL_Leaf *addFor(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_L
991 991
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) 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)
993{ 993{
994 gameGlobals *game = compiler->game; 994 gameGlobals *ourGlobals = compiler->game;
995 LSL_Statement *stat = calloc(1, sizeof(LSL_Statement)); 995 LSL_Statement *stat = calloc(1, sizeof(LSL_Statement));
996 boolean justOne = FALSE; 996 boolean justOne = FALSE;
997 997
@@ -2095,7 +2095,7 @@ static void outputStringToken(FILE *file, outputMode mode, LSL_Leaf *content)
2095 fprintf(file, "%s", content->value.stringValue); // The quotes are part of the string value already. 2095 fprintf(file, "%s", content->value.stringValue); // The quotes are part of the string value already.
2096} 2096}
2097 2097
2098boolean compilerSetup(gameGlobals *game) 2098boolean compilerSetup(gameGlobals *ourGlobals)
2099{ 2099{
2100 int i; 2100 int i;
2101 2101
@@ -2122,7 +2122,7 @@ boolean compilerSetup(gameGlobals *game)
2122 snprintf(buf, sizeof(buf), "lua -e 'require(\"LSL\").gimmeLSL()' > %s/constants.lsl", PACKAGE_DATA_DIR); 2122 snprintf(buf, sizeof(buf), "lua -e 'require(\"LSL\").gimmeLSL()' > %s/constants.lsl", PACKAGE_DATA_DIR);
2123 system(buf); 2123 system(buf);
2124 snprintf(buf, sizeof(buf), "%s/constants.lsl", PACKAGE_DATA_DIR); 2124 snprintf(buf, sizeof(buf), "%s/constants.lsl", PACKAGE_DATA_DIR);
2125 compileLSL(game, NULL, "FAKE_SID", buf, TRUE); 2125 compileLSL(ourGlobals, NULL, "FAKE_SID", buf, TRUE);
2126 2126
2127 return TRUE; 2127 return TRUE;
2128 } 2128 }
@@ -2142,7 +2142,7 @@ static int luaWriter(lua_State *L, const void* p, size_t sz, void* ud)
2142 return result; 2142 return result;
2143} 2143}
2144 2144
2145boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *SID, char *script, boolean doConstants) 2145boolean compileLSL(gameGlobals *ourGlobals, Ecore_Con_Client *client, char *SID, char *script, boolean doConstants)
2146{ 2146{
2147 boolean result = FALSE; 2147 boolean result = FALSE;
2148 LuaSL_compiler compiler; 2148 LuaSL_compiler compiler;
@@ -2153,7 +2153,7 @@ boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *SID, char
2153// Just pass all LSL constants and ll*() )function names through to Lua, assume they are globals there. 2153// Just pass all LSL constants and ll*() )function names through to Lua, assume they are globals there.
2154 2154
2155 memset(&compiler, 0, sizeof(LuaSL_compiler)); 2155 memset(&compiler, 0, sizeof(LuaSL_compiler));
2156 compiler.game = game; 2156 compiler.game = ourGlobals;
2157 compiler.client = client; 2157 compiler.client = client;
2158 compiler.script.functions = eina_hash_stringshared_new(burnLeaf); 2158 compiler.script.functions = eina_hash_stringshared_new(burnLeaf);
2159 compiler.script.states = eina_hash_stringshared_new(burnLeaf); 2159 compiler.script.states = eina_hash_stringshared_new(burnLeaf);
@@ -2220,7 +2220,7 @@ boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *SID, char
2220 call->call->basicType = func->basicType; 2220 call->call->basicType = func->basicType;
2221 } 2221 }
2222 else 2222 else
2223 sendBack(game, compiler.client, compiler.SID, "compilerError(%d,%d,Undeclared function %s called)", call->call->line, call->call->column, call->call->value.stringValue); 2223 sendBack(ourGlobals, compiler.client, compiler.SID, "compilerError(%d,%d,Undeclared function %s called)", call->call->line, call->call->column, call->call->value.stringValue);
2224 } 2224 }
2225 } 2225 }
2226 secondPass(&compiler, compiler.ast); 2226 secondPass(&compiler, compiler.ast);
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index 1ac3cc8..182789f 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -222,14 +222,14 @@ expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; }
222 222
223%parse_accept 223%parse_accept
224{ 224{
225// gameGlobals *game = compiler->game; 225// gameGlobals *ourGlobals = compiler->game;
226 226
227// PI("Parsing complete."); 227// PI("Parsing complete.");
228} 228}
229 229
230%parse_failure 230%parse_failure
231{ 231{
232 gameGlobals *game = compiler->game; 232 gameGlobals *ourGlobals = compiler->game;
233 233
234 compiler->script.bugCount++; 234 compiler->script.bugCount++;
235 PE("Giving up. Parser is hopelessly lost!"); 235 PE("Giving up. Parser is hopelessly lost!");
@@ -237,7 +237,7 @@ expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; }
237 237
238%stack_overflow 238%stack_overflow
239{ 239{
240 gameGlobals *game = compiler->game; 240 gameGlobals *ourGlobals = compiler->game;
241 241
242 compiler->script.bugCount++; 242 compiler->script.bugCount++;
243 PE("Giving up. Parser stack overflow @ line %d, column %d!", yypMinor->yy0->line, yypMinor->yy0->column); // Gotta love consistancy, if it ever happens. 243 PE("Giving up. Parser stack overflow @ line %d, column %d!", yypMinor->yy0->line, yypMinor->yy0->column); // Gotta love consistancy, if it ever happens.
@@ -245,7 +245,7 @@ expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; }
245 245
246%syntax_error 246%syntax_error
247{ 247{
248 gameGlobals *game = compiler->game; 248 gameGlobals *ourGlobals = compiler->game;
249 249
250 compiler->script.bugCount++; 250 compiler->script.bugCount++;
251 PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column); 251 PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column);
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c
index ac0b0c9..0a40712 100644
--- a/LuaSL/src/LuaSL_main.c
+++ b/LuaSL/src/LuaSL_main.c
@@ -9,24 +9,24 @@ static Eina_Strbuf *clientStream;
9static Eina_Bool _sleep_timer_cb(void *data) 9static Eina_Bool _sleep_timer_cb(void *data)
10{ 10{
11 script *script = data; 11 script *script = data;
12 gameGlobals *game = script->game; 12 gameGlobals *ourGlobals = script->game;
13 13
14 PD("Waking up %s", script->SID); 14 PD("Waking up %s", script->SID);
15 sendToChannel(game, script->SID, "return 0.0"); 15 sendToChannel(ourGlobals, script->SID, "return 0.0");
16 return ECORE_CALLBACK_CANCEL; 16 return ECORE_CALLBACK_CANCEL;
17} 17}
18 18
19static Eina_Bool _timer_timer_cb(void *data) 19static Eina_Bool _timer_timer_cb(void *data)
20{ 20{
21 script *script = data; 21 script *script = data;
22 gameGlobals *game = script->game; 22 gameGlobals *ourGlobals = script->game;
23 23
24 PD("Timer for %s", script->SID); 24 PD("Timer for %s", script->SID);
25 sendToChannel(game, script->SID, "events.timer()"); 25 sendToChannel(ourGlobals, script->SID, "events.timer()");
26 return ECORE_CALLBACK_RENEW; 26 return ECORE_CALLBACK_RENEW;
27} 27}
28 28
29static script *findThem(gameGlobals *game, const char *base, const char *text) 29static script *findThem(gameGlobals *ourGlobals, const char *base, const char *text)
30{ 30{
31 char name[PATH_MAX]; 31 char name[PATH_MAX];
32 char *temp; 32 char *temp;
@@ -38,12 +38,12 @@ static script *findThem(gameGlobals *game, const char *base, const char *text)
38 if ((temp = rindex(name, '"'))) 38 if ((temp = rindex(name, '"')))
39 temp[0] = '\0'; 39 temp[0] = '\0';
40 strcat(name, ".lsl"); 40 strcat(name, ".lsl");
41 return eina_hash_find(game->names, name); 41 return eina_hash_find(ourGlobals->names, name);
42} 42}
43 43
44static void resetScript(script *victim) 44static void resetScript(script *victim)
45{ 45{
46 gameGlobals *game = victim->game; 46 gameGlobals *ourGlobals = victim->game;
47 47
48 PD("Resetting %s", victim->fileName); 48 PD("Resetting %s", victim->fileName);
49 // TODO - now what? 49 // TODO - now what?
@@ -52,7 +52,7 @@ static void resetScript(script *victim)
52void scriptSendBack(void * data) 52void scriptSendBack(void * data)
53{ 53{
54 scriptMessage *message = data; 54 scriptMessage *message = data;
55 gameGlobals *game = message->script->game; 55 gameGlobals *ourGlobals = message->script->game;
56 56
57 if (0 == strncmp(message->message, "llSleep(", 8)) 57 if (0 == strncmp(message->message, "llSleep(", 8))
58 ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script); 58 ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script);
@@ -72,7 +72,7 @@ void scriptSendBack(void * data)
72 { 72 {
73 script *them; 73 script *them;
74 74
75 if ((them = findThem(game, message->script->fileName, &(message->message[18])))) 75 if ((them = findThem(ourGlobals, message->script->fileName, &(message->message[18]))))
76 { 76 {
77 char *temp = rindex(&(message->message[18]), ','); 77 char *temp = rindex(&(message->message[18]), ',');
78 78
@@ -82,9 +82,9 @@ void scriptSendBack(void * data)
82 while (isspace(*temp)) 82 while (isspace(*temp))
83 temp++; 83 temp++;
84 if ('1' == *temp) 84 if ('1' == *temp)
85 sendToChannel(game, them->SID, "start()"); 85 sendToChannel(ourGlobals, them->SID, "start()");
86 else 86 else
87 sendToChannel(game, them->SID, "stop()"); 87 sendToChannel(ourGlobals, them->SID, "stop()");
88 PD("Stopped %s", them->fileName); 88 PD("Stopped %s", them->fileName);
89 } 89 }
90 else 90 else
@@ -103,13 +103,13 @@ void scriptSendBack(void * data)
103 { 103 {
104 script *them; 104 script *them;
105 105
106 if ((them = findThem(game, message->script->fileName, &(message->message[20])))) 106 if ((them = findThem(ourGlobals, message->script->fileName, &(message->message[20]))))
107 resetScript(them); 107 resetScript(them);
108 } 108 }
109 else if (0 == strncmp(message->message, "llResetScript(", 14)) 109 else if (0 == strncmp(message->message, "llResetScript(", 14))
110 resetScript(message->script); 110 resetScript(message->script);
111 else 111 else
112 sendBack(game, message->script->client, message->script->SID, message->message); 112 sendBack(ourGlobals, message->script->client, message->script->SID, message->message);
113 free(message); 113 free(message);
114} 114}
115 115
@@ -121,7 +121,7 @@ static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Ad
121 121
122static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev) 122static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev)
123{ 123{
124 gameGlobals *game = data; 124 gameGlobals *ourGlobals = data;
125 char buf[PATH_MAX]; 125 char buf[PATH_MAX];
126 char SID[PATH_MAX]; 126 char SID[PATH_MAX];
127 const char *command; 127 const char *command;
@@ -154,28 +154,28 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
154 temp[0] = '\0'; 154 temp[0] = '\0';
155 155
156 PD("Compiling %s, %s.", SID, file); 156 PD("Compiling %s, %s.", SID, file);
157 if (compileLSL(game, ev->client, SID, file, FALSE)) 157 if (compileLSL(ourGlobals, ev->client, SID, file, FALSE))
158 { 158 {
159 script *me = calloc(1, sizeof(script)); 159 script *me = calloc(1, sizeof(script));
160 160
161 gettimeofday(&me->startTime, NULL); 161 gettimeofday(&me->startTime, NULL);
162 strncpy(me->SID, SID, sizeof(me->SID)); 162 strncpy(me->SID, SID, sizeof(me->SID));
163 strncpy(me->fileName, file, sizeof(me->fileName)); 163 strncpy(me->fileName, file, sizeof(me->fileName));
164 me->game = game; 164 me->game = ourGlobals;
165 me->client = ev->client; 165 me->client = ev->client;
166 eina_hash_add(game->scripts, me->SID, me); 166 eina_hash_add(ourGlobals->scripts, me->SID, me);
167 eina_hash_add(game->names, me->fileName, me); 167 eina_hash_add(ourGlobals->names, me->fileName, me);
168 sendBack(game, ev->client, SID, "compiled(true)"); 168 sendBack(ourGlobals, ev->client, SID, "compiled(true)");
169 } 169 }
170 else 170 else
171 sendBack(game, ev->client, SID, "compiled(false)"); 171 sendBack(ourGlobals, ev->client, SID, "compiled(false)");
172 } 172 }
173 else if (0 == strcmp(command, "run()")) 173 else if (0 == strcmp(command, "run()"))
174 { 174 {
175 script *me; 175 script *me;
176 char buf[PATH_MAX]; 176 char buf[PATH_MAX];
177 177
178 me = eina_hash_find(game->scripts, SID); 178 me = eina_hash_find(ourGlobals->scripts, SID);
179 if (me) 179 if (me)
180 { 180 {
181 sprintf(buf, "%s.lua.out", me->fileName); 181 sprintf(buf, "%s.lua.out", me->fileName);
@@ -191,7 +191,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
191 { 191 {
192 const char *status = NULL; 192 const char *status = NULL;
193 193
194 status = sendToChannel(game, SID, command); 194 status = sendToChannel(ourGlobals, SID, command);
195 if (status) 195 if (status)
196 PE("Error sending command %s to script %s : %s", command, SID, status); 196 PE("Error sending command %s to script %s : %s", command, SID, status);
197 } 197 }
@@ -206,7 +206,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
206 206
207static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev) 207static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev)
208{ 208{
209 gameGlobals *game = data; 209 gameGlobals *ourGlobals = data;
210 210
211 if (ev->client) 211 if (ev->client)
212 { 212 {
@@ -219,31 +219,31 @@ static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_De
219 219
220int main(int argc, char **argv) 220int main(int argc, char **argv)
221{ 221{
222 gameGlobals game; 222 gameGlobals ourGlobals;
223 int result = EXIT_FAILURE; 223 int result = EXIT_FAILURE;
224 224
225 memset(&game, 0, sizeof(gameGlobals)); 225 memset(&ourGlobals, 0, sizeof(gameGlobals));
226 game.address = "127.0.0.1"; 226 ourGlobals.address = "127.0.0.1";
227 game.port = 8211; 227 ourGlobals.port = 8211;
228 228
229 if (eina_init()) 229 if (eina_init())
230 { 230 {
231 loggingStartup(&game); 231 ourGlobals.logDom = loggingStartup("LuaSL", ourGlobals.logDom);
232 game.scripts = eina_hash_string_superfast_new(NULL); 232 ourGlobals.scripts = eina_hash_string_superfast_new(NULL);
233 game.names = eina_hash_string_superfast_new(NULL); 233 ourGlobals.names = eina_hash_string_superfast_new(NULL);
234 if (ecore_con_init()) 234 if (ecore_con_init())
235 { 235 {
236 if (ecore_con_init()) 236 if (ecore_con_init())
237 { 237 {
238 if ((game.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, game.address, game.port, &game))) 238 if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals)))
239 { 239 {
240 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &game); 240 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals);
241 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &game); 241 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals);
242 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &game); 242 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals);
243 ecore_con_server_timeout_set(game.server, 0); 243 ecore_con_server_timeout_set(ourGlobals.server, 0);
244 ecore_con_server_client_limit_set(game.server, -1, 0); 244 ecore_con_server_client_limit_set(ourGlobals.server, -1, 0);
245 ecore_con_server_timeout_set(game.server, 10); 245 ecore_con_server_timeout_set(ourGlobals.server, 10);
246 ecore_con_server_client_limit_set(game.server, 3, 0); 246 ecore_con_server_client_limit_set(ourGlobals.server, 3, 0);
247 clientStream = eina_strbuf_new(); 247 clientStream = eina_strbuf_new();
248 248
249 if (edje_init()) 249 if (edje_init())
@@ -251,7 +251,7 @@ int main(int argc, char **argv)
251 int i; 251 int i;
252 252
253 result = 0; 253 result = 0;
254 compilerSetup(&game); 254 compilerSetup(&ourGlobals);
255 luaprocInit(); 255 luaprocInit();
256 for (i = 0; i < CPUs; i++) 256 for (i = 0; i < CPUs; i++)
257 { 257 {
@@ -402,7 +402,7 @@ static int errFunc(lua_State *L)
402 return 0; 402 return 0;
403} 403}
404 404
405void runLuaFile(gameGlobals *game, const char *filename) 405void runLuaFile(gameGlobals *ourGlobals, const char *filename)
406{ 406{
407 PD("Starting %s", filename); 407 PD("Starting %s", filename);
408 newProc(filename, TRUE); 408 newProc(filename, TRUE);
diff --git a/LuaSL/src/LuaSL_test.c b/LuaSL/src/LuaSL_test.c
index 69cbf2c..51fd902 100644
--- a/LuaSL/src/LuaSL_test.c
+++ b/LuaSL/src/LuaSL_test.c
@@ -22,31 +22,31 @@ static const char *names[] =
22static void 22static void
23_edje_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source) 23_edje_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source)
24{ 24{
25// gameGlobals *game = data; 25// gameGlobals *ourGlobals = data;
26} 26}
27 27
28static 28static
29Eina_Bool anim(void *data) 29Eina_Bool anim(void *data)
30{ 30{
31 gameGlobals *game = data; 31 gameGlobals *ourGlobals = data;
32 Evas_Object *bub, *sh; 32 Evas_Object *bub, *sh;
33 Evas_Coord x, y, w, h, vw, vh; 33 Evas_Coord x, y, w, h, vw, vh;
34 double t, xx, yy, zz, r, fac; 34 double t, xx, yy, zz, r, fac;
35 double lx, ly; 35 double lx, ly;
36 unsigned int i; 36 unsigned int i;
37 37
38 evas_output_viewport_get(game->canvas, 0, 0, &vw, &vh); 38 evas_output_viewport_get(ourGlobals->canvas, 0, 0, &vw, &vh);
39 r = 48; 39 r = 48;
40 t = ecore_loop_time_get(); 40 t = ecore_loop_time_get();
41 fac = 2.0 / (double)((sizeof(names) / sizeof(char *) / 2)); 41 fac = 2.0 / (double)((sizeof(names) / sizeof(char *) / 2));
42 evas_pointer_canvas_xy_get(game->canvas, &x, &y); 42 evas_pointer_canvas_xy_get(ourGlobals->canvas, &x, &y);
43 lx = x; 43 lx = x;
44 ly = y; 44 ly = y;
45 45
46 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) 46 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
47 { 47 {
48 bub = evas_object_data_get(game->bg, names[i * 2]); 48 bub = evas_object_data_get(ourGlobals->bg, names[i * 2]);
49 sh = evas_object_data_get(game->bg, names[(i * 2) + 1]); 49 sh = evas_object_data_get(ourGlobals->bg, names[(i * 2) + 1]);
50 zz = (((2 + sin(t * 6 + (M_PI * (i * fac)))) / 3) * 64) * 2; 50 zz = (((2 + sin(t * 6 + (M_PI * (i * fac)))) / 3) * 64) * 2;
51 xx = (cos(t * 4 + (M_PI * (i * fac))) * r) * 2; 51 xx = (cos(t * 4 + (M_PI * (i * fac))) * r) * 2;
52 yy = (sin(t * 6 + (M_PI * (i * fac))) * r) * 2; 52 yy = (sin(t * 6 + (M_PI * (i * fac))) * r) * 2;
@@ -78,7 +78,7 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
78 78
79static void dirList_compile(const char *name, const char *path, void *data) 79static void dirList_compile(const char *name, const char *path, void *data)
80{ 80{
81 gameGlobals *game = data; 81 gameGlobals *ourGlobals = data;
82 82
83 char *ext = rindex(name, '.'); 83 char *ext = rindex(name, '.');
84 84
@@ -92,34 +92,34 @@ static void dirList_compile(const char *name, const char *path, void *data)
92 gettimeofday(&me->startTime, NULL); 92 gettimeofday(&me->startTime, NULL);
93 snprintf(me->SID, sizeof(me->SID), "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); 93 snprintf(me->SID, sizeof(me->SID), "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random());
94 snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); 94 snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name);
95 eina_hash_add(game->scripts, me->SID, me); 95 eina_hash_add(ourGlobals->scripts, me->SID, me);
96 sendForth(game, me->SID, "compile(%s)", me->fileName); 96 sendForth(ourGlobals, me->SID, "compile(%s)", me->fileName);
97 } 97 }
98 } 98 }
99} 99}
100 100
101static Eina_Bool _timer_cb(void *data) 101static Eina_Bool _timer_cb(void *data)
102{ 102{
103 gameGlobals *game = data; 103 gameGlobals *ourGlobals = data;
104 Eina_Iterator *scripts; 104 Eina_Iterator *scripts;
105 script *me; 105 script *me;
106 boolean exit = FALSE; 106 boolean exit = FALSE;
107 107
108 scripts = eina_hash_iterator_data_new(game->scripts); 108 scripts = eina_hash_iterator_data_new(ourGlobals->scripts);
109 while(eina_iterator_next(scripts, (void **) &me)) 109 while(eina_iterator_next(scripts, (void **) &me))
110 { 110 {
111 switch (timedEvent) 111 switch (timedEvent)
112 { 112 {
113 case 5 : 113 case 5 :
114 { 114 {
115 sendForth(game, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); 115 sendForth(ourGlobals, me->SID, "events.detectedKeys({\"%s\"})", ownerKey);
116 sendForth(game, me->SID, "events.detectedNames({\"%s\"})", ownerName); 116 sendForth(ourGlobals, me->SID, "events.detectedNames({\"%s\"})", ownerName);
117 sendForth(game, me->SID, "events.touch_start(1)"); 117 sendForth(ourGlobals, me->SID, "events.touch_start(1)");
118 break; 118 break;
119 } 119 }
120 case 9 : 120 case 9 :
121 { 121 {
122 sendForth(game, me->SID, "quit()"); 122 sendForth(ourGlobals, me->SID, "quit()");
123 break; 123 break;
124 } 124 }
125 case 11 : 125 case 11 :
@@ -133,7 +133,7 @@ static Eina_Bool _timer_cb(void *data)
133 133
134 if (exit) 134 if (exit)
135 { 135 {
136 sendForth(game, ownerKey, "exit()"); 136 sendForth(ourGlobals, ownerKey, "exit()");
137 ecore_main_loop_quit(); 137 ecore_main_loop_quit();
138 return ECORE_CALLBACK_CANCEL; 138 return ECORE_CALLBACK_CANCEL;
139 } 139 }
@@ -142,21 +142,21 @@ static Eina_Bool _timer_cb(void *data)
142 142
143static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev) 143static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev)
144{ 144{
145 gameGlobals *game = data; 145 gameGlobals *ourGlobals = data;
146 char buf[PATH_MAX]; 146 char buf[PATH_MAX];
147 147
148 game->server = ev->server; 148 ourGlobals->server = ev->server;
149 gettimeofday(&startTime, NULL); 149 gettimeofday(&startTime, NULL);
150 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR); 150 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR);
151 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, game); 151 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, ourGlobals);
152 // Wait awhile, then start sending events for testing. 152 // Wait awhile, then start sending events for testing.
153 ecore_timer_add(0.5, _timer_cb, game); 153 ecore_timer_add(0.5, _timer_cb, ourGlobals);
154 return ECORE_CALLBACK_RENEW; 154 return ECORE_CALLBACK_RENEW;
155} 155}
156 156
157static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Data *ev) 157static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Data *ev)
158{ 158{
159 gameGlobals *game = data; 159 gameGlobals *ourGlobals = data;
160 160
161 char buf[PATH_MAX]; 161 char buf[PATH_MAX];
162 char SID[PATH_MAX]; 162 char SID[PATH_MAX];
@@ -179,7 +179,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D
179 179
180 ext[0] = '\0'; 180 ext[0] = '\0';
181 command = ext + 1; 181 command = ext + 1;
182 me = eina_hash_find(game->scripts, SID); 182 me = eina_hash_find(ourGlobals->scripts, SID);
183 if (0 == strncmp(command, "compilerWarning(", 16)) 183 if (0 == strncmp(command, "compilerWarning(", 16))
184 { 184 {
185 char *temp; 185 char *temp;
@@ -247,31 +247,31 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D
247 PD("TOTAL compile speed is %f scripts per second", compiledCount / timeDiff(&now, &startTime)); 247 PD("TOTAL compile speed is %f scripts per second", compiledCount / timeDiff(&now, &startTime));
248 } 248 }
249// PD("The compile of %s worked, running it now.", SID); 249// PD("The compile of %s worked, running it now.", SID);
250 sendForth(game, SID, "run()"); 250 sendForth(ourGlobals, SID, "run()");
251 } 251 }
252 else 252 else
253 { 253 {
254 // Send back some random or fixed values for testing. 254 // Send back some random or fixed values for testing.
255 if (0 == strcmp(command, "llGetKey()")) 255 if (0 == strcmp(command, "llGetKey()"))
256 sendForth(game, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); 256 sendForth(ourGlobals, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random());
257 else if (0 == strcmp(command, "llGetOwner()")) 257 else if (0 == strcmp(command, "llGetOwner()"))
258 sendForth(game, SID, "return \"%s\"", ownerKey); 258 sendForth(ourGlobals, SID, "return \"%s\"", ownerKey);
259 else if (0 == strcmp(command, "llGetPos()")) 259 else if (0 == strcmp(command, "llGetPos()"))
260 sendForth(game, SID, "return {x=128.0, y=128.0, z=128.0}"); 260 sendForth(ourGlobals, SID, "return {x=128.0, y=128.0, z=128.0}");
261 else if (0 == strcmp(command, "llGetRot()")) 261 else if (0 == strcmp(command, "llGetRot()"))
262 sendForth(game, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}"); 262 sendForth(ourGlobals, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}");
263 else if (0 == strcmp(command, "llGetObjectDesc()")) 263 else if (0 == strcmp(command, "llGetObjectDesc()"))
264 sendForth(game, SID, "return \"\""); 264 sendForth(ourGlobals, SID, "return \"\"");
265 else if (0 == strncmp(command, "llGetAlpha(", 11)) 265 else if (0 == strncmp(command, "llGetAlpha(", 11))
266 sendForth(game, SID, "return 1.0"); 266 sendForth(ourGlobals, SID, "return 1.0");
267 else if (0 == strcmp(command, "llGetInventoryNumber(7)")) 267 else if (0 == strcmp(command, "llGetInventoryNumber(7)"))
268 sendForth(game, SID, "return 3"); 268 sendForth(ourGlobals, SID, "return 3");
269 else if (0 == strcmp(command, "llGetInventoryName(7, 2)")) 269 else if (0 == strcmp(command, "llGetInventoryName(7, 2)"))
270 sendForth(game, SID, "return \".readme\""); 270 sendForth(ourGlobals, SID, "return \".readme\"");
271 else if (0 == strcmp(command, "llGetInventoryName(7, 1)")) 271 else if (0 == strcmp(command, "llGetInventoryName(7, 1)"))
272 sendForth(game, SID, "return \".POSITIONS\""); 272 sendForth(ourGlobals, SID, "return \".POSITIONS\"");
273 else if (0 == strcmp(command, "llGetInventoryName(7, 0)")) 273 else if (0 == strcmp(command, "llGetInventoryName(7, 0)"))
274 sendForth(game, SID, "return \".MENUITEMS\""); 274 sendForth(ourGlobals, SID, "return \".MENUITEMS\"");
275 else 275 else
276 PI("Script %s sent command %s", SID, command); 276 PI("Script %s sent command %s", SID, command);
277 } 277 }
@@ -286,11 +286,11 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D
286 286
287static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev) 287static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev)
288{ 288{
289 gameGlobals *game = data; 289 gameGlobals *ourGlobals = data;
290 290
291 if (ev->server) 291 if (ev->server)
292 { 292 {
293 game->server = NULL; 293 ourGlobals->server = NULL;
294 ecore_con_server_del(ev->server); 294 ecore_con_server_del(ev->server);
295 ecore_main_loop_quit(); 295 ecore_main_loop_quit();
296 } 296 }
@@ -301,27 +301,27 @@ static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Server_De
301int main(int argc, char **argv) 301int main(int argc, char **argv)
302{ 302{
303 /* put here any init specific to this app like parsing args etc. */ 303 /* put here any init specific to this app like parsing args etc. */
304 gameGlobals game; 304 gameGlobals ourGlobals;
305 char *programName = argv[0]; 305 char *programName = argv[0];
306 boolean badArgs = FALSE; 306 boolean badArgs = FALSE;
307 int result = EXIT_FAILURE; 307 int result = EXIT_FAILURE;
308 308
309 memset(&game, 0, sizeof(gameGlobals)); 309 memset(&ourGlobals, 0, sizeof(gameGlobals));
310 game.address = "127.0.0.1"; 310 ourGlobals.address = "127.0.0.1";
311 game.port = 8211; 311 ourGlobals.port = 8211;
312 312
313 if (eina_init()) 313 if (eina_init())
314 { 314 {
315 loggingStartup(&game); 315 ourGlobals.logDom = loggingStartup("LuaSL_test", ourGlobals.logDom);
316 game.scripts = eina_hash_string_superfast_new(NULL); 316 ourGlobals.scripts = eina_hash_string_superfast_new(NULL);
317 317
318 if (ecore_con_init()) 318 if (ecore_con_init())
319 { 319 {
320 if ((game.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, game.address, game.port, &game))) 320 if ((ourGlobals.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals)))
321 { 321 {
322 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &game); 322 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals);
323 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &game); 323 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals);
324 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &game); 324 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals);
325 clientStream = eina_strbuf_new(); 325 clientStream = eina_strbuf_new();
326 326
327 if (ecore_evas_init()) 327 if (ecore_evas_init())
@@ -340,7 +340,7 @@ int main(int argc, char **argv)
340 { 340 {
341 case 'u': 341 case 'u':
342 { 342 {
343 game.ui = TRUE; 343 ourGlobals.ui = TRUE;
344 break; 344 break;
345 } 345 }
346 default: 346 default:
@@ -358,7 +358,7 @@ int main(int argc, char **argv)
358 printf(" -u: Show the test UI.\n"); 358 printf(" -u: Show the test UI.\n");
359 } 359 }
360 else 360 else
361 // else if ((game.config) && (game.data)) 361 // else if ((ourGlobals.config) && (ourGlobals.data))
362 { 362 {
363 unsigned int i; 363 unsigned int i;
364 Evas_Object *bub, *sh; 364 Evas_Object *bub, *sh;
@@ -366,80 +366,80 @@ int main(int argc, char **argv)
366 char *group = "main"; 366 char *group = "main";
367 char buf[PATH_MAX]; 367 char buf[PATH_MAX];
368 368
369 if (game.ui) 369 if (ourGlobals.ui)
370 { 370 {
371 /* this will give you a window with an Evas canvas under the first engine available */ 371 /* this will give you a window with an Evas canvas under the first engine available */
372 game.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 372 ourGlobals.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
373 if (!game.ee) 373 if (!ourGlobals.ee)
374 { 374 {
375 PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly."); 375 PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly.");
376 edje_shutdown(); 376 edje_shutdown();
377 ecore_evas_shutdown(); 377 ecore_evas_shutdown();
378 return -1; 378 return -1;
379 } 379 }
380 game.canvas = ecore_evas_get(game.ee); 380 ourGlobals.canvas = ecore_evas_get(ourGlobals.ee);
381 ecore_evas_title_set(game.ee, "LuaSL test harness"); 381 ecore_evas_title_set(ourGlobals.ee, "LuaSL test harness");
382 ecore_evas_show(game.ee); 382 ecore_evas_show(ourGlobals.ee);
383 383
384 game.bg = evas_object_rectangle_add(game.canvas); 384 ourGlobals.bg = evas_object_rectangle_add(ourGlobals.canvas);
385 evas_object_color_set(game.bg, 255, 255, 255, 255); /* white bg */ 385 evas_object_color_set(ourGlobals.bg, 255, 255, 255, 255); /* white bg */
386 evas_object_move(game.bg, 0, 0); /* at canvas' origin */ 386 evas_object_move(ourGlobals.bg, 0, 0); /* at canvas' origin */
387 evas_object_size_hint_weight_set(game.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 387 evas_object_size_hint_weight_set(ourGlobals.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
388 evas_object_resize(game.bg, WIDTH, HEIGHT); /* covers full canvas */ 388 evas_object_resize(ourGlobals.bg, WIDTH, HEIGHT); /* covers full canvas */
389 evas_object_show(game.bg); 389 evas_object_show(ourGlobals.bg);
390 ecore_evas_object_associate(game.ee, game.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); 390 ecore_evas_object_associate(ourGlobals.ee, ourGlobals.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
391 evas_object_focus_set(game.bg, EINA_TRUE); 391 evas_object_focus_set(ourGlobals.bg, EINA_TRUE);
392 392
393 game.edje = edje_object_add(game.canvas); 393 ourGlobals.edje = edje_object_add(ourGlobals.canvas);
394 snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL"); 394 snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL");
395 if (!edje_object_file_set(game.edje, buf, group)) 395 if (!edje_object_file_set(ourGlobals.edje, buf, group))
396 { 396 {
397 int err = edje_object_load_error_get(game.edje); 397 int err = edje_object_load_error_get(ourGlobals.edje);
398 const char *errmsg = edje_load_error_str(err); 398 const char *errmsg = edje_load_error_str(err);
399 PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg); 399 PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg);
400 400
401 evas_object_del(game.edje); 401 evas_object_del(ourGlobals.edje);
402 ecore_evas_free(game.ee); 402 ecore_evas_free(ourGlobals.ee);
403 edje_shutdown(); 403 edje_shutdown();
404 ecore_evas_shutdown(); 404 ecore_evas_shutdown();
405 return -2; 405 return -2;
406 } 406 }
407 evas_object_move(game.edje, 0, 0); 407 evas_object_move(ourGlobals.edje, 0, 0);
408 evas_object_resize(game.edje, WIDTH, HEIGHT); 408 evas_object_resize(ourGlobals.edje, WIDTH, HEIGHT);
409 evas_object_show(game.edje); 409 evas_object_show(ourGlobals.edje);
410 410
411 snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", PACKAGE_DATA_DIR); 411 snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", PACKAGE_DATA_DIR);
412 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) 412 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
413 { 413 {
414 sh = evas_object_image_filled_add(game.canvas); 414 sh = evas_object_image_filled_add(ourGlobals.canvas);
415 evas_object_image_file_set(sh, buf, NULL); 415 evas_object_image_file_set(sh, buf, NULL);
416 evas_object_resize(sh, 64, 64); 416 evas_object_resize(sh, 64, 64);
417 evas_object_show(sh); 417 evas_object_show(sh);
418 evas_object_data_set(game.bg, names[(i * 2) + 1], sh); 418 evas_object_data_set(ourGlobals.bg, names[(i * 2) + 1], sh);
419 } 419 }
420 420
421 snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR); 421 snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
422 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) 422 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
423 { 423 {
424 bub = evas_object_image_filled_add(game.canvas); 424 bub = evas_object_image_filled_add(ourGlobals.canvas);
425 evas_object_image_file_set(bub, buf, NULL); 425 evas_object_image_file_set(bub, buf, NULL);
426 evas_object_resize(bub, 64, 64); 426 evas_object_resize(bub, 64, 64);
427 evas_object_show(bub); 427 evas_object_show(bub);
428 evas_object_data_set(game.bg, names[(i * 2)], bub); 428 evas_object_data_set(ourGlobals.bg, names[(i * 2)], bub);
429 } 429 }
430 ani = ecore_animator_add(anim, &game); 430 ani = ecore_animator_add(anim, &ourGlobals);
431 evas_object_data_set(game.bg, "animator", ani); 431 evas_object_data_set(ourGlobals.bg, "animator", ani);
432 432
433 // Setup our callbacks. 433 // Setup our callbacks.
434 ecore_evas_callback_delete_request_set(game.ee, _on_delete); 434 ecore_evas_callback_delete_request_set(ourGlobals.ee, _on_delete);
435 edje_object_signal_callback_add(game.edje, "*", "game_*", _edje_signal_cb, &game); 435 edje_object_signal_callback_add(ourGlobals.edje, "*", "game_*", _edje_signal_cb, &ourGlobals);
436 } 436 }
437 437
438 ecore_main_loop_begin(); 438 ecore_main_loop_begin();
439 if (game.ui) 439 if (ourGlobals.ui)
440 { 440 {
441 ecore_animator_del(ani); 441 ecore_animator_del(ani);
442 ecore_evas_free(game.ee); 442 ecore_evas_free(ourGlobals.ee);
443 } 443 }
444 } 444 }
445 445
diff --git a/LuaSL/src/LuaSL_threads.c b/LuaSL/src/LuaSL_threads.c
index aec5ed6..234a7c5 100644
--- a/LuaSL/src/LuaSL_threads.c
+++ b/LuaSL/src/LuaSL_threads.c
@@ -392,7 +392,7 @@ const char *sendToChannelErrors[] =
392}; 392};
393 393
394/* send a message to a lua process */ 394/* send a message to a lua process */
395const char *sendToChannel(gameGlobals *game, const char *SID, const char *message) 395const char *sendToChannel(gameGlobals *ourGlobals, const char *SID, const char *message)
396{ 396{
397 const char *result = NULL; 397 const char *result = NULL;
398 script *dstlp; 398 script *dstlp;
@@ -401,7 +401,7 @@ const char *sendToChannel(gameGlobals *game, const char *SID, const char *messag
401 pthread_mutex_lock(&mutex_channel); 401 pthread_mutex_lock(&mutex_channel);
402 402
403 // Add the message to the queue. 403 // Add the message to the queue.
404 if ((dstlp = eina_hash_find(game->scripts, SID))) 404 if ((dstlp = eina_hash_find(ourGlobals->scripts, SID)))
405 { 405 {
406 scriptMessage *sm = NULL; 406 scriptMessage *sm = NULL;
407 407
diff --git a/LuaSL/src/LuaSL_threads.h b/LuaSL/src/LuaSL_threads.h
index 78c6639..9a11b5c 100644
--- a/LuaSL/src/LuaSL_threads.h
+++ b/LuaSL/src/LuaSL_threads.h
@@ -46,7 +46,7 @@ THE SOFTWARE.
46void luaprocInit(void); 46void luaprocInit(void);
47int sched_create_worker(void); 47int sched_create_worker(void);
48void newProc(const char *code, int file, script *lp); 48void newProc(const char *code, int file, script *lp);
49const char *sendToChannel(gameGlobals *game, const char *SID, const char *message); 49const char *sendToChannel(gameGlobals *ourGlobals, const char *SID, const char *message);
50 50
51/* join all worker threads and exit */ 51/* join all worker threads and exit */
52void sched_join_workerthreads(void); 52void sched_join_workerthreads(void);
diff --git a/LuaSL/src/LuaSL_utilities.c b/LuaSL/src/LuaSL_utilities.c
index e25b46c..40263df 100644
--- a/LuaSL/src/LuaSL_utilities.c
+++ b/LuaSL/src/LuaSL_utilities.c
@@ -1,83 +1,7 @@
1#include "LuaSL.h" 1#include "LuaSL.h"
2 2
3 3
4// "01:03:52 01-01-1973\n\0" 4void sendBack(gameGlobals *ourGlobals, Ecore_Con_Client *client, const char *SID, const char *message, ...)
5# define DATE_TIME_LEN 21
6
7
8char dateTime[DATE_TIME_LEN];
9
10
11static
12void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args)
13{
14 FILE *f = data;
15 char dt[DATE_TIME_LEN + 1];
16 char fileTab[256], funcTab[256];
17
18 getDateTime(NULL, dt, NULL);
19 dt[19] = '\0';
20 if (12 > strlen(file))
21 snprintf(fileTab, sizeof(fileTab), "%s\t\t", file);
22 else
23 snprintf(fileTab, sizeof(fileTab), "%s\t", file);
24 snprintf(funcTab, sizeof(funcTab), "\t%s", fnc);
25 fprintf(f, "%s ", dt);
26 if (f == stderr)
27 eina_log_print_cb_stderr(d, level, fileTab, funcTab, line, fmt, data, args);
28 else if (f == stdout)
29 eina_log_print_cb_stdout(d, level, fileTab, funcTab, line, fmt, data, args);
30 fflush(f);
31}
32
33void loggingStartup(gameGlobals *game)
34{
35 game->logDom = eina_log_domain_register("LuaSL", NULL);
36 if (game->logDom < 0)
37 {
38 EINA_LOG_CRIT("could not register log domain 'LuaSL'");
39 }
40 // TODO - should unregister this later.
41 eina_log_level_set(EINA_LOG_LEVEL_DBG);
42 eina_log_domain_level_set("LuaSL", EINA_LOG_LEVEL_DBG);
43 eina_log_print_cb_set(_ggg_log_print_cb, stderr);
44
45 // Shut up the excess debugging shit from EFL.
46 eina_log_domain_level_set("eo", EINA_LOG_LEVEL_WARN);
47 eina_log_domain_level_set("eldbus", EINA_LOG_LEVEL_WARN);
48 eina_log_domain_level_set("eet", EINA_LOG_LEVEL_WARN);
49 eina_log_domain_level_set("ecore", EINA_LOG_LEVEL_WARN);
50 eina_log_domain_level_set("ecore_audio", EINA_LOG_LEVEL_WARN);
51 eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_WARN);
52 eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN);
53 eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN);
54 eina_log_domain_level_set("ecore_system_upower", EINA_LOG_LEVEL_WARN);
55}
56
57char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut)
58{
59 struct tm *newTime;
60 time_t szClock;
61 char *date = dateTime;
62
63 // Get time in seconds
64 time(&szClock);
65 // Convert time to struct tm form
66 newTime = localtime(&szClock);
67
68 if (nowOut)
69 *nowOut = newTime;
70 if (dateOut)
71 date = dateOut;
72 if (timeOut)
73 *timeOut = szClock;
74
75 // format
76 strftime(date, DATE_TIME_LEN, "%d/%m/%Y %H:%M:%S\r", newTime);
77 return (dateTime);
78}
79
80void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message, ...)
81{ 5{
82 va_list args; 6 va_list args;
83 char buf[PATH_MAX]; 7 char buf[PATH_MAX];
@@ -94,7 +18,7 @@ void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, cons
94 ecore_con_client_flush(client); 18 ecore_con_client_flush(client);
95} 19}
96 20
97void sendForth(gameGlobals *game, const char *SID, const char *message, ...) 21void sendForth(gameGlobals *ourGlobals, const char *SID, const char *message, ...)
98{ 22{
99 va_list args; 23 va_list args;
100 char buf[PATH_MAX]; 24 char buf[PATH_MAX];
@@ -107,8 +31,8 @@ void sendForth(gameGlobals *game, const char *SID, const char *message, ...)
107 va_end(args); 31 va_end(args);
108 buf[length++] = '\n'; 32 buf[length++] = '\n';
109 buf[length++] = '\0'; 33 buf[length++] = '\0';
110 ecore_con_server_send(game->server, buf, strlen(buf)); 34 ecore_con_server_send(ourGlobals->server, buf, strlen(buf));
111 ecore_con_server_flush(game->server); 35 ecore_con_server_flush(ourGlobals->server);
112} 36}
113 37
114float timeDiff(struct timeval *now, struct timeval *then) 38float timeDiff(struct timeval *now, struct timeval *then)