aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-05 15:08:55 +1000
committerDavid Walter Seikel2014-05-05 15:08:55 +1000
commit334ba10e01c98b8d0ad2901b9ceafa45071050b9 (patch)
tree3fe60c140f14336ecd314b07d4a528bc7289ba78
parentPrepare for using GuiLua from extantz, but not going through with it just yet... (diff)
downloadSledjHamr-334ba10e01c98b8d0ad2901b9ceafa45071050b9.zip
SledjHamr-334ba10e01c98b8d0ad2901b9ceafa45071050b9.tar.gz
SledjHamr-334ba10e01c98b8d0ad2901b9ceafa45071050b9.tar.bz2
SledjHamr-334ba10e01c98b8d0ad2901b9ceafa45071050b9.tar.xz
Make logDom a stand alone, plus related fix ups and some clean ups.
-rw-r--r--src/GuiLua/GuiLua.c16
-rw-r--r--src/LuaSL/LuaSL_LSL_tree.h2
-rw-r--r--src/LuaSL/LuaSL_compile.c6
-rw-r--r--src/LuaSL/LuaSL_lemon_yaccer.y8
-rw-r--r--src/LuaSL/LuaSL_main.c17
-rw-r--r--src/LuaSL/LuaSL_test.c15
-rw-r--r--src/extantz/extantz.c9
-rw-r--r--src/libraries/LumbrJack.h20
8 files changed, 40 insertions, 53 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c
index f14d74d..1f5cbd5 100644
--- a/src/GuiLua/GuiLua.c
+++ b/src/GuiLua/GuiLua.c
@@ -143,7 +143,7 @@ and ordinary elementary widgets. Proper introspection can come later.
143#include "GuiLua.h" 143#include "GuiLua.h"
144 144
145 145
146 146static int logDom; // Our logging domain.
147globals ourGlobals; 147globals ourGlobals;
148static const char *globName = "ourGlobals"; 148static const char *globName = "ourGlobals";
149 149
@@ -165,10 +165,6 @@ static void _on_click(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
165 lua_State *L = data; 165 lua_State *L = data;
166 Widget *wid; 166 Widget *wid;
167 167
168 lua_getfield(L, LUA_REGISTRYINDEX, globName);
169 ourGlobals = lua_touserdata(L, -1);
170 lua_pop(L, 1);
171
172 wid = evas_object_data_get(obj, "Widget"); 168 wid = evas_object_data_get(obj, "Widget");
173 if (wid) 169 if (wid)
174 { 170 {
@@ -301,10 +297,10 @@ static int closeWindow(lua_State *L)
301 297
302 winFangDel(ourGlobals->win); 298 winFangDel(ourGlobals->win);
303 299
304 if (ourGlobals->logDom >= 0) 300 if (logDom >= 0)
305 { 301 {
306 eina_log_domain_unregister(ourGlobals->logDom); 302 eina_log_domain_unregister(logDom);
307 ourGlobals->logDom = -1; 303 logDom = -1;
308 } 304 }
309 305
310 // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed. 306 // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed.
@@ -330,7 +326,7 @@ int luaopen_GuiLua(lua_State *L)
330 int skang; 326 int skang;
331 327
332 // In theory this function only ever gets called once. 328 // In theory this function only ever gets called once.
333 ourGlobals.logDom = loggingStartup("GuiLua", ourGlobals.logDom); 329 logDom = loggingStartup("GuiLua", logDom);
334 330
335 elm_policy_set(ELM_POLICY_EXIT, ELM_POLICY_EXIT_NONE); 331 elm_policy_set(ELM_POLICY_EXIT, ELM_POLICY_EXIT_NONE);
336 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE); 332 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE);
@@ -414,7 +410,7 @@ void GuiLuaDo(int argc, char **argv, Eina_Bool mainloop)
414 // Run the main loop via a Lua call. 410 // Run the main loop via a Lua call.
415 // This does nothing if no module opened a window. 411 // This does nothing if no module opened a window.
416 if (0 != luaL_dostring(L, "skang.loopWindow()")) 412 if (0 != luaL_dostring(L, "skang.loopWindow()"))
417 PEm("Error running - skang.loopWindow()"); 413 PE("Error running - skang.loopWindow()");
418 lua_pop(L, closeWindow(L)); 414 lua_pop(L, closeWindow(L));
419 lua_close(L); 415 lua_close(L);
420 } 416 }
diff --git a/src/LuaSL/LuaSL_LSL_tree.h b/src/LuaSL/LuaSL_LSL_tree.h
index 5415228..1021be8 100644
--- a/src/LuaSL/LuaSL_LSL_tree.h
+++ b/src/LuaSL/LuaSL_LSL_tree.h
@@ -42,6 +42,8 @@ typedef struct _LSL_Script LSL_Script;
42 42
43extern LSL_Token **tokens; 43extern LSL_Token **tokens;
44extern int lowestToken; 44extern int lowestToken;
45extern int logDom; // Our logging domain.
46
45 47
46typedef int LSL_Type; 48typedef int LSL_Type;
47 49
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c
index f32e0c0..3265acf 100644
--- a/src/LuaSL/LuaSL_compile.c
+++ b/src/LuaSL/LuaSL_compile.c
@@ -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 *ourGlobals = 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
@@ -1112,17 +1112,17 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow,
1112 } 1112 }
1113 } 1113 }
1114 1114
1115#if LUASL_DIFF_CHECK
1116 if (justOne && (flow)) 1115 if (justOne && (flow))
1117 { 1116 {
1117#if LUASL_DIFF_CHECK
1118 stat->ignorable = calloc(2, sizeof(Eina_Strbuf *)); 1118 stat->ignorable = calloc(2, sizeof(Eina_Strbuf *));
1119 if (stat->ignorable) 1119 if (stat->ignorable)
1120 { 1120 {
1121 stat->ignorable[1] = flow->ignorable; 1121 stat->ignorable[1] = flow->ignorable;
1122 flow->ignorable = NULL; 1122 flow->ignorable = NULL;
1123 } 1123 }
1124 }
1125#endif 1124#endif
1125 }
1126 1126
1127 if (lval) 1127 if (lval)
1128 { 1128 {
diff --git a/src/LuaSL/LuaSL_lemon_yaccer.y b/src/LuaSL/LuaSL_lemon_yaccer.y
index 182789f..72c4479 100644
--- a/src/LuaSL/LuaSL_lemon_yaccer.y
+++ b/src/LuaSL/LuaSL_lemon_yaccer.y
@@ -222,31 +222,23 @@ expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; }
222 222
223%parse_accept 223%parse_accept
224{ 224{
225// gameGlobals *ourGlobals = compiler->game;
226
227// PI("Parsing complete."); 225// PI("Parsing complete.");
228} 226}
229 227
230%parse_failure 228%parse_failure
231{ 229{
232 gameGlobals *ourGlobals = compiler->game;
233
234 compiler->script.bugCount++; 230 compiler->script.bugCount++;
235 PE("Giving up. Parser is hopelessly lost!"); 231 PE("Giving up. Parser is hopelessly lost!");
236} 232}
237 233
238%stack_overflow 234%stack_overflow
239{ 235{
240 gameGlobals *ourGlobals = compiler->game;
241
242 compiler->script.bugCount++; 236 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. 237 PE("Giving up. Parser stack overflow @ line %d, column %d!", yypMinor->yy0->line, yypMinor->yy0->column); // Gotta love consistancy, if it ever happens.
244} 238}
245 239
246%syntax_error 240%syntax_error
247{ 241{
248 gameGlobals *ourGlobals = compiler->game;
249
250 compiler->script.bugCount++; 242 compiler->script.bugCount++;
251 PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column); 243 PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column);
252} 244}
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c
index 0a40712..f4c94ac 100644
--- a/src/LuaSL/LuaSL_main.c
+++ b/src/LuaSL/LuaSL_main.c
@@ -2,6 +2,7 @@
2#include "LuaSL.h" 2#include "LuaSL.h"
3 3
4 4
5int logDom; // Our logging domain.
5static int CPUs = 4; 6static int CPUs = 4;
6static Eina_Strbuf *clientStream; 7static Eina_Strbuf *clientStream;
7 8
@@ -43,7 +44,7 @@ static script *findThem(gameGlobals *ourGlobals, const char *base, const char *t
43 44
44static void resetScript(script *victim) 45static void resetScript(script *victim)
45{ 46{
46 gameGlobals *ourGlobals = victim->game; 47// gameGlobals *ourGlobals = victim->game;
47 48
48 PD("Resetting %s", victim->fileName); 49 PD("Resetting %s", victim->fileName);
49 // TODO - now what? 50 // TODO - now what?
@@ -206,7 +207,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
206 207
207static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev) 208static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev)
208{ 209{
209 gameGlobals *ourGlobals = data; 210// gameGlobals *ourGlobals = data;
210 211
211 if (ev->client) 212 if (ev->client)
212 { 213 {
@@ -228,7 +229,7 @@ int main(int argc, char **argv)
228 229
229 if (eina_init()) 230 if (eina_init())
230 { 231 {
231 ourGlobals.logDom = loggingStartup("LuaSL", ourGlobals.logDom); 232 logDom = loggingStartup("LuaSL", logDom);
232 ourGlobals.scripts = eina_hash_string_superfast_new(NULL); 233 ourGlobals.scripts = eina_hash_string_superfast_new(NULL);
233 ourGlobals.names = eina_hash_string_superfast_new(NULL); 234 ourGlobals.names = eina_hash_string_superfast_new(NULL);
234 if (ecore_con_init()) 235 if (ecore_con_init())
@@ -256,7 +257,7 @@ int main(int argc, char **argv)
256 for (i = 0; i < CPUs; i++) 257 for (i = 0; i < CPUs; i++)
257 { 258 {
258 if ( sched_create_worker( ) != LUAPROC_SCHED_OK ) 259 if ( sched_create_worker( ) != LUAPROC_SCHED_OK )
259 PEm("Error creating luaproc worker thread."); 260 PE("Error creating luaproc worker thread.");
260 } 261 }
261 ecore_main_loop_begin(); 262 ecore_main_loop_begin();
262 263
@@ -265,18 +266,18 @@ int main(int argc, char **argv)
265 edje_shutdown(); 266 edje_shutdown();
266 } 267 }
267 else 268 else
268 PCm("Failed to init edje!"); 269 PC("Failed to init edje!");
269 } 270 }
270 else 271 else
271 PCm("Failed to add server!"); 272 PC("Failed to add server!");
272 ecore_con_shutdown(); 273 ecore_con_shutdown();
273 } 274 }
274 else 275 else
275 PCm("Failed to init ecore_con!"); 276 PC("Failed to init ecore_con!");
276 ecore_shutdown(); 277 ecore_shutdown();
277 } 278 }
278 else 279 else
279 PCm("Failed to init ecore!"); 280 PC("Failed to init ecore!");
280 } 281 }
281 else 282 else
282 fprintf(stderr, "Failed to init eina!"); 283 fprintf(stderr, "Failed to init eina!");
diff --git a/src/LuaSL/LuaSL_test.c b/src/LuaSL/LuaSL_test.c
index 27b9626..8fc86c0 100644
--- a/src/LuaSL/LuaSL_test.c
+++ b/src/LuaSL/LuaSL_test.c
@@ -2,6 +2,7 @@
2#include "LuaSL.h" 2#include "LuaSL.h"
3 3
4 4
5int logDom; // Our logging domain.
5static Eina_Strbuf *clientStream; 6static Eina_Strbuf *clientStream;
6static int scriptCount = 0; 7static int scriptCount = 0;
7static int compiledCount = 0; 8static int compiledCount = 0;
@@ -313,7 +314,7 @@ int main(int argc, char **argv)
313 314
314 if (eina_init()) 315 if (eina_init())
315 { 316 {
316 ourGlobals.logDom = loggingStartup("LuaSL_test", ourGlobals.logDom); 317 logDom = loggingStartup("LuaSL_test", logDom);
317 ourGlobals.scripts = eina_hash_string_superfast_new(NULL); 318 ourGlobals.scripts = eina_hash_string_superfast_new(NULL);
318 319
319 if (ecore_con_init()) 320 if (ecore_con_init())
@@ -373,7 +374,7 @@ int main(int argc, char **argv)
373 ourGlobals.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 374 ourGlobals.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
374 if (!ourGlobals.ee) 375 if (!ourGlobals.ee)
375 { 376 {
376 PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly."); 377 PE("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly.");
377 edje_shutdown(); 378 edje_shutdown();
378 ecore_evas_shutdown(); 379 ecore_evas_shutdown();
379 return -1; 380 return -1;
@@ -397,7 +398,7 @@ int main(int argc, char **argv)
397 { 398 {
398 int err = edje_object_load_error_get(ourGlobals.edje); 399 int err = edje_object_load_error_get(ourGlobals.edje);
399 const char *errmsg = edje_load_error_str(err); 400 const char *errmsg = edje_load_error_str(err);
400 PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg); 401 PE("Could not load '%s' from %s: %s\n", group, buf, errmsg);
401 402
402 evas_object_del(ourGlobals.edje); 403 evas_object_del(ourGlobals.edje);
403 ecore_evas_free(ourGlobals.ee); 404 ecore_evas_free(ourGlobals.ee);
@@ -447,18 +448,18 @@ int main(int argc, char **argv)
447 edje_shutdown(); 448 edje_shutdown();
448 } 449 }
449 else 450 else
450 PCm("Failed to init edje!"); 451 PC("Failed to init edje!");
451 ecore_evas_shutdown(); 452 ecore_evas_shutdown();
452 } 453 }
453 else 454 else
454 PCm("Failed to init ecore_evas!"); 455 PC("Failed to init ecore_evas!");
455 } 456 }
456 else 457 else
457 PCm("Failed to connect to server!"); 458 PC("Failed to connect to server!");
458 ecore_con_shutdown(); 459 ecore_con_shutdown();
459 } 460 }
460 else 461 else
461 PCm("Failed to init ecore_con!"); 462 PC("Failed to init ecore_con!");
462 } 463 }
463 else 464 else
464 fprintf(stderr, "Failed to init eina!"); 465 fprintf(stderr, "Failed to init eina!");
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index efe3748..03b2362 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -1,6 +1,7 @@
1#include "extantz.h" 1#include "extantz.h"
2 2
3 3
4static int logDom; // Our logging domain.
4globals ourGlobals; 5globals ourGlobals;
5 6
6 7
@@ -404,7 +405,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
404 fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get()); 405 fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get());
405 fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get()); 406 fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get());
406 407
407 ourGlobals.logDom = loggingStartup("extantz", ourGlobals.logDom); 408 logDom = loggingStartup("extantz", logDom);
408 409
409 // Don't do this, we need to clean up other stuff to, so set a clean up function below. 410 // Don't do this, we need to clean up other stuff to, so set a clean up function below.
410 //elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 411 //elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
@@ -516,10 +517,10 @@ EAPI_MAIN int elm_main(int argc, char **argv)
516 evas_object_del(ourGlobals.win); 517 evas_object_del(ourGlobals.win);
517 } 518 }
518 519
519 if (ourGlobals.logDom >= 0) 520 if (logDom >= 0)
520 { 521 {
521 eina_log_domain_unregister(ourGlobals.logDom); 522 eina_log_domain_unregister(logDom);
522 ourGlobals.logDom = -1; 523 logDom = -1;
523 } 524 }
524 525
525 elm_shutdown(); 526 elm_shutdown();
diff --git a/src/libraries/LumbrJack.h b/src/libraries/LumbrJack.h
index 4a3290c..5ac0ce8 100644
--- a/src/libraries/LumbrJack.h
+++ b/src/libraries/LumbrJack.h
@@ -5,19 +5,13 @@
5#include <Eina.h> 5#include <Eina.h>
6 6
7 7
8#define PC(...) EINA_LOG_DOM_CRIT(ourGlobals->logDom, __VA_ARGS__) 8#define PC(...) EINA_LOG_DOM_CRIT(logDom, __VA_ARGS__)
9#define PE(...) EINA_LOG_DOM_ERR(ourGlobals->logDom, __VA_ARGS__) 9#define PE(...) EINA_LOG_DOM_ERR(logDom, __VA_ARGS__)
10#define PW(...) EINA_LOG_DOM_WARN(ourGlobals->logDom, __VA_ARGS__) 10#define PW(...) EINA_LOG_DOM_WARN(logDom, __VA_ARGS__)
11#define PD(...) EINA_LOG_DOM_DBG(ourGlobals->logDom, __VA_ARGS__) 11#define PD(...) EINA_LOG_DOM_DBG(logDom, __VA_ARGS__)
12#define PI(...) EINA_LOG_DOM_INFO(ourGlobals->logDom, __VA_ARGS__) 12#define PI(...) EINA_LOG_DOM_INFO(logDom, __VA_ARGS__)
13 13
14#define PCm(...) EINA_LOG_DOM_CRIT(ourGlobals.logDom, __VA_ARGS__) 14//#define D() PD("DEBUG")
15#define PEm(...) EINA_LOG_DOM_ERR(ourGlobals.logDom, __VA_ARGS__)
16#define PWm(...) EINA_LOG_DOM_WARN(ourGlobals.logDom, __VA_ARGS__)
17#define PDm(...) EINA_LOG_DOM_DBG(ourGlobals.logDom, __VA_ARGS__)
18#define PIm(...) EINA_LOG_DOM_INFO(ourGlobals.logDom, __VA_ARGS__)
19
20#define D() PD("DEBUG")
21 15
22 16
23// "01:03:52 01-01-1973\n\0" 17// "01:03:52 01-01-1973\n\0"