aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-02-12 17:23:32 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-02-12 17:23:32 -0200
commitf380d627f8f018e029c889e809f1c0f9cc6fc2e5 (patch)
tree2c16130cf50294a88be303e5ca42e502ee0eee7d
parentaafa106d108581ab8b259bfde3bcf1166a17c3e9 (diff)
downloadlua-f380d627f8f018e029c889e809f1c0f9cc6fc2e5.tar.gz
lua-f380d627f8f018e029c889e809f1c0f9cc6fc2e5.tar.bz2
lua-f380d627f8f018e029c889e809f1c0f9cc6fc2e5.zip
usefull macros also available as functions
-rw-r--r--lapi.c23
-rw-r--r--lbuiltin.c4
-rw-r--r--lua.h11
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 @@
1/* 1/*
2** $Id: lapi.c,v 1.19 1998/01/09 14:44:55 roberto Exp roberto $ 2** $Id: lapi.c,v 1.20 1998/01/27 19:13:45 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -572,6 +572,27 @@ lua_Object lua_getref (int ref)
572} 572}
573 573
574 574
575/*
576** =======================================================
577** Derived functions
578** =======================================================
579*/
580int (lua_call) (char *name) { return lua_call(name); }
581
582void (lua_pushref) (int ref) { lua_pushref(ref); }
583
584int (lua_refobject) (lua_Object o, int l) { return lua_refobject(o, l); }
585
586void (lua_register) (char *n, lua_CFunction f) { lua_register(n, f); }
587
588void (lua_pushuserdata) (void *u) { lua_pushuserdata(u); }
589
590void (lua_pushcfunction) (lua_CFunction f) { lua_pushcfunction(f); }
591
592int (lua_clonetag) (int t) { return lua_clonetag(t); }
593
594
595
575 596
576#ifdef LUA_COMPAT2_5 597#ifdef LUA_COMPAT2_5
577/* 598/*
diff --git a/lbuiltin.c b/lbuiltin.c
index 13ea4fa1..5562ccff 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.22 1998/01/07 16:26:48 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.23 1998/01/19 19:49:22 roberto Exp roberto $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -444,7 +444,7 @@ static void testC (void)
444 case '=': lua_setglobal(getname(s)); break; 444 case '=': lua_setglobal(getname(s)); break;
445 case 's': lua_pushstring(getname(s)); break; 445 case 's': lua_pushstring(getname(s)); break;
446 case 'o': lua_pushobject(reg[getnum(s)]); break; 446 case 'o': lua_pushobject(reg[getnum(s)]); break;
447 case 'f': lua_call(getname(s)); break; 447 case 'f': (lua_call)(getname(s)); break;
448 case 'i': reg[getnum(s)] = lua_gettable(); break; 448 case 'i': reg[getnum(s)] = lua_gettable(); break;
449 case 'I': reg[getnum(s)] = lua_rawgettable(); break; 449 case 'I': reg[getnum(s)] = lua_rawgettable(); break;
450 case 't': lua_settable(); break; 450 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 @@
1/* 1/*
2** $Id: lua.h,v 1.13 1998/01/02 17:46:32 roberto Exp roberto $ 2** $Id: lua.h,v 1.14 1998/01/07 16:26:48 roberto Exp roberto $
3** Lua - An Extensible Extension Language 3** Lua - An Extensible Extension Language
4** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil 4** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
5** e-mail: lua@tecgraf.puc-rio.br 5** e-mail: lua@tecgraf.puc-rio.br
@@ -126,20 +126,27 @@ long lua_collectgarbage (long limit);
126 126
127 127
128/* =============================================================== */ 128/* =============================================================== */
129/* some useful macros */ 129/* some useful macros/derived functions */
130 130
131int (lua_call) (char *name);
131#define lua_call(name) lua_callfunction(lua_getglobal(name)) 132#define lua_call(name) lua_callfunction(lua_getglobal(name))
132 133
134void (lua_pushref) (int ref);
133#define lua_pushref(ref) lua_pushobject(lua_getref(ref)) 135#define lua_pushref(ref) lua_pushobject(lua_getref(ref))
134 136
137int (lua_refobject) (lua_Object o, int l);
135#define lua_refobject(o,l) (lua_pushobject(o), lua_ref(l)) 138#define lua_refobject(o,l) (lua_pushobject(o), lua_ref(l))
136 139
140void (lua_register) (char *n, lua_CFunction f);
137#define lua_register(n,f) (lua_pushcfunction(f), lua_setglobal(n)) 141#define lua_register(n,f) (lua_pushcfunction(f), lua_setglobal(n))
138 142
143void (lua_pushuserdata) (void *u);
139#define lua_pushuserdata(u) lua_pushusertag(u, 0) 144#define lua_pushuserdata(u) lua_pushusertag(u, 0)
140 145
146void (lua_pushcfunction) (lua_CFunction f);
141#define lua_pushcfunction(f) lua_pushCclosure(f, 0) 147#define lua_pushcfunction(f) lua_pushCclosure(f, 0)
142 148
149int (lua_clonetag) (int t);
143#define lua_clonetag(t) lua_copytagmethods(lua_newtag(), (t)) 150#define lua_clonetag(t) lua_copytagmethods(lua_newtag(), (t))
144 151
145 152