lua_objsize -> lua_objlen (more compatible with use of `len´ in other

places [opcode name, metamethod index, etc.])
This commit is contained in:
Roberto Ierusalimschy 2005-05-31 11:34:02 -03:00
parent 05348d834b
commit d628795940
5 changed files with 12 additions and 12 deletions

4
lapi.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 2.41 2005/05/17 19:49:15 roberto Exp roberto $ ** $Id: lapi.c,v 2.42 2005/05/31 14:25:18 roberto Exp roberto $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -351,7 +351,7 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
} }
LUA_API size_t lua_objsize (lua_State *L, int idx) { LUA_API size_t lua_objlen (lua_State *L, int idx) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
switch (ttype(o)) { switch (ttype(o)) {
case LUA_TSTRING: return tsvalue(o)->len; case LUA_TSTRING: return tsvalue(o)->len;

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.c,v 1.135 2005/05/31 14:25:18 roberto Exp roberto $ ** $Id: lauxlib.c,v 1.136 2005/05/31 14:31:50 roberto Exp roberto $
** Auxiliary functions for building Lua libraries ** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -317,7 +317,7 @@ LUALIB_API int luaL_getn (lua_State *L, int t) {
if ((n = checkint(L, 2)) >= 0) return n; if ((n = checkint(L, 2)) >= 0) return n;
lua_getfield(L, t, "n"); /* else try t.n */ lua_getfield(L, t, "n"); /* else try t.n */
if ((n = checkint(L, 1)) >= 0) return n; if ((n = checkint(L, 1)) >= 0) return n;
return lua_objsize(L, t); return lua_objlen(L, t);
} }
#endif #endif
@ -542,7 +542,7 @@ LUALIB_API int luaL_ref (lua_State *L, int t) {
lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */
} }
else { /* no free elements */ else { /* no free elements */
ref = lua_objsize(L, t); ref = lua_objlen(L, t);
ref++; /* create new reference */ ref++; /* create new reference */
} }
lua_rawseti(L, t, ref); lua_rawseti(L, t, ref);

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.h,v 1.77 2005/05/25 13:21:26 roberto Exp roberto $ ** $Id: lauxlib.h,v 1.78 2005/05/31 14:25:18 roberto Exp roberto $
** Auxiliary functions for building Lua libraries ** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -16,7 +16,7 @@
#if !defined(LUA_COMPAT_GETN) #if !defined(LUA_COMPAT_GETN)
#define luaL_getn(L,i) ((int)lua_objsize(L, i)) #define luaL_getn(L,i) ((int)lua_objlen(L, i))
#define luaL_setn(L,i,j) ((void)0) /* no op! */ #define luaL_setn(L,i,j) ((void)0) /* no op! */
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltests.c,v 2.23 2005/03/28 17:17:53 roberto Exp roberto $ ** $Id: ltests.c,v 2.24 2005/05/03 19:01:17 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation ** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -882,7 +882,7 @@ static int testC (lua_State *L) {
lua_pushstring(L1, s); lua_pushstring(L1, s);
} }
else if EQ("objsize") { else if EQ("objsize") {
lua_pushinteger(L1, lua_objsize(L1, getindex)); lua_pushinteger(L1, lua_objlen(L1, getindex));
} }
else if EQ("tocfunction") { else if EQ("tocfunction") {
lua_pushcfunction(L1, lua_tocfunction(L1, getindex)); lua_pushcfunction(L1, lua_tocfunction(L1, getindex));

6
lua.h
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lua.h,v 1.207 2005/05/16 19:21:11 roberto Exp roberto $ ** $Id: lua.h,v 1.208 2005/05/17 19:49:15 roberto Exp roberto $
** Lua - An Extensible Extension Language ** Lua - An Extensible Extension Language
** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
** http://www.lua.org ** http://www.lua.org
@ -147,7 +147,7 @@ LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
LUA_API int (lua_toboolean) (lua_State *L, int idx); LUA_API int (lua_toboolean) (lua_State *L, int idx);
LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
LUA_API size_t (lua_objsize) (lua_State *L, int idx); LUA_API size_t (lua_objlen) (lua_State *L, int idx);
LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
LUA_API void *(lua_touserdata) (lua_State *L, int idx); LUA_API void *(lua_touserdata) (lua_State *L, int idx);
LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
@ -257,7 +257,7 @@ LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
#define lua_strlen(L,i) lua_objsize(L, (i)) #define lua_strlen(L,i) lua_objlen(L, (i))
#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)