moonbridge

changeset 238:73d832c4a9b5

Use luaL_setmetatable instead of luaL_getmetatable and lua_setmetatable
author jbe
date Sat Aug 20 21:56:02 2016 +0200 (2016-08-20)
parents 5f2a2f73e9d3
children 90e6db450677
files moonbridge_io.c
line diff
     1.1 --- a/moonbridge_io.c	Tue Jul 26 16:22:21 2016 +0200
     1.2 +++ b/moonbridge_io.c	Sat Aug 20 21:56:02 2016 +0200
     1.3 @@ -782,8 +782,7 @@
     1.4    handle->fd = *fd;  /* required for set_linger call */
     1.5    moonbr_io_handle_set_linger(L, handle, 0);
     1.6    handle->fd = -1;  /* avoid closing incomplete handle */
     1.7 -  luaL_getmetatable(L, MOONBR_IO_HANDLE_MT_REGKEY);
     1.8 -  lua_setmetatable(L, -2);
     1.9 +  luaL_setmetatable(L, MOONBR_IO_HANDLE_MT_REGKEY);
    1.10    lua_newtable(L);  // uservalue
    1.11    lua_newtable(L);
    1.12    lua_setfield(L, -2, "writequeue");
    1.13 @@ -867,8 +866,7 @@
    1.14      lua_pushinteger(L, ntohs(addr_in.sin_port));
    1.15      lua_setfield(L, -2, "remote_tcpport");
    1.16    }
    1.17 -  luaL_getmetatable(L, MOONBR_IO_HANDLE_PUBLIC_MT_REGKEY);
    1.18 -  lua_setmetatable(L, -2);
    1.19 +  luaL_setmetatable(L, MOONBR_IO_HANDLE_PUBLIC_MT_REGKEY);
    1.20    lua_setfield(L, -2, "public");
    1.21    lua_setuservalue(L, -2);
    1.22    handle->fd = *fd;
    1.23 @@ -1278,8 +1276,7 @@
    1.24    child->pid = 0;
    1.25    lua_newtable(L);
    1.26    lua_setuservalue(L, -2);
    1.27 -  luaL_getmetatable(L, MOONBR_IO_CHILD_MT_REGKEY);
    1.28 -  lua_setmetatable(L, -2);
    1.29 +  luaL_setmetatable(L, MOONBR_IO_CHILD_MT_REGKEY);
    1.30    if (socketpair(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0, sockin)) {
    1.31      moonbr_io_errmsg();
    1.32      lua_pushnil(L);

Impressum / About Us