diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-18 17:46:21 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-18 17:46:21 -0200 |
commit | 93ccdd52ef83e283f7357c7e9de3a8773b26a16d (patch) | |
tree | dabd6f8a9c903b4ea9397ec82d7829d268f7dec3 | |
parent | 333a4f13d084b99c3729414c9c2d66222a8a1fc7 (diff) | |
download | lua-93ccdd52ef83e283f7357c7e9de3a8773b26a16d.tar.gz lua-93ccdd52ef83e283f7357c7e9de3a8773b26a16d.tar.bz2 lua-93ccdd52ef83e283f7357c7e9de3a8773b26a16d.zip |
lua_lock receives its parameter via stack.
beginblock and endblock do not have parameters
-rw-r--r-- | lua.h | 13 | ||||
-rw-r--r-- | opcode.c | 34 |
2 files changed, 35 insertions, 12 deletions
@@ -2,7 +2,7 @@ | |||
2 | ** LUA - Linguagem para Usuarios de Aplicacao | 2 | ** LUA - Linguagem para Usuarios de Aplicacao |
3 | ** Grupo de Tecnologia em Computacao Grafica | 3 | ** Grupo de Tecnologia em Computacao Grafica |
4 | ** TeCGraf - PUC-Rio | 4 | ** TeCGraf - PUC-Rio |
5 | ** $Id: lua.h,v 3.9 1994/11/17 21:23:43 roberto Exp roberto $ | 5 | ** $Id: lua.h,v 3.10 1994/11/17 21:27:30 roberto Exp roberto $ |
6 | */ | 6 | */ |
7 | 7 | ||
8 | 8 | ||
@@ -36,8 +36,8 @@ int lua_dostring (char *string); | |||
36 | int lua_callfunction (lua_Object function); | 36 | int lua_callfunction (lua_Object function); |
37 | int lua_call (char *funcname); | 37 | int lua_call (char *funcname); |
38 | 38 | ||
39 | int lua_beginblock (void); | 39 | void lua_beginblock (void); |
40 | void lua_endblock (int block); | 40 | void lua_endblock (void); |
41 | 41 | ||
42 | lua_Object lua_getparam (int number); | 42 | lua_Object lua_getparam (int number); |
43 | #define lua_getresult(_) lua_getparam(_) | 43 | #define lua_getresult(_) lua_getparam(_) |
@@ -63,14 +63,17 @@ lua_Object lua_getsubscript (void); | |||
63 | 63 | ||
64 | int lua_type (lua_Object object); | 64 | int lua_type (lua_Object object); |
65 | 65 | ||
66 | int lua_lock (lua_Object object); | 66 | int lua_lock (void); |
67 | lua_Object lua_getlocked (int ref); | 67 | lua_Object lua_getlocked (int ref); |
68 | void lua_unlock (int ref); | 68 | void lua_unlock (int ref); |
69 | 69 | ||
70 | lua_Object lua_createTable (int initSize); | 70 | lua_Object lua_createtable (int initSize); |
71 | |||
71 | 72 | ||
72 | /* for lua 1.1 */ | 73 | /* for lua 1.1 */ |
73 | 74 | ||
75 | #define lua_lockobject(o) (lua_pushobject(o), lua_lock()) | ||
76 | |||
74 | #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n)) | 77 | #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n)) |
75 | 78 | ||
76 | #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getsubscript()) | 79 | #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getsubscript()) |
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.16 1994/11/17 19:43:34 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.17 1994/11/17 21:23:43 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
@@ -436,21 +436,33 @@ lua_Object lua_getsubscript (void) | |||
436 | return 0; | 436 | return 0; |
437 | } | 437 | } |
438 | 438 | ||
439 | |||
440 | #define MAX_C_BLOCKS 10 | ||
441 | |||
442 | static int numCblocks = 0; | ||
443 | static int Cblocks[MAX_C_BLOCKS]; | ||
444 | |||
439 | /* | 445 | /* |
440 | ** API: starts a new block | 446 | ** API: starts a new block |
441 | */ | 447 | */ |
442 | int lua_beginblock (void) | 448 | void lua_beginblock (void) |
443 | { | 449 | { |
444 | return CBase; | 450 | if (numCblocks < MAX_C_BLOCKS) |
451 | Cblocks[numCblocks] = CBase; | ||
452 | numCblocks++; | ||
445 | } | 453 | } |
446 | 454 | ||
447 | /* | 455 | /* |
448 | ** API: ends a block | 456 | ** API: ends a block |
449 | */ | 457 | */ |
450 | void lua_endblock (int block) | 458 | void lua_endblock (void) |
451 | { | 459 | { |
452 | CBase = block; | 460 | --numCblocks; |
453 | adjustC(0); | 461 | if (numCblocks < MAX_C_BLOCKS) |
462 | { | ||
463 | CBase = Cblocks[numCblocks]; | ||
464 | adjustC(0); | ||
465 | } | ||
454 | } | 466 | } |
455 | 467 | ||
456 | /* | 468 | /* |
@@ -468,7 +480,7 @@ int lua_storesubscript (void) | |||
468 | /* | 480 | /* |
469 | ** API: creates a new table | 481 | ** API: creates a new table |
470 | */ | 482 | */ |
471 | lua_Object lua_createTable (int initSize) | 483 | lua_Object lua_createtable (int initSize) |
472 | { | 484 | { |
473 | adjustC(0); | 485 | adjustC(0); |
474 | avalue(top) = lua_createarray(initSize); | 486 | avalue(top) = lua_createarray(initSize); |
@@ -550,6 +562,14 @@ lua_Object lua_getlocked (int ref) | |||
550 | return Ref(top-1); | 562 | return Ref(top-1); |
551 | } | 563 | } |
552 | 564 | ||
565 | |||
566 | int lua_lock (void) | ||
567 | { | ||
568 | adjustC(1); | ||
569 | return luaI_lock(--top); | ||
570 | } | ||
571 | |||
572 | |||
553 | /* | 573 | /* |
554 | ** Get a global object. Return the object handle or NULL on error. | 574 | ** Get a global object. Return the object handle or NULL on error. |
555 | */ | 575 | */ |