diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-04-02 20:04:12 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-04-02 20:04:12 -0300 |
commit | 075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2 (patch) | |
tree | ae1dd456984f4e7128b2d4a2e2e43e4f23b99d01 | |
parent | 7c99149a76ce0c7469c9bafec5dfff529f88512c (diff) | |
download | lua-075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2.tar.gz lua-075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2.tar.bz2 lua-075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2.zip |
new function "getintmethod"
-rw-r--r-- | fallback.c | 13 | ||||
-rw-r--r-- | fallback.h | 3 | ||||
-rw-r--r-- | inout.c | 3 | ||||
-rw-r--r-- | iolib.c | 9 | ||||
-rw-r--r-- | lua.h | 3 | ||||
-rw-r--r-- | opcode.c | 9 |
6 files changed, 30 insertions, 10 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.36 1997/03/31 20:59:09 roberto Exp roberto $"; | 6 | char *rcs_fallback="$Id: fallback.c,v 1.37 1997/04/02 22:52:42 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
@@ -223,6 +223,16 @@ TObject *luaI_getim (int tag, IMS event) | |||
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | void luaI_getintmethod (void) | ||
227 | { | ||
228 | int t = (int)luaL_check_number(1, "getintmethod"); | ||
229 | int e = luaI_checkevent(luaL_check_string(2, "getintmethod"), luaI_eventname); | ||
230 | checktag(t); | ||
231 | if (validevent(t, e)) | ||
232 | luaI_pushobject(&luaI_IMtable[-t].int_method[e]); | ||
233 | } | ||
234 | |||
235 | |||
226 | void luaI_setintmethod (void) | 236 | void luaI_setintmethod (void) |
227 | { | 237 | { |
228 | int t = (int)luaL_check_number(1, "setintmethod"); | 238 | int t = (int)luaL_check_number(1, "setintmethod"); |
@@ -233,7 +243,6 @@ void luaI_setintmethod (void) | |||
233 | lua_error("cannot change this internal method"); | 243 | lua_error("cannot change this internal method"); |
234 | luaL_arg_check(lua_isnil(func) || lua_isfunction(func), "setintmethod", | 244 | luaL_arg_check(lua_isnil(func) || lua_isfunction(func), "setintmethod", |
235 | 3, "function expected"); | 245 | 3, "function expected"); |
236 | luaI_pushobject(&luaI_IMtable[-t].int_method[e]); | ||
237 | luaI_IMtable[-t].int_method[e] = *luaI_Address(func); | 246 | luaI_IMtable[-t].int_method[e] = *luaI_Address(func); |
238 | } | 247 | } |
239 | 248 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: fallback.h,v 1.19 1997/03/31 20:59:09 roberto Exp roberto $ | 2 | ** $Id: fallback.h,v 1.20 1997/04/02 22:52:42 roberto Exp roberto $ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef fallback_h | 5 | #ifndef fallback_h |
@@ -52,6 +52,7 @@ TObject *luaI_getim (int tag, IMS event); | |||
52 | TObject *luaI_geterrorim (void); | 52 | TObject *luaI_geterrorim (void); |
53 | int luaI_tag (TObject *o); | 53 | int luaI_tag (TObject *o); |
54 | void luaI_setintmethod (void); | 54 | void luaI_setintmethod (void); |
55 | void luaI_getintmethod (void); | ||
55 | void luaI_seterrormethod (void); | 56 | void luaI_seterrormethod (void); |
56 | void luaI_initfallbacks (void); | 57 | void luaI_initfallbacks (void); |
57 | 58 | ||
@@ -5,7 +5,7 @@ | |||
5 | ** Also provides some predefined lua functions. | 5 | ** Also provides some predefined lua functions. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | char *rcs_inout="$Id: inout.c,v 2.52 1997/04/01 19:02:43 roberto Exp roberto $"; | 8 | char *rcs_inout="$Id: inout.c,v 2.53 1997/04/02 22:53:35 roberto Exp roberto $"; |
9 | 9 | ||
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include <string.h> | 11 | #include <string.h> |
@@ -342,6 +342,7 @@ static struct { | |||
342 | {"setfallback", luaI_setfallback}, | 342 | {"setfallback", luaI_setfallback}, |
343 | {"setglobal", luaI_setglobal}, | 343 | {"setglobal", luaI_setglobal}, |
344 | {"setintmethod", luaI_setintmethod}, | 344 | {"setintmethod", luaI_setintmethod}, |
345 | {"getintmethod", luaI_getintmethod}, | ||
345 | {"settag", luaIl_settag}, | 346 | {"settag", luaIl_settag}, |
346 | {"tonumber", lua_obj2number}, | 347 | {"tonumber", lua_obj2number}, |
347 | {"tostring", luaI_tostring}, | 348 | {"tostring", luaI_tostring}, |
@@ -288,9 +288,10 @@ static void getbyte (void) | |||
288 | lua_pushnumber(lua_getbindatasize(ud)); | 288 | lua_pushnumber(lua_getbindatasize(ud)); |
289 | else { | 289 | else { |
290 | i--; | 290 | i--; |
291 | luaL_arg_check(0 <= i && i < lua_getbindatasize(ud), "getbyte", 2, | 291 | if (0 <= i && i < lua_getbindatasize(ud)) |
292 | "out of range"); | 292 | lua_pushnumber(*(((char *)lua_getbinarydata(ud))+i)); |
293 | lua_pushnumber(*(((char *)lua_getbinarydata(ud))+i)); | 293 | else |
294 | lua_pushnil(); | ||
294 | } | 295 | } |
295 | } | 296 | } |
296 | 297 | ||
@@ -341,7 +342,7 @@ static struct luaL_reg iolib[] = { | |||
341 | 342 | ||
342 | void iolib_open (void) | 343 | void iolib_open (void) |
343 | { | 344 | { |
344 | lua_tagio = lua_newtag("userdata"); | 345 | lua_tagio = lua_newtag(); |
345 | lua_infile=stdin; lua_outfile=stdout; | 346 | lua_infile=stdin; lua_outfile=stdout; |
346 | luaL_openlib(iolib, (sizeof(iolib)/sizeof(iolib[0]))); | 347 | luaL_openlib(iolib, (sizeof(iolib)/sizeof(iolib[0]))); |
347 | lua_seterrormethod(errorfb); | 348 | lua_seterrormethod(errorfb); |
@@ -2,7 +2,7 @@ | |||
2 | ** LUA - Linguagem para Usuarios de Aplicacao | 2 | ** LUA - Linguagem para Usuarios de Aplicacao |
3 | ** Grupo de Tecnologia em Computacao Grafica | 3 | ** Grupo de Tecnologia em Computacao Grafica |
4 | ** TeCGraf - PUC-Rio | 4 | ** TeCGraf - PUC-Rio |
5 | ** $Id: lua.h,v 3.40 1997/04/02 17:44:18 roberto Exp roberto $ | 5 | ** $Id: lua.h,v 3.41 1997/04/02 22:52:42 roberto Exp roberto $ |
6 | */ | 6 | */ |
7 | 7 | ||
8 | 8 | ||
@@ -21,6 +21,7 @@ typedef unsigned int lua_Object; | |||
21 | 21 | ||
22 | lua_Object lua_setfallback (char *event, lua_CFunction fallback); | 22 | lua_Object lua_setfallback (char *event, lua_CFunction fallback); |
23 | void lua_setintmethod (int tag, char *event, lua_CFunction method); | 23 | void lua_setintmethod (int tag, char *event, lua_CFunction method); |
24 | void lua_getintmethod (int tag, char *event); /* out: method */ | ||
24 | void lua_seterrormethod (lua_CFunction method); | 25 | void lua_seterrormethod (lua_CFunction method); |
25 | 26 | ||
26 | int lua_newtag (void); | 27 | int lua_newtag (void); |
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.91 1997/04/02 17:44:18 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.92 1997/04/02 22:52:42 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
@@ -656,6 +656,13 @@ lua_Object lua_setfallback (char *name, lua_CFunction fallback) | |||
656 | return (Ref(top-1)); | 656 | return (Ref(top-1)); |
657 | } | 657 | } |
658 | 658 | ||
659 | void lua_getintmethod (int tag, char *event) | ||
660 | { | ||
661 | lua_pushnumber(tag); | ||
662 | lua_pushstring(event); | ||
663 | do_unprotectedrun(luaI_getintmethod, 2, 1); | ||
664 | } | ||
665 | |||
659 | void lua_setintmethod (int tag, char *event, lua_CFunction method) | 666 | void lua_setintmethod (int tag, char *event, lua_CFunction method) |
660 | { | 667 | { |
661 | lua_pushnumber(tag); | 668 | lua_pushnumber(tag); |