diff options
| author | Lua Team <team@lua.org> | 2010-11-16 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 2010-11-16 12:00:00 +0000 |
| commit | ccd28dfe034d5dfd130e5378a147e3e9fe7f6807 (patch) | |
| tree | f1c922e8064f556c1034511afbbb3376640c4d27 /src/lauxlib.c | |
| parent | d4bba06f4b8264eee00b25ee08e982d348486aaf (diff) | |
| download | lua-github-5.2.0-alpha-rc1.tar.gz | |
Lua 5.2.0-alpha-rc15.2.0-alpha-rc1
Diffstat (limited to 'src/lauxlib.c')
| -rw-r--r-- | src/lauxlib.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lauxlib.c b/src/lauxlib.c index 807c5522..cdd5a53f 100644 --- a/src/lauxlib.c +++ b/src/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.224 2010/10/29 12:52:21 roberto Exp $ +** $Id: lauxlib.c,v 1.227 2010/11/10 18:05:36 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -168,7 +168,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { } -LUALIB_API int luaL_typeerror (lua_State *L, int narg, const char *tname) { +static int typeerror (lua_State *L, int narg, const char *tname) { const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, luaL_typename(L, narg)); return luaL_argerror(L, narg, msg); @@ -176,7 +176,7 @@ LUALIB_API int luaL_typeerror (lua_State *L, int narg, const char *tname) { static void tag_error (lua_State *L, int narg, int tag) { - luaL_typeerror(L, narg, lua_typename(L, tag)); + typeerror(L, narg, lua_typename(L, tag)); } @@ -224,6 +224,12 @@ LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { } +LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) { + luaL_getmetatable(L, tname); + lua_setmetatable(L, -2); +} + + LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { void *p = lua_touserdata(L, ud); if (p != NULL) { /* value is a userdata? */ @@ -241,7 +247,7 @@ LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { void *p = luaL_testudata(L, ud, tname); - if (p == NULL) luaL_typeerror(L, ud, tname); + if (p == NULL) typeerror(L, ud, tname); return p; } @@ -377,7 +383,7 @@ LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) { if (newsize - B->n < sz) /* not bit enough? */ newsize = B->n + sz; if (newsize < B->n || newsize - B->n < sz) - luaL_error(L, "string too large"); + luaL_error(L, "buffer too large"); newbuff = (char *)lua_newuserdata(L, newsize); /* create larger buffer */ memcpy(newbuff, B->b, B->n); /* move content to new buffer */ if (buffonstack(B)) |
