aboutsummaryrefslogtreecommitdiff
path: root/src/lj_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_api.c')
-rw-r--r--src/lj_api.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lj_api.c b/src/lj_api.c
index c417af7e..c784ed3f 100644
--- a/src/lj_api.c
+++ b/src/lj_api.c
@@ -875,7 +875,7 @@ LUA_API void lua_upvaluejoin(lua_State *L, int idx1, int n1, int idx2, int n2)
875 lj_gc_objbarrier(L, fn1, gcref(fn1->l.uvptr[n1])); 875 lj_gc_objbarrier(L, fn1, gcref(fn1->l.uvptr[n1]));
876} 876}
877 877
878LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname) 878LUALIB_API void *luaL_testudata(lua_State *L, int idx, const char *tname)
879{ 879{
880 cTValue *o = index2adr(L, idx); 880 cTValue *o = index2adr(L, idx);
881 if (tvisudata(o)) { 881 if (tvisudata(o)) {
@@ -884,8 +884,14 @@ LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname)
884 if (tv && tvistab(tv) && tabV(tv) == tabref(ud->metatable)) 884 if (tv && tvistab(tv) && tabV(tv) == tabref(ud->metatable))
885 return uddata(ud); 885 return uddata(ud);
886 } 886 }
887 lj_err_argtype(L, idx, tname); 887 return NULL; /* value is not a userdata with a metatable */
888 return NULL; /* unreachable */ 888}
889
890LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname)
891{
892 void *p = luaL_testudata(L, idx, tname);
893 if (!p) lj_err_argtype(L, idx, tname);
894 return p;
889} 895}
890 896
891/* -- Object setters ------------------------------------------------------ */ 897/* -- Object setters ------------------------------------------------------ */