From f380d627f8f018e029c889e809f1c0f9cc6fc2e5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 12 Feb 1998 17:23:32 -0200 Subject: usefull macros also available as functions --- lapi.c | 23 ++++++++++++++++++++++- lbuiltin.c | 4 ++-- lua.h | 11 +++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lapi.c b/lapi.c index a1e975a3..8528dd65 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 1.19 1998/01/09 14:44:55 roberto Exp roberto $ +** $Id: lapi.c,v 1.20 1998/01/27 19:13:45 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -572,6 +572,27 @@ lua_Object lua_getref (int ref) } +/* +** ======================================================= +** Derived functions +** ======================================================= +*/ +int (lua_call) (char *name) { return lua_call(name); } + +void (lua_pushref) (int ref) { lua_pushref(ref); } + +int (lua_refobject) (lua_Object o, int l) { return lua_refobject(o, l); } + +void (lua_register) (char *n, lua_CFunction f) { lua_register(n, f); } + +void (lua_pushuserdata) (void *u) { lua_pushuserdata(u); } + +void (lua_pushcfunction) (lua_CFunction f) { lua_pushcfunction(f); } + +int (lua_clonetag) (int t) { return lua_clonetag(t); } + + + #ifdef LUA_COMPAT2_5 /* diff --git a/lbuiltin.c b/lbuiltin.c index 13ea4fa1..5562ccff 100644 --- a/lbuiltin.c +++ b/lbuiltin.c @@ -1,5 +1,5 @@ /* -** $Id: lbuiltin.c,v 1.22 1998/01/07 16:26:48 roberto Exp roberto $ +** $Id: lbuiltin.c,v 1.23 1998/01/19 19:49:22 roberto Exp roberto $ ** Built-in functions ** See Copyright Notice in lua.h */ @@ -444,7 +444,7 @@ static void testC (void) case '=': lua_setglobal(getname(s)); break; case 's': lua_pushstring(getname(s)); break; case 'o': lua_pushobject(reg[getnum(s)]); break; - case 'f': lua_call(getname(s)); break; + case 'f': (lua_call)(getname(s)); break; case 'i': reg[getnum(s)] = lua_gettable(); break; case 'I': reg[getnum(s)] = lua_rawgettable(); break; case 't': lua_settable(); break; diff --git a/lua.h b/lua.h index 71601e59..4e11f987 100644 --- a/lua.h +++ b/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.13 1998/01/02 17:46:32 roberto Exp roberto $ +** $Id: lua.h,v 1.14 1998/01/07 16:26:48 roberto Exp roberto $ ** Lua - An Extensible Extension Language ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil ** e-mail: lua@tecgraf.puc-rio.br @@ -126,20 +126,27 @@ long lua_collectgarbage (long limit); /* =============================================================== */ -/* some useful macros */ +/* some useful macros/derived functions */ +int (lua_call) (char *name); #define lua_call(name) lua_callfunction(lua_getglobal(name)) +void (lua_pushref) (int ref); #define lua_pushref(ref) lua_pushobject(lua_getref(ref)) +int (lua_refobject) (lua_Object o, int l); #define lua_refobject(o,l) (lua_pushobject(o), lua_ref(l)) +void (lua_register) (char *n, lua_CFunction f); #define lua_register(n,f) (lua_pushcfunction(f), lua_setglobal(n)) +void (lua_pushuserdata) (void *u); #define lua_pushuserdata(u) lua_pushusertag(u, 0) +void (lua_pushcfunction) (lua_CFunction f); #define lua_pushcfunction(f) lua_pushCclosure(f, 0) +int (lua_clonetag) (int t); #define lua_clonetag(t) lua_copytagmethods(lua_newtag(), (t)) -- cgit v1.2.3-55-g6feb