luaa: Stop using a_tokenize()

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-09-02 19:08:08 +02:00
parent 56fd77139e
commit f2e9767434
1 changed files with 37 additions and 52 deletions

55
luaa.c
View File

@ -310,13 +310,12 @@ luaA_wtable_ipairs(lua_State *L)
static int
luaA_wtable_index(lua_State *L)
{
size_t len;
const char *buf;
lua_pushvalue(L, 2);
/* check for size, waiting lua 5.2 and __len on tables */
if((buf = lua_tolstring(L, -1, &len)))
if(a_tokenize(buf, len) == A_TK_LEN)
if((buf = lua_tostring(L, -1)))
if(a_strcmp(buf, "len") == 0)
{
lua_pushnumber(L, lua_objlen(L, lua_upvalueindex(1)));
return 1;
@ -529,39 +528,28 @@ luaA_awesome_index(lua_State *L)
if(luaA_usemetatable(L, 1, 2))
return 1;
size_t len;
const char *buf = luaL_checklstring(L, 2, &len);
const char *buf = luaL_checkstring(L, 2);
switch(a_tokenize(buf, len))
{
case A_TK_FONT:
if(a_strcmp(buf, "font") == 0)
{
char *font = pango_font_description_to_string(globalconf.font->desc);
lua_pushstring(L, font);
g_free(font);
}
break;
case A_TK_FONT_HEIGHT:
else if(a_strcmp(buf, "font_height") == 0)
lua_pushnumber(L, globalconf.font->height);
break;
case A_TK_CONFFILE:
else if(a_strcmp(buf, "conffile") == 0)
lua_pushstring(L, conffile);
break;
case A_TK_FG:
else if(a_strcmp(buf, "fg") == 0)
luaA_pushxcolor(L, globalconf.colors.fg);
break;
case A_TK_BG:
else if(a_strcmp(buf, "bg") == 0)
luaA_pushxcolor(L, globalconf.colors.bg);
break;
case A_TK_VERSION:
else if(a_strcmp(buf, "version") == 0)
lua_pushliteral(L, AWESOME_VERSION);
break;
case A_TK_RELEASE:
else if(a_strcmp(buf, "release") == 0)
lua_pushliteral(L, AWESOME_RELEASE);
break;
default:
else
return 0;
}
return 1;
}
@ -576,12 +564,9 @@ luaA_awesome_newindex(lua_State *L)
if(luaA_usemetatable(L, 1, 2))
return 1;
size_t len;
const char *buf = luaL_checklstring(L, 2, &len);
const char *buf = luaL_checkstring(L, 2);
switch(a_tokenize(buf, len))
{
case A_TK_FONT:
if(a_strcmp(buf, "font") == 0)
{
const char *newfont = luaL_checkstring(L, 3);
font_delete(&globalconf.font);
@ -590,17 +575,17 @@ luaA_awesome_newindex(lua_State *L)
foreach(wibox, globalconf.wiboxes)
(*wibox)->need_update = true;
}
break;
case A_TK_FG:
else if(a_strcmp(buf, "fg") == 0)
{
size_t len;
if((buf = luaL_checklstring(L, 3, &len)))
xcolor_init_reply(xcolor_init_unchecked(&globalconf.colors.fg, buf, len));
break;
case A_TK_BG:
}
else if(a_strcmp(buf, "bg") == 0)
{
size_t len;
if((buf = luaL_checklstring(L, 3, &len)))
xcolor_init_reply(xcolor_init_unchecked(&globalconf.colors.bg, buf, len));
break;
default:
return 0;
}
return 0;