summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2010-08-30 13:54:13 +0000
committerdeva <deva>2010-08-30 13:54:13 +0000
commitf3847624ee5f99a37cf60be52067ad19bcdb4446 (patch)
treebeb2bf1edd693e8aeb792f172a9385e7da25dc4b
parentb7316bf6168ee316a07b616386c9f64c2d5476bd (diff)
Add missing typechecks for ComboBox
-rw-r--r--client/luawidget.cc56
1 files changed, 33 insertions, 23 deletions
diff --git a/client/luawidget.cc b/client/luawidget.cc
index bd000f0..5abc236 100644
--- a/client/luawidget.cc
+++ b/client/luawidget.cc
@@ -65,6 +65,7 @@ static int wdg_name(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
lua_pushstring(L, wdgu->widget->name().toStdString().c_str());
@@ -78,6 +79,7 @@ static int wdg_type(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
// return error code
@@ -92,6 +94,7 @@ static int wdg_value(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
lua_pushstring(L, wdgu->widget->value().toStdString().c_str());
@@ -105,6 +108,7 @@ static int wdg_set_value(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
const char *val = luaL_checkstring(L, 2);
@@ -120,6 +124,7 @@ static int wdg_enabled(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
lua_pushboolean(L, wdgu->widget->enabled());
@@ -133,6 +138,7 @@ static int wdg_set_enabled(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
bool val = luaL_checkbool(L, 2);
@@ -148,6 +154,7 @@ static int wdg_visible(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
lua_pushboolean(L, wdgu->widget->visible());
@@ -161,6 +168,7 @@ static int wdg_set_visible(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
bool val = luaL_checkbool(L, 2);
@@ -176,6 +184,7 @@ static int wdg_valid(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
lua_pushboolean(L, wdgu->widget->valid());
@@ -189,6 +198,7 @@ static int wdg_set_valid(lua_State *L)
wdgu = (wdg_userdata *)luaL_isudata(L, 1, "Widget");
if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "CheckBox");
+ if(!wdgu) wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox");
luaL_argcheck(L, wdgu, 1, "widget expected");
bool val = luaL_checkbool(L, 2);
@@ -210,7 +220,7 @@ static int wdg_set_valid(lua_State *L)
{"valid", wdg_valid},\
{"setValid", wdg_set_valid}
-static int wdg_chk_checked(lua_State *L)
+static int chk_checked(lua_State *L)
{
wdg_userdata *wdgu;
@@ -223,7 +233,7 @@ static int wdg_chk_checked(lua_State *L)
return 1;
}
-static int wdg_chk_set_checked(lua_State *L)
+static int chk_set_checked(lua_State *L)
{
wdg_userdata *wdgu;
@@ -238,11 +248,11 @@ static int wdg_chk_set_checked(lua_State *L)
return 0;
}
-#define WDG_CMBBOX_METHS \
- {"checked", wdg_chk_checked},\
- {"setChecked", wdg_chk_set_checked}
+#define CHKBOX_METHS \
+ {"checked", chk_checked},\
+ {"setChecked", chk_set_checked}
-static int wdg_cmb_clear(lua_State *L)
+static int cmb_clear(lua_State *L)
{
wdg_userdata *wdgu;
@@ -255,7 +265,7 @@ static int wdg_cmb_clear(lua_State *L)
return 0;
}
-static int wdg_cmb_add_item(lua_State *L)
+static int cmb_add_item(lua_State *L)
{
wdg_userdata *wdgu;
@@ -270,23 +280,18 @@ static int wdg_cmb_add_item(lua_State *L)
return 0;
}
-#define WDG_CHKBOX_METHS \
- {"clear", wdg_cmb_clear},\
- {"addItem", wdg_cmb_add_item}
+#define CMBBOX_METHS \
+ {"clear", cmb_clear},\
+ {"addItem", cmb_add_item}
-static const struct luaL_Reg wdg_meths[] = {
- WDG_METHS, {NULL, NULL} };
+static const struct luaL_Reg wdg_meths[] =
+ { WDG_METHS, {NULL, NULL} };
-static const struct luaL_Reg wdg_chkbox_meths[] = {
- WDG_METHS, WDG_CHKBOX_METHS, {NULL, NULL} };
+static const struct luaL_Reg chkbox_meths[] =
+ { WDG_METHS, CHKBOX_METHS, {NULL, NULL} };
-static const struct luaL_Reg wdg_cmbbox_meths[] = {
- WDG_METHS, WDG_CMBBOX_METHS, {NULL, NULL} };
-
-static const struct luaL_Reg wdg_chk_meths[] =
-{
- {NULL, NULL}
-};
+static const struct luaL_Reg cmbbox_meths[] =
+ { WDG_METHS, CMBBOX_METHS, {NULL, NULL} };
int wdg_make_widget(lua_State *L, Widget *widget)
{
@@ -312,17 +317,22 @@ void register_widget(lua_State *L)
lua_rawset(L, -3);
luaL_register(L, NULL, wdg_meths);
+ // lua_pop(L, 2);
+
luaL_newmetatable(L, "CheckBox");
lua_pushliteral(L, "__index");
lua_pushvalue(L, -2);
lua_rawset(L, -3);
- luaL_register(L, NULL, wdg_chkbox_meths);
+ luaL_register(L, NULL, chkbox_meths);
+
+ // lua_pop(L, 2);
luaL_newmetatable(L, "ComboBox");
lua_pushliteral(L, "__index");
lua_pushvalue(L, -2);
lua_rawset(L, -3);
- luaL_register(L, NULL, wdg_cmbbox_meths);
+ luaL_register(L, NULL, cmbbox_meths);
+ // lua_pop(L, 2);
}