diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-02 17:10:55 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-02 17:10:55 -0300 |
commit | f6834f4393eaa1055c2bbde82ebb33cc58be8371 (patch) | |
tree | 3583008ef181106d0fc7e130300f12adc70a5854 | |
parent | 78bc8e553d4190fc3b90be5b621fc0f3507586ef (diff) | |
download | lua-f6834f4393eaa1055c2bbde82ebb33cc58be8371.tar.gz lua-f6834f4393eaa1055c2bbde82ebb33cc58be8371.tar.bz2 lua-f6834f4393eaa1055c2bbde82ebb33cc58be8371.zip |
new API function `lua_type' + new type lua_Type
-rw-r--r-- | lapi.c | 21 | ||||
-rw-r--r-- | lauxlib.c | 29 | ||||
-rw-r--r-- | lauxlib.h | 5 | ||||
-rw-r--r-- | lbaselib.c | 68 | ||||
-rw-r--r-- | ldblib.c | 4 | ||||
-rw-r--r-- | ldebug.c | 10 | ||||
-rw-r--r-- | ldebug.h | 4 | ||||
-rw-r--r-- | ldo.c | 4 | ||||
-rw-r--r-- | liolib.c | 4 | ||||
-rw-r--r-- | lobject.c | 14 | ||||
-rw-r--r-- | lobject.h | 12 | ||||
-rw-r--r-- | ltests.c | 18 | ||||
-rw-r--r-- | ltm.c | 6 | ||||
-rw-r--r-- | lua.h | 24 | ||||
-rw-r--r-- | lvm.c | 4 |
15 files changed, 125 insertions, 102 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.101 2000/09/29 12:42:13 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.102 2000/10/02 14:47:43 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 | */ |
@@ -116,8 +116,16 @@ void lua_pushvalue (lua_State *L, int index) { | |||
116 | return ((test) ? (value) : (default)); } | 116 | return ((test) ? (value) : (default)); } |
117 | 117 | ||
118 | 118 | ||
119 | const char *lua_type (lua_State *L, int index) { | 119 | lua_Type lua_type (lua_State *L, int index) { |
120 | btest(L, index, luaO_typename(o), "NO VALUE"); | 120 | btest(L, index, luaO_type(o), LUA_NOVALUE); |
121 | } | ||
122 | |||
123 | const char *lua_typename (lua_State *L, lua_Type t) { | ||
124 | static const char *const names[] = { | ||
125 | "NO VALUE", "userdata", "number", "string", "table", "function", "nil" | ||
126 | }; | ||
127 | UNUSED(L); | ||
128 | return names[(int)t]; | ||
121 | } | 129 | } |
122 | 130 | ||
123 | int lua_iscfunction (lua_State *L, int index) { | 131 | int lua_iscfunction (lua_State *L, int index) { |
@@ -128,6 +136,11 @@ int lua_isnumber (lua_State *L, int index) { | |||
128 | btest(L, index, (tonumber(Index(L, index)) == 0), 0); | 136 | btest(L, index, (tonumber(Index(L, index)) == 0), 0); |
129 | } | 137 | } |
130 | 138 | ||
139 | int lua_isstring (lua_State *L, int index) { | ||
140 | lua_Type t = lua_type(L, index); | ||
141 | return (t == LUA_TSTRING || t == LUA_TNUMBER); | ||
142 | } | ||
143 | |||
131 | int lua_tag (lua_State *L, int index) { | 144 | int lua_tag (lua_State *L, int index) { |
132 | btest(L, index, | 145 | btest(L, index, |
133 | ((ttype(o) == TAG_USERDATA) ? tsvalue(o)->u.d.tag : | 146 | ((ttype(o) == TAG_USERDATA) ? tsvalue(o)->u.d.tag : |
@@ -411,7 +424,7 @@ void lua_settag (lua_State *L, int tag) { | |||
411 | break; | 424 | break; |
412 | default: | 425 | default: |
413 | luaO_verror(L, "cannot change the tag of a %.20s", | 426 | luaO_verror(L, "cannot change the tag of a %.20s", |
414 | luaO_typename(L->top-1)); | 427 | luaO_typename(L, L->top-1)); |
415 | } | 428 | } |
416 | L->top--; | 429 | L->top--; |
417 | } | 430 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.36 2000/09/12 13:48:22 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.37 2000/09/29 12:40:56 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 | */ |
@@ -40,11 +40,11 @@ void luaL_argerror (lua_State *L, int narg, const char *extramsg) { | |||
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | ||
43 | static void type_error (lua_State *L, int narg, const char *type_name) { | 43 | static void type_error (lua_State *L, int narg, lua_Type t) { |
44 | char buff[100]; | 44 | char buff[100]; |
45 | const char *rt = lua_type(L, narg); | 45 | const char *rt = lua_typename(L, lua_type(L, narg)); |
46 | if (*rt == 'N') rt = "no value"; | 46 | if (*rt == 'N') rt = "no value"; |
47 | sprintf(buff, "%.10s expected, got %.10s", type_name, 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 | ||
@@ -55,20 +55,21 @@ void luaL_checkstack (lua_State *L, int space, const char *mes) { | |||
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | /* | 58 | void luaL_checktype(lua_State *L, int narg, lua_Type t) { |
59 | ** use the 3rd letter of type names for testing: | 59 | if (lua_type(L, narg) != t) |
60 | ** nuMber, niL, stRing, fuNction, usErdata, taBle, anY | 60 | type_error(L, narg, t); |
61 | */ | 61 | } |
62 | void luaL_checktype(lua_State *L, int narg, const char *tname) { | 62 | |
63 | const char *rt = lua_type(L, narg); | 63 | |
64 | if (!(*rt != 'N' && (tname[2] == 'y' || tname[2] == rt[2]))) | 64 | void luaL_checkany (lua_State *L, int narg) { |
65 | type_error(L, narg, tname); | 65 | if (lua_type(L, narg) == LUA_NOVALUE) |
66 | luaL_argerror(L, narg, "value expected"); | ||
66 | } | 67 | } |
67 | 68 | ||
68 | 69 | ||
69 | const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { | 70 | const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) { |
70 | const char *s = lua_tostring(L, narg); | 71 | const char *s = lua_tostring(L, narg); |
71 | if (!s) type_error(L, narg, "string"); | 72 | if (!s) type_error(L, narg, LUA_TSTRING); |
72 | if (len) *len = lua_strlen(L, narg); | 73 | if (len) *len = lua_strlen(L, narg); |
73 | return s; | 74 | return s; |
74 | } | 75 | } |
@@ -88,7 +89,7 @@ const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, | |||
88 | double luaL_check_number (lua_State *L, int narg) { | 89 | double luaL_check_number (lua_State *L, int narg) { |
89 | double d = lua_tonumber(L, narg); | 90 | double d = lua_tonumber(L, narg); |
90 | 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 */ |
91 | type_error(L, narg, "number"); | 92 | type_error(L, narg, LUA_TNUMBER); |
92 | return d; | 93 | return d; |
93 | } | 94 | } |
94 | 95 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.h,v 1.24 2000/09/11 20:29:27 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.25 2000/09/12 13:48:22 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 | */ |
@@ -30,7 +30,8 @@ double luaL_check_number (lua_State *L, int numArg); | |||
30 | double luaL_opt_number (lua_State *L, int numArg, double def); | 30 | 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 | void luaL_checkstack (lua_State *L, int space, const char *msg); |
33 | void luaL_checktype (lua_State *L, int narg, const char *tname); | 33 | void luaL_checktype (lua_State *L, int narg, lua_Type t); |
34 | void luaL_checkany (lua_State *L, int narg); | ||
34 | 35 | ||
35 | void luaL_verror (lua_State *L, const char *fmt, ...); | 36 | void luaL_verror (lua_State *L, const char *fmt, ...); |
36 | int luaL_findstring (const char *name, const char *const list[]); | 37 | int luaL_findstring (const char *name, const char *const list[]); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.6 2000/09/20 12:54:17 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.7 2000/10/02 14:47: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 | */ |
@@ -34,7 +34,7 @@ static int luaB__ALERT (lua_State *L) { | |||
34 | ** The library `liolib' redefines _ERRORMESSAGE for better error information. | 34 | ** The library `liolib' redefines _ERRORMESSAGE for better error information. |
35 | */ | 35 | */ |
36 | static int luaB__ERRORMESSAGE (lua_State *L) { | 36 | static int luaB__ERRORMESSAGE (lua_State *L) { |
37 | luaL_checktype(L, 1, "string"); | 37 | luaL_checktype(L, 1, LUA_TSTRING); |
38 | lua_getglobal(L, LUA_ALERT); | 38 | lua_getglobal(L, LUA_ALERT); |
39 | if (lua_isfunction(L, -1)) { /* avoid error loop if _ALERT is not defined */ | 39 | if (lua_isfunction(L, -1)) { /* avoid error loop if _ALERT is not defined */ |
40 | lua_Debug ar; | 40 | lua_Debug ar; |
@@ -87,7 +87,7 @@ static int luaB_print (lua_State *L) { | |||
87 | static int luaB_tonumber (lua_State *L) { | 87 | static int luaB_tonumber (lua_State *L) { |
88 | int base = luaL_opt_int(L, 2, 10); | 88 | int base = luaL_opt_int(L, 2, 10); |
89 | if (base == 10) { /* standard conversion */ | 89 | if (base == 10) { /* standard conversion */ |
90 | luaL_checktype(L, 1, "any"); | 90 | luaL_checkany(L, 1); |
91 | if (lua_isnumber(L, 1)) { | 91 | if (lua_isnumber(L, 1)) { |
92 | lua_pushnumber(L, lua_tonumber(L, 1)); | 92 | lua_pushnumber(L, lua_tonumber(L, 1)); |
93 | return 1; | 93 | return 1; |
@@ -118,7 +118,7 @@ static int luaB_error (lua_State *L) { | |||
118 | } | 118 | } |
119 | 119 | ||
120 | static int luaB_setglobal (lua_State *L) { | 120 | static int luaB_setglobal (lua_State *L) { |
121 | luaL_checktype(L, 2, "any"); | 121 | luaL_checkany(L, 2); |
122 | lua_setglobal(L, luaL_check_string(L, 1)); | 122 | lua_setglobal(L, luaL_check_string(L, 1)); |
123 | return 0; | 123 | return 0; |
124 | } | 124 | } |
@@ -129,13 +129,13 @@ static int luaB_getglobal (lua_State *L) { | |||
129 | } | 129 | } |
130 | 130 | ||
131 | static int luaB_tag (lua_State *L) { | 131 | static int luaB_tag (lua_State *L) { |
132 | luaL_checktype(L, 1, "any"); | 132 | luaL_checkany(L, 1); |
133 | lua_pushnumber(L, lua_tag(L, 1)); | 133 | lua_pushnumber(L, lua_tag(L, 1)); |
134 | return 1; | 134 | return 1; |
135 | } | 135 | } |
136 | 136 | ||
137 | static int luaB_settag (lua_State *L) { | 137 | static int luaB_settag (lua_State *L) { |
138 | luaL_checktype(L, 1, "table"); | 138 | luaL_checktype(L, 1, LUA_TTABLE); |
139 | lua_pushvalue(L, 1); /* push table */ | 139 | lua_pushvalue(L, 1); /* push table */ |
140 | lua_settag(L, luaL_check_int(L, 2)); | 140 | lua_settag(L, luaL_check_int(L, 2)); |
141 | lua_pop(L, 1); /* remove second argument */ | 141 | lua_pop(L, 1); /* remove second argument */ |
@@ -156,7 +156,7 @@ static int luaB_copytagmethods (lua_State *L) { | |||
156 | static int luaB_globals (lua_State *L) { | 156 | static int luaB_globals (lua_State *L) { |
157 | lua_getglobals(L); /* value to be returned */ | 157 | lua_getglobals(L); /* value to be returned */ |
158 | if (!lua_isnull(L, 1)) { | 158 | if (!lua_isnull(L, 1)) { |
159 | luaL_checktype(L, 1, "table"); | 159 | luaL_checktype(L, 1, LUA_TTABLE); |
160 | lua_pushvalue(L, 1); /* new table of globals */ | 160 | lua_pushvalue(L, 1); /* new table of globals */ |
161 | lua_setglobals(L); | 161 | lua_setglobals(L); |
162 | } | 162 | } |
@@ -164,16 +164,16 @@ static int luaB_globals (lua_State *L) { | |||
164 | } | 164 | } |
165 | 165 | ||
166 | static int luaB_rawget (lua_State *L) { | 166 | static int luaB_rawget (lua_State *L) { |
167 | luaL_checktype(L, 1, "table"); | 167 | luaL_checktype(L, 1, LUA_TTABLE); |
168 | luaL_checktype(L, 2, "any"); | 168 | luaL_checkany(L, 2); |
169 | lua_rawget(L, -2); | 169 | lua_rawget(L, -2); |
170 | return 1; | 170 | return 1; |
171 | } | 171 | } |
172 | 172 | ||
173 | static int luaB_rawset (lua_State *L) { | 173 | static int luaB_rawset (lua_State *L) { |
174 | luaL_checktype(L, 1, "table"); | 174 | luaL_checktype(L, 1, LUA_TTABLE); |
175 | luaL_checktype(L, 2, "any"); | 175 | luaL_checkany(L, 2); |
176 | luaL_checktype(L, 3, "any"); | 176 | luaL_checkany(L, 3); |
177 | lua_rawset(L, -3); | 177 | lua_rawset(L, -3); |
178 | return 1; | 178 | return 1; |
179 | } | 179 | } |
@@ -209,14 +209,14 @@ static int luaB_collectgarbage (lua_State *L) { | |||
209 | 209 | ||
210 | 210 | ||
211 | static int luaB_type (lua_State *L) { | 211 | static int luaB_type (lua_State *L) { |
212 | luaL_checktype(L, 1, "any"); | 212 | luaL_checkany(L, 1); |
213 | lua_pushstring(L, lua_type(L, 1)); | 213 | lua_pushstring(L, lua_typename(L, lua_type(L, 1))); |
214 | return 1; | 214 | return 1; |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | static int luaB_next (lua_State *L) { | 218 | static int luaB_next (lua_State *L) { |
219 | luaL_checktype(L, 1, "table"); | 219 | luaL_checktype(L, 1, LUA_TTABLE); |
220 | lua_settop(L, 2); /* create a 2nd argument if there isn't one */ | 220 | lua_settop(L, 2); /* create a 2nd argument if there isn't one */ |
221 | if (lua_next(L, 1)) | 221 | if (lua_next(L, 1)) |
222 | return 2; | 222 | return 2; |
@@ -269,7 +269,7 @@ static int luaB_call (lua_State *L) { | |||
269 | int err = 0; /* index of old error method */ | 269 | int err = 0; /* index of old error method */ |
270 | int i, status; | 270 | int i, status; |
271 | int n; | 271 | int n; |
272 | luaL_checktype(L, 2, "table"); | 272 | luaL_checktype(L, 2, LUA_TTABLE); |
273 | n = lua_getn(L, 2); | 273 | n = lua_getn(L, 2); |
274 | if (!lua_isnull(L, 4)) { /* set new error method */ | 274 | if (!lua_isnull(L, 4)) { /* set new error method */ |
275 | lua_getglobal(L, LUA_ERRORMESSAGE); | 275 | lua_getglobal(L, LUA_ERRORMESSAGE); |
@@ -303,26 +303,26 @@ static int luaB_call (lua_State *L) { | |||
303 | 303 | ||
304 | static int luaB_tostring (lua_State *L) { | 304 | static int luaB_tostring (lua_State *L) { |
305 | char buff[64]; | 305 | char buff[64]; |
306 | switch (lua_type(L, 1)[2]) { | 306 | switch (lua_type(L, 1)) { |
307 | case 'm': /* nuMber */ | 307 | case LUA_TNUMBER: |
308 | lua_pushstring(L, lua_tostring(L, 1)); | 308 | lua_pushstring(L, lua_tostring(L, 1)); |
309 | return 1; | 309 | return 1; |
310 | case 'r': /* stRing */ | 310 | case LUA_TSTRING: |
311 | lua_pushvalue(L, 1); | 311 | lua_pushvalue(L, 1); |
312 | return 1; | 312 | return 1; |
313 | case 'b': /* taBle */ | 313 | case LUA_TTABLE: |
314 | sprintf(buff, "table: %p", lua_topointer(L, 1)); | 314 | sprintf(buff, "table: %p", lua_topointer(L, 1)); |
315 | break; | 315 | break; |
316 | case 'n': /* fuNction */ | 316 | case LUA_TFUNCTION: |
317 | sprintf(buff, "function: %p", lua_topointer(L, 1)); | 317 | sprintf(buff, "function: %p", lua_topointer(L, 1)); |
318 | break; | 318 | break; |
319 | case 'e': /* usErdata */ | 319 | case LUA_TUSERDATA: |
320 | sprintf(buff, "userdata(%d): %p", lua_tag(L, 1), lua_touserdata(L, 1)); | 320 | sprintf(buff, "userdata(%d): %p", lua_tag(L, 1), lua_touserdata(L, 1)); |
321 | break; | 321 | break; |
322 | case 'l': /* niL */ | 322 | case LUA_TNIL: |
323 | lua_pushstring(L, "nil"); | 323 | lua_pushstring(L, "nil"); |
324 | return 1; | 324 | return 1; |
325 | default: | 325 | case LUA_NOVALUE: |
326 | luaL_argerror(L, 1, "value expected"); | 326 | luaL_argerror(L, 1, "value expected"); |
327 | } | 327 | } |
328 | lua_pushstring(L, buff); | 328 | lua_pushstring(L, buff); |
@@ -332,8 +332,8 @@ static int luaB_tostring (lua_State *L) { | |||
332 | 332 | ||
333 | static int luaB_foreachi (lua_State *L) { | 333 | static int luaB_foreachi (lua_State *L) { |
334 | int n, i; | 334 | int n, i; |
335 | luaL_checktype(L, 1, "table"); | 335 | luaL_checktype(L, 1, LUA_TTABLE); |
336 | luaL_checktype(L, 2, "function"); | 336 | luaL_checktype(L, 2, LUA_TFUNCTION); |
337 | n = lua_getn(L, 1); | 337 | n = lua_getn(L, 1); |
338 | for (i=1; i<=n; i++) { | 338 | for (i=1; i<=n; i++) { |
339 | lua_pushvalue(L, 2); /* function */ | 339 | lua_pushvalue(L, 2); /* function */ |
@@ -349,8 +349,8 @@ static int luaB_foreachi (lua_State *L) { | |||
349 | 349 | ||
350 | 350 | ||
351 | static int luaB_foreach (lua_State *L) { | 351 | static int luaB_foreach (lua_State *L) { |
352 | luaL_checktype(L, 1, "table"); | 352 | luaL_checktype(L, 1, LUA_TTABLE); |
353 | luaL_checktype(L, 2, "function"); | 353 | luaL_checktype(L, 2, LUA_TFUNCTION); |
354 | lua_pushnil(L); /* first index */ | 354 | lua_pushnil(L); /* first index */ |
355 | for (;;) { | 355 | for (;;) { |
356 | if (lua_next(L, 1) == 0) | 356 | if (lua_next(L, 1) == 0) |
@@ -367,7 +367,7 @@ static int luaB_foreach (lua_State *L) { | |||
367 | 367 | ||
368 | 368 | ||
369 | static int luaB_assert (lua_State *L) { | 369 | static int luaB_assert (lua_State *L) { |
370 | luaL_checktype(L, 1, "any"); | 370 | luaL_checkany(L, 1); |
371 | if (lua_isnil(L, 1)) | 371 | if (lua_isnil(L, 1)) |
372 | luaL_verror(L, "assertion failed! %.90s", luaL_opt_string(L, 2, "")); | 372 | luaL_verror(L, "assertion failed! %.90s", luaL_opt_string(L, 2, "")); |
373 | return 0; | 373 | return 0; |
@@ -375,7 +375,7 @@ static int luaB_assert (lua_State *L) { | |||
375 | 375 | ||
376 | 376 | ||
377 | static int luaB_getn (lua_State *L) { | 377 | static int luaB_getn (lua_State *L) { |
378 | luaL_checktype(L, 1, "table"); | 378 | luaL_checktype(L, 1, LUA_TTABLE); |
379 | lua_pushnumber(L, lua_getn(L, 1)); | 379 | lua_pushnumber(L, lua_getn(L, 1)); |
380 | return 1; | 380 | return 1; |
381 | } | 381 | } |
@@ -384,7 +384,7 @@ static int luaB_getn (lua_State *L) { | |||
384 | static int luaB_tinsert (lua_State *L) { | 384 | static int luaB_tinsert (lua_State *L) { |
385 | int v = lua_gettop(L); /* last argument: to be inserted */ | 385 | int v = lua_gettop(L); /* last argument: to be inserted */ |
386 | int n, pos; | 386 | int n, pos; |
387 | luaL_checktype(L, 1, "table"); | 387 | luaL_checktype(L, 1, LUA_TTABLE); |
388 | n = lua_getn(L, 1); | 388 | n = lua_getn(L, 1); |
389 | if (v == 2) /* called with only 2 arguments */ | 389 | if (v == 2) /* called with only 2 arguments */ |
390 | pos = n+1; | 390 | pos = n+1; |
@@ -405,7 +405,7 @@ static int luaB_tinsert (lua_State *L) { | |||
405 | 405 | ||
406 | static int luaB_tremove (lua_State *L) { | 406 | static int luaB_tremove (lua_State *L) { |
407 | int pos, n; | 407 | int pos, n; |
408 | luaL_checktype(L, 1, "table"); | 408 | luaL_checktype(L, 1, LUA_TTABLE); |
409 | n = lua_getn(L, 1); | 409 | n = lua_getn(L, 1); |
410 | pos = luaL_opt_int(L, 2, n); | 410 | pos = luaL_opt_int(L, 2, n); |
411 | if (n <= 0) return 0; /* table is "empty" */ | 411 | if (n <= 0) return 0; /* table is "empty" */ |
@@ -517,10 +517,10 @@ static void auxsort (lua_State *L, int l, int u) { | |||
517 | 517 | ||
518 | static int luaB_sort (lua_State *L) { | 518 | static int luaB_sort (lua_State *L) { |
519 | int n; | 519 | int n; |
520 | luaL_checktype(L, 1, "table"); | 520 | luaL_checktype(L, 1, LUA_TTABLE); |
521 | n = lua_getn(L, 1); | 521 | n = lua_getn(L, 1); |
522 | if (!lua_isnull(L, 2)) /* is there a 2nd argument? */ | 522 | if (!lua_isnull(L, 2)) /* is there a 2nd argument? */ |
523 | luaL_checktype(L, 2, "function"); | 523 | luaL_checktype(L, 2, LUA_TFUNCTION); |
524 | lua_settop(L, 2); /* make sure there is two arguments */ | 524 | lua_settop(L, 2); /* make sure there is two arguments */ |
525 | auxsort(L, 1, n); | 525 | auxsort(L, 1, n); |
526 | return 0; | 526 | return 0; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.20 2000/09/05 19:33:32 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.21 2000/09/12 18:38:25 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 | */ |
@@ -103,7 +103,7 @@ static int setlocal (lua_State *L) { | |||
103 | lua_Debug ar; | 103 | lua_Debug ar; |
104 | if (!lua_getstack(L, luaL_check_int(L, 1), &ar)) /* level out of range? */ | 104 | if (!lua_getstack(L, luaL_check_int(L, 1), &ar)) /* level out of range? */ |
105 | luaL_argerror(L, 1, "level out of range"); | 105 | luaL_argerror(L, 1, "level out of range"); |
106 | luaL_checktype(L, 3, "any"); | 106 | luaL_checkany(L, 3); |
107 | lua_pushstring(L, lua_setlocal(L, &ar, luaL_check_int(L, 2))); | 107 | lua_pushstring(L, lua_setlocal(L, &ar, luaL_check_int(L, 2))); |
108 | return 1; | 108 | return 1; |
109 | } | 109 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.41 2000/09/12 18:38:02 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.42 2000/09/18 19:39:49 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 | */ |
@@ -433,7 +433,7 @@ static const char *getfuncname (lua_State *L, StkId f, const char **name) { | |||
433 | void luaG_typeerror (lua_State *L, StkId o, const char *op) { | 433 | void luaG_typeerror (lua_State *L, StkId o, const char *op) { |
434 | const char *name; | 434 | const char *name; |
435 | const char *kind = getobjname(L, o, &name); | 435 | const char *kind = getobjname(L, o, &name); |
436 | const char *t = luaO_typename(o); | 436 | const char *t = luaO_typename(L, o); |
437 | if (kind) | 437 | if (kind) |
438 | luaO_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)", | 438 | luaO_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)", |
439 | op, kind, name, t); | 439 | op, kind, name, t); |
@@ -442,7 +442,7 @@ void luaG_typeerror (lua_State *L, StkId o, const char *op) { | |||
442 | } | 442 | } |
443 | 443 | ||
444 | 444 | ||
445 | void luaG_binerror (lua_State *L, StkId p1, lua_Type t, const char *op) { | 445 | void luaG_binerror (lua_State *L, StkId p1, lua_Tag t, const char *op) { |
446 | if (ttype(p1) == t) p1++; | 446 | if (ttype(p1) == t) p1++; |
447 | LUA_ASSERT(ttype(p1) != t, "must be an error"); | 447 | LUA_ASSERT(ttype(p1) != t, "must be an error"); |
448 | luaG_typeerror(L, p1, op); | 448 | luaG_typeerror(L, p1, op); |
@@ -450,8 +450,8 @@ void luaG_binerror (lua_State *L, StkId p1, lua_Type t, const char *op) { | |||
450 | 450 | ||
451 | 451 | ||
452 | void luaG_ordererror (lua_State *L, StkId top) { | 452 | void luaG_ordererror (lua_State *L, StkId top) { |
453 | const char *t1 = luaO_typename(top-2); | 453 | const char *t1 = luaO_typename(L, top-2); |
454 | const char *t2 = luaO_typename(top-1); | 454 | const char *t2 = luaO_typename(L, top-1); |
455 | if (t1[2] == t2[2]) | 455 | if (t1[2] == t2[2]) |
456 | luaO_verror(L, "attempt to compare two %.10s values", t1); | 456 | luaO_verror(L, "attempt to compare two %.10s values", t1); |
457 | else | 457 | else |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.h,v 1.4 2000/08/10 19:50:47 roberto Exp roberto $ | 2 | ** $Id: ldebug.h,v 1.5 2000/08/11 16:17:28 roberto Exp roberto $ |
3 | ** Auxiliary functions from Debug Interface module | 3 | ** Auxiliary functions from Debug Interface module |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | 14 | ||
15 | void luaG_typeerror (lua_State *L, StkId o, const char *op); | 15 | void luaG_typeerror (lua_State *L, StkId o, const char *op); |
16 | void luaG_binerror (lua_State *L, StkId p1, lua_Type t, const char *op); | 16 | void luaG_binerror (lua_State *L, StkId p1, lua_Tag t, const char *op); |
17 | int luaG_getline (int *lineinfo, int pc, int refline, int *refi); | 17 | int luaG_getline (int *lineinfo, int pc, int refline, int *refi); |
18 | void luaG_ordererror (lua_State *L, StkId top); | 18 | void luaG_ordererror (lua_State *L, StkId top); |
19 | 19 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.98 2000/09/29 12:42:13 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.99 2000/10/02 14:47:43 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 | */ |
@@ -332,7 +332,7 @@ struct lua_longjmp { | |||
332 | 332 | ||
333 | static void message (lua_State *L, const char *s) { | 333 | static void message (lua_State *L, const char *s) { |
334 | const TObject *em = luaH_getglobal(L, LUA_ERRORMESSAGE); | 334 | const TObject *em = luaH_getglobal(L, LUA_ERRORMESSAGE); |
335 | if (*luaO_typename(em) == 'f') { | 335 | if (luaO_type(em) == LUA_TFUNCTION) { |
336 | *L->top = *em; | 336 | *L->top = *em; |
337 | incr_top; | 337 | incr_top; |
338 | lua_pushstring(L, s); | 338 | lua_pushstring(L, s); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.84 2000/09/14 14:09:31 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.85 2000/09/22 18:14:06 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 | */ |
@@ -449,7 +449,7 @@ static int io_write (lua_State *L) { | |||
449 | if (f) arg++; | 449 | if (f) arg++; |
450 | else f = getfilebyref(L, ctrl, OUTFILE); /* get _OUTPUT */ | 450 | else f = getfilebyref(L, ctrl, OUTFILE); /* get _OUTPUT */ |
451 | for (; arg <= lastarg; arg++) { | 451 | for (; arg <= lastarg; arg++) { |
452 | if (lua_type(L, arg)[2] == 'm') { /* nuMber? */ /* LUA_NUMBER */ | 452 | if (lua_type(L, arg) == LUA_TNUMBER) { /* LUA_NUMBER */ |
453 | /* optimization: could be done exactly as for strings */ | 453 | /* optimization: could be done exactly as for strings */ |
454 | status = status && fprintf(f, "%.16g", lua_tonumber(L, arg)) > 0; | 454 | status = status && fprintf(f, "%.16g", lua_tonumber(L, arg)) > 0; |
455 | } | 455 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 1.48 2000/09/12 13:47:39 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 1.49 2000/09/29 12:42:13 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -17,16 +17,14 @@ | |||
17 | #include "lstate.h" | 17 | #include "lstate.h" |
18 | 18 | ||
19 | 19 | ||
20 | /* | 20 | |
21 | ** you can use the fact that the 3rd letter of each name is always different | 21 | const lua_Type luaO_typearr[] = { /* ORDER LUA_T */ |
22 | ** (e-m-r-b-n-l) to compare and switch these strings | 22 | LUA_TUSERDATA, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, |
23 | */ | 23 | LUA_TFUNCTION, LUA_TFUNCTION, LUA_TNIL |
24 | const char *const luaO_typenames[] = { /* ORDER LUA_T */ | ||
25 | "userdata", "number", "string", "table", "function", "function", "nil", | ||
26 | "function", "function" | ||
27 | }; | 24 | }; |
28 | 25 | ||
29 | 26 | ||
27 | |||
30 | const TObject luaO_nilobject = {TAG_NIL, {NULL}}; | 28 | const TObject luaO_nilobject = {TAG_NIL, {NULL}}; |
31 | 29 | ||
32 | 30 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 1.76 2000/09/11 20:29:27 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 1.77 2000/09/29 12:42:13 roberto Exp roberto $ |
3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -48,7 +48,7 @@ typedef enum { | |||
48 | TAG_LMARK, /* mark for Lua closures */ | 48 | TAG_LMARK, /* mark for Lua closures */ |
49 | TAG_CMARK /* mark for C closures */ | 49 | TAG_CMARK /* mark for C closures */ |
50 | 50 | ||
51 | } lua_Type; | 51 | } lua_Tag; |
52 | 52 | ||
53 | /* tags for values visible from Lua == first user-created tag */ | 53 | /* tags for values visible from Lua == first user-created tag */ |
54 | #define NUM_TAGS 7 | 54 | #define NUM_TAGS 7 |
@@ -80,7 +80,7 @@ typedef union { | |||
80 | 80 | ||
81 | 81 | ||
82 | typedef struct lua_TObject { | 82 | typedef struct lua_TObject { |
83 | lua_Type ttype; | 83 | lua_Tag ttype; |
84 | Value value; | 84 | Value value; |
85 | } TObject; | 85 | } TObject; |
86 | 86 | ||
@@ -189,10 +189,12 @@ typedef struct CallInfo { | |||
189 | } CallInfo; | 189 | } CallInfo; |
190 | 190 | ||
191 | 191 | ||
192 | extern const char *const luaO_typenames[]; | 192 | extern const lua_Type luaO_typearr[]; |
193 | extern const TObject luaO_nilobject; | 193 | extern const TObject luaO_nilobject; |
194 | 194 | ||
195 | #define luaO_typename(o) luaO_typenames[ttype(o)] | 195 | #define luaO_tag2type(t) (luaO_typearr[(int)(t)]) |
196 | #define luaO_type(o) (luaO_tag2type(ttype(o))) | ||
197 | #define luaO_typename(L, o) (lua_typename(L, luaO_type(o))) | ||
196 | 198 | ||
197 | lint32 luaO_power2 (lint32 n); | 199 | lint32 luaO_power2 (lint32 n); |
198 | char *luaO_openspace (lua_State *L, size_t n); | 200 | char *luaO_openspace (lua_State *L, size_t n); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.45 2000/09/29 12:42:13 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.46 2000/10/02 14:47:43 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 | */ |
@@ -182,7 +182,7 @@ static int hash_query (lua_State *L) { | |||
182 | } | 182 | } |
183 | else { | 183 | else { |
184 | Hash *t; | 184 | Hash *t; |
185 | luaL_checktype(L, 2, "table"); | 185 | luaL_checktype(L, 2, LUA_TTABLE); |
186 | t = hvalue(luaA_index(L, 2)); | 186 | t = hvalue(luaA_index(L, 2)); |
187 | lua_pushnumber(L, luaH_mainposition(t, luaA_index(L, 1)) - t->node); | 187 | lua_pushnumber(L, luaH_mainposition(t, luaA_index(L, 1)) - t->node); |
188 | } | 188 | } |
@@ -193,7 +193,7 @@ static int hash_query (lua_State *L) { | |||
193 | static int table_query (lua_State *L) { | 193 | static int table_query (lua_State *L) { |
194 | const Hash *t; | 194 | const Hash *t; |
195 | int i = luaL_opt_int(L, 2, -1); | 195 | int i = luaL_opt_int(L, 2, -1); |
196 | luaL_checktype(L, 1, "table"); | 196 | luaL_checktype(L, 1, LUA_TTABLE); |
197 | t = hvalue(luaA_index(L, 1)); | 197 | t = hvalue(luaA_index(L, 1)); |
198 | if (i == -1) { | 198 | if (i == -1) { |
199 | lua_pushnumber(L, t->size); | 199 | lua_pushnumber(L, t->size); |
@@ -238,7 +238,7 @@ static int string_query (lua_State *L) { | |||
238 | 238 | ||
239 | 239 | ||
240 | static int tref (lua_State *L) { | 240 | static int tref (lua_State *L) { |
241 | luaL_checktype(L, 1, "any"); | 241 | luaL_checkany(L, 1); |
242 | lua_pushvalue(L, 1); | 242 | lua_pushvalue(L, 1); |
243 | lua_pushnumber(L, lua_ref(L, luaL_opt_int(L, 2, 1))); | 243 | lua_pushnumber(L, lua_ref(L, luaL_opt_int(L, 2, 1))); |
244 | return 1; | 244 | return 1; |
@@ -262,7 +262,7 @@ static int newuserdata (lua_State *L) { | |||
262 | } | 262 | } |
263 | 263 | ||
264 | static int udataval (lua_State *L) { | 264 | static int udataval (lua_State *L) { |
265 | luaL_checktype(L, 1, "userdata"); | 265 | luaL_checktype(L, 1, LUA_TUSERDATA); |
266 | lua_pushnumber(L, (int)lua_touserdata(L, 1)); | 266 | lua_pushnumber(L, (int)lua_touserdata(L, 1)); |
267 | return 1; | 267 | return 1; |
268 | } | 268 | } |
@@ -290,7 +290,7 @@ static int loadlib (lua_State *L) { | |||
290 | } | 290 | } |
291 | 291 | ||
292 | static int closestate (lua_State *L) { | 292 | static int closestate (lua_State *L) { |
293 | luaL_checktype(L, 1, "userdata"); | 293 | luaL_checktype(L, 1, LUA_TUSERDATA); |
294 | lua_close((lua_State *)lua_touserdata(L, 1)); | 294 | lua_close((lua_State *)lua_touserdata(L, 1)); |
295 | return 0; | 295 | return 0; |
296 | } | 296 | } |
@@ -299,7 +299,7 @@ static int doremote (lua_State *L) { | |||
299 | lua_State *L1; | 299 | lua_State *L1; |
300 | const char *code = luaL_check_string(L, 2); | 300 | const char *code = luaL_check_string(L, 2); |
301 | int status; | 301 | int status; |
302 | luaL_checktype(L, 1, "userdata"); | 302 | luaL_checktype(L, 1, LUA_TUSERDATA); |
303 | L1 = (lua_State *)lua_touserdata(L, 1); | 303 | L1 = (lua_State *)lua_touserdata(L, 1); |
304 | status = lua_dostring(L1, code); | 304 | status = lua_dostring(L1, code); |
305 | if (status != 0) { | 305 | if (status != 0) { |
@@ -316,7 +316,7 @@ static int doremote (lua_State *L) { | |||
316 | } | 316 | } |
317 | 317 | ||
318 | static int settagmethod (lua_State *L) { | 318 | static int settagmethod (lua_State *L) { |
319 | luaL_checktype(L, 3, "any"); | 319 | luaL_checkany(L, 3); |
320 | lua_settagmethod(L, luaL_check_int(L, 1), luaL_check_string(L, 2)); | 320 | lua_settagmethod(L, luaL_check_int(L, 1), luaL_check_string(L, 2)); |
321 | return 1; | 321 | return 1; |
322 | } | 322 | } |
@@ -436,7 +436,7 @@ static int testC (lua_State *L) { | |||
436 | lua_dostring(L, luaL_check_string(L, getnum)); | 436 | lua_dostring(L, luaL_check_string(L, getnum)); |
437 | } | 437 | } |
438 | else if EQ("type") { | 438 | else if EQ("type") { |
439 | lua_pushstring(L, lua_type(L, getnum)); | 439 | lua_pushstring(L, lua_typename(L, lua_type(L, getnum))); |
440 | } | 440 | } |
441 | else luaL_verror(L, "unknown instruction %.30s", buff); | 441 | else luaL_verror(L, "unknown instruction %.30s", buff); |
442 | } | 442 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.49 2000/09/11 20:29:27 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.50 2000/09/29 12:42:13 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 | */ |
@@ -118,7 +118,7 @@ int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) { | |||
118 | 118 | ||
119 | 119 | ||
120 | int luaT_effectivetag (lua_State *L, const TObject *o) { | 120 | int luaT_effectivetag (lua_State *L, const TObject *o) { |
121 | lua_Type t = ttype(o); | 121 | lua_Tag t = ttype(o); |
122 | switch (t) { | 122 | switch (t) { |
123 | case TAG_USERDATA: { | 123 | case TAG_USERDATA: { |
124 | int tag = tsvalue(o)->u.d.tag; | 124 | int tag = tsvalue(o)->u.d.tag; |
@@ -151,7 +151,7 @@ void lua_settagmethod (lua_State *L, int t, const char *event) { | |||
151 | checktag(L, t); | 151 | checktag(L, t); |
152 | if (!luaT_validevent(t, e)) | 152 | if (!luaT_validevent(t, e)) |
153 | luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", | 153 | luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", |
154 | luaT_eventname[e], luaO_typenames[t], | 154 | luaT_eventname[e], lua_typename(L, luaO_tag2type(t)), |
155 | (t == TAG_TABLE || t == TAG_USERDATA) ? " with default tag" | 155 | (t == TAG_TABLE || t == TAG_USERDATA) ? " with default tag" |
156 | : ""); | 156 | : ""); |
157 | temp = *(L->top - 1); | 157 | temp = *(L->top - 1); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.70 2000/09/18 19:39:18 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.71 2000/10/02 14:47: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 |
@@ -48,6 +48,13 @@ typedef struct lua_State lua_State; | |||
48 | typedef int (*lua_CFunction) (lua_State *L); | 48 | typedef int (*lua_CFunction) (lua_State *L); |
49 | 49 | ||
50 | 50 | ||
51 | typedef enum lua_Type { | ||
52 | LUA_NOVALUE, LUA_TUSERDATA, LUA_TNUMBER, LUA_TSTRING, | ||
53 | LUA_TTABLE, LUA_TFUNCTION, LUA_TNIL | ||
54 | } lua_Type; | ||
55 | |||
56 | |||
57 | |||
51 | /* | 58 | /* |
52 | ** state manipulation | 59 | ** state manipulation |
53 | */ | 60 | */ |
@@ -70,8 +77,10 @@ int lua_stackspace (lua_State *L); | |||
70 | ** access functions (stack -> C) | 77 | ** access functions (stack -> C) |
71 | */ | 78 | */ |
72 | 79 | ||
73 | const char *lua_type (lua_State *L, int index); | 80 | lua_Type lua_type (lua_State *L, int index); |
81 | const char *lua_typename (lua_State *L, lua_Type t); | ||
74 | int lua_isnumber (lua_State *L, int index); | 82 | int lua_isnumber (lua_State *L, int index); |
83 | int lua_isstring (lua_State *L, int index); | ||
75 | int lua_iscfunction (lua_State *L, int index); | 84 | int lua_iscfunction (lua_State *L, int index); |
76 | int lua_tag (lua_State *L, int index); | 85 | int lua_tag (lua_State *L, int index); |
77 | 86 | ||
@@ -171,12 +180,11 @@ void lua_concat (lua_State *L, int n); | |||
171 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0) | 180 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0) |
172 | #define lua_clonetag(L,t) lua_copytagmethods(L, lua_newtag(L), (t)) | 181 | #define lua_clonetag(L,t) lua_copytagmethods(L, lua_newtag(L), (t)) |
173 | 182 | ||
174 | #define lua_isfunction(L,n) (*lua_type(L,n) == 'f') | 183 | #define lua_isfunction(L,n) (lua_type(L,n) == LUA_TFUNCTION) |
175 | #define lua_isstring(L,n) (lua_tostring(L,n) != 0) | 184 | #define lua_istable(L,n) (lua_type(L,n) == LUA_TTABLE) |
176 | #define lua_istable(L,n) (*lua_type(L,n) == 't') | 185 | #define lua_isuserdata(L,n) (lua_type(L,n) == LUA_TUSERDATA) |
177 | #define lua_isuserdata(L,n) (*lua_type(L,n) == 'u') | 186 | #define lua_isnil(L,n) (lua_type(L,n) == LUA_TNIL) |
178 | #define lua_isnil(L,n) (lua_type(L,n)[2] == 'l') | 187 | #define lua_isnull(L,n) (lua_type(L,n) == LUA_NOVALUE) |
179 | #define lua_isnull(L,n) (*lua_type(L,n) == 'N') | ||
180 | 188 | ||
181 | #endif | 189 | #endif |
182 | 190 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.137 2000/09/25 14:48:42 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.138 2000/10/02 14:47:43 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -85,7 +85,7 @@ static void traceexec (lua_State *L, StkId base, StkId top, lua_Hook linehook) { | |||
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | static Closure *luaV_closure (lua_State *L, lua_Type t, int nelems) { | 88 | static Closure *luaV_closure (lua_State *L, lua_Tag t, int nelems) { |
89 | Closure *c = luaF_newclosure(L, nelems); | 89 | Closure *c = luaF_newclosure(L, nelems); |
90 | L->top -= nelems; | 90 | L->top -= nelems; |
91 | while (nelems--) | 91 | while (nelems--) |