From bd5fa9cc8fdd966edc46c3de2cc420a72240ead3 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 15 Jul 2009 15:37:19 -0300 Subject: new macro 'getproto' --- lapi.c | 4 ++-- lobject.h | 3 ++- ltests.c | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lapi.c b/lapi.c index 7865e0c8..b05897d7 100644 --- a/lapi.c +++ b/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 ** 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); o = L->top - 1; if (isLfunction(o)) - status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); + status = luaU_dump(L, getproto(o), writer, data, 0); else status = 1; lua_unlock(L); diff --git a/lobject.h b/lobject.h index 62c5cb21..10eb363f 100644 --- a/lobject.h +++ b/lobject.h @@ -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 ** 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 isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) +#define getproto(o) (clvalue(o)->l.p) /* ** Tables diff --git a/ltests.c b/ltests.c index cfa14c21..b508ccfa 100644 --- a/ltests.c +++ b/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 ** See Copyright Notice in lua.h */ @@ -440,7 +440,7 @@ static int listcode (lua_State *L) { Proto *p; luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, "Lua function expected"); - p = clvalue(obj_at(L, 1))->l.p; + p = getproto(obj_at(L, 1)); lua_newtable(L); setnameval(L, "maxstack", p->maxstacksize); setnameval(L, "numparams", p->numparams); @@ -459,7 +459,7 @@ static int listk (lua_State *L) { int i; luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, "Lua function expected"); - p = clvalue(obj_at(L, 1))->l.p; + p = getproto(obj_at(L, 1)); lua_createtable(L, p->sizek, 0); for (i=0; isizek; i++) { pushobject(L, p->k+i); @@ -476,7 +476,7 @@ static int listlocals (lua_State *L) { const char *name; luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 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) lua_pushstring(L, name); return i-1; -- cgit v1.2.3-55-g6feb