From 16ca9309b35ddadd103d1542818ea75f0a567c92 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Tue, 29 Nov 2016 18:44:41 +0000 Subject: Removed some temporary code and fixed a few tests. --- upb/bindings/lua/def.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'upb/bindings/lua') diff --git a/upb/bindings/lua/def.c b/upb/bindings/lua/def.c index 7e41782..c2df140 100644 --- a/upb/bindings/lua/def.c +++ b/upb/bindings/lua/def.c @@ -54,11 +54,13 @@ void *lupb_refcounted_check(lua_State *L, int narg, const char *type) { void *ud = lua_touserdata(L, narg); void *ret; - if (ud) { - memcpy(&ret, ud, sizeof(ret)); - if (!ret) { - luaL_error(L, "called into dead object"); - } + if (!ud) { + luaL_typerror(L, narg, "refcounted"); + } + + memcpy(&ret, ud, sizeof(ret)); + if (!ret) { + luaL_error(L, "called into dead object"); } luaL_checkudata(L, narg, type); @@ -164,11 +166,13 @@ static const upb_def *lupb_def_check(lua_State *L, int narg) { void *ud, *ud2; ud = lua_touserdata(L, narg); - if (ud) { - memcpy(&ret, ud, sizeof(ret)); - if (!ret) { - luaL_error(L, "called into dead object"); - } + if (!ud) { + luaL_typerror(L, narg, "upb def"); + } + + memcpy(&ret, ud, sizeof(ret)); + if (!ret) { + luaL_error(L, "called into dead object"); } ud2 = luaL_testudata(L, narg, LUPB_MSGDEF); -- cgit v1.2.3