aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-03-18 16:08:35 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-03-18 16:08:35 -0500
commit949d8e8829b7d689f516693cfeef1ef6e37608ba (patch)
tree73b4e95398482304b378354eb9ad09ffa174e7eb
parent8f1c876f63727f87227ec7739f63375931ccf847 (diff)
downloadluancurses-949d8e8829b7d689f516693cfeef1ef6e37608ba.tar.gz
luancurses-949d8e8829b7d689f516693cfeef1ef6e37608ba.zip
simplify the definition of simple wrapper functions
-rw-r--r--src/curses.c83
1 files changed, 18 insertions, 65 deletions
diff --git a/src/curses.c b/src/curses.c
index 125578f..f366811 100644
--- a/src/curses.c
+++ b/src/curses.c
@@ -8,6 +8,13 @@
#define REG_TABLE "luancurses"
+#define NO_ARG_FUNCTION(name) \
+static int l_##name(lua_State* L) \
+{ \
+ lua_pushboolean(L, name() == OK); \
+ return 1; \
+}
+
typedef struct _pos {
int x;
int y;
@@ -150,17 +157,17 @@ static int get_char_attr(lua_State* L, int stack_pos)
return mode;
}
-static int l_initscr(lua_State* L)
-{
- lua_pushboolean(L, initscr() == OK);
- return 1;
-}
-
-static int l_endwin(lua_State* L)
-{
- lua_pushboolean(L, endwin() == OK);
- return 1;
-}
+NO_ARG_FUNCTION(initscr)
+NO_ARG_FUNCTION(endwin)
+NO_ARG_FUNCTION(erase)
+NO_ARG_FUNCTION(clear)
+NO_ARG_FUNCTION(clrtobot)
+NO_ARG_FUNCTION(clrtoeol)
+NO_ARG_FUNCTION(deleteln)
+NO_ARG_FUNCTION(insertln)
+NO_ARG_FUNCTION(refresh)
+NO_ARG_FUNCTION(beep)
+NO_ARG_FUNCTION(flash)
static int l_isendwin(lua_State* L)
{
@@ -543,30 +550,6 @@ static int l_addstr(lua_State* L)
return 1;
}
-static int l_erase(lua_State* L)
-{
- lua_pushboolean(L, (erase() == OK));
- return 1;
-}
-
-static int l_clear(lua_State* L)
-{
- lua_pushboolean(L, (clear() == OK));
- return 1;
-}
-
-static int l_clrtobot(lua_State* L)
-{
- lua_pushboolean(L, (clrtobot() == OK));
- return 1;
-}
-
-static int l_clrtoeol(lua_State* L)
-{
- lua_pushboolean(L, (clrtoeol() == OK));
- return 1;
-}
-
static int l_delch(lua_State* L)
{
pos p;
@@ -581,12 +564,6 @@ static int l_delch(lua_State* L)
return 1;
}
-static int l_deleteln(lua_State* L)
-{
- lua_pushboolean(L, (deleteln() == OK));
- return 1;
-}
-
static int l_insch(lua_State* L)
{
int is_mv;
@@ -654,18 +631,6 @@ static int l_insdelln(lua_State* L)
return 1;
}
-static int l_insertln(lua_State* L)
-{
- lua_pushboolean(L, (insertln() == OK));
- return 1;
-}
-
-static int l_refresh(lua_State* L)
-{
- lua_pushboolean(L, (refresh() == OK));
- return 1;
-}
-
static int l_getmaxyx(lua_State* L)
{
int x, y;
@@ -700,18 +665,6 @@ static int l_color_pairs(lua_State* L)
return 1;
}
-static int l_beep(lua_State* L)
-{
- lua_pushboolean(L, (beep() == OK));
- return 1;
-}
-
-static int l_flash(lua_State* L)
-{
- lua_pushboolean(L, (beep() == OK));
- return 1;
-}
-
const luaL_Reg reg[] = {
{ "initscr", l_initscr },
{ "endwin", l_endwin },