diff options
| author | ruki <[email protected]> | 2026-03-29 23:16:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-03-29 23:16:45 +0800 |
| commit | 1c90ee36327264374e57b5f5070be33c53af0bea (patch) | |
| tree | e76a3b580a8792e7b7aecc8ba48ae4684bcb86fd | |
| parent | 8841ed9f7b427896f042abcfb3537dd731f6a923 (diff) | |
improve luaL_checkinteger
| -rw-r--r-- | core/src/xmake/curses/curses.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/core/src/xmake/curses/curses.c b/core/src/xmake/curses/curses.c index 8cf453660..6736ec05e 100644 --- a/core/src/xmake/curses/curses.c +++ b/core/src/xmake/curses/curses.c @@ -228,8 +228,8 @@ static int xm_curses_window_tostring(lua_State *lua) { // window:move(y, x) static int xm_curses_window_move(lua_State *lua) { WINDOW *w = xm_curses_window_check(lua, 1); - int y = luaL_checkinteger(lua, 2); - int x = luaL_checkinteger(lua, 3); + int y = (int)luaL_checkinteger(lua, 2); + int x = (int)luaL_checkinteger(lua, 3); lua_pushboolean(lua, XM_CURSES_OK(wmove(w, y, x))); return 1; } @@ -276,7 +276,7 @@ static int xm_curses_window_addch(lua_State *lua) { static int xm_curses_window_addnstr(lua_State *lua) { WINDOW *w = xm_curses_window_check(lua, 1); const char *str = luaL_checkstring(lua, 2); - int n = luaL_optinteger(lua, 3, -1); + int n = (int)luaL_optinteger(lua, 3, -1); if (n < 0) n = (int)lua_strlen(lua, 2); lua_pushboolean(lua, XM_CURSES_OK(waddnstr(w, str, n))); @@ -333,7 +333,7 @@ static int xm_curses_window_getch(lua_State *lua) { // window:attroff(attrs) static int xm_curses_window_attroff(lua_State *lua) { WINDOW *w = xm_curses_window_check(lua, 1); - int attrs = luaL_checkinteger(lua, 2); + int attrs = (int)luaL_checkinteger(lua, 2); lua_pushboolean(lua, XM_CURSES_OK(wattroff(w, attrs))); return 1; } @@ -341,7 +341,7 @@ static int xm_curses_window_attroff(lua_State *lua) { // window:attron(attrs) static int xm_curses_window_attron(lua_State *lua) { WINDOW *w = xm_curses_window_check(lua, 1); - int attrs = luaL_checkinteger(lua, 2); + int attrs = (int)luaL_checkinteger(lua, 2); lua_pushboolean(lua, XM_CURSES_OK(wattron(w, attrs))); return 1; } @@ -349,7 +349,7 @@ static int xm_curses_window_attron(lua_State *lua) { // window:attrset(attrs) static int xm_curses_window_attrset(lua_State *lua) { WINDOW *w = xm_curses_window_check(lua, 1); - int attrs = luaL_checkinteger(lua, 2); + int attrs = (int)luaL_checkinteger(lua, 2); lua_pushboolean(lua, XM_CURSES_OK(wattrset(w, attrs))); return 1; } @@ -358,12 +358,12 @@ static int xm_curses_window_attrset(lua_State *lua) { static int xm_curses_window_copywin(lua_State *lua) { WINDOW *srcwin = xm_curses_window_check(lua, 1); WINDOW *dstwin = xm_curses_window_check(lua, 2); - int sminrow = luaL_checkinteger(lua, 3); - int smincol = luaL_checkinteger(lua, 4); - int dminrow = luaL_checkinteger(lua, 5); - int dmincol = luaL_checkinteger(lua, 6); - int dmaxrow = luaL_checkinteger(lua, 7); - int dmaxcol = luaL_checkinteger(lua, 8); + int sminrow = (int)luaL_checkinteger(lua, 3); + int smincol = (int)luaL_checkinteger(lua, 4); + int dminrow = (int)luaL_checkinteger(lua, 5); + int dmincol = (int)luaL_checkinteger(lua, 6); + int dmaxrow = (int)luaL_checkinteger(lua, 7); + int dmaxcol = (int)luaL_checkinteger(lua, 8); int overlay = lua_toboolean(lua, 9); lua_pushboolean(lua, XM_CURSES_OK( @@ -646,7 +646,7 @@ static int xm_curses_getmouse(lua_State *lua) { } static int xm_curses_mousemask(lua_State *lua) { - mmask_t m = luaL_checkinteger(lua, 1); + mmask_t m = (mmask_t)luaL_checkinteger(lua, 1); mmask_t om; m = mousemask(m, &om); lua_pushinteger(lua, m); @@ -656,22 +656,22 @@ static int xm_curses_mousemask(lua_State *lua) { #endif static int xm_curses_init_pair(lua_State *lua) { - short pair = luaL_checkinteger(lua, 1); - short f = luaL_checkinteger(lua, 2); - short b = luaL_checkinteger(lua, 3); + short pair = (short)luaL_checkinteger(lua, 1); + short f = (short)luaL_checkinteger(lua, 2); + short b = (short)luaL_checkinteger(lua, 3); lua_pushboolean(lua, XM_CURSES_OK(init_pair(pair, f, b))); return 1; } static int xm_curses_COLOR_PAIR(lua_State *lua) { - int n = luaL_checkinteger(lua, 1); + int n = (int)luaL_checkinteger(lua, 1); lua_pushnumber(lua, COLOR_PAIR(n)); return 1; } static int xm_curses_curs_set(lua_State *lua) { - int vis = luaL_checkinteger(lua, 1); + int vis = (int)luaL_checkinteger(lua, 1); int state = curs_set(vis); if (state == ERR) return 0; @@ -681,7 +681,7 @@ static int xm_curses_curs_set(lua_State *lua) { } static int xm_curses_napms(lua_State *lua) { - int ms = luaL_checkinteger(lua, 1); + int ms = (int)luaL_checkinteger(lua, 1); lua_pushboolean(lua, XM_CURSES_OK(napms(ms))); return 1; } @@ -714,8 +714,8 @@ static int xm_curses_nl(lua_State *lua) { } static int xm_curses_newpad(lua_State *lua) { - int nlines = luaL_checkinteger(lua, 1); - int ncols = luaL_checkinteger(lua, 2); + int nlines = (int)luaL_checkinteger(lua, 1); + int ncols = (int)luaL_checkinteger(lua, 2); xm_curses_window_new(lua, newpad(nlines, ncols)); return 1; } |
