diff options
author | deva <deva> | 2010-08-17 14:29:05 +0000 |
---|---|---|
committer | deva <deva> | 2010-08-17 14:29:05 +0000 |
commit | d2295ad23ed22af07addc93b71e36f7bb688d534 (patch) | |
tree | 4915612e87646091275e291bae291951744585fc /client/lua.cc | |
parent | b23c3c321b80449aa22e14d40115d1e4a764a1b3 (diff) |
New format parser for metawidget et al. DBWidget is broken for the moment...
Diffstat (limited to 'client/lua.cc')
-rw-r--r-- | client/lua.cc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/client/lua.cc b/client/lua.cc index 3607a26..af64efb 100644 --- a/client/lua.cc +++ b/client/lua.cc @@ -106,39 +106,47 @@ void LUA::clear() register_widget(L); } -QString LUA::runParser(QString program) +QString LUA::runScriptS(QString script, Widget *widget, QString name) { if(L == NULL) { ERROR(lua, "LUA state not initialized!"); - return false; + return ""; } - DEBUG(lua, "Running %s\n", program.toStdString().c_str()); - int top = lua_gettop(L); + DEBUG(lua, "Running %s script %s on %s widget.\n", + name.toStdString().c_str(), + script.toStdString().c_str(), + widget?widget->name().toStdString().c_str():"NULL"); + + if(widget) { + wdg_make_widget(L, widget); + lua_setglobal(L, "this"); + } + if(luaL_loadbuffer(L, - program.toStdString().c_str(), - program.size(), - "parser")) { + script.toStdString().c_str(), + script.size(), + name.toStdString().c_str())) { ERROR(lua, "%s", lua_tostring(L, lua_gettop(L))); - return false; + return ""; } // Run the loaded code if(lua_pcall(L, 0, LUA_MULTRET, 0)) { ERROR(lua, "%s", lua_tostring(L, lua_gettop(L))); - return false; + return ""; } if(top != lua_gettop(L) - 1) { ERROR(lua, "Program did not return a single value.\n"); - return false; + return ""; } if(lua_isstring(L, lua_gettop(L)) == false) { ERROR(lua, "Program did not return a boolean value.\n"); - return false; + return ""; } QString res = lua_tostring(L, lua_gettop(L)); |