new macro 'getproto'
This commit is contained in:
4
lapi.c
4
lapi.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 2.85 2009/07/15 17:26:14 roberto Exp roberto $
|
** $Id: lapi.c,v 2.86 2009/07/15 17:57:03 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -910,7 +910,7 @@ LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
|
|||||||
api_checknelems(L, 1);
|
api_checknelems(L, 1);
|
||||||
o = L->top - 1;
|
o = L->top - 1;
|
||||||
if (isLfunction(o))
|
if (isLfunction(o))
|
||||||
status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
|
status = luaU_dump(L, getproto(o), writer, data, 0);
|
||||||
else
|
else
|
||||||
status = 1;
|
status = 1;
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 2.26 2009/06/17 17:48:34 roberto Exp roberto $
|
** $Id: lobject.h,v 2.27 2009/06/18 16:36:40 roberto Exp roberto $
|
||||||
** Type definitions for Lua objects
|
** Type definitions for Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -312,6 +312,7 @@ typedef union Closure {
|
|||||||
#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
|
#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
|
||||||
#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
|
#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
|
||||||
|
|
||||||
|
#define getproto(o) (clvalue(o)->l.p)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Tables
|
** Tables
|
||||||
|
|||||||
8
ltests.c
8
ltests.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltests.c,v 2.66 2009/06/17 17:53:14 roberto Exp roberto $
|
** $Id: ltests.c,v 2.67 2009/07/15 17:26:14 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
|
||||||
*/
|
*/
|
||||||
@@ -440,7 +440,7 @@ static int listcode (lua_State *L) {
|
|||||||
Proto *p;
|
Proto *p;
|
||||||
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
|
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
|
||||||
1, "Lua function expected");
|
1, "Lua function expected");
|
||||||
p = clvalue(obj_at(L, 1))->l.p;
|
p = getproto(obj_at(L, 1));
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
setnameval(L, "maxstack", p->maxstacksize);
|
setnameval(L, "maxstack", p->maxstacksize);
|
||||||
setnameval(L, "numparams", p->numparams);
|
setnameval(L, "numparams", p->numparams);
|
||||||
@@ -459,7 +459,7 @@ static int listk (lua_State *L) {
|
|||||||
int i;
|
int i;
|
||||||
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
|
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
|
||||||
1, "Lua function expected");
|
1, "Lua function expected");
|
||||||
p = clvalue(obj_at(L, 1))->l.p;
|
p = getproto(obj_at(L, 1));
|
||||||
lua_createtable(L, p->sizek, 0);
|
lua_createtable(L, p->sizek, 0);
|
||||||
for (i=0; i<p->sizek; i++) {
|
for (i=0; i<p->sizek; i++) {
|
||||||
pushobject(L, p->k+i);
|
pushobject(L, p->k+i);
|
||||||
@@ -476,7 +476,7 @@ static int listlocals (lua_State *L) {
|
|||||||
const char *name;
|
const char *name;
|
||||||
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
|
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
|
||||||
1, "Lua function expected");
|
1, "Lua function expected");
|
||||||
p = clvalue(obj_at(L, 1))->l.p;
|
p = getproto(obj_at(L, 1));
|
||||||
while ((name = luaF_getlocalname(p, ++i, pc)) != NULL)
|
while ((name = luaF_getlocalname(p, ++i, pc)) != NULL)
|
||||||
lua_pushstring(L, name);
|
lua_pushstring(L, name);
|
||||||
return i-1;
|
return i-1;
|
||||||
|
|||||||
Reference in New Issue
Block a user