diff options
| -rw-r--r-- | lauxlib.c | 36 | ||||
| -rw-r--r-- | lauxlib.h | 41 | ||||
| -rw-r--r-- | lbaselib.c | 4 | ||||
| -rw-r--r-- | ldblib.c | 4 | ||||
| -rw-r--r-- | liolib.c | 4 | ||||
| -rw-r--r-- | lmathlib.c | 4 | ||||
| -rw-r--r-- | lstrlib.c | 4 | ||||
| -rw-r--r-- | lualib.h | 17 |
8 files changed, 62 insertions, 52 deletions
| @@ -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 | ||
| 24 | LUA_API int luaL_findstring (const char *name, const char *const list[]) { | 24 | LUALIB_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 | ||
| 32 | LUA_API void luaL_argerror (lua_State *L, int narg, const char *extramsg) { | 32 | LUALIB_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 | ||
| 52 | LUA_API void luaL_checkstack (lua_State *L, int space, const char *mes) { | 52 | LUALIB_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 | ||
| 58 | LUA_API void luaL_checktype(lua_State *L, int narg, int t) { | 58 | LUALIB_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 | ||
| 64 | LUA_API void luaL_checkany (lua_State *L, int narg) { | 64 | LUALIB_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 | ||
| 70 | LUA_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { | 70 | LUALIB_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 | ||
| 78 | LUA_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, | 78 | LUALIB_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 | ||
| 89 | LUA_API double luaL_check_number (lua_State *L, int narg) { | 89 | LUALIB_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 | ||
| 97 | LUA_API double luaL_opt_number (lua_State *L, int narg, double def) { | 97 | LUALIB_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 | ||
| 103 | LUA_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n) { | 103 | LUALIB_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 | ||
| 110 | LUA_API void luaL_verror (lua_State *L, const char *fmt, ...) { | 110 | LUALIB_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 | ||
| 167 | LUA_API char *luaL_prepbuffer (luaL_Buffer *B) { | 167 | LUALIB_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 | ||
| 174 | LUA_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { | 174 | LUALIB_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 | ||
| 180 | LUA_API void luaL_addstring (luaL_Buffer *B, const char *s) { | 180 | LUALIB_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 | ||
| 185 | LUA_API void luaL_pushresult (luaL_Buffer *B) { | 185 | LUALIB_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 | ||
| 195 | LUA_API void luaL_addvalue (luaL_Buffer *B) { | 195 | LUALIB_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 | ||
| 212 | LUA_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { | 212 | LUALIB_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; |
| @@ -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 | |||
| 18 | struct luaL_reg { | 23 | struct luaL_reg { |
| 19 | const char *name; | 24 | const char *name; |
| 20 | lua_CFunction func; | 25 | lua_CFunction func; |
| 21 | }; | 26 | }; |
| 22 | 27 | ||
| 23 | 28 | ||
| 24 | LUA_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n); | 29 | LUALIB_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n); |
| 25 | LUA_API void luaL_argerror (lua_State *L, int numarg, const char *extramsg); | 30 | LUALIB_API void luaL_argerror (lua_State *L, int numarg, const char *extramsg); |
| 26 | LUA_API const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len); | 31 | LUALIB_API const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len); |
| 27 | LUA_API const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def, | 32 | LUALIB_API const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def, |
| 28 | size_t *len); | 33 | size_t *len); |
| 29 | LUA_API double luaL_check_number (lua_State *L, int numArg); | 34 | LUALIB_API double luaL_check_number (lua_State *L, int numArg); |
| 30 | LUA_API double luaL_opt_number (lua_State *L, int numArg, double def); | 35 | LUALIB_API double luaL_opt_number (lua_State *L, int numArg, double def); |
| 31 | 36 | ||
| 32 | LUA_API void luaL_checkstack (lua_State *L, int space, const char *msg); | 37 | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg); |
| 33 | LUA_API void luaL_checktype (lua_State *L, int narg, int t); | 38 | LUALIB_API void luaL_checktype (lua_State *L, int narg, int t); |
| 34 | LUA_API void luaL_checkany (lua_State *L, int narg); | 39 | LUALIB_API void luaL_checkany (lua_State *L, int narg); |
| 35 | 40 | ||
| 36 | LUA_API void luaL_verror (lua_State *L, const char *fmt, ...); | 41 | LUALIB_API void luaL_verror (lua_State *L, const char *fmt, ...); |
| 37 | LUA_API int luaL_findstring (const char *name, const char *const list[]); | 42 | LUALIB_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 | ||
| 83 | LUA_API void luaL_buffinit (lua_State *L, luaL_Buffer *B); | 88 | LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B); |
| 84 | LUA_API char *luaL_prepbuffer (luaL_Buffer *B); | 89 | LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B); |
| 85 | LUA_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l); | 90 | LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l); |
| 86 | LUA_API void luaL_addstring (luaL_Buffer *B, const char *s); | 91 | LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s); |
| 87 | LUA_API void luaL_addvalue (luaL_Buffer *B); | 92 | LUALIB_API void luaL_addvalue (luaL_Buffer *B); |
| 88 | LUA_API void luaL_pushresult (luaL_Buffer *B); | 93 | LUALIB_API void luaL_pushresult (luaL_Buffer *B); |
| 89 | 94 | ||
| 90 | 95 | ||
| 91 | /* }====================================================== */ | 96 | /* }====================================================== */ |
| @@ -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 | ||
| 642 | LUA_API void lua_baselibopen (lua_State *L) { | 642 | LUALIB_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"); |
| @@ -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 | ||
| 182 | LUA_API void lua_dblibopen (lua_State *L) { | 182 | LUALIB_API void lua_dblibopen (lua_State *L) { |
| 183 | luaL_openl(L, dblib); | 183 | luaL_openl(L, dblib); |
| 184 | } | 184 | } |
| 185 | 185 | ||
| @@ -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 | ||
| 715 | LUA_API void lua_iolibopen (lua_State *L) { | 715 | LUALIB_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 | } |
| @@ -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 | */ |
| 231 | LUA_API void lua_mathlibopen (lua_State *L) { | 231 | LUALIB_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"); |
| @@ -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 | */ |
| 619 | LUA_API void lua_strlibopen (lua_State *L) { | 619 | LUALIB_API void lua_strlibopen (lua_State *L) { |
| 620 | luaL_openl(L, strlib); | 620 | luaL_openl(L, strlib); |
| 621 | } | 621 | } |
| @@ -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 | ||
| 16 | LUA_API void lua_baselibopen (lua_State *L); | 21 | LUALIB_API void lua_baselibopen (lua_State *L); |
| 17 | LUA_API void lua_iolibopen (lua_State *L); | 22 | LUALIB_API void lua_iolibopen (lua_State *L); |
| 18 | LUA_API void lua_strlibopen (lua_State *L); | 23 | LUALIB_API void lua_strlibopen (lua_State *L); |
| 19 | LUA_API void lua_mathlibopen (lua_State *L); | 24 | LUALIB_API void lua_mathlibopen (lua_State *L); |
| 20 | LUA_API void lua_dblibopen (lua_State *L); | 25 | LUALIB_API void lua_dblibopen (lua_State *L); |
| 21 | 26 | ||
| 22 | 27 | ||
| 23 | 28 | ||
