From f2d2a10d9b5e2eafd5990b8ba08ad9f0efd86577 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 30 Jun 2008 13:50:49 +0200 Subject: [PATCH] lua: remove luaA_name_init Signed-off-by: Julien Danjou --- lua.h | 7 ------- statusbar.c | 7 +++++-- tag.c | 4 +++- widget.c | 6 +++++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lua.h b/lua.h index 4cbae7246..ea7311a61 100644 --- a/lua.h +++ b/lua.h @@ -172,13 +172,6 @@ luaA_settype(lua_State *L, const char *type) return 1; } -static inline char * -luaA_name_init(lua_State *L) -{ - lua_getfield(L, 1, "name"); - return a_strdup(luaL_checkstring(L, -1)); -} - void luaA_init(void); bool luaA_parserc(const char *); void luaA_pushpointer(lua_State *, void *, awesome_type_t); diff --git a/statusbar.c b/statusbar.c index 5557b24ac..653236c50 100644 --- a/statusbar.c +++ b/statusbar.c @@ -540,10 +540,13 @@ luaA_statusbar_new(lua_State *L) luaA_checktable(L, 1); + if(!(buf = luaA_getopt_string(L, 1, "name", NULL))) + luaL_error(L, "object statusbar must have a name"); + sb = p_new(statusbar_t, 1); - sb->name = luaA_name_init(L); - + sb->name = a_strdup(buf); + if(!(buf = luaA_getopt_string(L, 1, "fg", NULL)) || !xcolor_new(globalconf.connection, globalconf.default_screen, buf, &sb->colors.fg)) diff --git a/tag.c b/tag.c index cfee67f7a..ea7be0428 100644 --- a/tag.c +++ b/tag.c @@ -316,7 +316,9 @@ luaA_tag_new(lua_State *L) luaA_checktable(L, 1); - name = luaA_name_init(L); + if(!(name = luaA_getopt_string(L, 1, "name", NULL))) + luaL_error(L, "object tag must have a name"); + mwfact = luaA_getopt_number(L, 1, "mwfact", 0.5); ncol = luaA_getopt_number(L, 1, "ncol", 1); nmaster = luaA_getopt_number(L, 1, "nmaster", 1); diff --git a/widget.c b/widget.c index a34b3d5e6..9fa00f82f 100644 --- a/widget.c +++ b/widget.c @@ -271,9 +271,13 @@ luaA_widget_new(lua_State *L) size_t len; luaA_checktable(L, 1); + buf = luaA_getopt_lstring(L, 1, "align", "left", &len); align = draw_align_fromstr(buf, len); + if(!(buf = luaA_getopt_string(L, 1, "name", NULL))) + luaL_error(L, "object widget must have a name"); + type = luaA_getopt_string(L, 1, "type", NULL); if((wc = name_func_lookup(type, WidgetList))) @@ -286,7 +290,7 @@ luaA_widget_new(lua_State *L) /* Set visible by default. */ w->isvisible = true; - w->name = luaA_name_init(L); + w->name = a_strdup(buf); return luaA_widget_userdata_new(L, w); }