aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-27 14:15:53 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-27 14:15:53 -0200
commit2cbbf3933ac7aa82c788d388b64ad0df7a9d83f6 (patch)
treed2aba2867b81f95ebdf46741e616d8649e9c1a73 /lauxlib.c
parente2b6b7de1b51ac662ad76423e045d0cf3274f051 (diff)
downloadlua-2cbbf3933ac7aa82c788d388b64ad0df7a9d83f6.tar.gz
lua-2cbbf3933ac7aa82c788d388b64ad0df7a9d83f6.tar.bz2
lua-2cbbf3933ac7aa82c788d388b64ad0df7a9d83f6.zip
new macro LUALIB_API (so the lib can be a separate DLL)
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c36
1 files changed, 18 insertions, 18 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;