diff options
Diffstat (limited to 'lauxlib.c')
| -rw-r--r-- | lauxlib.c | 19 |
1 files changed, 6 insertions, 13 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.53 2001/10/31 19:40:14 roberto Exp $ | 2 | ** $Id: lauxlib.c,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $ |
| 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 | */ |
| @@ -43,7 +43,8 @@ LUALIB_API void luaL_argerror (lua_State *L, int narg, const char *extramsg) { | |||
| 43 | 43 | ||
| 44 | LUALIB_API void luaL_typerror (lua_State *L, int narg, const char *tname) { | 44 | LUALIB_API void luaL_typerror (lua_State *L, int narg, const char *tname) { |
| 45 | char buff[80]; | 45 | char buff[80]; |
| 46 | sprintf(buff, "%.25s expected, got %.25s", tname, lua_type(L,narg)); | 46 | sprintf(buff, "%.25s expected, got %.25s", tname, |
| 47 | lua_typename(L, lua_type(L,narg))); | ||
| 47 | luaL_argerror(L, narg, buff); | 48 | luaL_argerror(L, narg, buff); |
| 48 | } | 49 | } |
| 49 | 50 | ||
| @@ -59,26 +60,18 @@ LUALIB_API void luaL_check_stack (lua_State *L, int space, const char *mes) { | |||
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | 62 | ||
| 62 | LUALIB_API void luaL_check_rawtype(lua_State *L, int narg, int t) { | 63 | LUALIB_API void luaL_check_type(lua_State *L, int narg, int t) { |
| 63 | if (lua_rawtag(L, narg) != t) | 64 | if (lua_type(L, narg) != t) |
| 64 | tag_error(L, narg, t); | 65 | tag_error(L, narg, t); |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | 68 | ||
| 68 | LUALIB_API void luaL_check_any (lua_State *L, int narg) { | 69 | LUALIB_API void luaL_check_any (lua_State *L, int narg) { |
| 69 | if (lua_rawtag(L, narg) == LUA_TNONE) | 70 | if (lua_type(L, narg) == LUA_TNONE) |
| 70 | luaL_argerror(L, narg, "value expected"); | 71 | luaL_argerror(L, narg, "value expected"); |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | 74 | ||
| 74 | LUALIB_API void *luaL_check_userdata (lua_State *L, int narg, | ||
| 75 | const char *name) { | ||
| 76 | if (strcmp(lua_type(L, narg), name) != 0) | ||
| 77 | luaL_typerror(L, narg, name); | ||
| 78 | return lua_touserdata(L, narg); | ||
| 79 | } | ||
| 80 | |||
| 81 | |||
| 82 | LUALIB_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { | 75 | LUALIB_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { |
| 83 | const char *s = lua_tostring(L, narg); | 76 | const char *s = lua_tostring(L, narg); |
| 84 | if (!s) tag_error(L, narg, LUA_TSTRING); | 77 | if (!s) tag_error(L, narg, LUA_TSTRING); |
