diff options
Diffstat (limited to 'client/luawidget.cc')
-rw-r--r-- | client/luawidget.cc | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/client/luawidget.cc b/client/luawidget.cc index 2095a64..28ae488 100644 --- a/client/luawidget.cc +++ b/client/luawidget.cc @@ -31,36 +31,12 @@ #include "debug.h" -/** - ** Copied from lauxlib.c, but modified return NULL upon error instead of - ** casting a lua error. - **/ -void *luaL_isudata (lua_State *L, int ud, const char *tname) -{ - void *p = lua_touserdata(L, ud); - if (p != NULL) { /* value is a userdata? */ - if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ - lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ - if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ - lua_pop(L, 2); /* remove both metatables */ - return p; - } - } - } - // luaL_typerror(L, ud, tname); /* else error */ - return NULL; /* to avoid warnings */ -} - int wdg_make_widget(lua_State *L, Widget *widget) { wdg_userdata *wdgu; wdgu = (wdg_userdata *)lua_newuserdata(L, sizeof(wdg_userdata)); + luaL_getmetatable(L, widget->luaclass().toStdString().c_str()); - if(widget->type() == "combobox") luaL_getmetatable(L, "ComboBox"); - else if(widget->type() == "checkbox") luaL_getmetatable(L, "CheckBox"); - else if(widget->type() == "lineedit") luaL_getmetatable(L, "LineEdit"); - else luaL_getmetatable(L, "Widget"); - lua_setmetatable(L, -2); wdgu->widget = widget; @@ -71,8 +47,14 @@ int wdg_make_widget(lua_State *L, Widget *widget) void register_widgets(lua_State *L) { register_widget(L); + register_checkbox(L); + register_checkgroupbox(L); + register_combobox(L); + register_altcombobox(L); + + register_listbox(L); register_lineedit(L); } |