diff options
-rw-r--r-- | lapi.c | 52 | ||||
-rw-r--r-- | lbuiltin.c | 144 | ||||
-rw-r--r-- | lbuiltin.h | 8 | ||||
-rw-r--r-- | liolib.c | 11 | ||||
-rw-r--r-- | ltests.c | 27 | ||||
-rw-r--r-- | lua.h | 37 |
6 files changed, 177 insertions, 102 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.80 2000/05/08 20:49:05 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.81 2000/05/24 13:54:49 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 | */ |
@@ -120,11 +120,11 @@ lua_Object lua_gettable (lua_State *L) { | |||
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | lua_Object lua_rawgettable (lua_State *L) { | 123 | lua_Object lua_rawget (lua_State *L) { |
124 | lua_Object res; | 124 | lua_Object res; |
125 | luaA_checkCargs(L, 2); | 125 | luaA_checkCargs(L, 2); |
126 | if (ttype(L->top-2) != TAG_TABLE) | 126 | if (ttype(L->top-2) != TAG_TABLE) |
127 | lua_error(L, "indexed expression not a table in rawgettable"); | 127 | lua_error(L, "indexed expression not a table"); |
128 | res = luaA_putluaObject(L, luaH_get(L, avalue(L->top-2), L->top-1)); | 128 | res = luaA_putluaObject(L, luaH_get(L, avalue(L->top-2), L->top-1)); |
129 | L->top -= 2; | 129 | L->top -= 2; |
130 | return res; | 130 | return res; |
@@ -140,7 +140,7 @@ void lua_settable (lua_State *L) { | |||
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | void lua_rawsettable (lua_State *L) { | 143 | void lua_rawset (lua_State *L) { |
144 | luaA_checkCargs(L, 3); | 144 | luaA_checkCargs(L, 3); |
145 | if (ttype(L->top-3) != TAG_TABLE) | 145 | if (ttype(L->top-3) != TAG_TABLE) |
146 | lua_error(L, "indexed expression not a table"); | 146 | lua_error(L, "indexed expression not a table"); |
@@ -170,24 +170,6 @@ void lua_setglobal (lua_State *L, const char *name) { | |||
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | /* deprecated */ | ||
174 | lua_Object lua_rawgetglobal (lua_State *L, const char *name) { | ||
175 | lua_pushglobaltable(L); | ||
176 | lua_pushstring(L, name); | ||
177 | return lua_rawgettable(L); | ||
178 | } | ||
179 | |||
180 | |||
181 | /* deprecated */ | ||
182 | void lua_rawsetglobal (lua_State *L, const char *name) { | ||
183 | TObject key; | ||
184 | luaA_checkCargs(L, 1); | ||
185 | ttype(&key) = TAG_STRING; | ||
186 | tsvalue(&key) = luaS_new(L, name); | ||
187 | luaH_set(L, L->gt, &key, --L->top); | ||
188 | } | ||
189 | |||
190 | |||
191 | const char *lua_type (lua_State *L, lua_Object o) { | 173 | const char *lua_type (lua_State *L, lua_Object o) { |
192 | UNUSED(L); | 174 | UNUSED(L); |
193 | return (o == LUA_NOOBJECT) ? "NOOBJECT" : luaO_typename(o); | 175 | return (o == LUA_NOOBJECT) ? "NOOBJECT" : luaO_typename(o); |
@@ -376,3 +358,29 @@ int lua_next (lua_State *L, lua_Object t, int i) { | |||
376 | } | 358 | } |
377 | 359 | ||
378 | 360 | ||
361 | |||
362 | #if LUA_DEPRECATETFUNCS | ||
363 | |||
364 | /* | ||
365 | ** obsolete functions | ||
366 | */ | ||
367 | |||
368 | lua_Object lua_rawgetglobal (lua_State *L, const char *name) { | ||
369 | lua_pushglobaltable(L); | ||
370 | lua_pushstring(L, name); | ||
371 | return lua_rawget(L); | ||
372 | } | ||
373 | |||
374 | |||
375 | void lua_rawsetglobal (lua_State *L, const char *name) { | ||
376 | lua_Object value; | ||
377 | lua_beginblock(L); | ||
378 | value = lua_pop(L); | ||
379 | lua_pushglobaltable(L); | ||
380 | lua_pushstring(L, name); | ||
381 | lua_pushobject(L, value); | ||
382 | lua_rawset(L); | ||
383 | lua_endblock(L); | ||
384 | } | ||
385 | |||
386 | #endif | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuiltin.c,v 1.109 2000/05/09 14:50:16 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.110 2000/05/24 13:54:49 roberto Exp roberto $ |
3 | ** Built-in functions | 3 | ** Built-in functions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -106,7 +106,10 @@ void luaB__ALERT (lua_State *L) { | |||
106 | ** The library `liolib' redefines _ERRORMESSAGE for better error information. | 106 | ** The library `liolib' redefines _ERRORMESSAGE for better error information. |
107 | */ | 107 | */ |
108 | void luaB__ERRORMESSAGE (lua_State *L) { | 108 | void luaB__ERRORMESSAGE (lua_State *L) { |
109 | lua_Object al = lua_rawgetglobal(L, LUA_ALERT); | 109 | lua_Object al; |
110 | lua_pushglobaltable(L); | ||
111 | lua_pushstring(L, LUA_ALERT); | ||
112 | al = lua_rawget(L); | ||
110 | if (lua_isfunction(L, al)) { /* avoid error loop if _ALERT is not defined */ | 113 | if (lua_isfunction(L, al)) { /* avoid error loop if _ALERT is not defined */ |
111 | const char *s = luaL_check_string(L, 1); | 114 | const char *s = luaL_check_string(L, 1); |
112 | char *buff = luaL_openspace(L, strlen(s)+sizeof("error: \n")); | 115 | char *buff = luaL_openspace(L, strlen(s)+sizeof("error: \n")); |
@@ -214,17 +217,17 @@ void luaB_globals (lua_State *L) { | |||
214 | lua_setglobaltable(L, luaL_tablearg(L, 1)); | 217 | lua_setglobaltable(L, luaL_tablearg(L, 1)); |
215 | } | 218 | } |
216 | 219 | ||
217 | void luaB_rawgettable (lua_State *L) { | 220 | void luaB_rawget (lua_State *L) { |
218 | lua_pushobject(L, luaL_nonnullarg(L, 1)); | 221 | lua_pushobject(L, luaL_nonnullarg(L, 1)); |
219 | lua_pushobject(L, luaL_nonnullarg(L, 2)); | 222 | lua_pushobject(L, luaL_nonnullarg(L, 2)); |
220 | lua_pushobject(L, lua_rawgettable(L)); | 223 | lua_pushobject(L, lua_rawget(L)); |
221 | } | 224 | } |
222 | 225 | ||
223 | void luaB_rawsettable (lua_State *L) { | 226 | void luaB_rawset (lua_State *L) { |
224 | lua_pushobject(L, luaL_nonnullarg(L, 1)); | 227 | lua_pushobject(L, luaL_nonnullarg(L, 1)); |
225 | lua_pushobject(L, luaL_nonnullarg(L, 2)); | 228 | lua_pushobject(L, luaL_nonnullarg(L, 2)); |
226 | lua_pushobject(L, luaL_nonnullarg(L, 3)); | 229 | lua_pushobject(L, luaL_nonnullarg(L, 3)); |
227 | lua_rawsettable(L); | 230 | lua_rawset(L); |
228 | } | 231 | } |
229 | 232 | ||
230 | void luaB_settagmethod (lua_State *L) { | 233 | void luaB_settagmethod (lua_State *L) { |
@@ -399,44 +402,6 @@ void luaB_assert (lua_State *L) { | |||
399 | } | 402 | } |
400 | 403 | ||
401 | 404 | ||
402 | void luaB_foreachi (lua_State *L) { | ||
403 | const Hash *t = gettable(L, 1); | ||
404 | int n = (int)getnarg(L, t); | ||
405 | int i; | ||
406 | lua_Object f = luaL_functionarg(L, 2); | ||
407 | luaD_checkstack(L, 3); /* for f, key, and val */ | ||
408 | for (i=1; i<=n; i++) { | ||
409 | *(L->top++) = *f; | ||
410 | ttype(L->top) = TAG_NUMBER; nvalue(L->top++) = i; | ||
411 | *(L->top++) = *luaH_getnum(t, i); | ||
412 | luaD_call(L, L->top-3, 1); | ||
413 | if (ttype(L->top-1) != TAG_NIL) | ||
414 | return; | ||
415 | L->top--; /* remove nil result */ | ||
416 | } | ||
417 | } | ||
418 | |||
419 | |||
420 | void luaB_foreach (lua_State *L) { | ||
421 | const Hash *a = gettable(L, 1); | ||
422 | lua_Object f = luaL_functionarg(L, 2); | ||
423 | int i; | ||
424 | luaD_checkstack(L, 3); /* for f, key, and val */ | ||
425 | for (i=0; i<a->size; i++) { | ||
426 | const Node *nd = &(a->node[i]); | ||
427 | if (ttype(val(nd)) != TAG_NIL) { | ||
428 | *(L->top++) = *f; | ||
429 | *(L->top++) = *key(nd); | ||
430 | *(L->top++) = *val(nd); | ||
431 | luaD_call(L, L->top-3, 1); | ||
432 | if (ttype(L->top-1) != TAG_NIL) | ||
433 | return; | ||
434 | L->top--; /* remove result */ | ||
435 | } | ||
436 | } | ||
437 | } | ||
438 | |||
439 | |||
440 | void luaB_getn (lua_State *L) { | 405 | void luaB_getn (lua_State *L) { |
441 | lua_pushnumber(L, getnarg(L, gettable(L, 1))); | 406 | lua_pushnumber(L, getnarg(L, gettable(L, 1))); |
442 | } | 407 | } |
@@ -562,21 +527,70 @@ void luaB_sort (lua_State *L) { | |||
562 | /* }====================================================== */ | 527 | /* }====================================================== */ |
563 | 528 | ||
564 | 529 | ||
530 | |||
565 | /* | 531 | /* |
566 | ** {====================================================== | 532 | ** {====================================================== |
567 | ** Deprecated functions to manipulate global environment: | 533 | ** Deprecated functions to manipulate global environment: |
568 | ** all of them can be simulated through table operations | 534 | ** some of them can be simulated through table operations |
569 | ** over the global table. | 535 | ** over the global table. |
570 | ** ======================================================= | 536 | ** ======================================================= |
571 | */ | 537 | */ |
572 | 538 | ||
539 | |||
540 | #ifdef LUA_DEPRECATETFUNCS | ||
541 | |||
542 | static void luaB_foreachi (lua_State *L) { | ||
543 | const Hash *t = gettable(L, 1); | ||
544 | int n = (int)getnarg(L, t); | ||
545 | int i; | ||
546 | lua_Object f = luaL_functionarg(L, 2); | ||
547 | luaD_checkstack(L, 3); /* for f, key, and val */ | ||
548 | for (i=1; i<=n; i++) { | ||
549 | *(L->top++) = *f; | ||
550 | ttype(L->top) = TAG_NUMBER; nvalue(L->top++) = i; | ||
551 | *(L->top++) = *luaH_getnum(t, i); | ||
552 | luaD_call(L, L->top-3, 1); | ||
553 | if (ttype(L->top-1) != TAG_NIL) | ||
554 | return; | ||
555 | L->top--; /* remove nil result */ | ||
556 | } | ||
557 | } | ||
558 | |||
559 | |||
560 | static void luaB_foreach (lua_State *L) { | ||
561 | const Hash *a = gettable(L, 1); | ||
562 | lua_Object f = luaL_functionarg(L, 2); | ||
563 | int i; | ||
564 | luaD_checkstack(L, 3); /* for f, key, and val */ | ||
565 | for (i=0; i<a->size; i++) { | ||
566 | const Node *nd = &(a->node[i]); | ||
567 | if (ttype(val(nd)) != TAG_NIL) { | ||
568 | *(L->top++) = *f; | ||
569 | *(L->top++) = *key(nd); | ||
570 | *(L->top++) = *val(nd); | ||
571 | luaD_call(L, L->top-3, 1); | ||
572 | if (ttype(L->top-1) != TAG_NIL) | ||
573 | return; | ||
574 | L->top--; /* remove result */ | ||
575 | } | ||
576 | } | ||
577 | } | ||
578 | |||
573 | #define num_deprecated 4 | 579 | #define num_deprecated 4 |
574 | 580 | ||
575 | static const struct luaL_reg deprecated_global_funcs[num_deprecated] = { | 581 | static const struct luaL_reg deprecated_global_funcs[num_deprecated] = { |
576 | {"foreachvar", luaB_foreach}, | 582 | {"foreachvar", luaB_foreach}, |
577 | {"nextvar", luaB_next}, | 583 | {"nextvar", luaB_next}, |
578 | {"rawgetglobal", luaB_rawgettable}, | 584 | {"rawgetglobal", luaB_rawget}, |
579 | {"rawsetglobal", luaB_rawsettable} | 585 | {"rawsetglobal", luaB_rawset} |
586 | }; | ||
587 | |||
588 | |||
589 | static const struct luaL_reg other_deprecated_global_funcs[] = { | ||
590 | {"foreach", luaB_foreach}, | ||
591 | {"foreachi", luaB_foreachi}, | ||
592 | {"rawgettable", luaB_rawget}, | ||
593 | {"rawsettable", luaB_rawset} | ||
580 | }; | 594 | }; |
581 | 595 | ||
582 | 596 | ||
@@ -591,8 +605,38 @@ static void deprecated_funcs (lua_State *L) { | |||
591 | lua_pushcclosure(L, deprecated_global_funcs[i].func, 1); | 605 | lua_pushcclosure(L, deprecated_global_funcs[i].func, 1); |
592 | lua_setglobal(L, deprecated_global_funcs[i].name); | 606 | lua_setglobal(L, deprecated_global_funcs[i].name); |
593 | } | 607 | } |
608 | luaL_openl(L, other_deprecated_global_funcs); | ||
594 | } | 609 | } |
595 | 610 | ||
611 | #else | ||
612 | |||
613 | /* | ||
614 | ** gives an explicit error in any attempt to call an obsolet function | ||
615 | */ | ||
616 | static void obsolete_func (lua_State *L) { | ||
617 | luaL_verror(L, "function `%.20s' is obsolete", luaL_check_string(L, 1)); | ||
618 | } | ||
619 | |||
620 | |||
621 | #define num_deprecated 8 | ||
622 | |||
623 | static const char *const obsolete_names [num_deprecated] = { | ||
624 | "foreach", "foreachi", "foreachvar", "nextvar", "rawgetglobal", | ||
625 | "rawgettable", "rawsetglobal", "rawsettable" | ||
626 | }; | ||
627 | |||
628 | |||
629 | static void deprecated_funcs (lua_State *L) { | ||
630 | int i; | ||
631 | for (i=0; i<num_deprecated; i++) { | ||
632 | lua_pushstring(L, obsolete_names[i]); | ||
633 | lua_pushcclosure(L, obsolete_func, 1); | ||
634 | lua_setglobal(L, obsolete_names[i]); | ||
635 | } | ||
636 | } | ||
637 | |||
638 | #endif | ||
639 | |||
596 | /* }====================================================== */ | 640 | /* }====================================================== */ |
597 | 641 | ||
598 | static const struct luaL_reg builtin_funcs[] = { | 642 | static const struct luaL_reg builtin_funcs[] = { |
@@ -610,8 +654,8 @@ static const struct luaL_reg builtin_funcs[] = { | |||
610 | {"newtag", luaB_newtag}, | 654 | {"newtag", luaB_newtag}, |
611 | {"next", luaB_next}, | 655 | {"next", luaB_next}, |
612 | {"print", luaB_print}, | 656 | {"print", luaB_print}, |
613 | {"rawgettable", luaB_rawgettable}, | 657 | {"rawget", luaB_rawget}, |
614 | {"rawsettable", luaB_rawsettable}, | 658 | {"rawset", luaB_rawset}, |
615 | {"setglobal", luaB_setglobal}, | 659 | {"setglobal", luaB_setglobal}, |
616 | {"settag", luaB_settag}, | 660 | {"settag", luaB_settag}, |
617 | {"settagmethod", luaB_settagmethod}, | 661 | {"settagmethod", luaB_settagmethod}, |
@@ -621,8 +665,6 @@ static const struct luaL_reg builtin_funcs[] = { | |||
621 | {"type", luaB_type}, | 665 | {"type", luaB_type}, |
622 | /* "Extra" functions */ | 666 | /* "Extra" functions */ |
623 | {"assert", luaB_assert}, | 667 | {"assert", luaB_assert}, |
624 | {"foreach", luaB_foreach}, | ||
625 | {"foreachi", luaB_foreachi}, | ||
626 | {"getn", luaB_getn}, | 668 | {"getn", luaB_getn}, |
627 | {"sort", luaB_sort}, | 669 | {"sort", luaB_sort}, |
628 | {"tinsert", luaB_tinsert}, | 670 | {"tinsert", luaB_tinsert}, |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuiltin.h,v 1.7 2000/04/17 19:23:12 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.h,v 1.8 2000/05/08 19:32:53 roberto Exp roberto $ |
3 | ** Built-in functions | 3 | ** Built-in functions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -18,8 +18,6 @@ void luaB_copytagmethods (lua_State *L); | |||
18 | void luaB_dofile (lua_State *L); | 18 | void luaB_dofile (lua_State *L); |
19 | void luaB_dostring (lua_State *L); | 19 | void luaB_dostring (lua_State *L); |
20 | void luaB_error (lua_State *L); | 20 | void luaB_error (lua_State *L); |
21 | void luaB_foreach (lua_State *L); | ||
22 | void luaB_foreachi (lua_State *L); | ||
23 | void luaB_getglobal (lua_State *L); | 21 | void luaB_getglobal (lua_State *L); |
24 | void luaB_getn (lua_State *L); | 22 | void luaB_getn (lua_State *L); |
25 | void luaB_gettagmethod (lua_State *L); | 23 | void luaB_gettagmethod (lua_State *L); |
@@ -27,8 +25,8 @@ void luaB_globals (lua_State *L); | |||
27 | void luaB_newtag (lua_State *L); | 25 | void luaB_newtag (lua_State *L); |
28 | void luaB_next (lua_State *L); | 26 | void luaB_next (lua_State *L); |
29 | void luaB_print (lua_State *L); | 27 | void luaB_print (lua_State *L); |
30 | void luaB_rawgettable (lua_State *L); | 28 | void luaB_rawget (lua_State *L); |
31 | void luaB_rawsettable (lua_State *L); | 29 | void luaB_rawset (lua_State *L); |
32 | void luaB_setglobal (lua_State *L); | 30 | void luaB_setglobal (lua_State *L); |
33 | void luaB_settag (lua_State *L); | 31 | void luaB_settag (lua_State *L); |
34 | void luaB_settagmethod (lua_State *L); | 32 | void luaB_settagmethod (lua_State *L); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.63 2000/05/09 14:50:16 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.64 2000/05/24 13:54:49 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 | */ |
@@ -73,8 +73,10 @@ static void atribTM (lua_State *L) { | |||
73 | ctrl->file[inout] = (FILE *)lua_getuserdata(L, newvalue); | 73 | ctrl->file[inout] = (FILE *)lua_getuserdata(L, newvalue); |
74 | } | 74 | } |
75 | /* set the actual variable */ | 75 | /* set the actual variable */ |
76 | lua_pushglobaltable(L); | ||
77 | lua_pushstring(L, varname); | ||
76 | lua_pushobject(L, newvalue); | 78 | lua_pushobject(L, newvalue); |
77 | lua_rawsetglobal(L, varname); | 79 | lua_rawset(L); |
78 | } | 80 | } |
79 | 81 | ||
80 | 82 | ||
@@ -541,7 +543,7 @@ static void errorfb (lua_State *L) { | |||
541 | char buff[MAXMESSAGE]; | 543 | char buff[MAXMESSAGE]; |
542 | int level = 1; /* skip level 0 (it's this function) */ | 544 | int level = 1; /* skip level 0 (it's this function) */ |
543 | lua_Debug ar; | 545 | lua_Debug ar; |
544 | lua_Object alertfunc = lua_rawgetglobal(L, LUA_ALERT); | 546 | lua_Object alertfunc; |
545 | sprintf(buff, "error: %.200s\n", lua_getstring(L, lua_getparam(L, 1))); | 547 | sprintf(buff, "error: %.200s\n", lua_getstring(L, lua_getparam(L, 1))); |
546 | while (lua_getstack(L, level++, &ar)) { | 548 | while (lua_getstack(L, level++, &ar)) { |
547 | char buffchunk[60]; | 549 | char buffchunk[60]; |
@@ -580,6 +582,9 @@ static void errorfb (lua_State *L) { | |||
580 | sprintf(buff+strlen(buff), " [%.70s]", buffchunk); | 582 | sprintf(buff+strlen(buff), " [%.70s]", buffchunk); |
581 | strcat(buff, "\n"); | 583 | strcat(buff, "\n"); |
582 | } | 584 | } |
585 | lua_pushglobaltable(L); | ||
586 | lua_pushstring(L, LUA_ALERT); | ||
587 | alertfunc = lua_rawget(L); | ||
583 | if (lua_isfunction(L, alertfunc)) { /* avoid loop if _ALERT is not defined */ | 588 | if (lua_isfunction(L, alertfunc)) { /* avoid loop if _ALERT is not defined */ |
584 | lua_pushstring(L, buff); | 589 | lua_pushstring(L, buff); |
585 | lua_callfunction(L, alertfunc); | 590 | lua_callfunction(L, alertfunc); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.19 2000/05/15 19:48:04 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.20 2000/05/22 18:44:46 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 | */ |
@@ -246,10 +246,6 @@ static void testC (lua_State *L) { | |||
246 | int n = getreg(L, &pc); | 246 | int n = getreg(L, &pc); |
247 | reg[n] = lua_getglobal(L, getname(&pc)); | 247 | reg[n] = lua_getglobal(L, getname(&pc)); |
248 | } | 248 | } |
249 | else if EQ("rawgetglobal") { | ||
250 | int n = getreg(L, &pc); | ||
251 | reg[n] = lua_rawgetglobal(L, getname(&pc)); | ||
252 | } | ||
253 | else if EQ("ref") { | 249 | else if EQ("ref") { |
254 | lua_pushnumber(L, lua_ref(L, 0)); | 250 | lua_pushnumber(L, lua_ref(L, 0)); |
255 | reg[getreg(L, &pc)] = lua_pop(L); | 251 | reg[getreg(L, &pc)] = lua_pop(L); |
@@ -276,8 +272,8 @@ static void testC (lua_State *L) { | |||
276 | else if EQ("setglobal") { | 272 | else if EQ("setglobal") { |
277 | lua_setglobal(L, getname(&pc)); | 273 | lua_setglobal(L, getname(&pc)); |
278 | } | 274 | } |
279 | else if EQ("rawsetglobal") { | 275 | else if EQ("pushglobals") { |
280 | lua_rawsetglobal(L, getname(&pc)); | 276 | lua_pushglobaltable(L); |
281 | } | 277 | } |
282 | else if EQ("pushstring") { | 278 | else if EQ("pushstring") { |
283 | lua_pushstring(L, getname(&pc)); | 279 | lua_pushstring(L, getname(&pc)); |
@@ -291,14 +287,14 @@ static void testC (lua_State *L) { | |||
291 | else if EQ("gettable") { | 287 | else if EQ("gettable") { |
292 | reg[getreg(L, &pc)] = lua_gettable(L); | 288 | reg[getreg(L, &pc)] = lua_gettable(L); |
293 | } | 289 | } |
294 | else if EQ("rawgettable") { | 290 | else if EQ("rawget") { |
295 | reg[getreg(L, &pc)] = lua_rawgettable(L); | 291 | reg[getreg(L, &pc)] = lua_rawget(L); |
296 | } | 292 | } |
297 | else if EQ("settable") { | 293 | else if EQ("settable") { |
298 | lua_settable(L); | 294 | lua_settable(L); |
299 | } | 295 | } |
300 | else if EQ("rawsettable") { | 296 | else if EQ("rawset") { |
301 | lua_rawsettable(L); | 297 | lua_rawset(L); |
302 | } | 298 | } |
303 | else if EQ("tag") { | 299 | else if EQ("tag") { |
304 | lua_pushnumber(L, lua_tag(L, reg[getreg(L, &pc)])); | 300 | lua_pushnumber(L, lua_tag(L, reg[getreg(L, &pc)])); |
@@ -360,6 +356,15 @@ static void testC (lua_State *L) { | |||
360 | while ((temp = lua_getresult(L1, i++)) != LUA_NOOBJECT) | 356 | while ((temp = lua_getresult(L1, i++)) != LUA_NOOBJECT) |
361 | lua_pushstring(L, lua_getstring(L1, temp)); | 357 | lua_pushstring(L, lua_getstring(L1, temp)); |
362 | } | 358 | } |
359 | #if LUA_DEPRECATETFUNCS | ||
360 | else if EQ("rawsetglobal") { | ||
361 | lua_rawsetglobal(L, getname(&pc)); | ||
362 | } | ||
363 | else if EQ("rawgetglobal") { | ||
364 | int n = getreg(L, &pc); | ||
365 | reg[n] = lua_rawgetglobal(L, getname(&pc)); | ||
366 | } | ||
367 | #endif | ||
363 | else luaL_verror(L, "unknown command in `testC': %.20s", inst); | 368 | else luaL_verror(L, "unknown command in `testC': %.20s", inst); |
364 | } | 369 | } |
365 | } | 370 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.52 2000/05/10 16:35:18 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.53 2000/05/24 13:54:49 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 |
@@ -101,13 +101,12 @@ lua_Object lua_pop (lua_State *L); | |||
101 | 101 | ||
102 | lua_Object lua_getglobal (lua_State *L, const char *name); | 102 | lua_Object lua_getglobal (lua_State *L, const char *name); |
103 | void lua_setglobal (lua_State *L, const char *name); /* In: value */ | 103 | void lua_setglobal (lua_State *L, const char *name); /* In: value */ |
104 | lua_Object lua_rawgetglobal (lua_State *L, const char *name); | ||
105 | void lua_rawsetglobal (lua_State *L, const char *name);/* In: value */ | ||
106 | 104 | ||
107 | void lua_settable (lua_State *L); /* In: table, index, value */ | 105 | void lua_settable (lua_State *L); /* In: table, index, value */ |
108 | void lua_rawsettable (lua_State *L); /* In: table, index, value */ | ||
109 | lua_Object lua_gettable (lua_State *L); /* In: table, index */ | 106 | lua_Object lua_gettable (lua_State *L); /* In: table, index */ |
110 | lua_Object lua_rawgettable (lua_State *L); /* In: table, index */ | 107 | |
108 | void lua_rawset (lua_State *L); /* In: table, index, value */ | ||
109 | lua_Object lua_rawget (lua_State *L); /* In: table, index */ | ||
111 | 110 | ||
112 | int lua_tag (lua_State *L, lua_Object obj); | 111 | int lua_tag (lua_State *L, lua_Object obj); |
113 | 112 | ||
@@ -156,7 +155,7 @@ long lua_collectgarbage (lua_State *L, long limit); | |||
156 | 155 | ||
157 | #ifndef LUA_REENTRANT | 156 | #ifndef LUA_REENTRANT |
158 | /* | 157 | /* |
159 | ** =============================================================== | 158 | ** {============================================================== |
160 | ** Macros for single-state use | 159 | ** Macros for single-state use |
161 | ** =============================================================== | 160 | ** =============================================================== |
162 | */ | 161 | */ |
@@ -205,12 +204,10 @@ extern lua_State *lua_state; | |||
205 | #define lua_pop() (lua_pop)(lua_state) | 204 | #define lua_pop() (lua_pop)(lua_state) |
206 | #define lua_getglobal(name) (lua_getglobal)(lua_state, name) | 205 | #define lua_getglobal(name) (lua_getglobal)(lua_state, name) |
207 | #define lua_setglobal(name) (lua_setglobal)(lua_state, name) | 206 | #define lua_setglobal(name) (lua_setglobal)(lua_state, name) |
208 | #define lua_rawgetglobal(name) (lua_rawgetglobal)(lua_state, name) | ||
209 | #define lua_rawsetglobal(name) (lua_rawsetglobal)(lua_state, name) | ||
210 | #define lua_settable() (lua_settable)(lua_state) | 207 | #define lua_settable() (lua_settable)(lua_state) |
211 | #define lua_rawsettable() (lua_rawsettable)(lua_state) | ||
212 | #define lua_gettable() (lua_gettable)(lua_state) | 208 | #define lua_gettable() (lua_gettable)(lua_state) |
213 | #define lua_rawgettable() (lua_rawgettable)(lua_state) | 209 | #define lua_rawset() (lua_rawset)(lua_state) |
210 | #define lua_rawget() (lua_rawget)(lua_state) | ||
214 | #define lua_tag(obj) (lua_tag)(lua_state, obj) | 211 | #define lua_tag(obj) (lua_tag)(lua_state, obj) |
215 | #define lua_next(o,i) (lua_next)(lua_state, o,i) | 212 | #define lua_next(o,i) (lua_next)(lua_state, o,i) |
216 | #define lua_ref(lock) (lua_ref)(lua_state, lock) | 213 | #define lua_ref(lock) (lua_ref)(lua_state, lock) |
@@ -225,12 +222,32 @@ extern lua_State *lua_state; | |||
225 | #define lua_pushcclosure(fn,n) \ | 222 | #define lua_pushcclosure(fn,n) \ |
226 | (lua_pushcclosure)(lua_state, (lua_CFunction)(fn), n) | 223 | (lua_pushcclosure)(lua_state, (lua_CFunction)(fn), n) |
227 | 224 | ||
225 | |||
226 | /* | ||
227 | ** }============================================================== | ||
228 | */ | ||
228 | #endif | 229 | #endif |
229 | 230 | ||
231 | /* | ||
232 | ** compatibility with 3.2 | ||
233 | ** these functions are only available when Lua is compiled with | ||
234 | ** the option LUA_DEPRECATETFUNCS | ||
235 | */ | ||
236 | |||
237 | #define lua_rawsettable lua_rawset | ||
238 | #define lua_rawgettable lua_rawget | ||
239 | |||
240 | lua_Object lua_rawgetglobal (lua_State *L, const char *name); | ||
241 | void lua_rawsetglobal (lua_State *L, const char *name);/* In: value */ | ||
230 | 242 | ||
243 | #ifndef LUA_REENTRANT | ||
244 | #define lua_rawgetglobal(name) (lua_rawgetglobal(lua_state, name)) | ||
245 | #define lua_rawsetglobal(name) (lua_rawsetglobal(lua_state, name)) | ||
231 | #endif | 246 | #endif |
232 | 247 | ||
233 | 248 | ||
249 | #endif | ||
250 | |||
234 | 251 | ||
235 | 252 | ||
236 | /****************************************************************************** | 253 | /****************************************************************************** |