diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-27 17:08:02 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-27 17:08:02 -0300 |
commit | 102a1be6159b34190813bfd7a7ed6c04633c6200 (patch) | |
tree | b03054b4832fefea3c9f114d3b367f2fa0dbac88 /ltm.c | |
parent | 4c031966976a0ae5d24b709fe94e90dc3fbac9ef (diff) | |
download | lua-102a1be6159b34190813bfd7a7ed6c04633c6200.tar.gz lua-102a1be6159b34190813bfd7a7ed6c04633c6200.tar.bz2 lua-102a1be6159b34190813bfd7a7ed6c04633c6200.zip |
no more support for gc TM for tables
Diffstat (limited to 'ltm.c')
-rw-r--r-- | ltm.c | 28 |
1 files changed, 13 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.34 2000/03/10 18:37:44 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.35 2000/03/20 19:14:54 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 | */ |
@@ -25,10 +25,12 @@ const char *const luaT_eventname[] = { /* ORDER IM */ | |||
25 | }; | 25 | }; |
26 | 26 | ||
27 | 27 | ||
28 | static int luaI_checkevent (lua_State *L, const char *name) { | 28 | static int luaI_checkevent (lua_State *L, const char *name, int t) { |
29 | int e = luaL_findstring(name, luaT_eventname); | 29 | int e = luaL_findstring(name, luaT_eventname); |
30 | if (e >= IM_N) | 30 | if (e >= IM_N) |
31 | luaL_verror(L, "event `%.50s' is deprecated", name); | 31 | luaL_verror(L, "event `%.50s' is deprecated", name); |
32 | if (e == IM_GC && t == TAG_ARRAY) | ||
33 | luaL_verror(L, "event `gc' for tables is deprecated"); | ||
32 | if (e < 0) | 34 | if (e < 0) |
33 | luaL_verror(L, "`%.50s' is not a valid event name", name); | 35 | luaL_verror(L, "`%.50s' is not a valid event name", name); |
34 | return e; | 36 | return e; |
@@ -41,20 +43,16 @@ static int luaI_checkevent (lua_State *L, const char *name) { | |||
41 | */ | 43 | */ |
42 | /* ORDER LUA_T, ORDER IM */ | 44 | /* ORDER LUA_T, ORDER IM */ |
43 | static const char luaT_validevents[NUM_TAGS][IM_N] = { | 45 | static const char luaT_validevents[NUM_TAGS][IM_N] = { |
44 | {1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* TAG_USERDATA */ | 46 | {1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* TAG_USERDATA */ |
45 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, /* TAG_NUMBER */ | 47 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, /* TAG_NUMBER */ |
46 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* TAG_STRING */ | 48 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* TAG_STRING */ |
47 | {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* TAG_ARRAY */ | 49 | {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* TAG_ARRAY */ |
48 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* TAG_LPROTO */ | 50 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* TAG_LPROTO */ |
49 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* TAG_CPROTO */ | 51 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* TAG_CPROTO */ |
50 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* TAG_NIL */ | 52 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* TAG_NIL */ |
51 | }; | 53 | }; |
52 | 54 | ||
53 | static int luaT_validevent (int t, int e) { /* ORDER LUA_T */ | 55 | static int luaT_validevent (int t, int e) { /* ORDER LUA_T */ |
54 | #ifdef LUA_COMPAT_GC | ||
55 | if (t == TAG_ARRAY && e == IM_GC) | ||
56 | return 1; /* old versions allowed gc tag method for tables */ | ||
57 | #endif | ||
58 | return (t > TAG_NIL) ? 1 : luaT_validevents[t][e]; | 56 | return (t > TAG_NIL) ? 1 : luaT_validevents[t][e]; |
59 | } | 57 | } |
60 | 58 | ||
@@ -126,7 +124,7 @@ int luaT_effectivetag (lua_State *L, const TObject *o) { | |||
126 | 124 | ||
127 | const TObject *luaT_gettagmethod (lua_State *L, int t, const char *event) { | 125 | const TObject *luaT_gettagmethod (lua_State *L, int t, const char *event) { |
128 | int e; | 126 | int e; |
129 | e = luaI_checkevent(L, event); | 127 | e = luaI_checkevent(L, event, t); |
130 | checktag(L, t); | 128 | checktag(L, t); |
131 | if (luaT_validevent(t, e)) | 129 | if (luaT_validevent(t, e)) |
132 | return luaT_getim(L, t,e); | 130 | return luaT_getim(L, t,e); |
@@ -138,7 +136,7 @@ const TObject *luaT_gettagmethod (lua_State *L, int t, const char *event) { | |||
138 | void luaT_settagmethod (lua_State *L, int t, const char *event, TObject *func) { | 136 | void luaT_settagmethod (lua_State *L, int t, const char *event, TObject *func) { |
139 | TObject temp; | 137 | TObject temp; |
140 | int e; | 138 | int e; |
141 | e = luaI_checkevent(L, event); | 139 | e = luaI_checkevent(L, event, t); |
142 | checktag(L, t); | 140 | checktag(L, t); |
143 | if (!luaT_validevent(t, e)) | 141 | if (!luaT_validevent(t, e)) |
144 | luaL_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", | 142 | luaL_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", |