diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.93 2003/01/27 13:46:16 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.94 2003/02/11 09:44:38 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -121,6 +121,19 @@ LUALIB_API void luaL_checkany (lua_State *L, int narg) { | |||
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { | ||
125 | if (!lua_getmetatable(L, ud)) return NULL; /* no metatable? */ | ||
126 | lua_pushstring(L, tname); | ||
127 | lua_rawget(L, LUA_REGISTRYINDEX); | ||
128 | if (!lua_rawequal(L, -1, -2)) { | ||
129 | lua_pop(L, 2); | ||
130 | return NULL; | ||
131 | } | ||
132 | lua_pop(L, 2); | ||
133 | return lua_touserdata(L, ud); | ||
134 | } | ||
135 | |||
136 | |||
124 | LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { | 137 | LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { |
125 | const char *s = lua_tostring(L, narg); | 138 | const char *s = lua_tostring(L, narg); |
126 | if (!s) tag_error(L, narg, LUA_TSTRING); | 139 | if (!s) tag_error(L, narg, LUA_TSTRING); |