lua: Lua 5.3 support
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
65bb027054
commit
ebb1dc92e4
1 changed files with 7 additions and 6 deletions
13
lua/ubus.c
13
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);
|
||||
|
|
Loading…
Reference in a new issue