From ad5574c4c97af3ef863a6fb4b72142f3780103b2 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 31 Mar 1997 11:02:58 -0300 Subject: [PATCH] "Object" renamed to "TObject" (Tagged Object), to avoid conflicts with pre-defined names in some C compilers. --- fallback.c | 30 +++++++------- fallback.h | 18 ++++---- func.c | 2 +- hash.c | 14 +++---- hash.h | 12 +++--- opcode.c | 118 ++++++++++++++++++++++++++--------------------------- opcode.h | 14 +++---- table.c | 14 +++---- table.h | 8 ++-- tree.c | 4 +- 10 files changed, 117 insertions(+), 117 deletions(-) diff --git a/fallback.c b/fallback.c index 3e4d6c3b..32ff53d8 100644 --- a/fallback.c +++ b/fallback.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_fallback="$Id: fallback.c,v 1.32 1997/03/21 18:37:28 roberto Exp roberto $"; +char *rcs_fallback="$Id: fallback.c,v 1.33 1997/03/24 17:13:22 roberto Exp roberto $"; #include #include @@ -39,12 +39,12 @@ void luaI_type (void) */ static struct ref { - Object o; + TObject o; enum {LOCK, HOLD, FREE, COLLECTED} status; } *refArray = NULL; static int refSize = 0; -int luaI_ref (Object *object, int lock) +int luaI_ref (TObject *object, int lock) { int i; int oldSize; @@ -73,9 +73,9 @@ void lua_unref (int ref) } -Object *luaI_getref (int ref) +TObject *luaI_getref (int ref) { - static Object nul = {LUA_T_NIL, {0}}; + static TObject nul = {LUA_T_NIL, {0}}; if (ref == -1) return &nul; if (ref >= 0 && ref < refSize && @@ -86,7 +86,7 @@ Object *luaI_getref (int ref) } -void luaI_travlock (int (*fn)(Object *)) +void luaI_travlock (int (*fn)(TObject *)) { int i; for (i=0; i LUA_T_USERDATA) tag = LUA_T_USERDATA; /* default for non-registered tags */ @@ -263,11 +263,11 @@ void luaI_setintmethod (void) luaI_IMtable[-t].int_method[e] = *luaI_Address(func); } -static Object gmethod[GIM_N] = { +static TObject gmethod[GIM_N] = { {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}} }; -Object *luaI_getgim (IMGS event) +TObject *luaI_getgim (IMGS event) { return &gmethod[event]; } @@ -282,7 +282,7 @@ void luaI_setglobalmethod (void) gmethod[e] = *luaI_Address(func); } -char *luaI_travfallbacks (int (*fn)(Object *)) +char *luaI_travfallbacks (int (*fn)(TObject *)) { int e; for (e=GIM_ERROR; e<=GIM_SETGLOBAL; e++) { /* ORDER GIM */ @@ -324,7 +324,7 @@ static void typeFB (void) } -static void fillvalids (IMS e, Object *func) +static void fillvalids (IMS e, TObject *func) { int t; for (t=LUA_T_NIL; t<=LUA_T_USERDATA; t++) @@ -335,7 +335,7 @@ static void fillvalids (IMS e, Object *func) void luaI_setfallback (void) { int e; - Object oldfunc; + TObject oldfunc; lua_CFunction replace; char *name = luaL_check_string(1, "setfallback"); lua_Object func = lua_getparam(2); diff --git a/fallback.h b/fallback.h index 6442680a..323c35db 100644 --- a/fallback.h +++ b/fallback.h @@ -1,5 +1,5 @@ /* -** $Id: fallback.h,v 1.16 1997/03/20 19:20:43 roberto Exp roberto $ +** $Id: fallback.h,v 1.17 1997/03/24 17:13:22 roberto Exp roberto $ */ #ifndef fallback_h @@ -49,19 +49,19 @@ typedef enum { #define GIM_N 3 void luaI_setfallback (void); -int luaI_ref (Object *object, int lock); -Object *luaI_getref (int ref); -void luaI_travlock (int (*fn)(Object *)); +int luaI_ref (TObject *object, int lock); +TObject *luaI_getref (int ref); +void luaI_travlock (int (*fn)(TObject *)); void luaI_invalidaterefs (void); -char *luaI_travfallbacks (int (*fn)(Object *)); +char *luaI_travfallbacks (int (*fn)(TObject *)); void luaI_type (void); -void luaI_settag (int tag, Object *o); +void luaI_settag (int tag, TObject *o); lua_Type luaI_typetag (int tag); -Object *luaI_getim (int tag, IMS event); +TObject *luaI_getim (int tag, IMS event); #define luaI_getimbyObj(o,e) (luaI_getim(luaI_tag(o),(e))) -Object *luaI_getgim (IMGS event); -int luaI_tag (Object *o); +TObject *luaI_getgim (IMGS event); +int luaI_tag (TObject *o); void luaI_setintmethod (void); void luaI_setglobalmethod (void); void luaI_initfallbacks (void); diff --git a/func.c b/func.c index 61cd614a..f6055041 100644 --- a/func.c +++ b/func.c @@ -83,7 +83,7 @@ Long luaI_funccollector (void) void lua_funcinfo (lua_Object func, char **filename, int *linedefined) { - Object *f = luaI_Address(func); + TObject *f = luaI_Address(func); if (f->ttype == LUA_T_MARK || f->ttype == LUA_T_FUNCTION) { *filename = f->value.tf->fileName; diff --git a/hash.c b/hash.c index 8759938c..9e0170c4 100644 --- a/hash.c +++ b/hash.c @@ -3,7 +3,7 @@ ** hash manager for lua */ -char *rcs_hash="$Id: hash.c,v 2.36 1997/03/19 19:41:10 roberto Exp roberto $"; +char *rcs_hash="$Id: hash.c,v 2.37 1997/03/21 18:52:37 roberto Exp roberto $"; #include "mem.h" @@ -48,7 +48,7 @@ int luaI_redimension (int nhash) return 0; /* to avoid warnings */ } -static int hashindex (Hash *t, Object *ref) /* hash function */ +static int hashindex (Hash *t, TObject *ref) /* hash function */ { long int h; switch (ttype(ref)) { @@ -70,7 +70,7 @@ static int hashindex (Hash *t, Object *ref) /* hash function */ return h%nhash(t); /* make it a valid index */ } -int lua_equalObj (Object *t1, Object *t2) +int lua_equalObj (TObject *t1, TObject *t2) { if (ttype(t1) != ttype(t2)) return 0; switch (ttype(t1)) @@ -87,7 +87,7 @@ int lua_equalObj (Object *t1, Object *t2) } } -static int present (Hash *t, Object *ref) +static int present (Hash *t, TObject *ref) { int h = hashindex(t, ref); while (ttype(ref(node(t, h))) != LUA_T_NIL) @@ -162,7 +162,7 @@ void lua_hashmark (Hash *h) void luaI_hashcallIM (void) { Hash *curr_array; - Object t; + TObject t; ttype(&t) = LUA_T_ARRAY; for (curr_array = listhead; curr_array; curr_array = curr_array->next) if (markarray(curr_array) != 1) @@ -242,7 +242,7 @@ static void rehash (Hash *t) ** If the hash node is present, return its pointer, otherwise return ** null. */ -Object *lua_hashget (Hash *t, Object *ref) +TObject *lua_hashget (Hash *t, TObject *ref) { int h = present(t, ref); if (ttype(ref(node(t, h))) != LUA_T_NIL) return val(node(t, h)); @@ -254,7 +254,7 @@ Object *lua_hashget (Hash *t, Object *ref) ** If the hash node is present, return its pointer, otherwise create a new ** node for the given reference and also return its pointer. */ -Object *lua_hashdefine (Hash *t, Object *ref) +TObject *lua_hashdefine (Hash *t, TObject *ref) { int h; Node *n; diff --git a/hash.h b/hash.h index 1497dd0b..a91e1e15 100644 --- a/hash.h +++ b/hash.h @@ -1,7 +1,7 @@ /* ** hash.h ** hash manager for lua -** $Id: hash.h,v 2.13 1997/02/26 17:38:41 roberto Unstable roberto $ +** $Id: hash.h,v 2.14 1997/03/19 19:41:10 roberto Exp roberto $ */ #ifndef hash_h @@ -11,8 +11,8 @@ #include "opcode.h" typedef struct node { - Object ref; - Object val; + TObject ref; + TObject val; } Node; typedef struct Hash { @@ -25,14 +25,14 @@ typedef struct Hash { } Hash; -int lua_equalObj (Object *t1, Object *t2); +int lua_equalObj (TObject *t1, TObject *t2); int luaI_redimension (int nhash); Hash *lua_createarray (int nhash); void lua_hashmark (Hash *h); Long lua_hashcollector (void); void luaI_hashcallIM (void); -Object *lua_hashget (Hash *t, Object *ref); -Object *lua_hashdefine (Hash *t, Object *ref); +TObject *lua_hashget (Hash *t, TObject *ref); +TObject *lua_hashdefine (Hash *t, TObject *ref); void lua_next (void); #endif diff --git a/opcode.c b/opcode.c index 31ecdf85..595277a9 100644 --- a/opcode.c +++ b/opcode.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_opcode="$Id: opcode.c,v 3.85 1997/03/19 19:41:10 roberto Exp roberto $"; +char *rcs_opcode="$Id: opcode.c,v 3.86 1997/03/20 19:20:43 roberto Exp roberto $"; #include #include @@ -32,14 +32,14 @@ char *rcs_opcode="$Id: opcode.c,v 3.85 1997/03/19 19:41:10 roberto Exp roberto $ typedef int StkId; /* index to stack elements */ -static Object initial_stack; +static TObject initial_stack; -static Object *stackLimit = &initial_stack+1; -static Object *stack = &initial_stack; -static Object *top = &initial_stack; +static TObject *stackLimit = &initial_stack+1; +static TObject *stack = &initial_stack; +static TObject *top = &initial_stack; -/* macros to convert from lua_Object to (Object *) and back */ +/* macros to convert from lua_Object to (TObject *) and back */ #define Address(lo) ((lo)+stack-1) #define Ref(st) ((st)-stack+1) @@ -72,7 +72,7 @@ static void do_call (StkId base, int nResults); -Object *luaI_Address (lua_Object o) +TObject *luaI_Address (lua_Object o) { return Address(o); } @@ -84,7 +84,7 @@ Object *luaI_Address (lua_Object o) static void lua_initstack (void) { Long maxstack = STACK_SIZE; - stack = newvector(maxstack, Object); + stack = newvector(maxstack, TObject); stackLimit = stack+maxstack; top = stack; *(top++) = initial_stack; @@ -105,7 +105,7 @@ static void growstack (void) static int limit = STACK_LIMIT; StkId t = top-stack; Long stacksize = stackLimit - stack; - stacksize = growvector(&stack, stacksize, Object, stackEM, limit+100); + stacksize = growvector(&stack, stacksize, TObject, stackEM, limit+100); stackLimit = stack+stacksize; top = stack + t; if (stacksize >= limit) @@ -134,7 +134,7 @@ static char *lua_strconc (char *l, char *r) ** Convert, if possible, to a number object. ** Return 0 if success, not 0 if error. */ -static int lua_tonumber (Object *obj) +static int lua_tonumber (TObject *obj) { float t; char c; @@ -155,7 +155,7 @@ static int lua_tonumber (Object *obj) ** Convert, if possible, to a string ttype ** Return 0 in success or not 0 on error. */ -static int lua_tostring (Object *obj) +static int lua_tostring (TObject *obj) { if (ttype(obj) != LUA_T_NUMBER) return 1; @@ -179,7 +179,7 @@ static int lua_tostring (Object *obj) */ static void adjust_top (StkId newtop) { - Object *nt; + TObject *nt; lua_checkstack(stack+newtop); nt = stack+newtop; /* warning: previous call may change stack */ while (top < nt) ttype(top++) = LUA_T_NIL; @@ -228,7 +228,7 @@ static void callHook (StkId base, lua_Type type, int isreturn) (*lua_callhook)(LUA_NOOBJECT, "(return)", 0); else { - Object *f = stack+base-1; + TObject *f = stack+base-1; if (type == LUA_T_MARK) (*lua_callhook)(Ref(f), f->value.tf->fileName, f->value.tf->lineDefined); else @@ -261,7 +261,7 @@ static StkId callC (lua_CFunction func, StkId base) return firstResult; } -static void callIM (Object *f, int nParams, int nResults) +static void callIM (TObject *f, int nParams, int nResults) { open_stack(nParams); *(top-nParams-1) = *f; @@ -278,7 +278,7 @@ static void callIM (Object *f, int nParams, int nResults) static void do_call (StkId base, int nResults) { StkId firstResult; - Object *func = stack+base-1; + TObject *func = stack+base-1; int i; if (ttype(func) == LUA_T_CFUNCTION) { ttype(func) = LUA_T_CMARK; @@ -290,7 +290,7 @@ static void do_call (StkId base, int nResults) } else { /* func is not a function */ /* Check the fallback for invalid functions */ - Object *im = luaI_getimbyObj(func, IM_FUNCTION); + TObject *im = luaI_getimbyObj(func, IM_FUNCTION); if (ttype(im) == LUA_T_NIL) lua_error("call expression not a function"); open_stack((top-stack)-(base-1)); @@ -317,9 +317,9 @@ static void do_call (StkId base, int nResults) static void pushsubscript (void) { int tg = luaI_tag(top-2); - Object *im = luaI_getim(tg, IM_GETTABLE); + TObject *im = luaI_getim(tg, IM_GETTABLE); if (ttype(top-2) == LUA_T_ARRAY && ttype(im) == LUA_T_NIL) { - Object *h = lua_hashget(avalue(top-2), top-1); + TObject *h = lua_hashget(avalue(top-2), top-1); if (h != NULL && ttype(h) != LUA_T_NIL) { --top; *(top-1) = *h; @@ -346,7 +346,7 @@ lua_Object lua_basicindex (void) if (ttype(top-2) != LUA_T_ARRAY) lua_error("indexed expression not a table in basic indexing"); else { - Object *h = lua_hashget(avalue(top-2), top-1); + TObject *h = lua_hashget(avalue(top-2), top-1); --top; if (h != NULL) *(top-1) = *h; @@ -364,11 +364,11 @@ lua_Object lua_basicindex (void) ** mode = 1: normal store (with internal methods) ** mode = 2: "deep stack" store (with internal methods) */ -static void storesubscript (Object *t, int mode) +static void storesubscript (TObject *t, int mode) { - Object *im = (mode == 0) ? NULL : luaI_getimbyObj(t, IM_SETTABLE); + TObject *im = (mode == 0) ? NULL : luaI_getimbyObj(t, IM_SETTABLE); if (ttype(t) == LUA_T_ARRAY && (im == NULL || ttype(im) == LUA_T_NIL)) { - Object *h = lua_hashdefine(avalue(t), t+1); + TObject *h = lua_hashdefine(avalue(t), t+1); *h = *(top-1); top -= (mode == 2) ? 1 : 3; } @@ -394,7 +394,7 @@ static void getglobal (Word n) *top = lua_table[n].object; incr_top; if (ttype(top-1) == LUA_T_NIL) { /* check i.m. */ - Object *im = luaI_getgim(GIM_GETGLOBAL); + TObject *im = luaI_getgim(GIM_GETGLOBAL); if (ttype(im) != LUA_T_NIL) { ttype(top-1) = LUA_T_STRING; tsvalue(top-1) = lua_table[n].varname; @@ -406,9 +406,9 @@ static void getglobal (Word n) /* ** Traverse all objects on stack */ -void lua_travstack (int (*fn)(Object *)) +void lua_travstack (int (*fn)(TObject *)) { - Object *o; + TObject *o; for (o = top-1; o >= stack; o--) fn (o); } @@ -420,7 +420,7 @@ void lua_travstack (int (*fn)(Object *)) static void lua_message (char *s) { - Object *im = luaI_getgim(GIM_ERROR); + TObject *im = luaI_getgim(GIM_ERROR); if (ttype(im) == LUA_T_NIL) fprintf(stderr, "lua: %s\n", s); else { @@ -458,14 +458,14 @@ lua_Function lua_stackedfunction (int level) int lua_currentline (lua_Function func) { - Object *f = Address(func); + TObject *f = Address(func); return (f+1 < top && (f+1)->ttype == LUA_T_LINE) ? (f+1)->value.i : -1; } lua_Object lua_getlocal (lua_Function func, int local_number, char **name) { - Object *f = luaI_Address(func); + TObject *f = luaI_Address(func); *name = luaI_getlocalname(f->value.tf, local_number, lua_currentline(func)); if (*name) { @@ -479,7 +479,7 @@ lua_Object lua_getlocal (lua_Function func, int local_number, char **name) int lua_setlocal (lua_Function func, int local_number) { - Object *f = Address(func); + TObject *f = Address(func); char *name = luaI_getlocalname(f->value.tf, local_number, lua_currentline(func)); adjustC(1); --top; @@ -843,7 +843,7 @@ lua_CFunction lua_getcfunction (lua_Object object) lua_Object lua_getref (int ref) { - Object *o = luaI_getref(ref); + TObject *o = luaI_getref(ref); if (o == NULL) return LUA_NOOBJECT; adjustC(0); @@ -855,7 +855,7 @@ lua_Object lua_getref (int ref) void lua_pushref (int ref) { - Object *o = luaI_getref(ref); + TObject *o = luaI_getref(ref); if (o == NULL) lua_error("access to invalid (possibly garbage collected) reference"); luaI_pushobject(o); @@ -970,7 +970,7 @@ void lua_pushusertag (void *u, int tag) /* ** Push an object on the stack. */ -void luaI_pushobject (Object *o) +void luaI_pushobject (TObject *o) { *top = *o; incr_top; @@ -995,9 +995,9 @@ int lua_tag (lua_Object o) } -void luaI_gcIM (Object *o) +void luaI_gcIM (TObject *o) { - Object *im = luaI_getimbyObj(o, IM_GC); + TObject *im = luaI_getimbyObj(o, IM_GC); if (ttype(im) != LUA_T_NIL) { *top = *o; incr_top; @@ -1008,7 +1008,7 @@ void luaI_gcIM (Object *o) static void call_arith (IMS event) { - Object *im = luaI_getimbyObj(top-2, event); /* try first operand */ + TObject *im = luaI_getimbyObj(top-2, event); /* try first operand */ if (ttype(im) == LUA_T_NIL) { im = luaI_getimbyObj(top-1, event); /* try second operand */ if (ttype(im) == LUA_T_NIL) { @@ -1021,17 +1021,17 @@ static void call_arith (IMS event) callIM(im, 3, 1); } -static void concim (Object *o) +static void concim (TObject *o) { - Object *im = luaI_getimbyObj(o, IM_CONCAT); + TObject *im = luaI_getimbyObj(o, IM_CONCAT); if (ttype(im) == LUA_T_NIL) lua_error("unexpected type at conversion to string"); callIM(im, 2, 1); } -static void ordim (Object *o, IMS event) +static void ordim (TObject *o, IMS event) { - Object *im = luaI_getimbyObj(o, event); + TObject *im = luaI_getimbyObj(o, event); if (ttype(im) == LUA_T_NIL) lua_error("unexpected type at comparison"); lua_pushstring(luaI_eventname[event]); @@ -1041,8 +1041,8 @@ static void ordim (Object *o, IMS event) static void comparison (lua_Type ttype_less, lua_Type ttype_equal, lua_Type ttype_great, IMS op) { - Object *l = top-2; - Object *r = top-1; + TObject *l = top-2; + TObject *r = top-1; int result; if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER) result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1; @@ -1065,21 +1065,21 @@ static void comparison (lua_Type ttype_less, lua_Type ttype_equal, static void adjust_varargs (StkId first_extra_arg) { - Object arg; - Object *firstelem = stack+first_extra_arg; + TObject arg; + TObject *firstelem = stack+first_extra_arg; int nvararg = top-firstelem; int i; if (nvararg < 0) nvararg = 0; avalue(&arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */ ttype(&arg) = LUA_T_ARRAY; for (i=0; imarked)) @@ -142,7 +142,7 @@ int lua_markobject (Object *o) /* * returns 0 if the object is going to be (garbage) collected */ -int luaI_ismarked (Object *o) +int luaI_ismarked (TObject *o) { switch (o->ttype) { @@ -160,7 +160,7 @@ int luaI_ismarked (Object *o) static void call_nilIM (void) { /* signals end of garbage collection */ - Object t; + TObject t; ttype(&t) = LUA_T_NIL; luaI_gcIM(&t); /* end of list */ } @@ -227,8 +227,8 @@ void luaI_nextvar (void) } -static Object *functofind; -static int checkfunc (Object *o) +static TObject *functofind; +static int checkfunc (TObject *o) { if (o->ttype == LUA_T_FUNCTION) return diff --git a/table.h b/table.h index 42d44c07..d03a5607 100644 --- a/table.h +++ b/table.h @@ -1,7 +1,7 @@ /* ** Module to control static tables ** TeCGraf - PUC-Rio -** $Id: table.h,v 2.21 1996/04/22 18:00:37 roberto Exp roberto $ +** $Id: table.h,v 2.22 1997/02/26 17:38:41 roberto Unstable roberto $ */ #ifndef table_h @@ -12,7 +12,7 @@ typedef struct { - Object object; + TObject object; TaggedString *varname; } Symbol; @@ -30,8 +30,8 @@ Word luaI_findconstant (TaggedString *t); Word luaI_findconstantbyname (char *name); void luaI_nextvar (void); TaggedString *luaI_createfixedstring (char *str); -int lua_markobject (Object *o); -int luaI_ismarked (Object *o); +int lua_markobject (TObject *o); +int luaI_ismarked (TObject *o); Long luaI_collectgarbage (void); void lua_pack (void); diff --git a/tree.c b/tree.c index 1afded62..c993e199 100644 --- a/tree.c +++ b/tree.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_tree="$Id: tree.c,v 1.21 1997/02/11 11:35:05 roberto Exp roberto $"; +char *rcs_tree="$Id: tree.c,v 1.22 1997/03/19 19:41:10 roberto Exp roberto $"; #include @@ -125,7 +125,7 @@ TaggedString *lua_createstring (char *str) void luaI_strcallIM (void) { int i; - Object o; + TObject o; ttype(&o) = LUA_T_USERDATA; for (i=0; i