diff options
author | Josh Haberman <jhaberman@gmail.com> | 2016-11-29 18:44:41 +0000 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2016-11-29 18:44:41 +0000 |
commit | 16ca9309b35ddadd103d1542818ea75f0a567c92 (patch) | |
tree | fc79dab4ae279a5ae85bba54ec57e98c352dbcc7 /upb/bindings/lua | |
parent | 4b0c4ca7fb0aa9207af3398e04534b23fbb88f27 (diff) |
Removed some temporary code and fixed a few tests.
Diffstat (limited to 'upb/bindings/lua')
-rw-r--r-- | upb/bindings/lua/def.c | 24 |
1 files changed, 14 insertions, 10 deletions
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); |