diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-20 14:39:03 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-20 14:39:03 -0200 |
| commit | 64eecc0b8219cc3bcaa2b717826a4376c60d9305 (patch) | |
| tree | a1633501cdf21016a00bd555c475daea58ec24f5 | |
| parent | 8b88ab07f7cfc216407a88d75ad8f0546224c8d7 (diff) | |
| download | lua-64eecc0b8219cc3bcaa2b717826a4376c60d9305.tar.gz lua-64eecc0b8219cc3bcaa2b717826a4376c60d9305.tar.bz2 lua-64eecc0b8219cc3bcaa2b717826a4376c60d9305.zip | |
new macro LUA_API
| -rw-r--r-- | lapi.c | 99 | ||||
| -rw-r--r-- | lauxlib.c | 40 | ||||
| -rw-r--r-- | lauxlib.h | 40 | ||||
| -rw-r--r-- | lbaselib.c | 4 | ||||
| -rw-r--r-- | ldblib.c | 4 | ||||
| -rw-r--r-- | ldebug.c | 44 | ||||
| -rw-r--r-- | ldo.c | 12 | ||||
| -rw-r--r-- | liolib.c | 4 | ||||
| -rw-r--r-- | llex.c | 4 | ||||
| -rw-r--r-- | lmathlib.c | 4 | ||||
| -rw-r--r-- | lstate.c | 6 | ||||
| -rw-r--r-- | lstrlib.c | 4 | ||||
| -rw-r--r-- | ltests.c | 4 | ||||
| -rw-r--r-- | ltm.c | 10 | ||||
| -rw-r--r-- | lua.h | 127 | ||||
| -rw-r--r-- | luadebug.h | 16 | ||||
| -rw-r--r-- | lualib.h | 12 | ||||
| -rw-r--r-- | lundump.c | 28 | ||||
| -rw-r--r-- | lundump.h | 8 |
19 files changed, 238 insertions, 232 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.105 2000/10/05 12:14:08 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.106 2000/10/06 19:29:26 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 | */ |
| @@ -54,7 +54,7 @@ void luaA_pushobject (lua_State *L, const TObject *o) { | |||
| 54 | incr_top; | 54 | incr_top; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | int lua_stackspace (lua_State *L) { | 57 | LUA_API int lua_stackspace (lua_State *L) { |
| 58 | return (L->stack_last - L->top); | 58 | return (L->stack_last - L->top); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -65,12 +65,12 @@ int lua_stackspace (lua_State *L) { | |||
| 65 | */ | 65 | */ |
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | int lua_gettop (lua_State *L) { | 68 | LUA_API int lua_gettop (lua_State *L) { |
| 69 | return (L->top - L->Cbase); | 69 | return (L->top - L->Cbase); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | 72 | ||
| 73 | void lua_settop (lua_State *L, int index) { | 73 | LUA_API void lua_settop (lua_State *L, int index) { |
| 74 | if (index >= 0) | 74 | if (index >= 0) |
| 75 | luaD_adjusttop(L, L->Cbase, index); | 75 | luaD_adjusttop(L, L->Cbase, index); |
| 76 | else | 76 | else |
| @@ -78,14 +78,14 @@ void lua_settop (lua_State *L, int index) { | |||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | void lua_remove (lua_State *L, int index) { | 81 | LUA_API void lua_remove (lua_State *L, int index) { |
| 82 | StkId p = luaA_index(L, index); | 82 | StkId p = luaA_index(L, index); |
| 83 | while (++p < L->top) *(p-1) = *p; | 83 | while (++p < L->top) *(p-1) = *p; |
| 84 | L->top--; | 84 | L->top--; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | 87 | ||
| 88 | void lua_insert (lua_State *L, int index) { | 88 | LUA_API void lua_insert (lua_State *L, int index) { |
| 89 | StkId p = luaA_index(L, index); | 89 | StkId p = luaA_index(L, index); |
| 90 | StkId q; | 90 | StkId q; |
| 91 | for (q = L->top; q>p; q--) | 91 | for (q = L->top; q>p; q--) |
| @@ -94,7 +94,7 @@ void lua_insert (lua_State *L, int index) { | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | void lua_pushvalue (lua_State *L, int index) { | 97 | LUA_API void lua_pushvalue (lua_State *L, int index) { |
| 98 | *L->top = *luaA_index(L, index); | 98 | *L->top = *luaA_index(L, index); |
| 99 | api_incr_top(L); | 99 | api_incr_top(L); |
| 100 | } | 100 | } |
| @@ -106,50 +106,50 @@ void lua_pushvalue (lua_State *L, int index) { | |||
| 106 | */ | 106 | */ |
| 107 | 107 | ||
| 108 | 108 | ||
| 109 | int lua_type (lua_State *L, int index) { | 109 | LUA_API int lua_type (lua_State *L, int index) { |
| 110 | StkId o = luaA_indexAcceptable(L, index); | 110 | StkId o = luaA_indexAcceptable(L, index); |
| 111 | if (o == NULL) return LUA_TNONE; | 111 | if (o == NULL) return LUA_TNONE; |
| 112 | else return ttype(o); | 112 | else return ttype(o); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | const char *lua_typename (lua_State *L, int t) { | 115 | LUA_API const char *lua_typename (lua_State *L, int t) { |
| 116 | UNUSED(L); | 116 | UNUSED(L); |
| 117 | return luaO_typenames[t]; | 117 | return luaO_typenames[t]; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | 120 | ||
| 121 | int lua_iscfunction (lua_State *L, int index) { | 121 | LUA_API int lua_iscfunction (lua_State *L, int index) { |
| 122 | StkId o = luaA_indexAcceptable(L, index); | 122 | StkId o = luaA_indexAcceptable(L, index); |
| 123 | if (o == NULL) return 0; | 123 | if (o == NULL) return 0; |
| 124 | else return iscfunction(o); | 124 | else return iscfunction(o); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | int lua_isnumber (lua_State *L, int index) { | 127 | LUA_API int lua_isnumber (lua_State *L, int index) { |
| 128 | TObject *o = luaA_indexAcceptable(L, index); | 128 | TObject *o = luaA_indexAcceptable(L, index); |
| 129 | if (o == NULL) return 0; | 129 | if (o == NULL) return 0; |
| 130 | else return (tonumber(o) == 0); | 130 | else return (tonumber(o) == 0); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | int lua_isstring (lua_State *L, int index) { | 133 | LUA_API int lua_isstring (lua_State *L, int index) { |
| 134 | int t = lua_type(L, index); | 134 | int t = lua_type(L, index); |
| 135 | return (t == LUA_TSTRING || t == LUA_TNUMBER); | 135 | return (t == LUA_TSTRING || t == LUA_TNUMBER); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | 138 | ||
| 139 | int lua_tag (lua_State *L, int index) { | 139 | LUA_API int lua_tag (lua_State *L, int index) { |
| 140 | StkId o = luaA_indexAcceptable(L, index); | 140 | StkId o = luaA_indexAcceptable(L, index); |
| 141 | if (o == NULL) return LUA_NOTAG; | 141 | if (o == NULL) return LUA_NOTAG; |
| 142 | else return luaT_tag(o); | 142 | else return luaT_tag(o); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | int lua_equal (lua_State *L, int index1, int index2) { | 145 | LUA_API int lua_equal (lua_State *L, int index1, int index2) { |
| 146 | StkId o1 = luaA_indexAcceptable(L, index1); | 146 | StkId o1 = luaA_indexAcceptable(L, index1); |
| 147 | StkId o2 = luaA_indexAcceptable(L, index2); | 147 | StkId o2 = luaA_indexAcceptable(L, index2); |
| 148 | if (o1 == NULL || o2 == NULL) return 0; /* index out-of-range */ | 148 | if (o1 == NULL || o2 == NULL) return 0; /* index out-of-range */ |
| 149 | else return luaO_equalObj(o1, o2); | 149 | else return luaO_equalObj(o1, o2); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | int lua_lessthan (lua_State *L, int index1, int index2) { | 152 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { |
| 153 | StkId o1 = luaA_indexAcceptable(L, index1); | 153 | StkId o1 = luaA_indexAcceptable(L, index1); |
| 154 | StkId o2 = luaA_indexAcceptable(L, index2); | 154 | StkId o2 = luaA_indexAcceptable(L, index2); |
| 155 | if (o1 == NULL || o2 == NULL) return 0; /* index out-of-range */ | 155 | if (o1 == NULL || o2 == NULL) return 0; /* index out-of-range */ |
| @@ -158,37 +158,37 @@ int lua_lessthan (lua_State *L, int index1, int index2) { | |||
| 158 | 158 | ||
| 159 | 159 | ||
| 160 | 160 | ||
| 161 | double lua_tonumber (lua_State *L, int index) { | 161 | LUA_API double lua_tonumber (lua_State *L, int index) { |
| 162 | StkId o = luaA_indexAcceptable(L, index); | 162 | StkId o = luaA_indexAcceptable(L, index); |
| 163 | if (o == NULL || tonumber(o)) return 0; | 163 | if (o == NULL || tonumber(o)) return 0; |
| 164 | else return nvalue(o); | 164 | else return nvalue(o); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | const char *lua_tostring (lua_State *L, int index) { | 167 | LUA_API const char *lua_tostring (lua_State *L, int index) { |
| 168 | StkId o = luaA_indexAcceptable(L, index); | 168 | StkId o = luaA_indexAcceptable(L, index); |
| 169 | if (o == NULL || tostring(L, o)) return NULL; | 169 | if (o == NULL || tostring(L, o)) return NULL; |
| 170 | else return svalue(o); | 170 | else return svalue(o); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | size_t lua_strlen (lua_State *L, int index) { | 173 | LUA_API size_t lua_strlen (lua_State *L, int index) { |
| 174 | StkId o = luaA_indexAcceptable(L, index); | 174 | StkId o = luaA_indexAcceptable(L, index); |
| 175 | if (o == NULL || tostring(L, o)) return 0; | 175 | if (o == NULL || tostring(L, o)) return 0; |
| 176 | else return tsvalue(o)->u.s.len; | 176 | else return tsvalue(o)->u.s.len; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | lua_CFunction lua_tocfunction (lua_State *L, int index) { | 179 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { |
| 180 | StkId o = luaA_indexAcceptable(L, index); | 180 | StkId o = luaA_indexAcceptable(L, index); |
| 181 | if (o == NULL || !iscfunction(o)) return NULL; | 181 | if (o == NULL || !iscfunction(o)) return NULL; |
| 182 | else return clvalue(o)->f.c; | 182 | else return clvalue(o)->f.c; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | void *lua_touserdata (lua_State *L, int index) { | 185 | LUA_API void *lua_touserdata (lua_State *L, int index) { |
| 186 | StkId o = luaA_indexAcceptable(L, index); | 186 | StkId o = luaA_indexAcceptable(L, index); |
| 187 | if (o == NULL || ttype(o) != LUA_TUSERDATA) return NULL; | 187 | if (o == NULL || ttype(o) != LUA_TUSERDATA) return NULL; |
| 188 | else return tsvalue(o)->u.d.value; | 188 | else return tsvalue(o)->u.d.value; |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | const void *lua_topointer (lua_State *L, int index) { | 191 | LUA_API const void *lua_topointer (lua_State *L, int index) { |
| 192 | StkId o = luaA_indexAcceptable(L, index); | 192 | StkId o = luaA_indexAcceptable(L, index); |
| 193 | if (o == NULL) return NULL; | 193 | if (o == NULL) return NULL; |
| 194 | switch (ttype(o)) { | 194 | switch (ttype(o)) { |
| @@ -207,27 +207,27 @@ const void *lua_topointer (lua_State *L, int index) { | |||
| 207 | */ | 207 | */ |
| 208 | 208 | ||
| 209 | 209 | ||
| 210 | void lua_pushnil (lua_State *L) { | 210 | LUA_API void lua_pushnil (lua_State *L) { |
| 211 | ttype(L->top) = LUA_TNIL; | 211 | ttype(L->top) = LUA_TNIL; |
| 212 | api_incr_top(L); | 212 | api_incr_top(L); |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | 215 | ||
| 216 | void lua_pushnumber (lua_State *L, double n) { | 216 | LUA_API void lua_pushnumber (lua_State *L, double n) { |
| 217 | nvalue(L->top) = n; | 217 | nvalue(L->top) = n; |
| 218 | ttype(L->top) = LUA_TNUMBER; | 218 | ttype(L->top) = LUA_TNUMBER; |
| 219 | api_incr_top(L); | 219 | api_incr_top(L); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | 222 | ||
| 223 | void lua_pushlstring (lua_State *L, const char *s, size_t len) { | 223 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { |
| 224 | tsvalue(L->top) = luaS_newlstr(L, s, len); | 224 | tsvalue(L->top) = luaS_newlstr(L, s, len); |
| 225 | ttype(L->top) = LUA_TSTRING; | 225 | ttype(L->top) = LUA_TSTRING; |
| 226 | api_incr_top(L); | 226 | api_incr_top(L); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | 229 | ||
| 230 | void lua_pushstring (lua_State *L, const char *s) { | 230 | LUA_API void lua_pushstring (lua_State *L, const char *s) { |
| 231 | if (s == NULL) | 231 | if (s == NULL) |
| 232 | lua_pushnil(L); | 232 | lua_pushnil(L); |
| 233 | else | 233 | else |
| @@ -235,12 +235,13 @@ void lua_pushstring (lua_State *L, const char *s) { | |||
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | 237 | ||
| 238 | void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { | 238 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { |
| 239 | luaV_Cclosure(L, fn, n); | 239 | luaV_Cclosure(L, fn, n); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | 242 | ||
| 243 | void lua_pushusertag (lua_State *L, void *u, int tag) { /* ORDER LUA_T */ | 243 | LUA_API void lua_pushusertag (lua_State *L, void *u, int tag) { |
| 244 | /* ORDER LUA_T */ | ||
| 244 | if (!(tag == LUA_ANYTAG || tag == LUA_TUSERDATA || validtag(tag))) | 245 | if (!(tag == LUA_ANYTAG || tag == LUA_TUSERDATA || validtag(tag))) |
| 245 | luaO_verror(L, "invalid tag for a userdata (%d)", tag); | 246 | luaO_verror(L, "invalid tag for a userdata (%d)", tag); |
| 246 | tsvalue(L->top) = luaS_createudata(L, u, tag); | 247 | tsvalue(L->top) = luaS_createudata(L, u, tag); |
| @@ -255,7 +256,7 @@ void lua_pushusertag (lua_State *L, void *u, int tag) { /* ORDER LUA_T */ | |||
| 255 | */ | 256 | */ |
| 256 | 257 | ||
| 257 | 258 | ||
| 258 | void lua_getglobal (lua_State *L, const char *name) { | 259 | LUA_API void lua_getglobal (lua_State *L, const char *name) { |
| 259 | StkId top = L->top; | 260 | StkId top = L->top; |
| 260 | *top = *luaV_getglobal(L, luaS_new(L, name)); | 261 | *top = *luaV_getglobal(L, luaS_new(L, name)); |
| 261 | L->top = top; | 262 | L->top = top; |
| @@ -263,7 +264,7 @@ void lua_getglobal (lua_State *L, const char *name) { | |||
| 263 | } | 264 | } |
| 264 | 265 | ||
| 265 | 266 | ||
| 266 | void lua_gettable (lua_State *L, int index) { | 267 | LUA_API void lua_gettable (lua_State *L, int index) { |
| 267 | StkId t = Index(L, index); | 268 | StkId t = Index(L, index); |
| 268 | StkId top = L->top; | 269 | StkId top = L->top; |
| 269 | *(top-1) = *luaV_gettable(L, t); | 270 | *(top-1) = *luaV_gettable(L, t); |
| @@ -271,14 +272,14 @@ void lua_gettable (lua_State *L, int index) { | |||
| 271 | } | 272 | } |
| 272 | 273 | ||
| 273 | 274 | ||
| 274 | void lua_rawget (lua_State *L, int index) { | 275 | LUA_API void lua_rawget (lua_State *L, int index) { |
| 275 | StkId t = Index(L, index); | 276 | StkId t = Index(L, index); |
| 276 | LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected"); | 277 | LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected"); |
| 277 | *(L->top - 1) = *luaH_get(L, hvalue(t), L->top - 1); | 278 | *(L->top - 1) = *luaH_get(L, hvalue(t), L->top - 1); |
| 278 | } | 279 | } |
| 279 | 280 | ||
| 280 | 281 | ||
| 281 | void lua_rawgeti (lua_State *L, int index, int n) { | 282 | LUA_API void lua_rawgeti (lua_State *L, int index, int n) { |
| 282 | StkId o = Index(L, index); | 283 | StkId o = Index(L, index); |
| 283 | LUA_ASSERT(ttype(o) == LUA_TTABLE, "table expected"); | 284 | LUA_ASSERT(ttype(o) == LUA_TTABLE, "table expected"); |
| 284 | *L->top = *luaH_getnum(hvalue(o), n); | 285 | *L->top = *luaH_getnum(hvalue(o), n); |
| @@ -286,14 +287,14 @@ void lua_rawgeti (lua_State *L, int index, int n) { | |||
| 286 | } | 287 | } |
| 287 | 288 | ||
| 288 | 289 | ||
| 289 | void lua_getglobals (lua_State *L) { | 290 | LUA_API void lua_getglobals (lua_State *L) { |
| 290 | hvalue(L->top) = L->gt; | 291 | hvalue(L->top) = L->gt; |
| 291 | ttype(L->top) = LUA_TTABLE; | 292 | ttype(L->top) = LUA_TTABLE; |
| 292 | api_incr_top(L); | 293 | api_incr_top(L); |
| 293 | } | 294 | } |
| 294 | 295 | ||
| 295 | 296 | ||
| 296 | int lua_getref (lua_State *L, int ref) { | 297 | LUA_API int lua_getref (lua_State *L, int ref) { |
| 297 | if (ref == LUA_REFNIL) | 298 | if (ref == LUA_REFNIL) |
| 298 | ttype(L->top) = LUA_TNIL; | 299 | ttype(L->top) = LUA_TNIL; |
| 299 | else if (0 <= ref && ref < L->refSize && | 300 | else if (0 <= ref && ref < L->refSize && |
| @@ -306,7 +307,7 @@ int lua_getref (lua_State *L, int ref) { | |||
| 306 | } | 307 | } |
| 307 | 308 | ||
| 308 | 309 | ||
| 309 | void lua_newtable (lua_State *L) { | 310 | LUA_API void lua_newtable (lua_State *L) { |
| 310 | hvalue(L->top) = luaH_new(L, 0); | 311 | hvalue(L->top) = luaH_new(L, 0); |
| 311 | ttype(L->top) = LUA_TTABLE; | 312 | ttype(L->top) = LUA_TTABLE; |
| 312 | api_incr_top(L); | 313 | api_incr_top(L); |
| @@ -319,14 +320,14 @@ void lua_newtable (lua_State *L) { | |||
| 319 | */ | 320 | */ |
| 320 | 321 | ||
| 321 | 322 | ||
| 322 | void lua_setglobal (lua_State *L, const char *name) { | 323 | LUA_API void lua_setglobal (lua_State *L, const char *name) { |
| 323 | StkId top = L->top; | 324 | StkId top = L->top; |
| 324 | luaV_setglobal(L, luaS_new(L, name)); | 325 | luaV_setglobal(L, luaS_new(L, name)); |
| 325 | L->top = top-1; /* remove element from the top */ | 326 | L->top = top-1; /* remove element from the top */ |
| 326 | } | 327 | } |
| 327 | 328 | ||
| 328 | 329 | ||
| 329 | void lua_settable (lua_State *L, int index) { | 330 | LUA_API void lua_settable (lua_State *L, int index) { |
| 330 | StkId t = Index(L, index); | 331 | StkId t = Index(L, index); |
| 331 | StkId top = L->top; | 332 | StkId top = L->top; |
| 332 | luaV_settable(L, t, top-2); | 333 | luaV_settable(L, t, top-2); |
| @@ -334,7 +335,7 @@ void lua_settable (lua_State *L, int index) { | |||
| 334 | } | 335 | } |
| 335 | 336 | ||
| 336 | 337 | ||
| 337 | void lua_rawset (lua_State *L, int index) { | 338 | LUA_API void lua_rawset (lua_State *L, int index) { |
| 338 | StkId t = Index(L, index); | 339 | StkId t = Index(L, index); |
| 339 | LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected"); | 340 | LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected"); |
| 340 | *luaH_set(L, hvalue(t), L->top-2) = *(L->top-1); | 341 | *luaH_set(L, hvalue(t), L->top-2) = *(L->top-1); |
| @@ -342,7 +343,7 @@ void lua_rawset (lua_State *L, int index) { | |||
| 342 | } | 343 | } |
| 343 | 344 | ||
| 344 | 345 | ||
| 345 | void lua_rawseti (lua_State *L, int index, int n) { | 346 | LUA_API void lua_rawseti (lua_State *L, int index, int n) { |
| 346 | StkId o = Index(L, index); | 347 | StkId o = Index(L, index); |
| 347 | LUA_ASSERT(ttype(o) == LUA_TTABLE, "table expected"); | 348 | LUA_ASSERT(ttype(o) == LUA_TTABLE, "table expected"); |
| 348 | *luaH_setint(L, hvalue(o), n) = *(L->top-1); | 349 | *luaH_setint(L, hvalue(o), n) = *(L->top-1); |
| @@ -350,14 +351,14 @@ void lua_rawseti (lua_State *L, int index, int n) { | |||
| 350 | } | 351 | } |
| 351 | 352 | ||
| 352 | 353 | ||
| 353 | void lua_setglobals (lua_State *L) { | 354 | LUA_API void lua_setglobals (lua_State *L) { |
| 354 | StkId newtable = --L->top; | 355 | StkId newtable = --L->top; |
| 355 | LUA_ASSERT(ttype(newtable) == LUA_TTABLE, "table expected"); | 356 | LUA_ASSERT(ttype(newtable) == LUA_TTABLE, "table expected"); |
| 356 | L->gt = hvalue(newtable); | 357 | L->gt = hvalue(newtable); |
| 357 | } | 358 | } |
| 358 | 359 | ||
| 359 | 360 | ||
| 360 | int lua_ref (lua_State *L, int lock) { | 361 | LUA_API int lua_ref (lua_State *L, int lock) { |
| 361 | int ref; | 362 | int ref; |
| 362 | if (ttype(L->top-1) == LUA_TNIL) | 363 | if (ttype(L->top-1) == LUA_TNIL) |
| 363 | ref = LUA_REFNIL; | 364 | ref = LUA_REFNIL; |
| @@ -385,7 +386,7 @@ int lua_ref (lua_State *L, int lock) { | |||
| 385 | ** (most of them are in ldo.c) | 386 | ** (most of them are in ldo.c) |
| 386 | */ | 387 | */ |
| 387 | 388 | ||
| 388 | void lua_rawcall (lua_State *L, int nargs, int nresults) { | 389 | LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) { |
| 389 | luaD_call(L, L->top-(nargs+1), nresults); | 390 | luaD_call(L, L->top-(nargs+1), nresults); |
| 390 | } | 391 | } |
| 391 | 392 | ||
| @@ -398,15 +399,15 @@ void lua_rawcall (lua_State *L, int nargs, int nresults) { | |||
| 398 | #define GCscale(x) ((int)((x)>>10)) | 399 | #define GCscale(x) ((int)((x)>>10)) |
| 399 | #define GCunscale(x) ((unsigned long)(x)<<10) | 400 | #define GCunscale(x) ((unsigned long)(x)<<10) |
| 400 | 401 | ||
| 401 | int lua_getgcthreshold (lua_State *L) { | 402 | LUA_API int lua_getgcthreshold (lua_State *L) { |
| 402 | return GCscale(L->GCthreshold); | 403 | return GCscale(L->GCthreshold); |
| 403 | } | 404 | } |
| 404 | 405 | ||
| 405 | int lua_getgccount (lua_State *L) { | 406 | LUA_API int lua_getgccount (lua_State *L) { |
| 406 | return GCscale(L->nblocks); | 407 | return GCscale(L->nblocks); |
| 407 | } | 408 | } |
| 408 | 409 | ||
| 409 | void lua_setgcthreshold (lua_State *L, int newthreshold) { | 410 | LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { |
| 410 | if (newthreshold > GCscale(ULONG_MAX)) | 411 | if (newthreshold > GCscale(ULONG_MAX)) |
| 411 | L->GCthreshold = ULONG_MAX; | 412 | L->GCthreshold = ULONG_MAX; |
| 412 | else | 413 | else |
| @@ -419,7 +420,7 @@ void lua_setgcthreshold (lua_State *L, int newthreshold) { | |||
| 419 | ** miscellaneous functions | 420 | ** miscellaneous functions |
| 420 | */ | 421 | */ |
| 421 | 422 | ||
| 422 | void lua_settag (lua_State *L, int tag) { | 423 | LUA_API void lua_settag (lua_State *L, int tag) { |
| 423 | luaT_realtag(L, tag); | 424 | luaT_realtag(L, tag); |
| 424 | switch (ttype(L->top-1)) { | 425 | switch (ttype(L->top-1)) { |
| 425 | case LUA_TTABLE: | 426 | case LUA_TTABLE: |
| @@ -436,7 +437,7 @@ void lua_settag (lua_State *L, int tag) { | |||
| 436 | } | 437 | } |
| 437 | 438 | ||
| 438 | 439 | ||
| 439 | void lua_unref (lua_State *L, int ref) { | 440 | LUA_API void lua_unref (lua_State *L, int ref) { |
| 440 | if (ref >= 0) { | 441 | if (ref >= 0) { |
| 441 | LUA_ASSERT(ref < L->refSize && L->refArray[ref].st < 0, "invalid ref"); | 442 | LUA_ASSERT(ref < L->refSize && L->refArray[ref].st < 0, "invalid ref"); |
| 442 | L->refArray[ref].st = L->refFree; | 443 | L->refArray[ref].st = L->refFree; |
| @@ -445,7 +446,7 @@ void lua_unref (lua_State *L, int ref) { | |||
| 445 | } | 446 | } |
| 446 | 447 | ||
| 447 | 448 | ||
| 448 | int lua_next (lua_State *L, int index) { | 449 | LUA_API int lua_next (lua_State *L, int index) { |
| 449 | StkId t = luaA_index(L, index); | 450 | StkId t = luaA_index(L, index); |
| 450 | Node *n; | 451 | Node *n; |
| 451 | LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected"); | 452 | LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected"); |
| @@ -463,7 +464,7 @@ int lua_next (lua_State *L, int index) { | |||
| 463 | } | 464 | } |
| 464 | 465 | ||
| 465 | 466 | ||
| 466 | int lua_getn (lua_State *L, int index) { | 467 | LUA_API int lua_getn (lua_State *L, int index) { |
| 467 | Hash *h = hvalue(luaA_index(L, index)); | 468 | Hash *h = hvalue(luaA_index(L, index)); |
| 468 | const TObject *value = luaH_getstr(h, luaS_new(L, "n")); /* value = h.n */ | 469 | const TObject *value = luaH_getstr(h, luaS_new(L, "n")); /* value = h.n */ |
| 469 | if (ttype(value) == LUA_TNUMBER) | 470 | if (ttype(value) == LUA_TNUMBER) |
| @@ -484,7 +485,7 @@ int lua_getn (lua_State *L, int index) { | |||
| 484 | } | 485 | } |
| 485 | 486 | ||
| 486 | 487 | ||
| 487 | void lua_concat (lua_State *L, int n) { | 488 | LUA_API void lua_concat (lua_State *L, int n) { |
| 488 | StkId top = L->top; | 489 | StkId top = L->top; |
| 489 | luaV_strconc(L, n, top); | 490 | luaV_strconc(L, n, top); |
| 490 | L->top = top-(n-1); | 491 | L->top = top-(n-1); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.38 2000/10/02 20:10:55 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.39 2000/10/05 12:14:08 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 | int luaL_findstring (const char *name, const char *const list[]) { | 24 | LUA_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 @@ 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 | void luaL_argerror (lua_State *L, int narg, const char *extramsg) { | 32 | LUA_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); |
| @@ -42,32 +42,32 @@ void luaL_argerror (lua_State *L, int narg, const char *extramsg) { | |||
| 42 | 42 | ||
| 43 | static void type_error (lua_State *L, int narg, int t) { | 43 | static void type_error (lua_State *L, int narg, int t) { |
| 44 | char buff[100]; | 44 | char buff[100]; |
| 45 | const char *rt = lua_typename(L, lua_type(L, narg)); | 45 | int tt = lua_type(L, narg); |
| 46 | if (*rt == 'N') rt = "no value"; | 46 | const char *rt = (tt == LUA_TNONE) ? "no value" : lua_typename(L, tt); |
| 47 | sprintf(buff, "%.10s expected, got %.10s", lua_typename(L, t), rt); | 47 | sprintf(buff, "%.10s expected, got %.10s", lua_typename(L, t), rt); |
| 48 | luaL_argerror(L, narg, buff); | 48 | luaL_argerror(L, narg, buff); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | void luaL_checkstack (lua_State *L, int space, const char *mes) { | 52 | LUA_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 | void luaL_checktype(lua_State *L, int narg, int t) { | 58 | LUA_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 | void luaL_checkany (lua_State *L, int narg) { | 64 | LUA_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 | const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { | 70 | LUA_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 @@ const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { | |||
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, | 78 | LUA_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 @@ const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | 88 | ||
| 89 | double luaL_check_number (lua_State *L, int narg) { | 89 | LUA_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 @@ double luaL_check_number (lua_State *L, int narg) { | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | double luaL_opt_number (lua_State *L, int narg, double def) { | 97 | LUA_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 | void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n) { | 103 | LUA_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 | void luaL_verror (lua_State *L, const char *fmt, ...) { | 110 | LUA_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 | char *luaL_prepbuffer (luaL_Buffer *B) { | 167 | LUA_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 | void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { | 174 | LUA_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 | void luaL_addstring (luaL_Buffer *B, const char *s) { | 180 | LUA_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 | void luaL_pushresult (luaL_Buffer *B) { | 185 | LUA_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 @@ void luaL_pushresult (luaL_Buffer *B) { | |||
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | 194 | ||
| 195 | void luaL_addvalue (luaL_Buffer *B) { | 195 | LUA_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 @@ void luaL_addvalue (luaL_Buffer *B) { | |||
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | 211 | ||
| 212 | void luaL_buffinit (lua_State *L, luaL_Buffer *B) { | 212 | LUA_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.26 2000/10/02 20:10:55 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.27 2000/10/05 12:14:08 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,20 +21,20 @@ struct luaL_reg { | |||
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n); | 24 | LUA_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n); |
| 25 | void luaL_argerror (lua_State *L, int numarg, const char *extramsg); | 25 | LUA_API void luaL_argerror (lua_State *L, int numarg, const char *extramsg); |
| 26 | const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len); | 26 | LUA_API const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len); |
| 27 | const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def, | 27 | LUA_API const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def, |
| 28 | size_t *len); | 28 | size_t *len); |
| 29 | double luaL_check_number (lua_State *L, int numArg); | 29 | LUA_API double luaL_check_number (lua_State *L, int numArg); |
| 30 | double luaL_opt_number (lua_State *L, int numArg, double def); | 30 | LUA_API double luaL_opt_number (lua_State *L, int numArg, double def); |
| 31 | 31 | ||
| 32 | void luaL_checkstack (lua_State *L, int space, const char *msg); | 32 | LUA_API void luaL_checkstack (lua_State *L, int space, const char *msg); |
| 33 | void luaL_checktype (lua_State *L, int narg, int t); | 33 | LUA_API void luaL_checktype (lua_State *L, int narg, int t); |
| 34 | void luaL_checkany (lua_State *L, int narg); | 34 | LUA_API void luaL_checkany (lua_State *L, int narg); |
| 35 | 35 | ||
| 36 | void luaL_verror (lua_State *L, const char *fmt, ...); | 36 | LUA_API void luaL_verror (lua_State *L, const char *fmt, ...); |
| 37 | int luaL_findstring (const char *name, const char *const list[]); | 37 | LUA_API int luaL_findstring (const char *name, const char *const list[]); |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | 40 | ||
| @@ -62,7 +62,9 @@ int luaL_findstring (const char *name, const char *const list[]); | |||
| 62 | */ | 62 | */ |
| 63 | 63 | ||
| 64 | 64 | ||
| 65 | #ifndef LUAL_BUFFERSIZE | ||
| 65 | #define LUAL_BUFFERSIZE BUFSIZ | 66 | #define LUAL_BUFFERSIZE BUFSIZ |
| 67 | #endif | ||
| 66 | 68 | ||
| 67 | 69 | ||
| 68 | typedef struct luaL_Buffer { | 70 | typedef struct luaL_Buffer { |
| @@ -78,12 +80,12 @@ typedef struct luaL_Buffer { | |||
| 78 | 80 | ||
| 79 | #define luaL_addsize(B,n) ((B)->p += (n)) | 81 | #define luaL_addsize(B,n) ((B)->p += (n)) |
| 80 | 82 | ||
| 81 | void luaL_buffinit (lua_State *L, luaL_Buffer *B); | 83 | LUA_API void luaL_buffinit (lua_State *L, luaL_Buffer *B); |
| 82 | char *luaL_prepbuffer (luaL_Buffer *B); | 84 | LUA_API char *luaL_prepbuffer (luaL_Buffer *B); |
| 83 | void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l); | 85 | LUA_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l); |
| 84 | void luaL_addstring (luaL_Buffer *B, const char *s); | 86 | LUA_API void luaL_addstring (luaL_Buffer *B, const char *s); |
| 85 | void luaL_addvalue (luaL_Buffer *B); | 87 | LUA_API void luaL_addvalue (luaL_Buffer *B); |
| 86 | void luaL_pushresult (luaL_Buffer *B); | 88 | LUA_API void luaL_pushresult (luaL_Buffer *B); |
| 87 | 89 | ||
| 88 | 90 | ||
| 89 | /* }====================================================== */ | 91 | /* }====================================================== */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.10 2000/10/06 19:13:29 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.11 2000/10/09 15:46:43 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 | */ |
| @@ -636,7 +636,7 @@ static const struct luaL_reg base_funcs[] = { | |||
| 636 | 636 | ||
| 637 | 637 | ||
| 638 | 638 | ||
| 639 | void lua_baselibopen (lua_State *L) { | 639 | LUA_API void lua_baselibopen (lua_State *L) { |
| 640 | luaL_openl(L, base_funcs); | 640 | luaL_openl(L, base_funcs); |
| 641 | lua_pushstring(L, LUA_VERSION); | 641 | lua_pushstring(L, LUA_VERSION); |
| 642 | lua_setglobal(L, "_VERSION"); | 642 | lua_setglobal(L, "_VERSION"); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldblib.c,v 1.21 2000/09/12 18:38:25 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.22 2000/10/02 20:10:55 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 | */ |
| @@ -174,7 +174,7 @@ static const struct luaL_reg dblib[] = { | |||
| 174 | }; | 174 | }; |
| 175 | 175 | ||
| 176 | 176 | ||
| 177 | void lua_dblibopen (lua_State *L) { | 177 | LUA_API void lua_dblibopen (lua_State *L) { |
| 178 | luaL_openl(L, dblib); | 178 | luaL_openl(L, dblib); |
| 179 | } | 179 | } |
| 180 | 180 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 1.46 2000/10/06 12:45:25 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.47 2000/10/09 13:47:32 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 | */ |
| @@ -41,14 +41,14 @@ static int isLmark (StkId o) { | |||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | lua_Hook lua_setcallhook (lua_State *L, lua_Hook func) { | 44 | LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func) { |
| 45 | lua_Hook oldhook = L->callhook; | 45 | lua_Hook oldhook = L->callhook; |
| 46 | L->callhook = func; | 46 | L->callhook = func; |
| 47 | return oldhook; | 47 | return oldhook; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) { | 51 | LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) { |
| 52 | lua_Hook oldhook = L->linehook; | 52 | lua_Hook oldhook = L->linehook; |
| 53 | L->linehook = func; | 53 | L->linehook = func; |
| 54 | return oldhook; | 54 | return oldhook; |
| @@ -68,7 +68,7 @@ static StkId aux_stackedfunction (lua_State *L, int level, StkId top) { | |||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | int lua_getstack (lua_State *L, int level, lua_Debug *ar) { | 71 | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { |
| 72 | StkId f = aux_stackedfunction(L, level, L->top); | 72 | StkId f = aux_stackedfunction(L, level, L->top); |
| 73 | if (f == NULL) return 0; /* there is no such level */ | 73 | if (f == NULL) return 0; /* there is no such level */ |
| 74 | else { | 74 | else { |
| @@ -78,7 +78,7 @@ int lua_getstack (lua_State *L, int level, lua_Debug *ar) { | |||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | static int lua_nups (StkId f) { | 81 | static int nups (StkId f) { |
| 82 | switch (ttype(f)) { | 82 | switch (ttype(f)) { |
| 83 | case LUA_TFUNCTION: | 83 | case LUA_TFUNCTION: |
| 84 | return clvalue(f)->nupvalues; | 84 | return clvalue(f)->nupvalues; |
| @@ -121,7 +121,7 @@ int luaG_getline (int *lineinfo, int pc, int refline, int *prefi) { | |||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | 123 | ||
| 124 | static int lua_currentpc (StkId f) { | 124 | static int currentpc (StkId f) { |
| 125 | CallInfo *ci = infovalue(f); | 125 | CallInfo *ci = infovalue(f); |
| 126 | LUA_ASSERT(isLmark(f), "function has no pc"); | 126 | LUA_ASSERT(isLmark(f), "function has no pc"); |
| 127 | if (ci->pc) | 127 | if (ci->pc) |
| @@ -131,13 +131,13 @@ static int lua_currentpc (StkId f) { | |||
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | 133 | ||
| 134 | static int lua_currentline (StkId f) { | 134 | static int currentline (StkId f) { |
| 135 | if (!isLmark(f)) | 135 | if (!isLmark(f)) |
| 136 | return -1; /* only active lua functions have current-line information */ | 136 | return -1; /* only active lua functions have current-line information */ |
| 137 | else { | 137 | else { |
| 138 | CallInfo *ci = infovalue(f); | 138 | CallInfo *ci = infovalue(f); |
| 139 | int *lineinfo = ci->func->f.l->lineinfo; | 139 | int *lineinfo = ci->func->f.l->lineinfo; |
| 140 | return luaG_getline(lineinfo, lua_currentpc(f), 1, NULL); | 140 | return luaG_getline(lineinfo, currentpc(f), 1, NULL); |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | 143 | ||
| @@ -148,25 +148,27 @@ static Proto *getluaproto (StkId f) { | |||
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | 150 | ||
| 151 | const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int localnum) { | 151 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, |
| 152 | int localnum) { | ||
| 152 | const char *name; | 153 | const char *name; |
| 153 | StkId f = ar->_func; | 154 | StkId f = ar->_func; |
| 154 | Proto *fp = getluaproto(f); | 155 | Proto *fp = getluaproto(f); |
| 155 | if (!fp) return NULL; /* `f' is not a Lua function? */ | 156 | if (!fp) return NULL; /* `f' is not a Lua function? */ |
| 156 | name = luaF_getlocalname(fp, localnum, lua_currentpc(f)); | 157 | name = luaF_getlocalname(fp, localnum, currentpc(f)); |
| 157 | if (!name) return NULL; | 158 | if (!name) return NULL; |
| 158 | luaA_pushobject(L, (f+1)+(localnum-1)); /* push value */ | 159 | luaA_pushobject(L, (f+1)+(localnum-1)); /* push value */ |
| 159 | return name; | 160 | return name; |
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | 163 | ||
| 163 | const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int localnum) { | 164 | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, |
| 165 | int localnum) { | ||
| 164 | const char *name; | 166 | const char *name; |
| 165 | StkId f = ar->_func; | 167 | StkId f = ar->_func; |
| 166 | Proto *fp = getluaproto(f); | 168 | Proto *fp = getluaproto(f); |
| 167 | L->top--; /* pop new value */ | 169 | L->top--; /* pop new value */ |
| 168 | if (!fp) return NULL; /* `f' is not a Lua function? */ | 170 | if (!fp) return NULL; /* `f' is not a Lua function? */ |
| 169 | name = luaF_getlocalname(fp, localnum, lua_currentpc(f)); | 171 | name = luaF_getlocalname(fp, localnum, currentpc(f)); |
| 170 | if (!name || name[0] == '*') return NULL; /* `*' starts private locals */ | 172 | if (!name || name[0] == '*') return NULL; /* `*' starts private locals */ |
| 171 | *((f+1)+(localnum-1)) = *L->top; | 173 | *((f+1)+(localnum-1)) = *L->top; |
| 172 | return name; | 174 | return name; |
| @@ -180,7 +182,7 @@ static void infoLproto (lua_Debug *ar, Proto *f) { | |||
| 180 | } | 182 | } |
| 181 | 183 | ||
| 182 | 184 | ||
| 183 | static void lua_funcinfo (lua_State *L, lua_Debug *ar, StkId func) { | 185 | static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) { |
| 184 | Closure *cl = NULL; | 186 | Closure *cl = NULL; |
| 185 | switch (ttype(func)) { | 187 | switch (ttype(func)) { |
| 186 | case LUA_TFUNCTION: | 188 | case LUA_TFUNCTION: |
| @@ -231,7 +233,7 @@ static const char *travglobals (lua_State *L, const TObject *o) { | |||
| 231 | } | 233 | } |
| 232 | 234 | ||
| 233 | 235 | ||
| 234 | static void lua_getname (lua_State *L, StkId f, lua_Debug *ar) { | 236 | static void getname (lua_State *L, StkId f, lua_Debug *ar) { |
| 235 | TObject o; | 237 | TObject o; |
| 236 | setnormalized(&o, f); | 238 | setnormalized(&o, f); |
| 237 | /* try to find a name for given function */ | 239 | /* try to find a name for given function */ |
| @@ -244,7 +246,7 @@ static void lua_getname (lua_State *L, StkId f, lua_Debug *ar) { | |||
| 244 | } | 246 | } |
| 245 | 247 | ||
| 246 | 248 | ||
| 247 | int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | 249 | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { |
| 248 | StkId func; | 250 | StkId func; |
| 249 | int isactive = (*what != '>'); | 251 | int isactive = (*what != '>'); |
| 250 | if (isactive) | 252 | if (isactive) |
| @@ -256,21 +258,21 @@ int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
| 256 | for (; *what; what++) { | 258 | for (; *what; what++) { |
| 257 | switch (*what) { | 259 | switch (*what) { |
| 258 | case 'S': { | 260 | case 'S': { |
| 259 | lua_funcinfo(L, ar, func); | 261 | funcinfo(L, ar, func); |
| 260 | break; | 262 | break; |
| 261 | } | 263 | } |
| 262 | case 'l': { | 264 | case 'l': { |
| 263 | ar->currentline = lua_currentline(func); | 265 | ar->currentline = currentline(func); |
| 264 | break; | 266 | break; |
| 265 | } | 267 | } |
| 266 | case 'u': { | 268 | case 'u': { |
| 267 | ar->nups = lua_nups(func); | 269 | ar->nups = nups(func); |
| 268 | break; | 270 | break; |
| 269 | } | 271 | } |
| 270 | case 'n': { | 272 | case 'n': { |
| 271 | ar->namewhat = (isactive) ? getfuncname(L, func, &ar->name) : NULL; | 273 | ar->namewhat = (isactive) ? getfuncname(L, func, &ar->name) : NULL; |
| 272 | if (ar->namewhat == NULL) | 274 | if (ar->namewhat == NULL) |
| 273 | lua_getname(L, func, ar); | 275 | getname(L, func, ar); |
| 274 | break; | 276 | break; |
| 275 | } | 277 | } |
| 276 | case 'f': { | 278 | case 'f': { |
| @@ -387,7 +389,7 @@ static const char *getobjname (lua_State *L, StkId obj, const char **name) { | |||
| 387 | return NULL; /* not an active Lua function */ | 389 | return NULL; /* not an active Lua function */ |
| 388 | else { | 390 | else { |
| 389 | Proto *p = infovalue(func)->func->f.l; | 391 | Proto *p = infovalue(func)->func->f.l; |
| 390 | int pc = lua_currentpc(func); | 392 | int pc = currentpc(func); |
| 391 | int stackpos = obj - (func+1); /* func+1 == function base */ | 393 | int stackpos = obj - (func+1); /* func+1 == function base */ |
| 392 | Instruction i = luaG_symbexec(p, pc, stackpos); | 394 | Instruction i = luaG_symbexec(p, pc, stackpos); |
| 393 | LUA_ASSERT(pc != -1, "function must be active"); | 395 | LUA_ASSERT(pc != -1, "function must be active"); |
| @@ -419,7 +421,7 @@ static const char *getfuncname (lua_State *L, StkId f, const char **name) { | |||
| 419 | return NULL; /* not an active Lua function */ | 421 | return NULL; /* not an active Lua function */ |
| 420 | else { | 422 | else { |
| 421 | Proto *p = infovalue(func)->func->f.l; | 423 | Proto *p = infovalue(func)->func->f.l; |
| 422 | int pc = lua_currentpc(func); | 424 | int pc = currentpc(func); |
| 423 | Instruction i; | 425 | Instruction i; |
| 424 | if (pc == -1) return NULL; /* function is not activated */ | 426 | if (pc == -1) return NULL; /* function is not activated */ |
| 425 | i = p->code[pc]; | 427 | i = p->code[pc]; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 1.106 2000/10/09 15:46:43 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.107 2000/10/10 19:51:39 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 | */ |
| @@ -212,7 +212,7 @@ static void f_call (lua_State *L, void *ud) { | |||
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | 214 | ||
| 215 | int lua_call (lua_State *L, int nargs, int nresults) { | 215 | LUA_API int lua_call (lua_State *L, int nargs, int nresults) { |
| 216 | StkId func = L->top - (nargs+1); /* function to be called */ | 216 | StkId func = L->top - (nargs+1); /* function to be called */ |
| 217 | struct CallS c; | 217 | struct CallS c; |
| 218 | int status; | 218 | int status; |
| @@ -284,7 +284,7 @@ static int parse_file (lua_State *L, const char *filename) { | |||
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | 286 | ||
| 287 | int lua_dofile (lua_State *L, const char *filename) { | 287 | LUA_API int lua_dofile (lua_State *L, const char *filename) { |
| 288 | int status = parse_file(L, filename); | 288 | int status = parse_file(L, filename); |
| 289 | if (status == 0) /* parse OK? */ | 289 | if (status == 0) /* parse OK? */ |
| 290 | status = lua_call(L, 0, LUA_MULTRET); /* call main */ | 290 | status = lua_call(L, 0, LUA_MULTRET); /* call main */ |
| @@ -301,7 +301,7 @@ static int parse_buffer (lua_State *L, const char *buff, size_t size, | |||
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | 303 | ||
| 304 | int lua_dobuffer (lua_State *L, const char *buff, size_t size, | 304 | LUA_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, |
| 305 | const char *name) { | 305 | const char *name) { |
| 306 | int status = parse_buffer(L, buff, size, name); | 306 | int status = parse_buffer(L, buff, size, name); |
| 307 | if (status == 0) /* parse OK? */ | 307 | if (status == 0) /* parse OK? */ |
| @@ -310,7 +310,7 @@ int lua_dobuffer (lua_State *L, const char *buff, size_t size, | |||
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | 312 | ||
| 313 | int lua_dostring (lua_State *L, const char *str) { | 313 | LUA_API int lua_dostring (lua_State *L, const char *str) { |
| 314 | return lua_dobuffer(L, str, strlen(str), str); | 314 | return lua_dobuffer(L, str, strlen(str), str); |
| 315 | } | 315 | } |
| 316 | 316 | ||
| @@ -343,7 +343,7 @@ static void message (lua_State *L, const char *s) { | |||
| 343 | /* | 343 | /* |
| 344 | ** Reports an error, and jumps up to the available recovery label | 344 | ** Reports an error, and jumps up to the available recovery label |
| 345 | */ | 345 | */ |
| 346 | void lua_error (lua_State *L, const char *s) { | 346 | LUA_API void lua_error (lua_State *L, const char *s) { |
| 347 | if (s) message(L, s); | 347 | if (s) message(L, s); |
| 348 | luaD_breakrun(L, LUA_ERRRUN); | 348 | luaD_breakrun(L, LUA_ERRRUN); |
| 349 | } | 349 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 1.85 2000/09/22 18:14:06 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.86 2000/10/02 20:10: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 | */ |
| @@ -721,7 +721,7 @@ static void openwithcontrol (lua_State *L) { | |||
| 721 | } | 721 | } |
| 722 | 722 | ||
| 723 | 723 | ||
| 724 | void lua_iolibopen (lua_State *L) { | 724 | LUA_API void lua_iolibopen (lua_State *L) { |
| 725 | luaL_openl(L, iolib); | 725 | luaL_openl(L, iolib); |
| 726 | openwithcontrol(L); | 726 | openwithcontrol(L); |
| 727 | } | 727 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.c,v 1.70 2000/09/11 20:29:27 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 1.71 2000/09/27 17:41:58 roberto Exp roberto $ |
| 3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -58,7 +58,7 @@ void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) { | |||
| 58 | void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { | 58 | void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { |
| 59 | char buff[MAXSRC]; | 59 | char buff[MAXSRC]; |
| 60 | luaO_chunkid(buff, ls->source->str, sizeof(buff)); | 60 | luaO_chunkid(buff, ls->source->str, sizeof(buff)); |
| 61 | luaO_verror(ls->L, "%.99s;\n last token read: `%.50s' at line %d in %.80s", | 61 | luaO_verror(ls->L, "%.99s;\n last token read: `%.30s' at line %d in %.80s", |
| 62 | s, token, ls->linenumber, buff); | 62 | s, token, ls->linenumber, buff); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmathlib.c,v 1.27 2000/08/28 17:57:04 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.28 2000/08/31 20:23:40 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 | void lua_mathlibopen (lua_State *L) { | 231 | LUA_API void lua_mathlibopen (lua_State *L) { |
| 232 | luaL_openl(L, mathlib); | 232 | luaL_openl(L, mathlib); |
| 233 | lua_pushnumber(L, 0); /* to get its tag */ | 233 | lua_pushnumber(L, 0); /* to get its tag */ |
| 234 | lua_pushcfunction(L, math_pow); | 234 | lua_pushcfunction(L, math_pow); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 1.43 2000/10/05 13:00:17 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.44 2000/10/06 19:28:47 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -60,7 +60,7 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | 62 | ||
| 63 | lua_State *lua_open (int stacksize) { | 63 | LUA_API lua_State *lua_open (int stacksize) { |
| 64 | lua_State *L = luaM_new(NULL, lua_State); | 64 | lua_State *L = luaM_new(NULL, lua_State); |
| 65 | if (L == NULL) return NULL; /* memory allocation error */ | 65 | if (L == NULL) return NULL; /* memory allocation error */ |
| 66 | L->stack = NULL; | 66 | L->stack = NULL; |
| @@ -94,7 +94,7 @@ lua_State *lua_open (int stacksize) { | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | void lua_close (lua_State *L) { | 97 | LUA_API void lua_close (lua_State *L) { |
| 98 | luaC_collect(L, 1); /* collect all elements */ | 98 | luaC_collect(L, 1); /* collect all elements */ |
| 99 | LUA_ASSERT(L->rootproto == NULL, "list should be empty"); | 99 | LUA_ASSERT(L->rootproto == NULL, "list should be empty"); |
| 100 | LUA_ASSERT(L->rootcl == NULL, "list should be empty"); | 100 | LUA_ASSERT(L->rootcl == NULL, "list should be empty"); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstrlib.c,v 1.53 2000/09/14 14:09:31 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.54 2000/10/05 12:14:08 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 | void lua_strlibopen (lua_State *L) { | 619 | LUA_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: ltests.c,v 1.49 2000/10/05 13:00:17 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.50 2000/10/06 19:29:26 roberto Exp roberto $ |
| 3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -72,7 +72,7 @@ static int pushop (lua_State *L, Proto *p, int pc) { | |||
| 72 | sprintf(buff, "%5d - ", luaG_getline(p->lineinfo, pc, 1, NULL)); | 72 | sprintf(buff, "%5d - ", luaG_getline(p->lineinfo, pc, 1, NULL)); |
| 73 | switch ((enum Mode)luaK_opproperties[o].mode) { | 73 | switch ((enum Mode)luaK_opproperties[o].mode) { |
| 74 | case iO: | 74 | case iO: |
| 75 | sprintf(buff+8, "%s", name); | 75 | sprintf(buff+8, "%-12s", name); |
| 76 | break; | 76 | break; |
| 77 | case iU: | 77 | case iU: |
| 78 | sprintf(buff+8, "%-12s%4u", name, GETARG_U(i)); | 78 | sprintf(buff+8, "%-12s%4u", name, GETARG_U(i)); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.c,v 1.53 2000/10/05 12:14:08 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.54 2000/10/05 13:00:17 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -83,7 +83,7 @@ void luaT_init (lua_State *L) { | |||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | 85 | ||
| 86 | int lua_newtag (lua_State *L) { | 86 | LUA_API int lua_newtag (lua_State *L) { |
| 87 | luaM_growvector(L, L->TMtable, L->last_tag, 1, struct TM, | 87 | luaM_growvector(L, L->TMtable, L->last_tag, 1, struct TM, |
| 88 | "tag table overflow", MAX_INT); | 88 | "tag table overflow", MAX_INT); |
| 89 | L->nblocks += sizeof(struct TM); | 89 | L->nblocks += sizeof(struct TM); |
| @@ -104,7 +104,7 @@ void luaT_realtag (lua_State *L, int tag) { | |||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | 106 | ||
| 107 | int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) { | 107 | LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) { |
| 108 | int e; | 108 | int e; |
| 109 | checktag(L, tagto); | 109 | checktag(L, tagto); |
| 110 | checktag(L, tagfrom); | 110 | checktag(L, tagfrom); |
| @@ -126,7 +126,7 @@ int luaT_tag (const TObject *o) { | |||
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | 128 | ||
| 129 | void lua_gettagmethod (lua_State *L, int t, const char *event) { | 129 | LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) { |
| 130 | int e; | 130 | int e; |
| 131 | e = luaI_checkevent(L, event, t); | 131 | e = luaI_checkevent(L, event, t); |
| 132 | checktag(L, t); | 132 | checktag(L, t); |
| @@ -140,7 +140,7 @@ void lua_gettagmethod (lua_State *L, int t, const char *event) { | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | 142 | ||
| 143 | void lua_settagmethod (lua_State *L, int t, const char *event) { | 143 | LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) { |
| 144 | Closure *oldtm; | 144 | Closure *oldtm; |
| 145 | int e = luaI_checkevent(L, event, t); | 145 | int e = luaI_checkevent(L, event, t); |
| 146 | checktag(L, t); | 146 | checktag(L, t); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.h,v 1.73 2000/10/05 12:14:08 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.74 2000/10/09 15:46:43 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,6 +16,11 @@ | |||
| 16 | #include <stddef.h> | 16 | #include <stddef.h> |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | #ifndef LUA_API | ||
| 20 | #define LUA_API extern | ||
| 21 | #endif | ||
| 22 | |||
| 23 | |||
| 19 | #define LUA_VERSION "Lua 4.0 (beta)" | 24 | #define LUA_VERSION "Lua 4.0 (beta)" |
| 20 | #define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio" | 25 | #define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio" |
| 21 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" | 26 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" |
| @@ -65,113 +70,113 @@ typedef int (*lua_CFunction) (lua_State *L); | |||
| 65 | /* | 70 | /* |
| 66 | ** state manipulation | 71 | ** state manipulation |
| 67 | */ | 72 | */ |
| 68 | lua_State *lua_open (int stacksize); | 73 | LUA_API lua_State *lua_open (int stacksize); |
| 69 | void lua_close (lua_State *L); | 74 | LUA_API void lua_close (lua_State *L); |
| 70 | 75 | ||
| 71 | 76 | ||
| 72 | /* | 77 | /* |
| 73 | ** basic stack manipulation | 78 | ** basic stack manipulation |
| 74 | */ | 79 | */ |
| 75 | int lua_gettop (lua_State *L); | 80 | LUA_API int lua_gettop (lua_State *L); |
| 76 | void lua_settop (lua_State *L, int index); | 81 | LUA_API void lua_settop (lua_State *L, int index); |
| 77 | void lua_pushvalue (lua_State *L, int index); | 82 | LUA_API void lua_pushvalue (lua_State *L, int index); |
| 78 | void lua_remove (lua_State *L, int index); | 83 | LUA_API void lua_remove (lua_State *L, int index); |
| 79 | void lua_insert (lua_State *L, int index); | 84 | LUA_API void lua_insert (lua_State *L, int index); |
| 80 | int lua_stackspace (lua_State *L); | 85 | LUA_API int lua_stackspace (lua_State *L); |
| 81 | 86 | ||
| 82 | 87 | ||
| 83 | /* | 88 | /* |
| 84 | ** access functions (stack -> C) | 89 | ** access functions (stack -> C) |
| 85 | */ | 90 | */ |
| 86 | 91 | ||
| 87 | int lua_type (lua_State *L, int index); | 92 | LUA_API int lua_type (lua_State *L, int index); |
| 88 | const char *lua_typename (lua_State *L, int t); | 93 | LUA_API const char *lua_typename (lua_State *L, int t); |
| 89 | int lua_isnumber (lua_State *L, int index); | 94 | LUA_API int lua_isnumber (lua_State *L, int index); |
| 90 | int lua_isstring (lua_State *L, int index); | 95 | LUA_API int lua_isstring (lua_State *L, int index); |
| 91 | int lua_iscfunction (lua_State *L, int index); | 96 | LUA_API int lua_iscfunction (lua_State *L, int index); |
| 92 | int lua_tag (lua_State *L, int index); | 97 | LUA_API int lua_tag (lua_State *L, int index); |
| 93 | 98 | ||
| 94 | int lua_equal (lua_State *L, int index1, int index2); | 99 | LUA_API int lua_equal (lua_State *L, int index1, int index2); |
| 95 | int lua_lessthan (lua_State *L, int index1, int index2); | 100 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); |
| 96 | 101 | ||
| 97 | double lua_tonumber (lua_State *L, int index); | 102 | LUA_API double lua_tonumber (lua_State *L, int index); |
| 98 | const char *lua_tostring (lua_State *L, int index); | 103 | LUA_API const char *lua_tostring (lua_State *L, int index); |
| 99 | size_t lua_strlen (lua_State *L, int index); | 104 | LUA_API size_t lua_strlen (lua_State *L, int index); |
| 100 | lua_CFunction lua_tocfunction (lua_State *L, int index); | 105 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index); |
| 101 | void *lua_touserdata (lua_State *L, int index); | 106 | LUA_API void *lua_touserdata (lua_State *L, int index); |
| 102 | const void *lua_topointer (lua_State *L, int index); | 107 | LUA_API const void *lua_topointer (lua_State *L, int index); |
| 103 | 108 | ||
| 104 | 109 | ||
| 105 | /* | 110 | /* |
| 106 | ** push functions (C -> stack) | 111 | ** push functions (C -> stack) |
| 107 | */ | 112 | */ |
| 108 | void lua_pushnil (lua_State *L); | 113 | LUA_API void lua_pushnil (lua_State *L); |
| 109 | void lua_pushnumber (lua_State *L, double n); | 114 | LUA_API void lua_pushnumber (lua_State *L, double n); |
| 110 | void lua_pushlstring (lua_State *L, const char *s, size_t len); | 115 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len); |
| 111 | void lua_pushstring (lua_State *L, const char *s); | 116 | LUA_API void lua_pushstring (lua_State *L, const char *s); |
| 112 | void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); | 117 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); |
| 113 | void lua_pushusertag (lua_State *L, void *u, int tag); | 118 | LUA_API void lua_pushusertag (lua_State *L, void *u, int tag); |
| 114 | 119 | ||
| 115 | 120 | ||
| 116 | /* | 121 | /* |
| 117 | ** get functions (Lua -> stack) | 122 | ** get functions (Lua -> stack) |
| 118 | */ | 123 | */ |
| 119 | void lua_getglobal (lua_State *L, const char *name); | 124 | LUA_API void lua_getglobal (lua_State *L, const char *name); |
| 120 | void lua_gettable (lua_State *L, int index); | 125 | LUA_API void lua_gettable (lua_State *L, int index); |
| 121 | void lua_rawget (lua_State *L, int index); | 126 | LUA_API void lua_rawget (lua_State *L, int index); |
| 122 | void lua_rawgeti (lua_State *L, int index, int n); | 127 | LUA_API void lua_rawgeti (lua_State *L, int index, int n); |
| 123 | void lua_getglobals (lua_State *L); | 128 | LUA_API void lua_getglobals (lua_State *L); |
| 124 | void lua_gettagmethod (lua_State *L, int tag, const char *event); | 129 | LUA_API void lua_gettagmethod (lua_State *L, int tag, const char *event); |
| 125 | 130 | ||
| 126 | int lua_getref (lua_State *L, int ref); | 131 | LUA_API int lua_getref (lua_State *L, int ref); |
| 127 | 132 | ||
| 128 | void lua_newtable (lua_State *L); | 133 | LUA_API void lua_newtable (lua_State *L); |
| 129 | 134 | ||
| 130 | 135 | ||
| 131 | /* | 136 | /* |
| 132 | ** set functions (stack -> Lua) | 137 | ** set functions (stack -> Lua) |
| 133 | */ | 138 | */ |
| 134 | void lua_setglobal (lua_State *L, const char *name); | 139 | LUA_API void lua_setglobal (lua_State *L, const char *name); |
| 135 | void lua_settable (lua_State *L, int index); | 140 | LUA_API void lua_settable (lua_State *L, int index); |
| 136 | void lua_rawset (lua_State *L, int index); | 141 | LUA_API void lua_rawset (lua_State *L, int index); |
| 137 | void lua_rawseti (lua_State *L, int index, int n); | 142 | LUA_API void lua_rawseti (lua_State *L, int index, int n); |
| 138 | void lua_setglobals (lua_State *L); | 143 | LUA_API void lua_setglobals (lua_State *L); |
| 139 | void lua_settagmethod (lua_State *L, int tag, const char *event); | 144 | LUA_API void lua_settagmethod (lua_State *L, int tag, const char *event); |
| 140 | int lua_ref (lua_State *L, int lock); | 145 | LUA_API int lua_ref (lua_State *L, int lock); |
| 141 | 146 | ||
| 142 | 147 | ||
| 143 | /* | 148 | /* |
| 144 | ** "do" functions (run Lua code) | 149 | ** "do" functions (run Lua code) |
| 145 | */ | 150 | */ |
| 146 | int lua_call (lua_State *L, int nargs, int nresults); | 151 | LUA_API int lua_call (lua_State *L, int nargs, int nresults); |
| 147 | void lua_rawcall (lua_State *L, int nargs, int nresults); | 152 | LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults); |
| 148 | int lua_dofile (lua_State *L, const char *filename); | 153 | LUA_API int lua_dofile (lua_State *L, const char *filename); |
| 149 | int lua_dostring (lua_State *L, const char *str); | 154 | LUA_API int lua_dostring (lua_State *L, const char *str); |
| 150 | int lua_dobuffer (lua_State *L, const char *buff, size_t size, | 155 | LUA_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, |
| 151 | const char *name); | 156 | const char *name); |
| 152 | 157 | ||
| 153 | /* | 158 | /* |
| 154 | ** Garbage-collection functions | 159 | ** Garbage-collection functions |
| 155 | */ | 160 | */ |
| 156 | int lua_getgcthreshold (lua_State *L); | 161 | LUA_API int lua_getgcthreshold (lua_State *L); |
| 157 | int lua_getgccount (lua_State *L); | 162 | LUA_API int lua_getgccount (lua_State *L); |
| 158 | void lua_setgcthreshold (lua_State *L, int newthreshold); | 163 | LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold); |
| 159 | 164 | ||
| 160 | /* | 165 | /* |
| 161 | ** miscellaneous functions | 166 | ** miscellaneous functions |
| 162 | */ | 167 | */ |
| 163 | int lua_newtag (lua_State *L); | 168 | LUA_API int lua_newtag (lua_State *L); |
| 164 | int lua_copytagmethods (lua_State *L, int tagto, int tagfrom); | 169 | LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom); |
| 165 | void lua_settag (lua_State *L, int tag); | 170 | LUA_API void lua_settag (lua_State *L, int tag); |
| 166 | 171 | ||
| 167 | void lua_error (lua_State *L, const char *s); | 172 | LUA_API void lua_error (lua_State *L, const char *s); |
| 168 | 173 | ||
| 169 | void lua_unref (lua_State *L, int ref); | 174 | LUA_API void lua_unref (lua_State *L, int ref); |
| 170 | 175 | ||
| 171 | int lua_next (lua_State *L, int index); | 176 | LUA_API int lua_next (lua_State *L, int index); |
| 172 | int lua_getn (lua_State *L, int index); | 177 | LUA_API int lua_getn (lua_State *L, int index); |
| 173 | 178 | ||
| 174 | void lua_concat (lua_State *L, int n); | 179 | LUA_API void lua_concat (lua_State *L, int n); |
| 175 | 180 | ||
| 176 | 181 | ||
| 177 | /* | 182 | /* |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luadebug.h,v 1.14 2000/09/11 20:29:27 roberto Exp roberto $ | 2 | ** $Id: luadebug.h,v 1.15 2000/09/12 18:38:02 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 | */ |
| @@ -17,13 +17,15 @@ typedef struct lua_Localvar lua_Localvar; | |||
| 17 | typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); | 17 | typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | int lua_getstack (lua_State *L, int level, lua_Debug *ar); | 20 | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); |
| 21 | int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); | 21 | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); |
| 22 | const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int localnum); | 22 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, |
| 23 | const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int localnum); | 23 | int localnum); |
| 24 | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, | ||
| 25 | int localnum); | ||
| 24 | 26 | ||
| 25 | lua_Hook lua_setcallhook (lua_State *L, lua_Hook func); | 27 | LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func); |
| 26 | lua_Hook lua_setlinehook (lua_State *L, lua_Hook func); | 28 | LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func); |
| 27 | 29 | ||
| 28 | 30 | ||
| 29 | #define LUA_IDSIZE 60 | 31 | #define LUA_IDSIZE 60 |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lualib.h,v 1.11 2000/09/05 19:33:32 roberto Exp roberto $ | 2 | ** $Id: lualib.h,v 1.12 2000/09/12 13:46:59 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 | */ |
| @@ -13,11 +13,11 @@ | |||
| 13 | 13 | ||
| 14 | #define LUA_ALERT "_ALERT" | 14 | #define LUA_ALERT "_ALERT" |
| 15 | 15 | ||
| 16 | void lua_baselibopen (lua_State *L); | 16 | LUA_API void lua_baselibopen (lua_State *L); |
| 17 | void lua_iolibopen (lua_State *L); | 17 | LUA_API void lua_iolibopen (lua_State *L); |
| 18 | void lua_strlibopen (lua_State *L); | 18 | LUA_API void lua_strlibopen (lua_State *L); |
| 19 | void lua_mathlibopen (lua_State *L); | 19 | LUA_API void lua_mathlibopen (lua_State *L); |
| 20 | void lua_dblibopen (lua_State *L); | 20 | LUA_API void lua_dblibopen (lua_State *L); |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lundump.c,v 1.32 2000/09/21 03:15:36 lhf Exp $ | 2 | ** $Id: lundump.c,v 1.32 2000/09/21 03:15:36 lhf Exp lhf $ |
| 3 | ** load bytecodes from files | 3 | ** load bytecodes from files |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -23,7 +23,7 @@ static const char* ZNAME (ZIO* Z) | |||
| 23 | 23 | ||
| 24 | static void unexpectedEOZ (lua_State* L, ZIO* Z) | 24 | static void unexpectedEOZ (lua_State* L, ZIO* Z) |
| 25 | { | 25 | { |
| 26 | luaO_verror(L,"unexpected end of file in `%.255s'",ZNAME(Z)); | 26 | luaO_verror(L,"unexpected end of file in `%.99s'",ZNAME(Z)); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | static int ezgetc (lua_State* L, ZIO* Z) | 29 | static int ezgetc (lua_State* L, ZIO* Z) |
| @@ -107,7 +107,8 @@ static void LoadCode (lua_State* L, Proto* tf, ZIO* Z, int swap) | |||
| 107 | int size=LoadInt(L,Z,swap); | 107 | int size=LoadInt(L,Z,swap); |
| 108 | tf->code=luaM_newvector(L,size,Instruction); | 108 | tf->code=luaM_newvector(L,size,Instruction); |
| 109 | LoadVector(L,tf->code,size,sizeof(*tf->code),Z,swap); | 109 | LoadVector(L,tf->code,size,sizeof(*tf->code),Z,swap); |
| 110 | if (tf->code[size-1]!=OP_END) luaO_verror(L,"bad code in `%.255s'",ZNAME(Z)); | 110 | if (tf->code[size-1]!=OP_END) luaO_verror(L,"bad code in `%.99s'",ZNAME(Z)); |
| 111 | luaF_protook(L,tf,size); | ||
| 111 | } | 112 | } |
| 112 | 113 | ||
| 113 | static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap) | 114 | static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap) |
| @@ -125,8 +126,8 @@ static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap) | |||
| 125 | 126 | ||
| 126 | static void LoadLines (lua_State* L, Proto* tf, ZIO* Z, int swap) | 127 | static void LoadLines (lua_State* L, Proto* tf, ZIO* Z, int swap) |
| 127 | { | 128 | { |
| 128 | int n=LoadInt(L,Z,swap); | 129 | int n; |
| 129 | if (n==0) return; | 130 | tf->nlineinfo=n=LoadInt(L,Z,swap); |
| 130 | tf->lineinfo=luaM_newvector(L,n,int); | 131 | tf->lineinfo=luaM_newvector(L,n,int); |
| 131 | LoadVector(L,tf->lineinfo,n,sizeof(*tf->lineinfo),Z,swap); | 132 | LoadVector(L,tf->lineinfo,n,sizeof(*tf->lineinfo),Z,swap); |
| 132 | } | 133 | } |
| @@ -157,10 +158,10 @@ static Proto* LoadFunction (lua_State* L, ZIO* Z, int swap) | |||
| 157 | tf->numparams=LoadInt(L,Z,swap); | 158 | tf->numparams=LoadInt(L,Z,swap); |
| 158 | tf->is_vararg=LoadByte(L,Z); | 159 | tf->is_vararg=LoadByte(L,Z); |
| 159 | tf->maxstacksize=LoadInt(L,Z,swap); | 160 | tf->maxstacksize=LoadInt(L,Z,swap); |
| 160 | LoadCode(L,tf,Z,swap); | ||
| 161 | LoadLocals(L,tf,Z,swap); | 161 | LoadLocals(L,tf,Z,swap); |
| 162 | LoadLines(L,tf,Z,swap); | 162 | LoadLines(L,tf,Z,swap); |
| 163 | LoadConstants(L,tf,Z,swap); | 163 | LoadConstants(L,tf,Z,swap); |
| 164 | LoadCode(L,tf,Z,swap); | ||
| 164 | return tf; | 165 | return tf; |
| 165 | } | 166 | } |
| 166 | 167 | ||
| @@ -169,14 +170,14 @@ static void LoadSignature (lua_State* L, ZIO* Z) | |||
| 169 | const char* s=SIGNATURE; | 170 | const char* s=SIGNATURE; |
| 170 | while (*s!=0 && ezgetc(L,Z)==*s) | 171 | while (*s!=0 && ezgetc(L,Z)==*s) |
| 171 | ++s; | 172 | ++s; |
| 172 | if (*s!=0) luaO_verror(L,"bad signature in `%.255s'",ZNAME(Z)); | 173 | if (*s!=0) luaO_verror(L,"bad signature in `%.99s'",ZNAME(Z)); |
| 173 | } | 174 | } |
| 174 | 175 | ||
| 175 | static void TestSize (lua_State* L, int s, const char* what, ZIO* Z) | 176 | static void TestSize (lua_State* L, int s, const char* what, ZIO* Z) |
| 176 | { | 177 | { |
| 177 | int r=ezgetc(L,Z); | 178 | int r=ezgetc(L,Z); |
| 178 | if (r!=s) | 179 | if (r!=s) |
| 179 | luaO_verror(L,"virtual machine mismatch in `%.255s':\n" | 180 | luaO_verror(L,"virtual machine mismatch in `%.99s':\n" |
| 180 | " %s is %d but read %d",ZNAME(Z),what,s,r); | 181 | " %s is %d but read %d",ZNAME(Z),what,s,r); |
| 181 | } | 182 | } |
| 182 | 183 | ||
| @@ -190,11 +191,11 @@ static int LoadHeader (lua_State* L, ZIO* Z) | |||
| 190 | LoadSignature(L,Z); | 191 | LoadSignature(L,Z); |
| 191 | version=ezgetc(L,Z); | 192 | version=ezgetc(L,Z); |
| 192 | if (version>VERSION) | 193 | if (version>VERSION) |
| 193 | luaO_verror(L,"`%.255s' too new:\n" | 194 | luaO_verror(L,"`%.99s' too new:\n" |
| 194 | " read version %d.%d; expected at most %d.%d", | 195 | " read version %d.%d; expected at most %d.%d", |
| 195 | ZNAME(Z),V(version),V(VERSION)); | 196 | ZNAME(Z),V(version),V(VERSION)); |
| 196 | if (version<VERSION0) /* check last major change */ | 197 | if (version<VERSION0) /* check last major change */ |
| 197 | luaO_verror(L,"`%.255s' too old:\n" | 198 | luaO_verror(L,"`%.99s' too old:\n" |
| 198 | " read version %d.%d; expected at least %d.%d", | 199 | " read version %d.%d; expected at least %d.%d", |
| 199 | ZNAME(Z),V(version),V(VERSION)); | 200 | ZNAME(Z),V(version),V(VERSION)); |
| 200 | swap=(luaU_endianess()!=ezgetc(L,Z)); /* need to swap bytes? */ | 201 | swap=(luaU_endianess()!=ezgetc(L,Z)); /* need to swap bytes? */ |
| @@ -207,9 +208,8 @@ static int LoadHeader (lua_State* L, ZIO* Z) | |||
| 207 | TESTSIZE(sizeof(Number)); | 208 | TESTSIZE(sizeof(Number)); |
| 208 | f=LoadNumber(L,Z,swap); | 209 | f=LoadNumber(L,Z,swap); |
| 209 | if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */ | 210 | if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */ |
| 210 | luaO_verror(L,"unknown number format in `%.255s':\n" | 211 | luaO_verror(L,"unknown number format in `%.99s':\n" |
| 211 | " read " NUMBER_FMT "; expected " NUMBER_FMT, | 212 | " read " NUMBER_FMT "; expected " NUMBER_FMT, ZNAME(Z),f,tf); |
| 212 | ZNAME(Z),f,tf); | ||
| 213 | return swap; | 213 | return swap; |
| 214 | } | 214 | } |
| 215 | 215 | ||
| @@ -230,7 +230,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z) | |||
| 230 | tf=LoadChunk(L,Z); | 230 | tf=LoadChunk(L,Z); |
| 231 | c=zgetc(Z); | 231 | c=zgetc(Z); |
| 232 | if (c!=EOZ) | 232 | if (c!=EOZ) |
| 233 | luaO_verror(L,"`%.255s' apparently contains more than one chunk",ZNAME(Z)); | 233 | luaO_verror(L,"`%.99s' apparently contains more than one chunk",ZNAME(Z)); |
| 234 | return tf; | 234 | return tf; |
| 235 | } | 235 | } |
| 236 | 236 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lundump.h,v 1.19 2000/04/24 17:32:29 lhf Exp lhf $ | 2 | ** $Id: lundump.h,v 1.20 2000/09/18 20:03:46 lhf Exp lhf $ |
| 3 | ** load pre-compiled Lua chunks | 3 | ** load pre-compiled Lua chunks |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -12,7 +12,6 @@ | |||
| 12 | 12 | ||
| 13 | /* load one chunk */ | 13 | /* load one chunk */ |
| 14 | Proto* luaU_undump (lua_State* L, ZIO* Z); | 14 | Proto* luaU_undump (lua_State* L, ZIO* Z); |
| 15 | #define luaU_undump1 luaU_undump | ||
| 16 | 15 | ||
| 17 | /* find byte order */ | 16 | /* find byte order */ |
| 18 | int luaU_endianess (void); | 17 | int luaU_endianess (void); |
| @@ -29,11 +28,6 @@ int luaU_endianess (void); | |||
| 29 | #define IN " in %p " SOURCE | 28 | #define IN " in %p " SOURCE |
| 30 | #define INLOC tf,tf->source->str,tf->lineDefined | 29 | #define INLOC tf,tf->source->str,tf->lineDefined |
| 31 | 30 | ||
| 32 | /* format for numbers in listings and error messages */ | ||
| 33 | #ifndef NUMBER_FMT | ||
| 34 | #define NUMBER_FMT "%.16g" /* LUA_NUMBER */ | ||
| 35 | #endif | ||
| 36 | |||
| 37 | /* a multiple of PI for testing native format */ | 31 | /* a multiple of PI for testing native format */ |
| 38 | /* multiplying by 1E8 gives non-trivial integer values */ | 32 | /* multiplying by 1E8 gives non-trivial integer values */ |
| 39 | #define TEST_NUMBER 3.14159265358979323846E8 | 33 | #define TEST_NUMBER 3.14159265358979323846E8 |
