commit d68209e822c21d3678cc53f1e02ba1c9dd26e23e
parent 1088cde03c5551bab90e211e979b11278d666cd5
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 3 Oct 2000 11:27:22 -0300
details.
Diffstat:
4 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/lapi.c b/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 1.102 2000/10/02 14:47:43 roberto Exp roberto $
+** $Id: lapi.c,v 1.103 2000/10/02 20:10:55 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -141,10 +141,14 @@ int lua_isstring (lua_State *L, int index) {
return (t == LUA_TSTRING || t == LUA_TNUMBER);
}
+
+static int auxtag (const TObject *o) {
+return ((ttype(o) == TAG_USERDATA) ? tsvalue(o)->u.d.tag :
+ (ttype(o) == TAG_TABLE) ? hvalue(o)->htag : (int)ttype(o));
+}
+
int lua_tag (lua_State *L, int index) {
- btest(L, index,
- ((ttype(o) == TAG_USERDATA) ? tsvalue(o)->u.d.tag :
- luaT_effectivetag(L, o)), LUA_NOTAG);
+ btest(L, index, auxtag(o), LUA_NOTAG);
}
int lua_equal (lua_State *L, int index1, int index2) {
diff --git a/ltm.c b/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 1.50 2000/09/29 12:42:13 roberto Exp roberto $
+** $Id: ltm.c,v 1.51 2000/10/02 20:10:55 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -117,15 +117,20 @@ int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) {
}
-int luaT_effectivetag (lua_State *L, const TObject *o) {
+const TObject *luaT_gettagmethods (lua_State *L, const TObject *o) {
lua_Tag t = ttype(o);
switch (t) {
case TAG_USERDATA: {
int tag = tsvalue(o)->u.d.tag;
- return (tag > L->last_tag) ? TAG_USERDATA : tag; /* deprecated test */
+ if (tag > L->last_tag)
+ return L->IMtable[TAG_USERDATA].int_method;
+ else
+ return L->IMtable[tag].int_method;
}
- case TAG_TABLE: return hvalue(o)->htag;
- default: return t;
+ case TAG_TABLE:
+ return L->IMtable[hvalue(o)->htag].int_method;
+ default:
+ return L->IMtable[(int)t].int_method;;
}
}
diff --git a/ltm.h b/ltm.h
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.h,v 1.14 2000/08/07 20:21:34 roberto Exp roberto $
+** $Id: ltm.h,v 1.15 2000/09/05 19:33:32 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -42,14 +42,14 @@ struct IM {
#define luaT_getim(L,tag,event) (&L->IMtable[tag].int_method[event])
-#define luaT_getimbyObj(L,o,e) (luaT_getim(L, luaT_effectivetag(L, o),(e)))
+#define luaT_getimbyObj(L,o,e) (&luaT_gettagmethods((L),(o))[e])
extern const char *const luaT_eventname[];
void luaT_init (lua_State *L);
void luaT_realtag (lua_State *L, int tag);
-int luaT_effectivetag (lua_State *L, const TObject *o);
+const TObject *luaT_gettagmethods (lua_State *L, const TObject *o);
int luaT_validevent (int t, int e); /* used by compatibility module */
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 1.139 2000/10/02 20:10:55 roberto Exp roberto $
+** $Id: lvm.c,v 1.140 2000/10/03 14:03:21 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -174,7 +174,7 @@ void luaV_settable (lua_State *L, StkId t, StkId key) {
const TObject *luaV_getglobal (lua_State *L, TString *s) {
const TObject *value = luaH_getstr(L->gt, s);
- TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL);
+ const TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL);
if (ttype(im) == TAG_NIL) /* is there a tag method? */
return value; /* default behavior */
else { /* tag method */