From 334ba10e01c98b8d0ad2901b9ceafa45071050b9 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 5 May 2014 15:08:55 +1000 Subject: Make logDom a stand alone, plus related fix ups and some clean ups. --- src/GuiLua/GuiLua.c | 16 ++++++---------- src/LuaSL/LuaSL_LSL_tree.h | 2 ++ src/LuaSL/LuaSL_compile.c | 6 +++--- src/LuaSL/LuaSL_lemon_yaccer.y | 8 -------- src/LuaSL/LuaSL_main.c | 17 +++++++++-------- src/LuaSL/LuaSL_test.c | 15 ++++++++------- src/extantz/extantz.c | 9 +++++---- src/libraries/LumbrJack.h | 20 +++++++------------- 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. #include "GuiLua.h" - +static int logDom; // Our logging domain. globals ourGlobals; static const char *globName = "ourGlobals"; @@ -165,10 +165,6 @@ static void _on_click(void *data, Evas_Object *obj, void *event_info EINA_UNUSED lua_State *L = data; Widget *wid; - lua_getfield(L, LUA_REGISTRYINDEX, globName); - ourGlobals = lua_touserdata(L, -1); - lua_pop(L, 1); - wid = evas_object_data_get(obj, "Widget"); if (wid) { @@ -301,10 +297,10 @@ static int closeWindow(lua_State *L) winFangDel(ourGlobals->win); - if (ourGlobals->logDom >= 0) + if (logDom >= 0) { - eina_log_domain_unregister(ourGlobals->logDom); - ourGlobals->logDom = -1; + eina_log_domain_unregister(logDom); + logDom = -1; } // 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) int skang; // In theory this function only ever gets called once. - ourGlobals.logDom = loggingStartup("GuiLua", ourGlobals.logDom); + logDom = loggingStartup("GuiLua", logDom); elm_policy_set(ELM_POLICY_EXIT, ELM_POLICY_EXIT_NONE); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE); @@ -414,7 +410,7 @@ void GuiLuaDo(int argc, char **argv, Eina_Bool mainloop) // Run the main loop via a Lua call. // This does nothing if no module opened a window. if (0 != luaL_dostring(L, "skang.loopWindow()")) - PEm("Error running - skang.loopWindow()"); + PE("Error running - skang.loopWindow()"); lua_pop(L, closeWindow(L)); lua_close(L); } 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; extern LSL_Token **tokens; extern int lowestToken; +extern int logDom; // Our logging domain. + typedef int LSL_Type; 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 LSL_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) { - gameGlobals *ourGlobals = compiler->game; +// gameGlobals *ourGlobals = compiler->game; LSL_Statement *stat = calloc(1, sizeof(LSL_Statement)); boolean justOne = FALSE; @@ -1112,17 +1112,17 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, } } -#if LUASL_DIFF_CHECK if (justOne && (flow)) { +#if LUASL_DIFF_CHECK stat->ignorable = calloc(2, sizeof(Eina_Strbuf *)); if (stat->ignorable) { stat->ignorable[1] = flow->ignorable; flow->ignorable = NULL; } - } #endif + } if (lval) { 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; } %parse_accept { -// gameGlobals *ourGlobals = compiler->game; - // PI("Parsing complete."); } %parse_failure { - gameGlobals *ourGlobals = compiler->game; - compiler->script.bugCount++; PE("Giving up. Parser is hopelessly lost!"); } %stack_overflow { - gameGlobals *ourGlobals = compiler->game; - compiler->script.bugCount++; PE("Giving up. Parser stack overflow @ line %d, column %d!", yypMinor->yy0->line, yypMinor->yy0->column); // Gotta love consistancy, if it ever happens. } %syntax_error { - gameGlobals *ourGlobals = compiler->game; - compiler->script.bugCount++; PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column); } 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 @@ #include "LuaSL.h" +int logDom; // Our logging domain. static int CPUs = 4; static Eina_Strbuf *clientStream; @@ -43,7 +44,7 @@ static script *findThem(gameGlobals *ourGlobals, const char *base, const char *t static void resetScript(script *victim) { - gameGlobals *ourGlobals = victim->game; +// gameGlobals *ourGlobals = victim->game; PD("Resetting %s", victim->fileName); // TODO - now what? @@ -206,7 +207,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev) { - gameGlobals *ourGlobals = data; +// gameGlobals *ourGlobals = data; if (ev->client) { @@ -228,7 +229,7 @@ int main(int argc, char **argv) if (eina_init()) { - ourGlobals.logDom = loggingStartup("LuaSL", ourGlobals.logDom); + logDom = loggingStartup("LuaSL", logDom); ourGlobals.scripts = eina_hash_string_superfast_new(NULL); ourGlobals.names = eina_hash_string_superfast_new(NULL); if (ecore_con_init()) @@ -256,7 +257,7 @@ int main(int argc, char **argv) for (i = 0; i < CPUs; i++) { if ( sched_create_worker( ) != LUAPROC_SCHED_OK ) - PEm("Error creating luaproc worker thread."); + PE("Error creating luaproc worker thread."); } ecore_main_loop_begin(); @@ -265,18 +266,18 @@ int main(int argc, char **argv) edje_shutdown(); } else - PCm("Failed to init edje!"); + PC("Failed to init edje!"); } else - PCm("Failed to add server!"); + PC("Failed to add server!"); ecore_con_shutdown(); } else - PCm("Failed to init ecore_con!"); + PC("Failed to init ecore_con!"); ecore_shutdown(); } else - PCm("Failed to init ecore!"); + PC("Failed to init ecore!"); } else 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 @@ #include "LuaSL.h" +int logDom; // Our logging domain. static Eina_Strbuf *clientStream; static int scriptCount = 0; static int compiledCount = 0; @@ -313,7 +314,7 @@ int main(int argc, char **argv) if (eina_init()) { - ourGlobals.logDom = loggingStartup("LuaSL_test", ourGlobals.logDom); + logDom = loggingStartup("LuaSL_test", logDom); ourGlobals.scripts = eina_hash_string_superfast_new(NULL); if (ecore_con_init()) @@ -373,7 +374,7 @@ int main(int argc, char **argv) ourGlobals.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); if (!ourGlobals.ee) { - PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly."); + PE("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly."); edje_shutdown(); ecore_evas_shutdown(); return -1; @@ -397,7 +398,7 @@ int main(int argc, char **argv) { int err = edje_object_load_error_get(ourGlobals.edje); const char *errmsg = edje_load_error_str(err); - PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg); + PE("Could not load '%s' from %s: %s\n", group, buf, errmsg); evas_object_del(ourGlobals.edje); ecore_evas_free(ourGlobals.ee); @@ -447,18 +448,18 @@ int main(int argc, char **argv) edje_shutdown(); } else - PCm("Failed to init edje!"); + PC("Failed to init edje!"); ecore_evas_shutdown(); } else - PCm("Failed to init ecore_evas!"); + PC("Failed to init ecore_evas!"); } else - PCm("Failed to connect to server!"); + PC("Failed to connect to server!"); ecore_con_shutdown(); } else - PCm("Failed to init ecore_con!"); + PC("Failed to init ecore_con!"); } else 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 @@ #include "extantz.h" +static int logDom; // Our logging domain. globals ourGlobals; @@ -404,7 +405,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get()); fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get()); - ourGlobals.logDom = loggingStartup("extantz", ourGlobals.logDom); + logDom = loggingStartup("extantz", logDom); // Don't do this, we need to clean up other stuff to, so set a clean up function below. //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) evas_object_del(ourGlobals.win); } - if (ourGlobals.logDom >= 0) + if (logDom >= 0) { - eina_log_domain_unregister(ourGlobals.logDom); - ourGlobals.logDom = -1; + eina_log_domain_unregister(logDom); + logDom = -1; } 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 @@ #include -#define PC(...) EINA_LOG_DOM_CRIT(ourGlobals->logDom, __VA_ARGS__) -#define PE(...) EINA_LOG_DOM_ERR(ourGlobals->logDom, __VA_ARGS__) -#define PW(...) EINA_LOG_DOM_WARN(ourGlobals->logDom, __VA_ARGS__) -#define PD(...) EINA_LOG_DOM_DBG(ourGlobals->logDom, __VA_ARGS__) -#define PI(...) EINA_LOG_DOM_INFO(ourGlobals->logDom, __VA_ARGS__) - -#define PCm(...) EINA_LOG_DOM_CRIT(ourGlobals.logDom, __VA_ARGS__) -#define PEm(...) EINA_LOG_DOM_ERR(ourGlobals.logDom, __VA_ARGS__) -#define PWm(...) EINA_LOG_DOM_WARN(ourGlobals.logDom, __VA_ARGS__) -#define PDm(...) EINA_LOG_DOM_DBG(ourGlobals.logDom, __VA_ARGS__) -#define PIm(...) EINA_LOG_DOM_INFO(ourGlobals.logDom, __VA_ARGS__) - -#define D() PD("DEBUG") +#define PC(...) EINA_LOG_DOM_CRIT(logDom, __VA_ARGS__) +#define PE(...) EINA_LOG_DOM_ERR(logDom, __VA_ARGS__) +#define PW(...) EINA_LOG_DOM_WARN(logDom, __VA_ARGS__) +#define PD(...) EINA_LOG_DOM_DBG(logDom, __VA_ARGS__) +#define PI(...) EINA_LOG_DOM_INFO(logDom, __VA_ARGS__) + +//#define D() PD("DEBUG") // "01:03:52 01-01-1973\n\0" -- cgit v1.1