summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-08-19 20:52:46 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-08-19 20:52:46 +0000
commit47dc4ded767f863f03279bc099d28ba0f0661c2a (patch)
treeb554ff2f7bcf92a6d66e9ab9050ed1d48e71b87e /libs
parent7f6538004335d2a09180817a88bd61745d59732a (diff)
libs/iwinfo: unify LUA_WRAP_ASSOCLIST and LUA_WRAP_TXPWRLIST macros
Diffstat (limited to 'libs')
-rw-r--r--libs/iwinfo/src/iwinfo_lualib.c15
-rw-r--r--libs/iwinfo/src/iwinfo_lualib.h14
2 files changed, 10 insertions, 19 deletions
diff --git a/libs/iwinfo/src/iwinfo_lualib.c b/libs/iwinfo/src/iwinfo_lualib.c
index 6974280b74..e63eeabd4d 100644
--- a/libs/iwinfo/src/iwinfo_lualib.c
+++ b/libs/iwinfo/src/iwinfo_lualib.c
@@ -92,7 +92,6 @@ static int iwinfo_L_txpwrlist(lua_State *L, int (*func)(const char *, char *, in
{
e = (struct iwinfo_txpwrlist_entry *) &rv[i];
- lua_pushinteger(L, x);
lua_newtable(L);
lua_pushnumber(L, e->mw);
@@ -101,7 +100,7 @@ static int iwinfo_L_txpwrlist(lua_State *L, int (*func)(const char *, char *, in
lua_pushnumber(L, e->dbm);
lua_setfield(L, -2, "dbm");
- lua_settable(L, -3);
+ lua_rawseti(L, -2, x);
}
}
@@ -121,8 +120,8 @@ LUA_WRAP_STRING(wl,mode)
LUA_WRAP_STRING(wl,ssid)
LUA_WRAP_STRING(wl,bssid)
LUA_WRAP_STRING(wl,enctype)
-LUA_WRAP_ASSOCLIST(wl)
-LUA_WRAP_TXPWRLIST(wl)
+LUA_WRAP_LIST(wl,assoclist)
+LUA_WRAP_LIST(wl,txpwrlist)
/* Madwifi */
LUA_WRAP_INT(madwifi,channel)
@@ -137,8 +136,8 @@ LUA_WRAP_STRING(madwifi,mode)
LUA_WRAP_STRING(madwifi,ssid)
LUA_WRAP_STRING(madwifi,bssid)
LUA_WRAP_STRING(madwifi,enctype)
-LUA_WRAP_ASSOCLIST(madwifi)
-LUA_WRAP_TXPWRLIST(madwifi)
+LUA_WRAP_LIST(madwifi,assoclist)
+LUA_WRAP_LIST(madwifi,txpwrlist)
/* Wext */
LUA_WRAP_INT(wext,channel)
@@ -153,8 +152,8 @@ LUA_WRAP_STRING(wext,mode)
LUA_WRAP_STRING(wext,ssid)
LUA_WRAP_STRING(wext,bssid)
LUA_WRAP_STRING(wext,enctype)
-LUA_WRAP_ASSOCLIST(wext)
-LUA_WRAP_TXPWRLIST(wext)
+LUA_WRAP_LIST(wext,assoclist)
+LUA_WRAP_LIST(wext,txpwrlist)
/* Broadcom table */
static const luaL_reg R_wl[] = {
diff --git a/libs/iwinfo/src/iwinfo_lualib.h b/libs/iwinfo/src/iwinfo_lualib.h
index 909080bb45..f7eba149d1 100644
--- a/libs/iwinfo/src/iwinfo_lualib.h
+++ b/libs/iwinfo/src/iwinfo_lualib.h
@@ -59,18 +59,10 @@
return 1; \
}
-#define LUA_WRAP_ASSOCLIST(type) \
- static int iwinfo_L_##type##_assoclist(lua_State *L)\
- { \
- return iwinfo_L_assoclist(L, \
- type##_get_assoclist); \
- }
-
-#define LUA_WRAP_TXPWRLIST(type) \
- static int iwinfo_L_##type##_txpwrlist(lua_State *L)\
+#define LUA_WRAP_LIST(type,op) \
+ static int iwinfo_L_##type##_##op(lua_State *L) \
{ \
- return iwinfo_L_txpwrlist(L, \
- type##_get_txpwrlist); \
+ return iwinfo_L_##op(L, type##_get_##op); \
}
#endif