diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-05 16:33:32 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-05 16:33:32 -0300 |
commit | 6e80c1cde193b767d63d2cc30ebd71d65512e061 (patch) | |
tree | cb599bdc956c0dc9b3d469bb01de47185db3e4e2 /ltm.c | |
parent | f67f324377aff66d78479eaaffbb94a6b092ae45 (diff) | |
download | lua-6e80c1cde193b767d63d2cc30ebd71d65512e061.tar.gz lua-6e80c1cde193b767d63d2cc30ebd71d65512e061.tar.bz2 lua-6e80c1cde193b767d63d2cc30ebd71d65512e061.zip |
new version for API
Diffstat (limited to 'ltm.c')
-rw-r--r-- | ltm.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.45 2000/08/07 20:21:34 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.46 2000/08/09 19:16:57 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 | */ |
@@ -119,20 +119,23 @@ int luaT_effectivetag (lua_State *L, const TObject *o) { | |||
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | const TObject *luaT_gettagmethod (lua_State *L, int t, const char *event) { | 122 | void lua_gettagmethod (lua_State *L, int t, const char *event) { |
123 | int e; | 123 | int e; |
124 | e = luaI_checkevent(L, event, t); | 124 | e = luaI_checkevent(L, event, t); |
125 | checktag(L, t); | 125 | checktag(L, t); |
126 | if (luaT_validevent(t, e)) | 126 | if (luaT_validevent(t, e)) |
127 | return luaT_getim(L, t,e); | 127 | *L->top = *luaT_getim(L, t,e); |
128 | else | 128 | else |
129 | return &luaO_nilobject; | 129 | ttype(L->top) = TAG_NIL; |
130 | L->top++; | ||
130 | } | 131 | } |
131 | 132 | ||
132 | 133 | ||
133 | void luaT_settagmethod (lua_State *L, int t, const char *event, TObject *func) { | 134 | void lua_settagmethod (lua_State *L, int t, const char *event) { |
134 | TObject temp; | 135 | TObject temp; |
135 | int e; | 136 | int e; |
137 | LUA_ASSERT(lua_isnil(L, -1) || lua_isfunction(L, -1), | ||
138 | "function or nil expected"); | ||
136 | e = luaI_checkevent(L, event, t); | 139 | e = luaI_checkevent(L, event, t); |
137 | checktag(L, t); | 140 | checktag(L, t); |
138 | if (!luaT_validevent(t, e)) | 141 | if (!luaT_validevent(t, e)) |
@@ -140,8 +143,8 @@ void luaT_settagmethod (lua_State *L, int t, const char *event, TObject *func) { | |||
140 | luaT_eventname[e], luaO_typenames[t], | 143 | luaT_eventname[e], luaO_typenames[t], |
141 | (t == TAG_TABLE || t == TAG_USERDATA) ? " with default tag" | 144 | (t == TAG_TABLE || t == TAG_USERDATA) ? " with default tag" |
142 | : ""); | 145 | : ""); |
143 | temp = *func; | 146 | temp = *(L->top - 1); |
144 | *func = *luaT_getim(L, t,e); | 147 | *(L->top - 1) = *luaT_getim(L, t,e); |
145 | *luaT_getim(L, t, e) = temp; | 148 | *luaT_getim(L, t, e) = temp; |
146 | } | 149 | } |
147 | 150 | ||