summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2010-08-18 15:18:07 +0000
committerdeva <deva>2010-08-18 15:18:07 +0000
commitd2aa6fc31b7b867b9eba402ac25f4e0014837191 (patch)
tree1532324dd0f74fc37dda889ba81ab2fbae7696af
parentc11f22451c98d69f036114066772eb8f39582a9c (diff)
New debug CFunction
-rw-r--r--client/lua.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/client/lua.cc b/client/lua.cc
index af64efb..8a18b1e 100644
--- a/client/lua.cc
+++ b/client/lua.cc
@@ -60,19 +60,31 @@ static int get_widget(lua_State *L)
Widget *widget = lua->getWidget(name);
- DEBUG(lua, "FIND: %s (%p)\n", name.toStdString().c_str(), widget);
-
if(widget) {
wdg_make_widget(L, widget);
} else {
lua_pushnil(L);
}
- DEBUG(lua, "DONE\n");
-
return 1;
}
+static int debug(lua_State *L)
+{
+ int n = lua_gettop(L); // number of arguments
+ if(n != 1) {
+ char errstr[512];
+ sprintf(errstr, "Number of args expected 1, got %d", n);
+ lua_pushstring(L, errstr);
+ lua_error(L);
+ return 1;
+ }
+
+ DEBUG(lua, "%s", lua_tostring(L, lua_gettop(L)));
+
+ return 0;
+}
+
LUA::LUA(Widget **rootwidget)
{
this->rootwidget = rootwidget;
@@ -102,6 +114,7 @@ void LUA::clear()
lua_setglobal(L, GLOBAL_POINTER); // Assign it to a global lua var.
lua_register(L, "widget", get_widget);
+ lua_register(L, "debug", debug);
register_widget(L);
}