summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lauxlib.c36
-rw-r--r--lauxlib.h41
-rw-r--r--lbaselib.c4
-rw-r--r--ldblib.c4
-rw-r--r--liolib.c4
-rw-r--r--lmathlib.c4
-rw-r--r--lstrlib.c4
-rw-r--r--lualib.h17
8 files changed, 62 insertions, 52 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 08ad3fba..97e8c896 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.39 2000/10/05 12:14:08 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.40 2000/10/20 16:39:03 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*/
@@ -21,7 +21,7 @@
21 21
22 22
23 23
24LUA_API int luaL_findstring (const char *name, const char *const list[]) { 24LUALIB_API int luaL_findstring (const char *name, const char *const list[]) {
25 int i; 25 int i;
26 for (i=0; list[i]; i++) 26 for (i=0; list[i]; i++)
27 if (strcmp(list[i], name) == 0) 27 if (strcmp(list[i], name) == 0)
@@ -29,7 +29,7 @@ LUA_API int luaL_findstring (const char *name, const char *const list[]) {
29 return -1; /* name not found */ 29 return -1; /* name not found */
30} 30}
31 31
32LUA_API void luaL_argerror (lua_State *L, int narg, const char *extramsg) { 32LUALIB_API void luaL_argerror (lua_State *L, int narg, const char *extramsg) {
33 lua_Debug ar; 33 lua_Debug ar;
34 lua_getstack(L, 0, &ar); 34 lua_getstack(L, 0, &ar);
35 lua_getinfo(L, "n", &ar); 35 lua_getinfo(L, "n", &ar);
@@ -49,25 +49,25 @@ static void type_error (lua_State *L, int narg, int t) {
49} 49}
50 50
51 51
52LUA_API void luaL_checkstack (lua_State *L, int space, const char *mes) { 52LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
53 if (space > lua_stackspace(L)) 53 if (space > lua_stackspace(L))
54 luaL_verror(L, "stack overflow (%.30s)", mes); 54 luaL_verror(L, "stack overflow (%.30s)", mes);
55} 55}
56 56
57 57
58LUA_API void luaL_checktype(lua_State *L, int narg, int t) { 58LUALIB_API void luaL_checktype(lua_State *L, int narg, int t) {
59 if (lua_type(L, narg) != t) 59 if (lua_type(L, narg) != t)
60 type_error(L, narg, t); 60 type_error(L, narg, t);
61} 61}
62 62
63 63
64LUA_API void luaL_checkany (lua_State *L, int narg) { 64LUALIB_API void luaL_checkany (lua_State *L, int narg) {
65 if (lua_type(L, narg) == LUA_TNONE) 65 if (lua_type(L, narg) == LUA_TNONE)
66 luaL_argerror(L, narg, "value expected"); 66 luaL_argerror(L, narg, "value expected");
67} 67}
68 68
69 69
70LUA_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { 70LUALIB_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) {
71 const char *s = lua_tostring(L, narg); 71 const char *s = lua_tostring(L, narg);
72 if (!s) type_error(L, narg, LUA_TSTRING); 72 if (!s) type_error(L, narg, LUA_TSTRING);
73 if (len) *len = lua_strlen(L, narg); 73 if (len) *len = lua_strlen(L, narg);
@@ -75,7 +75,7 @@ LUA_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) {
75} 75}
76 76
77 77
78LUA_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,
79 size_t *len) { 79 size_t *len) {
80 if (lua_isnull(L, narg)) { 80 if (lua_isnull(L, narg)) {
81 if (len) 81 if (len)
@@ -86,7 +86,7 @@ LUA_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def,
86} 86}
87 87
88 88
89LUA_API double luaL_check_number (lua_State *L, int narg) { 89LUALIB_API double luaL_check_number (lua_State *L, int narg) {
90 double d = lua_tonumber(L, narg); 90 double d = lua_tonumber(L, narg);
91 if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ 91 if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
92 type_error(L, narg, LUA_TNUMBER); 92 type_error(L, narg, LUA_TNUMBER);
@@ -94,20 +94,20 @@ LUA_API double luaL_check_number (lua_State *L, int narg) {
94} 94}
95 95
96 96
97LUA_API double luaL_opt_number (lua_State *L, int narg, double def) { 97LUALIB_API double luaL_opt_number (lua_State *L, int narg, double def) {
98 if (lua_isnull(L, narg)) return def; 98 if (lua_isnull(L, narg)) return def;
99 else return luaL_check_number(L, narg); 99 else return luaL_check_number(L, narg);
100} 100}
101 101
102 102
103LUA_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n) { 103LUALIB_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n) {
104 int i; 104 int i;
105 for (i=0; i<n; i++) 105 for (i=0; i<n; i++)
106 lua_register(L, l[i].name, l[i].func); 106 lua_register(L, l[i].name, l[i].func);
107} 107}
108 108
109 109
110LUA_API void luaL_verror (lua_State *L, const char *fmt, ...) { 110LUALIB_API void luaL_verror (lua_State *L, const char *fmt, ...) {
111 char buff[500]; 111 char buff[500];
112 va_list argp; 112 va_list argp;
113 va_start(argp, fmt); 113 va_start(argp, fmt);
@@ -164,25 +164,25 @@ static void adjuststack (luaL_Buffer *B) {
164} 164}
165 165
166 166
167LUA_API char *luaL_prepbuffer (luaL_Buffer *B) { 167LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
168 if (emptybuffer(B)) 168 if (emptybuffer(B))
169 adjuststack(B); 169 adjuststack(B);
170 return B->buffer; 170 return B->buffer;
171} 171}
172 172
173 173
174LUA_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { 174LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
175 while (l--) 175 while (l--)
176 luaL_putchar(B, *s++); 176 luaL_putchar(B, *s++);
177} 177}
178 178
179 179
180LUA_API void luaL_addstring (luaL_Buffer *B, const char *s) { 180LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
181 luaL_addlstring(B, s, strlen(s)); 181 luaL_addlstring(B, s, strlen(s));
182} 182}
183 183
184 184
185LUA_API void luaL_pushresult (luaL_Buffer *B) { 185LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
186 emptybuffer(B); 186 emptybuffer(B);
187 if (B->level == 0) 187 if (B->level == 0)
188 lua_pushlstring(B->L, NULL, 0); 188 lua_pushlstring(B->L, NULL, 0);
@@ -192,7 +192,7 @@ LUA_API void luaL_pushresult (luaL_Buffer *B) {
192} 192}
193 193
194 194
195LUA_API void luaL_addvalue (luaL_Buffer *B) { 195LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
196 lua_State *L = B->L; 196 lua_State *L = B->L;
197 size_t vl = lua_strlen(L, -1); 197 size_t vl = lua_strlen(L, -1);
198 if (vl <= bufffree(B)) { /* fit into buffer? */ 198 if (vl <= bufffree(B)) { /* fit into buffer? */
@@ -209,7 +209,7 @@ LUA_API void luaL_addvalue (luaL_Buffer *B) {
209} 209}
210 210
211 211
212LUA_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { 212LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
213 B->L = L; 213 B->L = L;
214 B->p = B->buffer; 214 B->p = B->buffer;
215 B->level = 0; 215 B->level = 0;
diff --git a/lauxlib.h b/lauxlib.h
index 2f159e23..47aedc07 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.27 2000/10/05 12:14:08 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.28 2000/10/20 16:39:03 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*/
@@ -15,26 +15,31 @@
15#include "lua.h" 15#include "lua.h"
16 16
17 17
18#ifndef LUALIB_API
19#define LUALIB_API extern
20#endif
21
22
18struct luaL_reg { 23struct luaL_reg {
19 const char *name; 24 const char *name;
20 lua_CFunction func; 25 lua_CFunction func;
21}; 26};
22 27
23 28
24LUA_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);
25LUA_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);
26LUA_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);
27LUA_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,
28 size_t *len); 33 size_t *len);
29LUA_API double luaL_check_number (lua_State *L, int numArg); 34LUALIB_API double luaL_check_number (lua_State *L, int numArg);
30LUA_API double luaL_opt_number (lua_State *L, int numArg, double def); 35LUALIB_API double luaL_opt_number (lua_State *L, int numArg, double def);
31 36
32LUA_API void luaL_checkstack (lua_State *L, int space, const char *msg); 37LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg);
33LUA_API void luaL_checktype (lua_State *L, int narg, int t); 38LUALIB_API void luaL_checktype (lua_State *L, int narg, int t);
34LUA_API void luaL_checkany (lua_State *L, int narg); 39LUALIB_API void luaL_checkany (lua_State *L, int narg);
35 40
36LUA_API void luaL_verror (lua_State *L, const char *fmt, ...); 41LUALIB_API void luaL_verror (lua_State *L, const char *fmt, ...);
37LUA_API int luaL_findstring (const char *name, const char *const list[]); 42LUALIB_API int luaL_findstring (const char *name, const char *const list[]);
38 43
39 44
40 45
@@ -80,12 +85,12 @@ typedef struct luaL_Buffer {
80 85
81#define luaL_addsize(B,n) ((B)->p += (n)) 86#define luaL_addsize(B,n) ((B)->p += (n))
82 87
83LUA_API void luaL_buffinit (lua_State *L, luaL_Buffer *B); 88LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B);
84LUA_API char *luaL_prepbuffer (luaL_Buffer *B); 89LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B);
85LUA_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l); 90LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
86LUA_API void luaL_addstring (luaL_Buffer *B, const char *s); 91LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s);
87LUA_API void luaL_addvalue (luaL_Buffer *B); 92LUALIB_API void luaL_addvalue (luaL_Buffer *B);
88LUA_API void luaL_pushresult (luaL_Buffer *B); 93LUALIB_API void luaL_pushresult (luaL_Buffer *B);
89 94
90 95
91/* }====================================================== */ 96/* }====================================================== */
diff --git a/lbaselib.c b/lbaselib.c
index bb5a0d7f..e588f0c3 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.13 2000/10/20 16:57:42 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.14 2000/10/24 19:19:15 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -639,7 +639,7 @@ static const struct luaL_reg base_funcs[] = {
639 639
640 640
641 641
642LUA_API void lua_baselibopen (lua_State *L) { 642LUALIB_API void lua_baselibopen (lua_State *L) {
643 luaL_openl(L, base_funcs); 643 luaL_openl(L, base_funcs);
644 lua_pushstring(L, LUA_VERSION); 644 lua_pushstring(L, LUA_VERSION);
645 lua_setglobal(L, "_VERSION"); 645 lua_setglobal(L, "_VERSION");
diff --git a/ldblib.c b/ldblib.c
index 02dca507..a6148ae6 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.25 2000/10/26 18:44:26 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.26 2000/10/26 19:04:22 roberto Exp roberto $
3** Interface from Lua to its debug API 3** Interface from Lua to its debug API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -179,7 +179,7 @@ static const struct luaL_reg dblib[] = {
179}; 179};
180 180
181 181
182LUA_API void lua_dblibopen (lua_State *L) { 182LUALIB_API void lua_dblibopen (lua_State *L) {
183 luaL_openl(L, dblib); 183 luaL_openl(L, dblib);
184} 184}
185 185
diff --git a/liolib.c b/liolib.c
index d71965a6..6693df33 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 1.88 2000/10/26 12:47:05 roberto Exp roberto $ 2** $Id: liolib.c,v 1.89 2000/10/26 12:53:55 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -712,7 +712,7 @@ static void openwithcontrol (lua_State *L) {
712} 712}
713 713
714 714
715LUA_API void lua_iolibopen (lua_State *L) { 715LUALIB_API void lua_iolibopen (lua_State *L) {
716 luaL_openl(L, iolib); 716 luaL_openl(L, iolib);
717 openwithcontrol(L); 717 openwithcontrol(L);
718} 718}
diff --git a/lmathlib.c b/lmathlib.c
index 6551564a..19e0c5ac 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.29 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.30 2000/10/26 12:47:05 roberto Exp roberto $
3** Standard mathematical library 3** Standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -228,7 +228,7 @@ static const struct luaL_reg mathlib[] = {
228/* 228/*
229** Open math library 229** Open math library
230*/ 230*/
231LUA_API void lua_mathlibopen (lua_State *L) { 231LUALIB_API void lua_mathlibopen (lua_State *L) {
232 luaL_openl(L, mathlib); 232 luaL_openl(L, mathlib);
233 lua_pushcfunction(L, math_pow); 233 lua_pushcfunction(L, math_pow);
234 lua_settagmethod(L, LUA_TNUMBER, "pow"); 234 lua_settagmethod(L, LUA_TNUMBER, "pow");
diff --git a/lstrlib.c b/lstrlib.c
index a82f1b8f..6013de24 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.54 2000/10/05 12:14:08 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.55 2000/10/20 16:39:03 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -616,6 +616,6 @@ static const struct luaL_reg strlib[] = {
616/* 616/*
617** Open string library 617** Open string library
618*/ 618*/
619LUA_API void lua_strlibopen (lua_State *L) { 619LUALIB_API void lua_strlibopen (lua_State *L) {
620 luaL_openl(L, strlib); 620 luaL_openl(L, strlib);
621} 621}
diff --git a/lualib.h b/lualib.h
index 68fa86b3..d39a71bc 100644
--- a/lualib.h
+++ b/lualib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lualib.h,v 1.12 2000/09/12 13:46:59 roberto Exp roberto $ 2** $Id: lualib.h,v 1.13 2000/10/20 16:39:03 roberto Exp roberto $
3** Lua standard libraries 3** Lua standard libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -11,13 +11,18 @@
11#include "lua.h" 11#include "lua.h"
12 12
13 13
14#ifndef LUALIB_API
15#define LUALIB_API extern
16#endif
17
18
14#define LUA_ALERT "_ALERT" 19#define LUA_ALERT "_ALERT"
15 20
16LUA_API void lua_baselibopen (lua_State *L); 21LUALIB_API void lua_baselibopen (lua_State *L);
17LUA_API void lua_iolibopen (lua_State *L); 22LUALIB_API void lua_iolibopen (lua_State *L);
18LUA_API void lua_strlibopen (lua_State *L); 23LUALIB_API void lua_strlibopen (lua_State *L);
19LUA_API void lua_mathlibopen (lua_State *L); 24LUALIB_API void lua_mathlibopen (lua_State *L);
20LUA_API void lua_dblibopen (lua_State *L); 25LUALIB_API void lua_dblibopen (lua_State *L);
21 26
22 27
23 28