From ebb1dc92e4985538a8e18b7e926264118138f281 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sun, 8 Sep 2024 01:07:25 +0200 Subject: [PATCH] lua: Lua 5.3 support Signed-off-by: Raito Bezarius --- lua/ubus.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lua/ubus.c b/lua/ubus.c index 07b816d..1958cd7 100644 --- a/lua/ubus.c +++ b/lua/ubus.c @@ -252,7 +252,7 @@ ubus_lua_connect(lua_State *L) { struct ubus_lua_connection *c; const char *sockpath = luaL_optstring(L, 1, NULL); - int timeout = luaL_optint(L, 2, 30); + int timeout = luaL_optinteger(L, 2, 30); if ((c = lua_newuserdata(L, sizeof(*c))) != NULL && (c->ctx = ubus_connect(sockpath)) != NULL) @@ -278,7 +278,7 @@ ubus_lua_objects_cb(struct ubus_context *c, struct ubus_object_data *o, void *p) lua_State *L = (lua_State *)p; lua_pushstring(L, o->path); - lua_rawseti(L, -2, lua_objlen(L, -2) + 1); + lua_rawseti(L, -2, lua_rawlen(L, -2) + 1); } static int @@ -404,7 +404,7 @@ static int ubus_lua_load_methods(lua_State *L, struct ubus_method *m) /* check if the method table is valid */ if ((lua_type(L, -2) != LUA_TFUNCTION) || (lua_type(L, -1) != LUA_TTABLE) || - lua_objlen(L, -1)) { + lua_rawlen(L, -1)) { lua_pop(L, 2); return 1; } @@ -536,7 +536,7 @@ static struct ubus_object* ubus_lua_load_object(lua_State *L) /* check if it looks like a method */ if ((lua_type(L, -2) != LUA_TSTRING) || (lua_type(L, -1) != LUA_TTABLE) || - !lua_objlen(L, -1)) { + !lua_rawlen(L, -1)) { lua_pop(L, 1); continue; } @@ -977,11 +977,12 @@ luaopen_ubus(lua_State *L) lua_setfield(L, -2, "__index"); /* fill metatable */ - luaL_register(L, NULL, ubus); + luaL_setfuncs(L, ubus, 0); lua_pop(L, 1); /* create module */ - luaL_register(L, MODNAME, ubus); + luaL_newmetatable(L, MODNAME); + luaL_setfuncs(L, ubus, 0); /* set some enum defines */ lua_pushinteger(L, BLOBMSG_TYPE_ARRAY);