From 429a817baca0018c9d4b53f864fd05bdbaa81ba5 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Thu, 14 Jan 2016 12:05:45 -0500 Subject: Changes to Lua functions called based on some googling --- vis-lua.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'vis-lua.c') diff --git a/vis-lua.c b/vis-lua.c index 5b44ea1..bbe774f 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -92,7 +92,7 @@ static void *obj_ref_get(lua_State *L, void *addr, const char *type) { lua_getfield(L, LUA_REGISTRYINDEX, "vis.objects"); lua_pushlightuserdata(L, addr); lua_gettable(L, -2); - lua_remove(L, -2); + lua_pop(L, -2); if (lua_isnil(L, -1)) { lua_pop(L, 1); return NULL; @@ -294,17 +294,17 @@ static int window_cursor_index(lua_State *L) { if (lua_isstring(L, 2)) { const char *key = lua_tostring(L, 2); if (strcmp(key, "pos") == 0) { - lua_pushunsigned(L, view_cursor_get(view)); + lua_pushinteger(L, view_cursor_get(view)); return 1; } if (strcmp(key, "line") == 0) { - lua_pushunsigned(L, view_cursor_getpos(view).line); + lua_pushinteger(L, view_cursor_getpos(view).line); return 1; } if (strcmp(key, "col") == 0) { - lua_pushunsigned(L, view_cursor_getpos(view).col); + lua_pushinteger(L, view_cursor_getpos(view).col); return 1; } } @@ -319,7 +319,7 @@ static int window_cursor_newindex(lua_State *L) { if (lua_isstring(L, 2)) { const char *key = lua_tostring(L, 2); if (strcmp(key, "pos") == 0) { - size_t pos = luaL_checkunsigned(L, 3); + size_t pos = luaL_checkinteger(L, 3); view_cursor_to(view, pos); return 0; } @@ -365,7 +365,7 @@ static int file_newindex(lua_State *L) { static int file_insert(lua_State *L) { File *file = obj_ref_check(L, 1, "vis.file"); if (file) { - size_t pos = luaL_checkunsigned(L, 2); + size_t pos = luaL_checkinteger(L, 2); size_t len; luaL_checkstring(L, 3); const char *data = lua_tolstring(L, 3, &len); @@ -380,8 +380,8 @@ static int file_insert(lua_State *L) { static int file_delete(lua_State *L) { File *file = obj_ref_check(L, 1, "vis.file"); if (file) { - size_t pos = luaL_checkunsigned(L, 2); - size_t len = luaL_checkunsigned(L, 3); + size_t pos = luaL_checkinteger(L, 2); + size_t len = luaL_checkinteger(L, 3); bool ret = text_delete(file->text, pos, len); lua_pushboolean(L, ret); } else { @@ -395,7 +395,7 @@ static int file_lines_iterator_it(lua_State *L); static int file_lines_iterator(lua_State *L) { /* need to check second parameter first, because obj_ref_check_get * modifies the stack */ - size_t line = luaL_optunsigned(L, 2, 1); + size_t line = luaL_optinteger(L, 2, 1); File *file = obj_ref_check_get(L, 1, "vis.file"); size_t *pos = lua_newuserdata(L, sizeof *pos); *pos = text_pos_by_lineno(file->text, line); @@ -433,7 +433,7 @@ static int file_lines_index(lua_State *L) { Text *txt = obj_ref_check(L, 1, "vis.file.text"); if (!txt) goto err; - size_t line = luaL_checkunsigned(L, 2); + size_t line = luaL_checkinteger(L, 2); size_t start = text_pos_by_lineno(txt, line); size_t end = text_line_end(txt, start); if (start != EPOS && end != EPOS) { @@ -455,7 +455,7 @@ static int file_lines_newindex(lua_State *L) { Text *txt = obj_ref_check(L, 1, "vis.file.text"); if (!txt) return 0; - size_t line = luaL_checkunsigned(L, 2); + size_t line = luaL_checkinteger(L, 2); size_t size; const char *data = luaL_checklstring(L, 3, &size); if (line == 0) { @@ -485,7 +485,7 @@ static int file_lines_len(lua_State *L) { if (lines > 1 && text_byte_get(txt, size-1, &lastchar) && lastchar == '\n') lines--; } - lua_pushunsigned(L, lines); + lua_pushinteger(L, lines); return 1; } @@ -503,7 +503,7 @@ static void vis_lua_event(Vis *vis, const char *name) { if (lua_istable(L, -1)) { lua_getfield(L, -1, name); } - lua_remove(L, -2); + lua_pop(L, -2); } void vis_lua_start(Vis *vis) { -- cgit v1.2.3