diff options
Diffstat (limited to 'fallback.c')
-rw-r--r-- | fallback.c | 33 |
1 files changed, 18 insertions, 15 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_fallback="$Id: fallback.c,v 1.38 1997/04/02 23:04:12 roberto Exp roberto $"; | 6 | char *rcs_fallback="$Id: fallback.c,v 2.1 1997/04/03 18:24:23 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
@@ -115,7 +115,7 @@ static int luaI_checkevent (char *name, char *list[]) | |||
115 | { | 115 | { |
116 | int e = findstring(name, list); | 116 | int e = findstring(name, list); |
117 | if (e < 0) | 117 | if (e < 0) |
118 | luaL_verror("invalid event name `%s'", name); | 118 | luaL_verror("`%s' is not a valid event name", name); |
119 | return e; | 119 | return e; |
120 | } | 120 | } |
121 | 121 | ||
@@ -180,17 +180,19 @@ int lua_newtag (void) | |||
180 | static void checktag (int tag) | 180 | static void checktag (int tag) |
181 | { | 181 | { |
182 | if (!(last_tag <= tag && tag <= 0)) | 182 | if (!(last_tag <= tag && tag <= 0)) |
183 | lua_error("invalid tag"); | 183 | luaL_verror("%d is not a valid tag", tag); |
184 | } | 184 | } |
185 | 185 | ||
186 | int luaI_userdatatag (int tag) | 186 | void luaI_realtag (int tag) |
187 | { | 187 | { |
188 | return (tag >= 0 || (last_tag <= tag && tag < LUA_T_NIL)); | 188 | if (!(last_tag <= tag && tag < LUA_T_NIL)) |
189 | luaL_verror("tag %d is not result of `newtag'", tag); | ||
189 | } | 190 | } |
190 | 191 | ||
191 | 192 | ||
192 | void luaI_settag (int tag, TObject *o) | 193 | void luaI_settag (int tag, TObject *o) |
193 | { | 194 | { |
195 | luaI_realtag(tag); | ||
194 | switch (ttype(o)) { | 196 | switch (ttype(o)) { |
195 | case LUA_T_ARRAY: | 197 | case LUA_T_ARRAY: |
196 | o->value.a->htag = tag; | 198 | o->value.a->htag = tag; |
@@ -199,7 +201,7 @@ void luaI_settag (int tag, TObject *o) | |||
199 | o->value.ts->tag = tag; | 201 | o->value.ts->tag = tag; |
200 | break; | 202 | break; |
201 | default: | 203 | default: |
202 | lua_error("settag: cannot change tag of given object"); | 204 | luaL_verror("cannot change tag of a %s", luaI_typenames[-ttype(o)]); |
203 | } | 205 | } |
204 | } | 206 | } |
205 | 207 | ||
@@ -223,25 +225,26 @@ TObject *luaI_getim (int tag, IMS event) | |||
223 | } | 225 | } |
224 | 226 | ||
225 | 227 | ||
226 | void luaI_getintmethod (void) | 228 | void luaI_gettagmethod (void) |
227 | { | 229 | { |
228 | int t = (int)luaL_check_number(1, "getintmethod"); | 230 | int t = (int)luaL_check_number(1, "gettagmethod"); |
229 | int e = luaI_checkevent(luaL_check_string(2, "getintmethod"), luaI_eventname); | 231 | int e = luaI_checkevent(luaL_check_string(2, "gettagmethod"), luaI_eventname); |
230 | checktag(t); | 232 | checktag(t); |
231 | if (validevent(t, e)) | 233 | if (validevent(t, e)) |
232 | luaI_pushobject(&luaI_IMtable[-t].int_method[e]); | 234 | luaI_pushobject(&luaI_IMtable[-t].int_method[e]); |
233 | } | 235 | } |
234 | 236 | ||
235 | 237 | ||
236 | void luaI_setintmethod (void) | 238 | void luaI_settagmethod (void) |
237 | { | 239 | { |
238 | int t = (int)luaL_check_number(1, "setintmethod"); | 240 | int t = (int)luaL_check_number(1, "settagmethod"); |
239 | int e = luaI_checkevent(luaL_check_string(2, "setintmethod"), luaI_eventname); | 241 | int e = luaI_checkevent(luaL_check_string(2, "settagmethod"), luaI_eventname); |
240 | lua_Object func = lua_getparam(3); | 242 | lua_Object func = lua_getparam(3); |
241 | checktag(t); | 243 | checktag(t); |
242 | if (!validevent(t, e)) | 244 | if (!validevent(t, e)) |
243 | lua_error("cannot change this internal method"); | 245 | luaL_verror("cannot change internal method `%s' for tag %d", |
244 | luaL_arg_check(lua_isnil(func) || lua_isfunction(func), "setintmethod", | 246 | luaI_eventname[e], t); |
247 | luaL_arg_check(lua_isnil(func) || lua_isfunction(func), "settagmethod", | ||
245 | 3, "function expected"); | 248 | 3, "function expected"); |
246 | luaI_pushobject(&luaI_IMtable[-t].int_method[e]); | 249 | luaI_pushobject(&luaI_IMtable[-t].int_method[e]); |
247 | luaI_IMtable[-t].int_method[e] = *luaI_Address(func); | 250 | luaI_IMtable[-t].int_method[e] = *luaI_Address(func); |
@@ -352,7 +355,7 @@ void luaI_setfallback (void) | |||
352 | replace = typeFB; | 355 | replace = typeFB; |
353 | } | 356 | } |
354 | else { | 357 | else { |
355 | lua_error("invalid fallback name"); | 358 | luaL_verror("`%s' is not a valid fallback name", name); |
356 | replace = NULL; /* to avoid warnings */ | 359 | replace = NULL; /* to avoid warnings */ |
357 | } | 360 | } |
358 | if (oldfunc.ttype != LUA_T_NIL) | 361 | if (oldfunc.ttype != LUA_T_NIL) |