diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-03 11:27:44 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-03 11:27:44 -0300 |
| commit | d68209e822c21d3678cc53f1e02ba1c9dd26e23e (patch) | |
| tree | 76feb02bb882d8b40fd3b969017b811e39389dff | |
| parent | 1088cde03c5551bab90e211e979b11278d666cd5 (diff) | |
| download | lua-d68209e822c21d3678cc53f1e02ba1c9dd26e23e.tar.gz lua-d68209e822c21d3678cc53f1e02ba1c9dd26e23e.tar.bz2 lua-d68209e822c21d3678cc53f1e02ba1c9dd26e23e.zip | |
details.
| -rw-r--r-- | lapi.c | 12 | ||||
| -rw-r--r-- | ltm.c | 15 | ||||
| -rw-r--r-- | ltm.h | 6 | ||||
| -rw-r--r-- | lvm.c | 4 |
4 files changed, 23 insertions, 14 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.102 2000/10/02 14:47:43 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.103 2000/10/02 20:10:55 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -141,10 +141,14 @@ int lua_isstring (lua_State *L, int index) { | |||
| 141 | return (t == LUA_TSTRING || t == LUA_TNUMBER); | 141 | return (t == LUA_TSTRING || t == LUA_TNUMBER); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | |||
| 145 | static int auxtag (const TObject *o) { | ||
| 146 | return ((ttype(o) == TAG_USERDATA) ? tsvalue(o)->u.d.tag : | ||
| 147 | (ttype(o) == TAG_TABLE) ? hvalue(o)->htag : (int)ttype(o)); | ||
| 148 | } | ||
| 149 | |||
| 144 | int lua_tag (lua_State *L, int index) { | 150 | int lua_tag (lua_State *L, int index) { |
| 145 | btest(L, index, | 151 | btest(L, index, auxtag(o), LUA_NOTAG); |
| 146 | ((ttype(o) == TAG_USERDATA) ? tsvalue(o)->u.d.tag : | ||
| 147 | luaT_effectivetag(L, o)), LUA_NOTAG); | ||
| 148 | } | 152 | } |
| 149 | 153 | ||
| 150 | int lua_equal (lua_State *L, int index1, int index2) { | 154 | int lua_equal (lua_State *L, int index1, int index2) { |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.c,v 1.50 2000/09/29 12:42:13 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.51 2000/10/02 20:10:55 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -117,15 +117,20 @@ int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) { | |||
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | 119 | ||
| 120 | int luaT_effectivetag (lua_State *L, const TObject *o) { | 120 | const TObject *luaT_gettagmethods (lua_State *L, const TObject *o) { |
| 121 | lua_Tag t = ttype(o); | 121 | lua_Tag t = ttype(o); |
| 122 | switch (t) { | 122 | switch (t) { |
| 123 | case TAG_USERDATA: { | 123 | case TAG_USERDATA: { |
| 124 | int tag = tsvalue(o)->u.d.tag; | 124 | int tag = tsvalue(o)->u.d.tag; |
| 125 | return (tag > L->last_tag) ? TAG_USERDATA : tag; /* deprecated test */ | 125 | if (tag > L->last_tag) |
| 126 | return L->IMtable[TAG_USERDATA].int_method; | ||
| 127 | else | ||
| 128 | return L->IMtable[tag].int_method; | ||
| 126 | } | 129 | } |
| 127 | case TAG_TABLE: return hvalue(o)->htag; | 130 | case TAG_TABLE: |
| 128 | default: return t; | 131 | return L->IMtable[hvalue(o)->htag].int_method; |
| 132 | default: | ||
| 133 | return L->IMtable[(int)t].int_method;; | ||
| 129 | } | 134 | } |
| 130 | } | 135 | } |
| 131 | 136 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.h,v 1.14 2000/08/07 20:21:34 roberto Exp roberto $ | 2 | ** $Id: ltm.h,v 1.15 2000/09/05 19:33:32 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -42,14 +42,14 @@ struct IM { | |||
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | #define luaT_getim(L,tag,event) (&L->IMtable[tag].int_method[event]) | 44 | #define luaT_getim(L,tag,event) (&L->IMtable[tag].int_method[event]) |
| 45 | #define luaT_getimbyObj(L,o,e) (luaT_getim(L, luaT_effectivetag(L, o),(e))) | 45 | #define luaT_getimbyObj(L,o,e) (&luaT_gettagmethods((L),(o))[e]) |
| 46 | 46 | ||
| 47 | extern const char *const luaT_eventname[]; | 47 | extern const char *const luaT_eventname[]; |
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | void luaT_init (lua_State *L); | 50 | void luaT_init (lua_State *L); |
| 51 | void luaT_realtag (lua_State *L, int tag); | 51 | void luaT_realtag (lua_State *L, int tag); |
| 52 | int luaT_effectivetag (lua_State *L, const TObject *o); | 52 | const TObject *luaT_gettagmethods (lua_State *L, const TObject *o); |
| 53 | int luaT_validevent (int t, int e); /* used by compatibility module */ | 53 | int luaT_validevent (int t, int e); /* used by compatibility module */ |
| 54 | 54 | ||
| 55 | 55 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.139 2000/10/02 20:10:55 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.140 2000/10/03 14:03:21 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -174,7 +174,7 @@ void luaV_settable (lua_State *L, StkId t, StkId key) { | |||
| 174 | 174 | ||
| 175 | const TObject *luaV_getglobal (lua_State *L, TString *s) { | 175 | const TObject *luaV_getglobal (lua_State *L, TString *s) { |
| 176 | const TObject *value = luaH_getstr(L->gt, s); | 176 | const TObject *value = luaH_getstr(L->gt, s); |
| 177 | TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL); | 177 | const TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL); |
| 178 | if (ttype(im) == TAG_NIL) /* is there a tag method? */ | 178 | if (ttype(im) == TAG_NIL) /* is there a tag method? */ |
| 179 | return value; /* default behavior */ | 179 | return value; /* default behavior */ |
| 180 | else { /* tag method */ | 180 | else { /* tag method */ |
