Skip to content

Commit

Permalink
remove seri.lightuserdata
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Mar 20, 2024
1 parent 1f01891 commit 4c04ee7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 31 deletions.
18 changes: 0 additions & 18 deletions binding/lua_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,11 @@ namespace bee::lua_serialization {
free(data);
return 1;
}
static int lightuserdata(lua_State* L) {
switch (lua_type(L, 1)) {
case LUA_TLIGHTUSERDATA:
lua_pushinteger(L, lua::tolightud<lua_Integer>(L, 1));
return 1;
case LUA_TNUMBER:
if (lua_isinteger(L, 1)) {
lua_pushlightuserdata(L, (void*)lua::checkinteger<intptr_t>(L, 1));
return 1;
}
else {
return luaL_error(L, "unsupported type float");
}
default:
return luaL_error(L, "unsupported type %s", luaL_typename(L, lua_type(L, 1)));
}
}
static int luaopen(lua_State* L) {
luaL_Reg lib[] = {
{ "unpack", unpack },
{ "pack", pack },
{ "packstring", packstring },
{ "lightuserdata", lightuserdata },
{ NULL, NULL }
};
luaL_newlibtable(L, lib);
Expand Down
13 changes: 0 additions & 13 deletions test/test_serialization.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,3 @@ function test_seri:test_ref()
end
end
end

function test_seri:test_lightuserdata()
lt.assertError(seri.lightuserdata, "")
lt.assertError(seri.lightuserdata, 1.1)
lt.assertEquals(seri.lightuserdata(1), seri.lightuserdata(1))
lt.assertNotEquals(seri.lightuserdata(1), seri.lightuserdata(2))
lt.assertEquals(type(seri.lightuserdata(1)), "userdata")
lt.assertEquals(seri.lightuserdata((seri.lightuserdata(10086))), 10086)

local t = { [seri.lightuserdata(0)] = seri.lightuserdata(1) }
local newt = seri.unpack(seri.pack(t))
lt.assertEquals(t, newt)
end

0 comments on commit 4c04ee7

Please sign in to comment.