From 93ccdd52ef83e283f7357c7e9de3a8773b26a16d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy <roberto@inf.puc-rio.br> Date: Fri, 18 Nov 1994 17:46:21 -0200 Subject: lua_lock receives its parameter via stack. beginblock and endblock do not have parameters --- lua.h | 13 ++++++++----- opcode.c | 34 +++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/lua.h b/lua.h index 91fec003..221060eb 100644 --- a/lua.h +++ b/lua.h @@ -2,7 +2,7 @@ ** LUA - Linguagem para Usuarios de Aplicacao ** Grupo de Tecnologia em Computacao Grafica ** TeCGraf - PUC-Rio -** $Id: lua.h,v 3.9 1994/11/17 21:23:43 roberto Exp roberto $ +** $Id: lua.h,v 3.10 1994/11/17 21:27:30 roberto Exp roberto $ */ @@ -36,8 +36,8 @@ int lua_dostring (char *string); int lua_callfunction (lua_Object function); int lua_call (char *funcname); -int lua_beginblock (void); -void lua_endblock (int block); +void lua_beginblock (void); +void lua_endblock (void); lua_Object lua_getparam (int number); #define lua_getresult(_) lua_getparam(_) @@ -63,14 +63,17 @@ lua_Object lua_getsubscript (void); int lua_type (lua_Object object); -int lua_lock (lua_Object object); +int lua_lock (void); lua_Object lua_getlocked (int ref); void lua_unlock (int ref); -lua_Object lua_createTable (int initSize); +lua_Object lua_createtable (int initSize); + /* for lua 1.1 */ +#define lua_lockobject(o) (lua_pushobject(o), lua_lock()) + #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n)) #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getsubscript()) diff --git a/opcode.c b/opcode.c index 92b88c83..d1869654 100644 --- a/opcode.c +++ b/opcode.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_opcode="$Id: opcode.c,v 3.16 1994/11/17 19:43:34 roberto Exp roberto $"; +char *rcs_opcode="$Id: opcode.c,v 3.17 1994/11/17 21:23:43 roberto Exp roberto $"; #include <setjmp.h> #include <stdio.h> @@ -436,21 +436,33 @@ lua_Object lua_getsubscript (void) return 0; } + +#define MAX_C_BLOCKS 10 + +static int numCblocks = 0; +static int Cblocks[MAX_C_BLOCKS]; + /* ** API: starts a new block */ -int lua_beginblock (void) +void lua_beginblock (void) { - return CBase; + if (numCblocks < MAX_C_BLOCKS) + Cblocks[numCblocks] = CBase; + numCblocks++; } /* ** API: ends a block */ -void lua_endblock (int block) +void lua_endblock (void) { - CBase = block; - adjustC(0); + --numCblocks; + if (numCblocks < MAX_C_BLOCKS) + { + CBase = Cblocks[numCblocks]; + adjustC(0); + } } /* @@ -468,7 +480,7 @@ int lua_storesubscript (void) /* ** API: creates a new table */ -lua_Object lua_createTable (int initSize) +lua_Object lua_createtable (int initSize) { adjustC(0); avalue(top) = lua_createarray(initSize); @@ -550,6 +562,14 @@ lua_Object lua_getlocked (int ref) return Ref(top-1); } + +int lua_lock (void) +{ + adjustC(1); + return luaI_lock(--top); +} + + /* ** Get a global object. Return the object handle or NULL on error. */ -- cgit v1.2.3-55-g6feb