diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-23 14:17:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-23 14:17:25 -0300 |
commit | 39b79783297bee79db9853b63d199e120a009a8f (patch) | |
tree | c738c621c4c28d8822c2f785400786301985273b /ltests.c | |
parent | d164e2294f73d8e69f00d95a66014514b2dd0ec0 (diff) | |
download | lua-39b79783297bee79db9853b63d199e120a009a8f.tar.gz lua-39b79783297bee79db9853b63d199e120a009a8f.tar.bz2 lua-39b79783297bee79db9853b63d199e120a009a8f.zip |
first (big) step to support wide chars
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 266 |
1 files changed, 133 insertions, 133 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.70 2001/02/21 16:51:25 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.71 2001/02/22 18:59:59 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 | */ |
@@ -42,7 +42,7 @@ int islocked = 0; | |||
42 | 42 | ||
43 | 43 | ||
44 | 44 | ||
45 | static void setnameval (lua_State *L, const char *name, int val) { | 45 | static void setnameval (lua_State *L, const l_char *name, int val) { |
46 | lua_pushstring(L, name); | 46 | lua_pushstring(L, name); |
47 | lua_pushnumber(L, val); | 47 | lua_pushnumber(L, val); |
48 | lua_settable(L, -3); | 48 | lua_settable(L, -3); |
@@ -63,7 +63,7 @@ static void setnameval (lua_State *L, const char *name, int val) { | |||
63 | #define MARK 0x55 /* 01010101 (a nice pattern) */ | 63 | #define MARK 0x55 /* 01010101 (a nice pattern) */ |
64 | 64 | ||
65 | 65 | ||
66 | #define blocksize(b) ((size_t *)((char *)(b) - HEADER)) | 66 | #define blocksize(b) ((size_t *)((l_char *)(b) - HEADER)) |
67 | 67 | ||
68 | unsigned long memdebug_numblocks = 0; | 68 | unsigned long memdebug_numblocks = 0; |
69 | unsigned long memdebug_total = 0; | 69 | unsigned long memdebug_total = 0; |
@@ -76,7 +76,7 @@ static void *checkblock (void *block) { | |||
76 | size_t size = *b; | 76 | size_t size = *b; |
77 | int i; | 77 | int i; |
78 | for (i=0;i<MARKSIZE;i++) | 78 | for (i=0;i<MARKSIZE;i++) |
79 | lua_assert(*(((char *)b)+HEADER+size+i) == MARK+i); /* corrupted block? */ | 79 | lua_assert(*(((l_char *)b)+HEADER+size+i) == MARK+i); /* corrupted block? */ |
80 | return b; | 80 | return b; |
81 | } | 81 | } |
82 | 82 | ||
@@ -102,11 +102,11 @@ void *debug_realloc (void *block, size_t oldsize, size_t size) { | |||
102 | else if (memdebug_total+size-oldsize > memdebug_memlimit) | 102 | else if (memdebug_total+size-oldsize > memdebug_memlimit) |
103 | return NULL; /* to test memory allocation errors */ | 103 | return NULL; /* to test memory allocation errors */ |
104 | else { | 104 | else { |
105 | char *newblock; | 105 | l_char *newblock; |
106 | int i; | 106 | int i; |
107 | size_t realsize = HEADER+size+MARKSIZE; | 107 | size_t realsize = HEADER+size+MARKSIZE; |
108 | if (realsize < size) return NULL; /* overflow! */ | 108 | if (realsize < size) return NULL; /* overflow! */ |
109 | newblock = (char *)malloc(realsize); /* alloc a new block */ | 109 | newblock = (l_char *)malloc(realsize); /* alloc a new block */ |
110 | if (newblock == NULL) return NULL; | 110 | if (newblock == NULL) return NULL; |
111 | if (oldsize > size) oldsize = size; | 111 | if (oldsize > size) oldsize = size; |
112 | if (block) { | 112 | if (block) { |
@@ -121,7 +121,7 @@ void *debug_realloc (void *block, size_t oldsize, size_t size) { | |||
121 | memdebug_numblocks++; | 121 | memdebug_numblocks++; |
122 | *(size_t *)newblock = size; | 122 | *(size_t *)newblock = size; |
123 | for (i=0;i<MARKSIZE;i++) | 123 | for (i=0;i<MARKSIZE;i++) |
124 | *(newblock+HEADER+size+i) = (char)(MARK+i); | 124 | *(newblock+HEADER+size+i) = (l_char)(MARK+i); |
125 | return newblock+HEADER; | 125 | return newblock+HEADER; |
126 | } | 126 | } |
127 | } | 127 | } |
@@ -138,36 +138,36 @@ void *debug_realloc (void *block, size_t oldsize, size_t size) { | |||
138 | */ | 138 | */ |
139 | 139 | ||
140 | 140 | ||
141 | static const char *const instrname[NUM_OPCODES] = { | 141 | static const l_char *const instrname[NUM_OPCODES] = { |
142 | "RETURN", "CALL", "TAILCALL", "PUSHNIL", "POP", "PUSHINT", | 142 | l_s("RETURN"), l_s("CALL"), l_s("TAILCALL"), l_s("PUSHNIL"), l_s("POP"), l_s("PUSHINT"), |
143 | "PUSHSTRING", "PUSHNUM", "PUSHNEGNUM", "PUSHUPVALUE", "GETLOCAL", | 143 | l_s("PUSHSTRING"), l_s("PUSHNUM"), l_s("PUSHNEGNUM"), l_s("PUSHUPVALUE"), l_s("GETLOCAL"), |
144 | "GETGLOBAL", "GETTABLE", "GETDOTTED", "GETINDEXED", "PUSHSELF", | 144 | l_s("GETGLOBAL"), l_s("GETTABLE"), l_s("GETDOTTED"), l_s("GETINDEXED"), l_s("PUSHSELF"), |
145 | "CREATETABLE", "SETLOCAL", "SETGLOBAL", "SETTABLE", "SETLIST", "SETMAP", | 145 | l_s("CREATETABLE"), l_s("SETLOCAL"), l_s("SETGLOBAL"), l_s("SETTABLE"), l_s("SETLIST"), l_s("SETMAP"), |
146 | "ADD", "ADDI", "SUB", "MULT", "DIV", "POW", "CONCAT", "MINUS", "NOT", | 146 | l_s("ADD"), l_s("ADDI"), l_s("SUB"), l_s("MULT"), l_s("DIV"), l_s("POW"), l_s("CONCAT"), l_s("MINUS"), l_s("NOT"), |
147 | "JMPNE", "JMPEQ", "JMPLT", "JMPLE", "JMPGT", "JMPGE", "JMPT", "JMPF", | 147 | l_s("JMPNE"), l_s("JMPEQ"), l_s("JMPLT"), l_s("JMPLE"), l_s("JMPGT"), l_s("JMPGE"), l_s("JMPT"), l_s("JMPF"), |
148 | "JMPONT", "JMPONF", "JMP", "PUSHNILJMP", "FORPREP", "FORLOOP", "LFORPREP", | 148 | l_s("JMPONT"), l_s("JMPONF"), l_s("JMP"), l_s("PUSHNILJMP"), l_s("FORPREP"), l_s("FORLOOP"), l_s("LFORPREP"), |
149 | "LFORLOOP", "CLOSURE" | 149 | l_s("LFORLOOP"), l_s("CLOSURE") |
150 | }; | 150 | }; |
151 | 151 | ||
152 | 152 | ||
153 | static void pushop (lua_State *L, Proto *p, int pc) { | 153 | static void pushop (lua_State *L, Proto *p, int pc) { |
154 | char buff[100]; | 154 | l_char buff[100]; |
155 | Instruction i = p->code[pc]; | 155 | Instruction i = p->code[pc]; |
156 | OpCode o = GET_OPCODE(i); | 156 | OpCode o = GET_OPCODE(i); |
157 | const char *name = instrname[o]; | 157 | const l_char *name = instrname[o]; |
158 | sprintf(buff, "%5d - ", luaG_getline(p->lineinfo, pc, 1, NULL)); | 158 | sprintf(buff, l_s("%5d - "), luaG_getline(p->lineinfo, pc, 1, NULL)); |
159 | switch ((enum Mode)luaK_opproperties[o].mode) { | 159 | switch ((enum Mode)luaK_opproperties[o].mode) { |
160 | case iO: | 160 | case iO: |
161 | sprintf(buff+8, "%-12s", name); | 161 | sprintf(buff+8, l_s("%-12s"), name); |
162 | break; | 162 | break; |
163 | case iU: | 163 | case iU: |
164 | sprintf(buff+8, "%-12s%4u", name, GETARG_U(i)); | 164 | sprintf(buff+8, l_s("%-12s%4u"), name, GETARG_U(i)); |
165 | break; | 165 | break; |
166 | case iS: | 166 | case iS: |
167 | sprintf(buff+8, "%-12s%4d", name, GETARG_S(i)); | 167 | sprintf(buff+8, l_s("%-12s%4d"), name, GETARG_S(i)); |
168 | break; | 168 | break; |
169 | case iAB: | 169 | case iAB: |
170 | sprintf(buff+8, "%-12s%4d %4d", name, GETARG_A(i), GETARG_B(i)); | 170 | sprintf(buff+8, l_s("%-12s%4d %4d"), name, GETARG_A(i), GETARG_B(i)); |
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | lua_pushstring(L, buff); | 173 | lua_pushstring(L, buff); |
@@ -178,11 +178,11 @@ static int listcode (lua_State *L) { | |||
178 | int pc; | 178 | int pc; |
179 | Proto *p; | 179 | Proto *p; |
180 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 180 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
181 | 1, "Lua function expected"); | 181 | 1, l_s("Lua function expected")); |
182 | p = clvalue(luaA_index(L, 1))->f.l; | 182 | p = clvalue(luaA_index(L, 1))->f.l; |
183 | lua_newtable(L); | 183 | lua_newtable(L); |
184 | setnameval(L, "maxstack", p->maxstacksize); | 184 | setnameval(L, l_s("maxstack"), p->maxstacksize); |
185 | setnameval(L, "numparams", p->numparams); | 185 | setnameval(L, l_s("numparams"), p->numparams); |
186 | for (pc=0; pc<p->sizecode; pc++) { | 186 | for (pc=0; pc<p->sizecode; pc++) { |
187 | lua_pushnumber(L, pc+1); | 187 | lua_pushnumber(L, pc+1); |
188 | pushop(L, p, pc); | 188 | pushop(L, p, pc); |
@@ -196,7 +196,7 @@ static int liststrings (lua_State *L) { | |||
196 | Proto *p; | 196 | Proto *p; |
197 | int i; | 197 | int i; |
198 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 198 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
199 | 1, "Lua function expected"); | 199 | 1, l_s("Lua function expected")); |
200 | p = clvalue(luaA_index(L, 1))->f.l; | 200 | p = clvalue(luaA_index(L, 1))->f.l; |
201 | lua_newtable(L); | 201 | lua_newtable(L); |
202 | for (i=0; i<p->sizekstr; i++) { | 202 | for (i=0; i<p->sizekstr; i++) { |
@@ -212,9 +212,9 @@ static int listlocals (lua_State *L) { | |||
212 | Proto *p; | 212 | Proto *p; |
213 | int pc = luaL_check_int(L, 2) - 1; | 213 | int pc = luaL_check_int(L, 2) - 1; |
214 | int i = 0; | 214 | int i = 0; |
215 | const char *name; | 215 | const l_char *name; |
216 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 216 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
217 | 1, "Lua function expected"); | 217 | 1, l_s("Lua function expected")); |
218 | p = clvalue(luaA_index(L, 1))->f.l; | 218 | p = clvalue(luaA_index(L, 1))->f.l; |
219 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) | 219 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) |
220 | lua_pushstring(L, name); | 220 | lua_pushstring(L, name); |
@@ -234,22 +234,22 @@ static int pushbool (lua_State *L, int b) { | |||
234 | 234 | ||
235 | static int get_limits (lua_State *L) { | 235 | static int get_limits (lua_State *L) { |
236 | lua_newtable(L); | 236 | lua_newtable(L); |
237 | setnameval(L, "BITS_INT", BITS_INT); | 237 | setnameval(L, l_s("BITS_INT"), BITS_INT); |
238 | setnameval(L, "LFPF", LFIELDS_PER_FLUSH); | 238 | setnameval(L, l_s("LFPF"), LFIELDS_PER_FLUSH); |
239 | setnameval(L, "MAXARG_A", MAXARG_A); | 239 | setnameval(L, l_s("MAXARG_A"), MAXARG_A); |
240 | setnameval(L, "MAXARG_B", MAXARG_B); | 240 | setnameval(L, l_s("MAXARG_B"), MAXARG_B); |
241 | setnameval(L, "MAXARG_S", MAXARG_S); | 241 | setnameval(L, l_s("MAXARG_S"), MAXARG_S); |
242 | setnameval(L, "MAXARG_U", MAXARG_U); | 242 | setnameval(L, l_s("MAXARG_U"), MAXARG_U); |
243 | setnameval(L, "MAXLOCALS", MAXLOCALS); | 243 | setnameval(L, l_s("MAXLOCALS"), MAXLOCALS); |
244 | setnameval(L, "MAXPARAMS", MAXPARAMS); | 244 | setnameval(L, l_s("MAXPARAMS"), MAXPARAMS); |
245 | setnameval(L, "MAXSTACK", MAXSTACK); | 245 | setnameval(L, l_s("MAXSTACK"), MAXSTACK); |
246 | setnameval(L, "MAXUPVALUES", MAXUPVALUES); | 246 | setnameval(L, l_s("MAXUPVALUES"), MAXUPVALUES); |
247 | setnameval(L, "MAXVARSLH", MAXVARSLH); | 247 | setnameval(L, l_s("MAXVARSLH"), MAXVARSLH); |
248 | setnameval(L, "RFPF", RFIELDS_PER_FLUSH); | 248 | setnameval(L, l_s("RFPF"), RFIELDS_PER_FLUSH); |
249 | setnameval(L, "SIZE_A", SIZE_A); | 249 | setnameval(L, l_s("SIZE_A"), SIZE_A); |
250 | setnameval(L, "SIZE_B", SIZE_B); | 250 | setnameval(L, l_s("SIZE_B"), SIZE_B); |
251 | setnameval(L, "SIZE_OP", SIZE_OP); | 251 | setnameval(L, l_s("SIZE_OP"), SIZE_OP); |
252 | setnameval(L, "SIZE_U", SIZE_U); | 252 | setnameval(L, l_s("SIZE_U"), SIZE_U); |
253 | return 1; | 253 | return 1; |
254 | } | 254 | } |
255 | 255 | ||
@@ -270,7 +270,7 @@ static int mem_query (lua_State *L) { | |||
270 | 270 | ||
271 | static int hash_query (lua_State *L) { | 271 | static int hash_query (lua_State *L) { |
272 | if (lua_isnull(L, 2)) { | 272 | if (lua_isnull(L, 2)) { |
273 | luaL_arg_check(L, lua_tag(L, 1) == LUA_TSTRING, 1, "string expected"); | 273 | luaL_arg_check(L, lua_tag(L, 1) == LUA_TSTRING, 1, l_s("string expected")); |
274 | lua_pushnumber(L, tsvalue(luaA_index(L, 1))->u.s.hash); | 274 | lua_pushnumber(L, tsvalue(luaA_index(L, 1))->u.s.hash); |
275 | } | 275 | } |
276 | else { | 276 | else { |
@@ -313,7 +313,7 @@ static int table_query (lua_State *L) { | |||
313 | 313 | ||
314 | 314 | ||
315 | static int string_query (lua_State *L) { | 315 | static int string_query (lua_State *L) { |
316 | stringtable *tb = (*luaL_check_string(L, 1) == 's') ? &G(L)->strt : | 316 | stringtable *tb = (*luaL_check_string(L, 1) == l_c('s')) ? &G(L)->strt : |
317 | &G(L)->udt; | 317 | &G(L)->udt; |
318 | int s = luaL_opt_int(L, 2, 0) - 1; | 318 | int s = luaL_opt_int(L, 2, 0) - 1; |
319 | if (s==-1) { | 319 | if (s==-1) { |
@@ -364,8 +364,8 @@ static int newuserdata (lua_State *L) { | |||
364 | } | 364 | } |
365 | else { | 365 | else { |
366 | size_t size = luaL_check_int(L, 1); | 366 | size_t size = luaL_check_int(L, 1); |
367 | char *p = (char *)lua_newuserdata(L, size); | 367 | l_char *p = (l_char *)lua_newuserdata(L, size); |
368 | while (size--) *p++ = '\0'; | 368 | while (size--) *p++ = l_c('\0'); |
369 | return 1; | 369 | return 1; |
370 | } | 370 | } |
371 | } | 371 | } |
@@ -400,7 +400,7 @@ static int s2d (lua_State *L) { | |||
400 | 400 | ||
401 | static int d2s (lua_State *L) { | 401 | static int d2s (lua_State *L) { |
402 | double d = luaL_check_number(L, 1); | 402 | double d = luaL_check_number(L, 1); |
403 | lua_pushlstring(L, (char *)&d, sizeof(d)); | 403 | lua_pushlstring(L, (l_char *)&d, sizeof(d)); |
404 | return 1; | 404 | return 1; |
405 | } | 405 | } |
406 | 406 | ||
@@ -419,12 +419,12 @@ static int newstate (lua_State *L) { | |||
419 | static int loadlib (lua_State *L) { | 419 | static int loadlib (lua_State *L) { |
420 | lua_State *L1 = (lua_State *)lua_touserdata(L, 1); | 420 | lua_State *L1 = (lua_State *)lua_touserdata(L, 1); |
421 | switch (*luaL_check_string(L, 2)) { | 421 | switch (*luaL_check_string(L, 2)) { |
422 | case 'm': lua_mathlibopen(L1); break; | 422 | case l_c('m'): lua_mathlibopen(L1); break; |
423 | case 's': lua_strlibopen(L1); break; | 423 | case l_c('s'): lua_strlibopen(L1); break; |
424 | case 'i': lua_iolibopen(L1); break; | 424 | case l_c('i'): lua_iolibopen(L1); break; |
425 | case 'd': lua_dblibopen(L1); break; | 425 | case l_c('d'): lua_dblibopen(L1); break; |
426 | case 'b': lua_baselibopen(L1); break; | 426 | case l_c('b'): lua_baselibopen(L1); break; |
427 | default: luaL_argerror(L, 2, "invalid option"); | 427 | default: luaL_argerror(L, 2, l_s("invalid option")); |
428 | } | 428 | } |
429 | return 0; | 429 | return 0; |
430 | } | 430 | } |
@@ -438,7 +438,7 @@ static int closestate (lua_State *L) { | |||
438 | 438 | ||
439 | static int doremote (lua_State *L) { | 439 | static int doremote (lua_State *L) { |
440 | lua_State *L1; | 440 | lua_State *L1; |
441 | const char *code = luaL_check_string(L, 2); | 441 | const l_char *code = luaL_check_string(L, 2); |
442 | int status; | 442 | int status; |
443 | L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1); | 443 | L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1); |
444 | status = lua_dostring(L1, code); | 444 | status = lua_dostring(L1, code); |
@@ -457,7 +457,7 @@ static int doremote (lua_State *L) { | |||
457 | 457 | ||
458 | static int settagmethod (lua_State *L) { | 458 | static int settagmethod (lua_State *L) { |
459 | int tag = luaL_check_int(L, 1); | 459 | int tag = luaL_check_int(L, 1); |
460 | const char *event = luaL_check_string(L, 2); | 460 | const l_char *event = luaL_check_string(L, 2); |
461 | luaL_checkany(L, 3); | 461 | luaL_checkany(L, 3); |
462 | lua_gettagmethod(L, tag, event); | 462 | lua_gettagmethod(L, tag, event); |
463 | lua_pushvalue(L, 3); | 463 | lua_pushvalue(L, 3); |
@@ -478,36 +478,36 @@ static int equal (lua_State *L) { | |||
478 | ** ======================================================= | 478 | ** ======================================================= |
479 | */ | 479 | */ |
480 | 480 | ||
481 | static const char *const delimits = " \t\n,;"; | 481 | static const l_char *const delimits = l_s(" \t\n,;"); |
482 | 482 | ||
483 | static void skip (const char **pc) { | 483 | static void skip (const l_char **pc) { |
484 | while (**pc != '\0' && strchr(delimits, **pc)) (*pc)++; | 484 | while (**pc != l_c('\0') && strchr(delimits, **pc)) (*pc)++; |
485 | } | 485 | } |
486 | 486 | ||
487 | static int getnum (lua_State *L, const char **pc) { | 487 | static int getnum (lua_State *L, const l_char **pc) { |
488 | int res = 0; | 488 | int res = 0; |
489 | int sig = 1; | 489 | int sig = 1; |
490 | skip(pc); | 490 | skip(pc); |
491 | if (**pc == '.') { | 491 | if (**pc == l_c('.')) { |
492 | res = (int)lua_tonumber(L, -1); | 492 | res = (int)lua_tonumber(L, -1); |
493 | lua_pop(L, 1); | 493 | lua_pop(L, 1); |
494 | (*pc)++; | 494 | (*pc)++; |
495 | return res; | 495 | return res; |
496 | } | 496 | } |
497 | else if (**pc == '-') { | 497 | else if (**pc == l_c('-')) { |
498 | sig = -1; | 498 | sig = -1; |
499 | (*pc)++; | 499 | (*pc)++; |
500 | } | 500 | } |
501 | while (isdigit(**pc)) res = res*10 + (*(*pc)++) - '0'; | 501 | while (isdigit(**pc)) res = res*10 + (*(*pc)++) - l_c('0'); |
502 | return sig*res; | 502 | return sig*res; |
503 | } | 503 | } |
504 | 504 | ||
505 | static const char *getname (char *buff, const char **pc) { | 505 | static const l_char *getname (l_char *buff, const l_char **pc) { |
506 | int i = 0; | 506 | int i = 0; |
507 | skip(pc); | 507 | skip(pc); |
508 | while (**pc != '\0' && !strchr(delimits, **pc)) | 508 | while (**pc != l_c('\0') && !strchr(delimits, **pc)) |
509 | buff[i++] = *(*pc)++; | 509 | buff[i++] = *(*pc)++; |
510 | buff[i] = '\0'; | 510 | buff[i] = l_c('\0'); |
511 | return buff; | 511 | return buff; |
512 | } | 512 | } |
513 | 513 | ||
@@ -519,121 +519,121 @@ static const char *getname (char *buff, const char **pc) { | |||
519 | 519 | ||
520 | 520 | ||
521 | static int testC (lua_State *L) { | 521 | static int testC (lua_State *L) { |
522 | char buff[30]; | 522 | l_char buff[30]; |
523 | const char *pc = luaL_check_string(L, 1); | 523 | const l_char *pc = luaL_check_string(L, 1); |
524 | for (;;) { | 524 | for (;;) { |
525 | const char *inst = getname; | 525 | const l_char *inst = getname; |
526 | if EQ("") return 0; | 526 | if EQ(l_s("")) return 0; |
527 | else if EQ("isnumber") { | 527 | else if EQ(l_s("isnumber")) { |
528 | lua_pushnumber(L, lua_isnumber(L, getnum)); | 528 | lua_pushnumber(L, lua_isnumber(L, getnum)); |
529 | } | 529 | } |
530 | else if EQ("isstring") { | 530 | else if EQ(l_s("isstring")) { |
531 | lua_pushnumber(L, lua_isstring(L, getnum)); | 531 | lua_pushnumber(L, lua_isstring(L, getnum)); |
532 | } | 532 | } |
533 | else if EQ("istable") { | 533 | else if EQ(l_s("istable")) { |
534 | lua_pushnumber(L, lua_istable(L, getnum)); | 534 | lua_pushnumber(L, lua_istable(L, getnum)); |
535 | } | 535 | } |
536 | else if EQ("iscfunction") { | 536 | else if EQ(l_s("iscfunction")) { |
537 | lua_pushnumber(L, lua_iscfunction(L, getnum)); | 537 | lua_pushnumber(L, lua_iscfunction(L, getnum)); |
538 | } | 538 | } |
539 | else if EQ("isfunction") { | 539 | else if EQ(l_s("isfunction")) { |
540 | lua_pushnumber(L, lua_isfunction(L, getnum)); | 540 | lua_pushnumber(L, lua_isfunction(L, getnum)); |
541 | } | 541 | } |
542 | else if EQ("isuserdata") { | 542 | else if EQ(l_s("isuserdata")) { |
543 | lua_pushnumber(L, lua_isuserdata(L, getnum)); | 543 | lua_pushnumber(L, lua_isuserdata(L, getnum)); |
544 | } | 544 | } |
545 | else if EQ("isnil") { | 545 | else if EQ(l_s("isnil")) { |
546 | lua_pushnumber(L, lua_isnil(L, getnum)); | 546 | lua_pushnumber(L, lua_isnil(L, getnum)); |
547 | } | 547 | } |
548 | else if EQ("isnull") { | 548 | else if EQ(l_s("isnull")) { |
549 | lua_pushnumber(L, lua_isnull(L, getnum)); | 549 | lua_pushnumber(L, lua_isnull(L, getnum)); |
550 | } | 550 | } |
551 | else if EQ("tonumber") { | 551 | else if EQ(l_s("tonumber")) { |
552 | lua_pushnumber(L, lua_tonumber(L, getnum)); | 552 | lua_pushnumber(L, lua_tonumber(L, getnum)); |
553 | } | 553 | } |
554 | else if EQ("tostring") { | 554 | else if EQ(l_s("tostring")) { |
555 | const char *s = lua_tostring(L, getnum); | 555 | const l_char *s = lua_tostring(L, getnum); |
556 | lua_pushstring(L, s); | 556 | lua_pushstring(L, s); |
557 | } | 557 | } |
558 | else if EQ("tonumber") { | 558 | else if EQ(l_s("tonumber")) { |
559 | lua_pushnumber(L, lua_tonumber(L, getnum)); | 559 | lua_pushnumber(L, lua_tonumber(L, getnum)); |
560 | } | 560 | } |
561 | else if EQ("strlen") { | 561 | else if EQ(l_s("strlen")) { |
562 | lua_pushnumber(L, lua_strlen(L, getnum)); | 562 | lua_pushnumber(L, lua_strlen(L, getnum)); |
563 | } | 563 | } |
564 | else if EQ("tocfunction") { | 564 | else if EQ(l_s("tocfunction")) { |
565 | lua_pushcfunction(L, lua_tocfunction(L, getnum)); | 565 | lua_pushcfunction(L, lua_tocfunction(L, getnum)); |
566 | } | 566 | } |
567 | else if EQ("return") { | 567 | else if EQ(l_s("return")) { |
568 | return getnum; | 568 | return getnum; |
569 | } | 569 | } |
570 | else if EQ("gettop") { | 570 | else if EQ(l_s("gettop")) { |
571 | lua_pushnumber(L, lua_gettop(L)); | 571 | lua_pushnumber(L, lua_gettop(L)); |
572 | } | 572 | } |
573 | else if EQ("settop") { | 573 | else if EQ(l_s("settop")) { |
574 | lua_settop(L, getnum); | 574 | lua_settop(L, getnum); |
575 | } | 575 | } |
576 | else if EQ("pop") { | 576 | else if EQ(l_s("pop")) { |
577 | lua_pop(L, getnum); | 577 | lua_pop(L, getnum); |
578 | } | 578 | } |
579 | else if EQ("pushnum") { | 579 | else if EQ(l_s("pushnum")) { |
580 | lua_pushnumber(L, getnum); | 580 | lua_pushnumber(L, getnum); |
581 | } | 581 | } |
582 | else if EQ("pushvalue") { | 582 | else if EQ(l_s("pushvalue")) { |
583 | lua_pushvalue(L, getnum); | 583 | lua_pushvalue(L, getnum); |
584 | } | 584 | } |
585 | else if EQ("remove") { | 585 | else if EQ(l_s("remove")) { |
586 | lua_remove(L, getnum); | 586 | lua_remove(L, getnum); |
587 | } | 587 | } |
588 | else if EQ("insert") { | 588 | else if EQ(l_s("insert")) { |
589 | lua_insert(L, getnum); | 589 | lua_insert(L, getnum); |
590 | } | 590 | } |
591 | else if EQ("gettable") { | 591 | else if EQ(l_s("gettable")) { |
592 | lua_gettable(L, getnum); | 592 | lua_gettable(L, getnum); |
593 | } | 593 | } |
594 | else if EQ("settable") { | 594 | else if EQ(l_s("settable")) { |
595 | lua_settable(L, getnum); | 595 | lua_settable(L, getnum); |
596 | } | 596 | } |
597 | else if EQ("next") { | 597 | else if EQ(l_s("next")) { |
598 | lua_next(L, -2); | 598 | lua_next(L, -2); |
599 | } | 599 | } |
600 | else if EQ("concat") { | 600 | else if EQ(l_s("concat")) { |
601 | lua_concat(L, getnum); | 601 | lua_concat(L, getnum); |
602 | } | 602 | } |
603 | else if EQ("lessthan") { | 603 | else if EQ(l_s("lessthan")) { |
604 | int a = getnum; | 604 | int a = getnum; |
605 | if (lua_lessthan(L, a, getnum)) | 605 | if (lua_lessthan(L, a, getnum)) |
606 | lua_pushnumber(L, 1); | 606 | lua_pushnumber(L, 1); |
607 | else | 607 | else |
608 | lua_pushnil(L); | 608 | lua_pushnil(L); |
609 | } | 609 | } |
610 | else if EQ("rawcall") { | 610 | else if EQ(l_s("rawcall")) { |
611 | int narg = getnum; | 611 | int narg = getnum; |
612 | int nres = getnum; | 612 | int nres = getnum; |
613 | lua_rawcall(L, narg, nres); | 613 | lua_rawcall(L, narg, nres); |
614 | } | 614 | } |
615 | else if EQ("call") { | 615 | else if EQ(l_s("call")) { |
616 | int narg = getnum; | 616 | int narg = getnum; |
617 | int nres = getnum; | 617 | int nres = getnum; |
618 | lua_call(L, narg, nres); | 618 | lua_call(L, narg, nres); |
619 | } | 619 | } |
620 | else if EQ("dostring") { | 620 | else if EQ(l_s("dostring")) { |
621 | lua_dostring(L, luaL_check_string(L, getnum)); | 621 | lua_dostring(L, luaL_check_string(L, getnum)); |
622 | } | 622 | } |
623 | else if EQ("settagmethod") { | 623 | else if EQ(l_s("settagmethod")) { |
624 | int tag = getnum; | 624 | int tag = getnum; |
625 | const char *event = getname; | 625 | const l_char *event = getname; |
626 | lua_settagmethod(L, tag, event); | 626 | lua_settagmethod(L, tag, event); |
627 | } | 627 | } |
628 | else if EQ("gettagmethod") { | 628 | else if EQ(l_s("gettagmethod")) { |
629 | int tag = getnum; | 629 | int tag = getnum; |
630 | const char *event = getname; | 630 | const l_char *event = getname; |
631 | lua_gettagmethod(L, tag, event); | 631 | lua_gettagmethod(L, tag, event); |
632 | } | 632 | } |
633 | else if EQ("type") { | 633 | else if EQ(l_s("type")) { |
634 | lua_pushstring(L, lua_typename(L, lua_type(L, getnum))); | 634 | lua_pushstring(L, lua_typename(L, lua_type(L, getnum))); |
635 | } | 635 | } |
636 | else luaL_verror(L, "unknown instruction %.30s", buff); | 636 | else luaL_verror(L, l_s("unknown instruction %.30s"), buff); |
637 | } | 637 | } |
638 | return 0; | 638 | return 0; |
639 | } | 639 | } |
@@ -643,30 +643,30 @@ static int testC (lua_State *L) { | |||
643 | 643 | ||
644 | 644 | ||
645 | static const struct luaL_reg tests_funcs[] = { | 645 | static const struct luaL_reg tests_funcs[] = { |
646 | {"hash", hash_query}, | 646 | {l_s("hash"), hash_query}, |
647 | {"limits", get_limits}, | 647 | {l_s("limits"), get_limits}, |
648 | {"listcode", listcode}, | 648 | {l_s("listcode"), listcode}, |
649 | {"liststrings", liststrings}, | 649 | {l_s("liststrings"), liststrings}, |
650 | {"listlocals", listlocals}, | 650 | {l_s("listlocals"), listlocals}, |
651 | {"loadlib", loadlib}, | 651 | {l_s("loadlib"), loadlib}, |
652 | {"querystr", string_query}, | 652 | {l_s("querystr"), string_query}, |
653 | {"querytab", table_query}, | 653 | {l_s("querytab"), table_query}, |
654 | {"testC", testC}, | 654 | {l_s("testC"), testC}, |
655 | {"ref", tref}, | 655 | {l_s("ref"), tref}, |
656 | {"getref", getref}, | 656 | {l_s("getref"), getref}, |
657 | {"unref", unref}, | 657 | {l_s("unref"), unref}, |
658 | {"d2s", d2s}, | 658 | {l_s("d2s"), d2s}, |
659 | {"s2d", s2d}, | 659 | {l_s("s2d"), s2d}, |
660 | {"newuserdata", newuserdata}, | 660 | {l_s("newuserdata"), newuserdata}, |
661 | {"udataval", udataval}, | 661 | {l_s("udataval"), udataval}, |
662 | {"newtag", newtag}, | 662 | {l_s("newtag"), newtag}, |
663 | {"doonnewstack", doonnewstack}, | 663 | {l_s("doonnewstack"), doonnewstack}, |
664 | {"newstate", newstate}, | 664 | {l_s("newstate"), newstate}, |
665 | {"closestate", closestate}, | 665 | {l_s("closestate"), closestate}, |
666 | {"doremote", doremote}, | 666 | {l_s("doremote"), doremote}, |
667 | {"settagmethod", settagmethod}, | 667 | {l_s("settagmethod"), settagmethod}, |
668 | {"equal", equal}, | 668 | {l_s("equal"), equal}, |
669 | {"totalmem", mem_query} | 669 | {l_s("totalmem"), mem_query} |
670 | }; | 670 | }; |
671 | 671 | ||
672 | 672 | ||
@@ -680,7 +680,7 @@ void luaB_opentests (lua_State *L) { | |||
680 | lua_setglobals(L); | 680 | lua_setglobals(L); |
681 | luaL_openl(L, tests_funcs); /* open functions inside new table */ | 681 | luaL_openl(L, tests_funcs); /* open functions inside new table */ |
682 | lua_setglobals(L); /* restore old table of globals */ | 682 | lua_setglobals(L); /* restore old table of globals */ |
683 | lua_setglobal(L, "T"); /* set new table as global T */ | 683 | lua_setglobal(L, l_s("T")); /* set new table as global T */ |
684 | } | 684 | } |
685 | 685 | ||
686 | #endif | 686 | #endif |