commit 075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2
parent 7c99149a76ce0c7469c9bafec5dfff529f88512c
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 2 Apr 1997 20:03:52 -0300
new function "getintmethod"
Diffstat:
6 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/fallback.c b/fallback.c
@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio
*/
-char *rcs_fallback="$Id: fallback.c,v 1.36 1997/03/31 20:59:09 roberto Exp roberto $";
+char *rcs_fallback="$Id: fallback.c,v 1.37 1997/04/02 22:52:42 roberto Exp roberto $";
#include <stdio.h>
#include <string.h>
@@ -223,6 +223,16 @@ TObject *luaI_getim (int tag, IMS event)
}
+void luaI_getintmethod (void)
+{
+ int t = (int)luaL_check_number(1, "getintmethod");
+ int e = luaI_checkevent(luaL_check_string(2, "getintmethod"), luaI_eventname);
+ checktag(t);
+ if (validevent(t, e))
+ luaI_pushobject(&luaI_IMtable[-t].int_method[e]);
+}
+
+
void luaI_setintmethod (void)
{
int t = (int)luaL_check_number(1, "setintmethod");
@@ -233,7 +243,6 @@ void luaI_setintmethod (void)
lua_error("cannot change this internal method");
luaL_arg_check(lua_isnil(func) || lua_isfunction(func), "setintmethod",
3, "function expected");
- luaI_pushobject(&luaI_IMtable[-t].int_method[e]);
luaI_IMtable[-t].int_method[e] = *luaI_Address(func);
}
diff --git a/fallback.h b/fallback.h
@@ -1,5 +1,5 @@
/*
-** $Id: fallback.h,v 1.19 1997/03/31 20:59:09 roberto Exp roberto $
+** $Id: fallback.h,v 1.20 1997/04/02 22:52:42 roberto Exp roberto $
*/
#ifndef fallback_h
@@ -52,6 +52,7 @@ TObject *luaI_getim (int tag, IMS event);
TObject *luaI_geterrorim (void);
int luaI_tag (TObject *o);
void luaI_setintmethod (void);
+void luaI_getintmethod (void);
void luaI_seterrormethod (void);
void luaI_initfallbacks (void);
diff --git a/inout.c b/inout.c
@@ -5,7 +5,7 @@
** Also provides some predefined lua functions.
*/
-char *rcs_inout="$Id: inout.c,v 2.52 1997/04/01 19:02:43 roberto Exp roberto $";
+char *rcs_inout="$Id: inout.c,v 2.53 1997/04/02 22:53:35 roberto Exp roberto $";
#include <stdio.h>
#include <string.h>
@@ -342,6 +342,7 @@ static struct {
{"setfallback", luaI_setfallback},
{"setglobal", luaI_setglobal},
{"setintmethod", luaI_setintmethod},
+ {"getintmethod", luaI_getintmethod},
{"settag", luaIl_settag},
{"tonumber", lua_obj2number},
{"tostring", luaI_tostring},
diff --git a/iolib.c b/iolib.c
@@ -288,9 +288,10 @@ static void getbyte (void)
lua_pushnumber(lua_getbindatasize(ud));
else {
i--;
- luaL_arg_check(0 <= i && i < lua_getbindatasize(ud), "getbyte", 2,
- "out of range");
- lua_pushnumber(*(((char *)lua_getbinarydata(ud))+i));
+ if (0 <= i && i < lua_getbindatasize(ud))
+ lua_pushnumber(*(((char *)lua_getbinarydata(ud))+i));
+ else
+ lua_pushnil();
}
}
@@ -341,7 +342,7 @@ static struct luaL_reg iolib[] = {
void iolib_open (void)
{
- lua_tagio = lua_newtag("userdata");
+ lua_tagio = lua_newtag();
lua_infile=stdin; lua_outfile=stdout;
luaL_openlib(iolib, (sizeof(iolib)/sizeof(iolib[0])));
lua_seterrormethod(errorfb);
diff --git a/lua.h b/lua.h
@@ -2,7 +2,7 @@
** LUA - Linguagem para Usuarios de Aplicacao
** Grupo de Tecnologia em Computacao Grafica
** TeCGraf - PUC-Rio
-** $Id: lua.h,v 3.40 1997/04/02 17:44:18 roberto Exp roberto $
+** $Id: lua.h,v 3.41 1997/04/02 22:52:42 roberto Exp roberto $
*/
@@ -21,6 +21,7 @@ typedef unsigned int lua_Object;
lua_Object lua_setfallback (char *event, lua_CFunction fallback);
void lua_setintmethod (int tag, char *event, lua_CFunction method);
+void lua_getintmethod (int tag, char *event); /* out: method */
void lua_seterrormethod (lua_CFunction method);
int lua_newtag (void);
diff --git a/opcode.c b/opcode.c
@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio
*/
-char *rcs_opcode="$Id: opcode.c,v 3.91 1997/04/02 17:44:18 roberto Exp roberto $";
+char *rcs_opcode="$Id: opcode.c,v 3.92 1997/04/02 22:52:42 roberto Exp roberto $";
#include <setjmp.h>
#include <stdio.h>
@@ -656,6 +656,13 @@ lua_Object lua_setfallback (char *name, lua_CFunction fallback)
return (Ref(top-1));
}
+void lua_getintmethod (int tag, char *event)
+{
+ lua_pushnumber(tag);
+ lua_pushstring(event);
+ do_unprotectedrun(luaI_getintmethod, 2, 1);
+}
+
void lua_setintmethod (int tag, char *event, lua_CFunction method)
{
lua_pushnumber(tag);