Skip to content
Snippets Groups Projects
Commit 449d3cc3 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

daemon/bindings: fixed Lua <=5.1 compat and bad cast

parent 4435edb1
Branches
Tags
No related merge requests found
......@@ -39,7 +39,7 @@ static lookup_table_t wire_flag_names[] = {
static int pkt_flag(lua_State *L)
{
knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT);
knot_pkt_t *pkt = lua_touserdata(L, 1);
if (lua_gettop(L) > 1 && lua_isnumber(L, 2)) {
int flag_id = lua_tonumber(L, 2);
switch(flag_id) {
......@@ -53,7 +53,7 @@ static int pkt_flag(lua_State *L)
static int pkt_opcode(lua_State *L)
{
knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT);
knot_pkt_t *pkt = lua_touserdata(L, 1);
if (lua_gettop(L) > 1 && lua_isnumber(L, 2)) {
knot_wire_set_opcode(pkt->wire, lua_tonumber(L, 2));
}
......@@ -63,7 +63,7 @@ static int pkt_opcode(lua_State *L)
static int pkt_rcode(lua_State *L)
{
knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT);
knot_pkt_t *pkt = lua_touserdata(L, 1);
if (lua_gettop(L) > 1 && lua_isnumber(L, 2)) {
knot_wire_set_rcode(pkt->wire, lua_tonumber(L, 2));
}
......@@ -73,21 +73,21 @@ static int pkt_rcode(lua_State *L)
static int pkt_qtype(lua_State *L)
{
knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT);
knot_pkt_t *pkt = lua_touserdata(L, 1);
lua_pushnumber(L, knot_pkt_qtype(pkt));
return 1;
}
static int pkt_qclass(lua_State *L)
{
knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT);
knot_pkt_t *pkt = lua_touserdata(L, 1);
lua_pushnumber(L, knot_pkt_qclass(pkt));
return 1;
}
static int pkt_qname(lua_State *L)
{
knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT);
knot_pkt_t *pkt = lua_touserdata(L, 1);
const knot_dname_t *dname = knot_pkt_qname(pkt);
char dname_str[KNOT_DNAME_MAXLEN];
knot_dname_to_str(dname_str, dname, sizeof(dname_str));
......
......@@ -81,7 +81,7 @@ static inline int l_ffi_call(lua_State *L, int argc)
if (lua_isthread(L, -1)) { /* Continuations */
status = l_ffi_defer(lua_tothread(L, -1));
} else if (lua_isnumber(L, -1)) { /* Return code */
status = lua_tonumber(L, 1);
status = lua_tonumber(L, -1);
}
lua_pop(L, 1);
}
......
......@@ -91,8 +91,6 @@ block.layer = {
else
return state
end
end
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment