'luaL_findtable' -> 'luaL_getsubtable'

This commit is contained in:
Roberto Ierusalimschy 2011-04-08 16:17:36 -03:00
parent 427ee519db
commit 19fbdf6cae
6 changed files with 18 additions and 18 deletions

View file

@ -1,5 +1,5 @@
/*
** $Id: lauxlib.c,v 1.228 2011/01/10 15:51:42 roberto Exp roberto $
** $Id: lauxlib.c,v 1.229 2011/03/03 16:34:46 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@ -758,8 +758,8 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
*/
#if defined(LUA_COMPAT_MODULE)
static const char *luaL_findtablex (lua_State *L, int idx,
const char *fname, int szhint) {
static const char *luaL_findtable (lua_State *L, int idx,
const char *fname, int szhint) {
const char *e;
if (idx) lua_pushvalue(L, idx);
do {
@ -803,13 +803,13 @@ static int libsize (const luaL_Reg *l) {
*/
LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname,
int sizehint) {
luaL_findtablex(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */
lua_getfield(L, -1, modname); /* get _LOADED[modname] */
if (!lua_istable(L, -1)) { /* not found? */
lua_pop(L, 1); /* remove previous result */
/* try global variable (and create one if it does not exist) */
lua_pushglobaltable(L);
if (luaL_findtablex(L, 0, modname, sizehint) != NULL)
if (luaL_findtable(L, 0, modname, sizehint) != NULL)
luaL_error(L, "name conflict for module " LUA_QS, modname);
lua_pushvalue(L, -1);
lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */
@ -853,7 +853,7 @@ LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
** ensure that stack[idx][fname] has a table and push that table
** into the stack
*/
LUALIB_API int luaL_findtable (lua_State *L, int idx, const char *fname) {
LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) {
lua_getfield(L, idx, fname);
if (lua_istable(L, -1)) return 1; /* table already there */
else {
@ -878,7 +878,7 @@ LUALIB_API void luaL_requiref (lua_State *L, const char *modname,
lua_pushcfunction(L, openf);
lua_pushstring(L, modname); /* argument to open function */
lua_call(L, 1, 1); /* open module */
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED");
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
lua_pushvalue(L, -2); /* make copy of module (call result) */
lua_setfield(L, -2, modname); /* _LOADED[modname] = module */
lua_pop(L, 1); /* remove _LOADED table */

View file

@ -1,5 +1,5 @@
/*
** $Id: lauxlib.h,v 1.114 2011/01/10 15:51:42 roberto Exp roberto $
** $Id: lauxlib.h,v 1.115 2011/03/03 16:34:46 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@ -86,7 +86,7 @@ LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
LUALIB_API int (luaL_findtable) (lua_State *L, int idx, const char *fname);
LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);
LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
const char *msg, int level);

View file

@ -1,5 +1,5 @@
/*
** $Id: ldblib.c,v 1.128 2011/01/10 15:51:19 roberto Exp roberto $
** $Id: ldblib.c,v 1.129 2011/01/26 16:30:02 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@ -253,7 +253,7 @@ static int db_upvaluejoin (lua_State *L) {
}
#define gethooktable(L) luaL_findtable(L, LUA_REGISTRYINDEX, HOOKKEY);
#define gethooktable(L) luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY);
static void hookf (lua_State *L, lua_Debug *ar) {

View file

@ -1,5 +1,5 @@
/*
** $Id: linit.c,v 1.30 2010/11/12 15:48:30 roberto Exp roberto $
** $Id: linit.c,v 1.31 2011/01/26 16:30:02 roberto Exp roberto $
** Initialization of libraries for lua.c and other clients
** See Copyright Notice in lua.h
*/
@ -57,7 +57,7 @@ LUALIB_API void luaL_openlibs (lua_State *L) {
lua_pop(L, 1); /* remove lib */
}
/* add open functions from 'preloadedlibs' into 'package.preload' table */
luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
for (lib = preloadedlibs; lib->func; lib++) {
lua_pushcfunction(L, lib->func);
lua_setfield(L, -2, lib->name);

View file

@ -1,5 +1,5 @@
/*
** $Id: loadlib.c,v 1.96 2011/02/07 19:15:24 roberto Exp roberto $
** $Id: loadlib.c,v 1.97 2011/03/01 17:01:53 roberto Exp roberto $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@ -652,10 +652,10 @@ LUAMOD_API int luaopen_package (lua_State *L) {
LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
lua_setfield(L, -2, "config");
/* set field `loaded' */
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED");
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
lua_setfield(L, -2, "loaded");
/* set field `preload' */
luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
lua_setfield(L, -2, "preload");
lua_pushglobaltable(L);
lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */

View file

@ -1,5 +1,5 @@
/*
** $Id: ltests.c,v 2.114 2010/11/26 14:32:31 roberto Exp roberto $
** $Id: ltests.c,v 2.115 2010/12/10 13:40:22 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@ -853,7 +853,7 @@ static int loadlib (lua_State *L) {
lua_State *L1 = getstate(L);
int i;
luaL_requiref(L1, "package", luaopen_package, 1);
luaL_findtable(L1, LUA_REGISTRYINDEX, "_PRELOAD");
luaL_getsubtable(L1, LUA_REGISTRYINDEX, "_PRELOAD");
for (i = 0; libs[i].name; i++) {
lua_pushcfunction(L1, libs[i].func);
lua_setfield(L1, -2, libs[i].name);