aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/GuiLua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/GuiLua/GuiLua.c64
1 files changed, 2 insertions, 62 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c
index 3bdada9..92254ea 100644
--- a/src/GuiLua/GuiLua.c
+++ b/src/GuiLua/GuiLua.c
@@ -144,6 +144,7 @@ and ordinary elementary widgets. Proper introspection can come later.
144 144
145#include "LumbrJack.h" 145#include "LumbrJack.h"
146#include "GuiLua.h" 146#include "GuiLua.h"
147#include "Runnr.h"
147 148
148 149
149static int logDom; // Our logging domain. 150static int logDom; // Our logging domain.
@@ -158,77 +159,16 @@ win.quitter.colour.r = 5 -> direct access to the table, well "direct" via Th
158*/ 159*/
159 160
160 161
161static int traceBack(lua_State *L)
162{
163 const char *msg = "";
164 int top = lua_gettop(L);
165// int i;
166
167// printf("Stack is %d deep\n", top);
168// for (i = 1; i <= top; i++)
169// dumpStack(L, i);
170
171 if (top)
172 msg = lua_tostring(L, 1);
173 lua_getglobal(L, "debug");
174 push_lua(L, "@ ( )", lua_gettop(L), "traceback", 1);
175 lua_pushstring(L, "\n");
176 lua_pushstring(L, msg);
177 lua_concat(L, 3);
178
179 return 1;
180}
181
182static void _on_click(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 162static void _on_click(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
183{ 163{
184 Widget *wid = data; 164 Widget *wid = data;
185 165
186 if (wid) 166 if (wid)
187 { 167 {
188 int _T, _A, err;
189 lua_State *L = wid->data; 168 lua_State *L = wid->data;
190 169
191 PD("Doing action %s", wid->action); 170 PD("Doing action %s", wid->action);
192 171 doLuaString(L, wid->action, wid->win->module);
193 lua_pushcfunction(L, traceBack);
194 _T = lua_gettop(L);
195
196 if (luaL_loadstring(L, wid->action))
197 {
198 const char *err = lua_tostring(L, 1);
199
200 PE("Error parsing - %s, ERROR %s", wid->action, err);
201 }
202 else
203 {
204 _A = lua_gettop(L);
205 if (wid->win->module)
206 {
207 lua_getfield(L, LUA_REGISTRYINDEX, wid->win->module);
208
209 // Consistancy would be good, just sayin'.
210 if (0 == lua_setfenv(L, _A))
211 {
212 PE("Error setting environment for - %s", wid->action);
213 return;
214 }
215 }
216
217 if ((err = lua_pcall(L, 0, LUA_MULTRET, _T)))
218 {
219 const char *err_type;
220
221 switch (err)
222 {
223 case LUA_ERRRUN: err_type = "runtime"; break;
224 case LUA_ERRSYNTAX: err_type = "syntax"; break;
225 case LUA_ERRMEM: err_type = "memory allocation"; break;
226 case LUA_ERRERR: err_type = "error handler"; break;
227 default: err_type = "unknown"; break;
228 }
229 PE("Error running - %s, \n%s - %s", wid->action, err_type, lua_tostring(L, -1));
230 }
231 }
232 } 172 }
233} 173}
234 174