aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-04-02 20:04:12 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-04-02 20:04:12 -0300
commit075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2 (patch)
treeae1dd456984f4e7128b2d4a2e2e43e4f23b99d01
parent7c99149a76ce0c7469c9bafec5dfff529f88512c (diff)
downloadlua-075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2.tar.gz
lua-075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2.tar.bz2
lua-075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2.zip
new function "getintmethod"
-rw-r--r--fallback.c13
-rw-r--r--fallback.h3
-rw-r--r--inout.c3
-rw-r--r--iolib.c9
-rw-r--r--lua.h3
-rw-r--r--opcode.c9
6 files changed, 30 insertions, 10 deletions
diff --git a/fallback.c b/fallback.c
index c86d04cd..a85de236 100644
--- a/fallback.c
+++ b/fallback.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_fallback="$Id: fallback.c,v 1.36 1997/03/31 20:59:09 roberto Exp roberto $"; 6char *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
226void 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
226void luaI_setintmethod (void) 236void 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
diff --git a/fallback.h b/fallback.h
index 44341ca4..1275c6d4 100644
--- a/fallback.h
+++ b/fallback.h
@@ -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);
52TObject *luaI_geterrorim (void); 52TObject *luaI_geterrorim (void);
53int luaI_tag (TObject *o); 53int luaI_tag (TObject *o);
54void luaI_setintmethod (void); 54void luaI_setintmethod (void);
55void luaI_getintmethod (void);
55void luaI_seterrormethod (void); 56void luaI_seterrormethod (void);
56void luaI_initfallbacks (void); 57void luaI_initfallbacks (void);
57 58
diff --git a/inout.c b/inout.c
index af4ff550..db48039d 100644
--- a/inout.c
+++ b/inout.c
@@ -5,7 +5,7 @@
5** Also provides some predefined lua functions. 5** Also provides some predefined lua functions.
6*/ 6*/
7 7
8char *rcs_inout="$Id: inout.c,v 2.52 1997/04/01 19:02:43 roberto Exp roberto $"; 8char *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},
diff --git a/iolib.c b/iolib.c
index fa105828..1a2a9009 100644
--- a/iolib.c
+++ b/iolib.c
@@ -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
342void iolib_open (void) 343void 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);
diff --git a/lua.h b/lua.h
index bcc8213e..e6960a36 100644
--- a/lua.h
+++ b/lua.h
@@ -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
22lua_Object lua_setfallback (char *event, lua_CFunction fallback); 22lua_Object lua_setfallback (char *event, lua_CFunction fallback);
23void lua_setintmethod (int tag, char *event, lua_CFunction method); 23void lua_setintmethod (int tag, char *event, lua_CFunction method);
24void lua_getintmethod (int tag, char *event); /* out: method */
24void lua_seterrormethod (lua_CFunction method); 25void lua_seterrormethod (lua_CFunction method);
25 26
26int lua_newtag (void); 27int lua_newtag (void);
diff --git a/opcode.c b/opcode.c
index 5bbfe609..e36ba184 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 3.91 1997/04/02 17:44:18 roberto Exp roberto $"; 6char *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
659void lua_getintmethod (int tag, char *event)
660{
661 lua_pushnumber(tag);
662 lua_pushstring(event);
663 do_unprotectedrun(luaI_getintmethod, 2, 1);
664}
665
659void lua_setintmethod (int tag, char *event, lua_CFunction method) 666void lua_setintmethod (int tag, char *event, lua_CFunction method)
660{ 667{
661 lua_pushnumber(tag); 668 lua_pushnumber(tag);