aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries/Runnr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libraries/Runnr.c')
-rw-r--r--src/libraries/Runnr.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c
index 5ec5a9c..04547b4 100644
--- a/src/libraries/Runnr.c
+++ b/src/libraries/Runnr.c
@@ -60,12 +60,12 @@ static int traceBack(lua_State *L)
60 lua_Debug ar; 60 lua_Debug ar;
61 int i, top = lua_gettop(L), b = 1; 61 int i, top = lua_gettop(L), b = 1;
62 62
63// printf("Stack is %d deep\n", top); 63// PI("Stack is %d deep", top);
64// for (i = 1; i <= top; i++) 64// for (i = 1; i <= top; i++)
65// dumpStack(L, i); 65// dumpStack(L, i);
66 66
67 if (top) 67 if (top)
68 printf("Lua error - %s\n", lua_tostring(L, 1)); 68 PE("Lua error - %s", lua_tostring(L, 1));
69 69
70 i = 0; 70 i = 0;
71 while (lua_getstack(L, i++, &ar)) 71 while (lua_getstack(L, i++, &ar))
@@ -74,15 +74,15 @@ static int traceBack(lua_State *L)
74 { 74 {
75 if (NULL == ar.name) 75 if (NULL == ar.name)
76 ar.name = "DUNNO"; 76 ar.name = "DUNNO";
77 printf(" Lua backtrace %d - %s %s %s @ %s : %d\n", i, ar.what, ar.namewhat, ar.name, ar.short_src, ar.currentline); 77 PE(" Lua backtrace %d - %s %s %s @ %s : %d", i, ar.what, ar.namewhat, ar.name, ar.short_src, ar.currentline);
78 b = 0; 78 b = 0;
79 } 79 }
80 else 80 else
81 printf(" Failed to get trace line!\n"); 81 PE(" Failed to get trace line!");
82 } 82 }
83 83
84 if (b) 84 if (b)
85 printf(" NO BACKTRACE!\n"); 85 PE(" NO BACKTRACE!");
86 86
87 return 0; 87 return 0;
88} 88}
@@ -99,7 +99,7 @@ static void printLuaError(int err, char *string, lua_State *L)
99 case LUA_ERRERR: err_type = "error handler"; break; 99 case LUA_ERRERR: err_type = "error handler"; break;
100 default: err_type = "unknown"; break; 100 default: err_type = "unknown"; break;
101 } 101 }
102 printf("Error running - %s, \n %s - %s\n", string, err_type, lua_tostring(L, -1)); 102 PW("Error running - %s, \n %s - %s", string, err_type, lua_tostring(L, -1));
103} 103}
104 104
105static int panics = 0; 105static int panics = 0;
@@ -109,9 +109,9 @@ static int _panic(lua_State *L) // Stack usage [-0, +0, m]
109 // of memory in the following lua_tostring() call. 109 // of memory in the following lua_tostring() call.
110 panics++; 110 panics++;
111 if (panics) 111 if (panics)
112 printf("Lua PANICS!!!!!"); 112 PE("Lua PANICS!!!!!");
113 else 113 else
114 printf("Lua PANIC!!!!!: %s", lua_tostring(L, -1)); // Stack usage [-0, +0, m] 114 PE("Lua PANIC!!!!!: %s", lua_tostring(L, -1)); // Stack usage [-0, +0, m]
115 // The docs say that this will cause an exit(EXIT_FAILURE) if we return, 115 // The docs say that this will cause an exit(EXIT_FAILURE) if we return,
116 // and that we we should long jump some where to avoid that. This is only 116 // and that we we should long jump some where to avoid that. This is only
117 // called for things not called from a protected environment. We always 117 // called for things not called from a protected environment. We always
@@ -147,7 +147,7 @@ void doLuaString(lua_State *L, char *string, char *module)
147 { 147 {
148 const char *err = lua_tostring(L, 1); 148 const char *err = lua_tostring(L, 1);
149 149
150 printf("Error parsing - %s, ERROR %s", string, err); 150 PE("Error parsing - %s, ERROR %s", string, err);
151 } 151 }
152 else 152 else
153 { 153 {
@@ -159,12 +159,12 @@ void doLuaString(lua_State *L, char *string, char *module)
159 // Consistancy would be good, just sayin'. 159 // Consistancy would be good, just sayin'.
160 if (0 == lua_setfenv(L, _A)) 160 if (0 == lua_setfenv(L, _A))
161 { 161 {
162 printf("Error setting environment for - %s", string); 162 PE("Error setting environment for - %s", string);
163 return; 163 return;
164 } 164 }
165 } 165 }
166 166
167//printf("doLuaString(%s)\n", string); 167//PD("doLuaString(%s)\", string);
168 if ((err = lua_pcall(L, 0, LUA_MULTRET, _T))) 168 if ((err = lua_pcall(L, 0, LUA_MULTRET, _T)))
169 printLuaError(err, string, L); 169 printLuaError(err, string, L);
170 } 170 }
@@ -174,7 +174,7 @@ static void _stopScript(script *s)
174{ 174{
175 scriptMessage *sm0, *sm1; 175 scriptMessage *sm0, *sm1;
176 176
177//printf("^^^^^^^^^^^^^^^^^^^_stop(, %s)\n", s->name); 177//PD("^^^^^^^^^^^^^^^^^^^_stop(, %s)", s->name);
178 if (s->L) lua_close(s->L); s->L = NULL; 178 if (s->L) lua_close(s->L); s->L = NULL;
179 if (s->timer) ecore_timer_del(s->timer); s->timer = NULL; 179 if (s->timer) ecore_timer_del(s->timer); s->timer = NULL;
180 EINA_CLIST_FOR_EACH_ENTRY_SAFE(sm0, sm1, &(s->messages), scriptMessage, node) 180 EINA_CLIST_FOR_EACH_ENTRY_SAFE(sm0, sm1, &(s->messages), scriptMessage, node)
@@ -210,7 +210,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
210 210
211 if (RUNNR_READY == s->status) 211 if (RUNNR_READY == s->status)
212 { 212 {
213//printf("_workerFunction() READY %s\n", s->name); 213//PD("_workerFunction() READY %s", s->name);
214 if ((msg = (scriptMessage *) eina_clist_head(&(s->messages)))) 214 if ((msg = (scriptMessage *) eina_clist_head(&(s->messages))))
215 { 215 {
216 eina_clist_remove(&(msg->node)); 216 eina_clist_remove(&(msg->node));
@@ -226,7 +226,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
226 { 226 {
227 int err; 227 int err;
228 228
229//printf("_workerFunction() STARTING %s\n", s->name); 229//PD("_workerFunction() STARTING %s", s->name);
230 s->status = RUNNR_RUNNING; 230 s->status = RUNNR_RUNNING;
231 s->L = luaL_newstate(); // Sets a standard allocator and panic function. 231 s->L = luaL_newstate(); // Sets a standard allocator and panic function.
232 232
@@ -243,7 +243,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
243 if (err != 0) 243 if (err != 0)
244 { 244 {
245 s->status = RUNNR_FINISHED; 245 s->status = RUNNR_FINISHED;
246 printf("Error loading compiled Lua %s.", s->binName); 246 PE("Error loading compiled Lua %s.", s->binName);
247 } 247 }
248 gettimeofday(&s->startTime, NULL); 248 gettimeofday(&s->startTime, NULL);
249 } 249 }
@@ -254,7 +254,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
254 { 254 {
255 int stat; 255 int stat;
256 256
257//printf("_workerFunction() RUNNING %s %s\n", s->name, message); 257//PD("_workerFunction() RUNNING %s %s", s->name, message);
258 // Resume running the script. 258 // Resume running the script.
259 // lua_resume() needs a Lua thread, and the initial Lua state is a thread. 259 // lua_resume() needs a Lua thread, and the initial Lua state is a thread.
260 // Other Lua threads have their own state, but share the environment with the initial state. 260 // Other Lua threads have their own state, but share the environment with the initial state.
@@ -270,7 +270,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
270 s->status = RUNNR_FINISHED; 270 s->status = RUNNR_FINISHED;
271 else if (stat != LUA_YIELD) 271 else if (stat != LUA_YIELD)
272 { 272 {
273 printf("lua_resume error at %s\n", s->name); 273 PE("lua_resume error at %s", s->name);
274 printLuaError(stat, s->name, s->L); 274 printLuaError(stat, s->name, s->L);
275 s->status = RUNNR_FINISHED; 275 s->status = RUNNR_FINISHED;
276 } 276 }
@@ -288,7 +288,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
288 // Start again from the top when Ecore_Thread has a spare thread ready, unless the script finished. 288 // Start again from the top when Ecore_Thread has a spare thread ready, unless the script finished.
289 if (RUNNR_FINISHED == s->status) 289 if (RUNNR_FINISHED == s->status)
290 { 290 {
291//printf("_workerFunction() FINISHED %s\n", s->name); 291//PD("_workerFunction() FINISHED %s", s->name);
292#if THREADIT 292#if THREADIT
293 ecore_thread_cancel(thread); 293 ecore_thread_cancel(thread);
294#else 294#else
@@ -297,7 +297,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
297 } 297 }
298 else if (RUNNR_WAIT == s->status) 298 else if (RUNNR_WAIT == s->status)
299 { 299 {
300;//printf("_workerFunction() WAIT %s\n", s->name); 300;//PD("_workerFunction() WAIT %s", s->name);
301 } 301 }
302#if THREADIT 302#if THREADIT
303 else if (RUNNR_READY == s->status) 303 else if (RUNNR_READY == s->status)
@@ -323,7 +323,7 @@ static void _cancel(void *data, Ecore_Thread *thread)
323 s->status = RUNNR_FINISHED; 323 s->status = RUNNR_FINISHED;
324 eina_clist_remove(&(s->node)); 324 eina_clist_remove(&(s->node));
325 if (s->SID[0]) ecore_thread_global_data_del(s->SID); s->SID[0] = 0; 325 if (s->SID[0]) ecore_thread_global_data_del(s->SID); s->SID[0] = 0;
326//printf("^^^^^^^^^^^^^^^^^^^_del(, %s)\n", s->name); 326//PD("^^^^^^^^^^^^^^^^^^^_del(, %s)", s->name);
327 // TODO - Perhaps have our own deletion callback to pass back? 327 // TODO - Perhaps have our own deletion callback to pass back?
328 releaseScript(s); 328 releaseScript(s);
329#if THREADIT 329#if THREADIT
@@ -444,11 +444,11 @@ static void _compileThread(void *data, Ecore_Thread *thread)
444 compiler->bugCount++; 444 compiler->bugCount++;
445#if COMPILE_OUTPUT 445#if COMPILE_OUTPUT
446 if (LUA_ERRSYNTAX == err) 446 if (LUA_ERRSYNTAX == err)
447 printf("Lua syntax error in %s: %s\n", name, lua_tostring(L, -1)); 447 PI("Lua syntax error in %s: %s", name, lua_tostring(L, -1));
448 else if (LUA_ERRFILE == err) 448 else if (LUA_ERRFILE == err)
449 printf("Lua compile file error in %s: %s\n", name, lua_tostring(L, -1)); 449 PE("Lua compile file error in %s: %s", name, lua_tostring(L, -1));
450 else if (LUA_ERRMEM == err) 450 else if (LUA_ERRMEM == err)
451 printf("Lua compile memory allocation error in %s: %s\n", name, lua_tostring(L, -1)); 451 PC("Lua compile memory allocation error in %s: %s", name, lua_tostring(L, -1));
452#endif 452#endif
453 } 453 }
454 else 454 else
@@ -462,28 +462,28 @@ static void _compileThread(void *data, Ecore_Thread *thread)
462 if (err) 462 if (err)
463 { 463 {
464 compiler->bugCount++; 464 compiler->bugCount++;
465 printf("Lua compile file error writing to %s\n", name); 465 PE("Lua compile file error writing to %s", name);
466 } 466 }
467 fclose(out); 467 fclose(out);
468 } 468 }
469 else 469 else
470 { 470 {
471 compiler->bugCount++; 471 compiler->bugCount++;
472 printf("CRITICAL! Unable to open file %s for writing!\n", name); 472 PE("CRITICAL! Unable to open file %s for writing!", name);
473 } 473 }
474 } 474 }
475 } 475 }
476 else if (!compiler->doConstants) 476 else if (!compiler->doConstants)
477 { 477 {
478 compiler->bugCount++; 478 compiler->bugCount++;
479 printf("Can't create a new Lua state!\n"); 479 PC("Can't create a new Lua state!");
480 } 480 }
481 } 481 }
482 else 482 else
483 { 483 {
484 compiler->bugCount++; 484 compiler->bugCount++;
485#if COMPILE_OUTPUT 485#if COMPILE_OUTPUT
486 printf("Nothing for Lua to compile!\n"); 486 PW("Nothing for Lua to compile!");
487#endif 487#endif
488 } 488 }
489} 489}
@@ -544,8 +544,8 @@ void takeScript(script *s)
544{ 544{
545#if THREADIT 545#if THREADIT
546 Eina_Lock_Result result = eina_lock_take(&s->mutex); 546 Eina_Lock_Result result = eina_lock_take(&s->mutex);
547 if (EINA_LOCK_DEADLOCK == result) printf("Script %s IS DEADLOCKED!\n", s->name); 547 if (EINA_LOCK_DEADLOCK == result) PE("Script %s IS DEADLOCKED!", s->name);
548 if (EINA_LOCK_FAIL == result) printf("Script %s LOCK FAILED!\n", s->name); 548 if (EINA_LOCK_FAIL == result) PE("Script %s LOCK FAILED!", s->name);
549#endif 549#endif
550} 550}
551 551
@@ -861,7 +861,7 @@ int push_lua(lua_State *L, char *params, ...) // Stack usage [-0, +n, em]
861 { 861 {
862 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] 862 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
863 char *t = va_arg(vl, char *); 863 char *t = va_arg(vl, char *);
864//printf("push_lua %s string %s\n", p, t); 864//PD("push_lua %s string %s", p, t);
865 lua_pushstring(L, t); // Stack usage [-0, +1, m] 865 lua_pushstring(L, t); // Stack usage [-0, +1, m]
866 break; 866 break;
867 } 867 }