aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-30 10:38:50 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-30 10:38:50 -0200
commitf379d06e24f22cb4d0afa3937c27ef35b73b00a6 (patch)
treee87e3def52e622040ec2724433e21daee8322ee3
parent728ff2070135b54c544b90020be268f53bf2d15a (diff)
downloadlua-f379d06e24f22cb4d0afa3937c27ef35b73b00a6.tar.gz
lua-f379d06e24f22cb4d0afa3937c27ef35b73b00a6.tar.bz2
lua-f379d06e24f22cb4d0afa3937c27ef35b73b00a6.zip
all API functions are declared in a single line (to facilitate pre-processing).
-rw-r--r--lauxlib.c5
-rw-r--r--lauxlib.h5
-rw-r--r--ldebug.c16
-rw-r--r--ldo.c5
-rw-r--r--lua.h13
-rw-r--r--luadebug.h8
6 files changed, 23 insertions, 29 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 97e8c896..a817f613 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.40 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.41 2000/10/27 16:15:53 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -75,8 +75,7 @@ LUALIB_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) {
75} 75}
76 76
77 77
78LUALIB_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, 78LUALIB_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, size_t *len) {
79 size_t *len) {
80 if (lua_isnull(L, narg)) { 79 if (lua_isnull(L, narg)) {
81 if (len) 80 if (len)
82 *len = (def ? strlen(def) : 0); 81 *len = (def ? strlen(def) : 0);
diff --git a/lauxlib.h b/lauxlib.h
index 47aedc07..332c34cf 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.28 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.29 2000/10/27 16:15:53 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -29,8 +29,7 @@ struct luaL_reg {
29LUALIB_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n); 29LUALIB_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n);
30LUALIB_API void luaL_argerror (lua_State *L, int numarg, const char *extramsg); 30LUALIB_API void luaL_argerror (lua_State *L, int numarg, const char *extramsg);
31LUALIB_API const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len); 31LUALIB_API const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len);
32LUALIB_API const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def, 32LUALIB_API const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def, size_t *len);
33 size_t *len);
34LUALIB_API double luaL_check_number (lua_State *L, int numArg); 33LUALIB_API double luaL_check_number (lua_State *L, int numArg);
35LUALIB_API double luaL_opt_number (lua_State *L, int numArg, double def); 34LUALIB_API double luaL_opt_number (lua_State *L, int numArg, double def);
36 35
diff --git a/ldebug.c b/ldebug.c
index 744263a6..b3d2dfac 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.48 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.49 2000/10/27 11:39:52 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -148,29 +148,27 @@ static Proto *getluaproto (StkId f) {
148} 148}
149 149
150 150
151LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, 151LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
152 int localnum) {
153 const char *name; 152 const char *name;
154 StkId f = ar->_func; 153 StkId f = ar->_func;
155 Proto *fp = getluaproto(f); 154 Proto *fp = getluaproto(f);
156 if (!fp) return NULL; /* `f' is not a Lua function? */ 155 if (!fp) return NULL; /* `f' is not a Lua function? */
157 name = luaF_getlocalname(fp, localnum, currentpc(f)); 156 name = luaF_getlocalname(fp, n, currentpc(f));
158 if (!name) return NULL; 157 if (!name) return NULL;
159 luaA_pushobject(L, (f+1)+(localnum-1)); /* push value */ 158 luaA_pushobject(L, (f+1)+(n-1)); /* push value */
160 return name; 159 return name;
161} 160}
162 161
163 162
164LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, 163LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
165 int localnum) {
166 const char *name; 164 const char *name;
167 StkId f = ar->_func; 165 StkId f = ar->_func;
168 Proto *fp = getluaproto(f); 166 Proto *fp = getluaproto(f);
169 L->top--; /* pop new value */ 167 L->top--; /* pop new value */
170 if (!fp) return NULL; /* `f' is not a Lua function? */ 168 if (!fp) return NULL; /* `f' is not a Lua function? */
171 name = luaF_getlocalname(fp, localnum, currentpc(f)); 169 name = luaF_getlocalname(fp, n, currentpc(f));
172 if (!name || name[0] == '(') return NULL; /* `(' starts private locals */ 170 if (!name || name[0] == '(') return NULL; /* `(' starts private locals */
173 *((f+1)+(localnum-1)) = *L->top; 171 *((f+1)+(n-1)) = *L->top;
174 return name; 172 return name;
175} 173}
176 174
diff --git a/ldo.c b/ldo.c
index 8b5b1d63..0aedd8fb 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.107 2000/10/10 19:51:39 roberto Exp roberto $ 2** $Id: ldo.c,v 1.108 2000/10/20 16:39:03 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -301,8 +301,7 @@ static int parse_buffer (lua_State *L, const char *buff, size_t size,
301} 301}
302 302
303 303
304LUA_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, 304LUA_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, const char *name) {
305 const char *name) {
306 int status = parse_buffer(L, buff, size, name); 305 int status = parse_buffer(L, buff, size, name);
307 if (status == 0) /* parse OK? */ 306 if (status == 0) /* parse OK? */
308 status = lua_call(L, 0, LUA_MULTRET); /* call main */ 307 status = lua_call(L, 0, LUA_MULTRET); /* call main */
diff --git a/lua.h b/lua.h
index 599dfafd..7d18c4d3 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.76 2000/10/24 19:12:06 roberto Exp roberto $ 2** $Id: lua.h,v 1.77 2000/10/26 12:47:05 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
@@ -16,16 +16,18 @@
16#include <stddef.h> 16#include <stddef.h>
17 17
18 18
19/* mark for all API functions */
19#ifndef LUA_API 20#ifndef LUA_API
20#define LUA_API extern 21#define LUA_API extern
21#endif 22#endif
22 23
23 24
24#define LUA_VERSION "Lua 4.0 (beta)" 25#define LUA_VERSION "Lua 4.0"
25#define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio" 26#define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio"
26#define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" 27#define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
27 28
28 29
30/* name of global variable with error handler */
29#define LUA_ERRORMESSAGE "_ERRORMESSAGE" 31#define LUA_ERRORMESSAGE "_ERRORMESSAGE"
30 32
31 33
@@ -39,9 +41,11 @@
39#define LUA_NOTAG (-2) 41#define LUA_NOTAG (-2)
40 42
41 43
44/* option for multiple returns in lua_call */
42#define LUA_MULTRET (-1) 45#define LUA_MULTRET (-1)
43 46
44 47
48/* minimum stack avaiable for a C function */
45#define LUA_MINSTACK 20 49#define LUA_MINSTACK 20
46 50
47 51
@@ -131,9 +135,7 @@ LUA_API void lua_rawget (lua_State *L, int index);
131LUA_API void lua_rawgeti (lua_State *L, int index, int n); 135LUA_API void lua_rawgeti (lua_State *L, int index, int n);
132LUA_API void lua_getglobals (lua_State *L); 136LUA_API void lua_getglobals (lua_State *L);
133LUA_API void lua_gettagmethod (lua_State *L, int tag, const char *event); 137LUA_API void lua_gettagmethod (lua_State *L, int tag, const char *event);
134
135LUA_API int lua_getref (lua_State *L, int ref); 138LUA_API int lua_getref (lua_State *L, int ref);
136
137LUA_API void lua_newtable (lua_State *L); 139LUA_API void lua_newtable (lua_State *L);
138 140
139 141
@@ -156,8 +158,7 @@ LUA_API int lua_call (lua_State *L, int nargs, int nresults);
156LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults); 158LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults);
157LUA_API int lua_dofile (lua_State *L, const char *filename); 159LUA_API int lua_dofile (lua_State *L, const char *filename);
158LUA_API int lua_dostring (lua_State *L, const char *str); 160LUA_API int lua_dostring (lua_State *L, const char *str);
159LUA_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, 161LUA_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, const char *name);
160 const char *name);
161 162
162/* 163/*
163** Garbage-collection functions 164** Garbage-collection functions
diff --git a/luadebug.h b/luadebug.h
index cb46ec32..72994165 100644
--- a/luadebug.h
+++ b/luadebug.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luadebug.h,v 1.15 2000/09/12 18:38:02 roberto Exp roberto $ 2** $Id: luadebug.h,v 1.16 2000/10/20 16:39:03 roberto Exp roberto $
3** Debugging API 3** Debugging API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -19,10 +19,8 @@ typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
19 19
20LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); 20LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
21LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); 21LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
22LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, 22LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
23 int localnum); 23LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
24LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar,
25 int localnum);
26 24
27LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func); 25LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func);
28LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func); 26LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);