lower-case for macros with arguments

This commit is contained in:
Roberto Ierusalimschy 2001-03-02 14:27:50 -03:00
parent 1e40b4dc61
commit 7b84f9e65c
10 changed files with 156 additions and 156 deletions

206
lapi.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 1.133 2001/02/23 17:17:25 roberto Exp roberto $
** $Id: lapi.c,v 1.134 2001/02/23 17:28:12 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@ -70,9 +70,9 @@ void luaA_pushobject (lua_State *L, const TObject *o) {
LUA_API int lua_stackspace (lua_State *L) {
int i;
LUA_LOCK(L);
lua_lock(L);
i = (L->stack_last - L->top);
LUA_UNLOCK(L);
lua_unlock(L);
return i;
}
@ -85,51 +85,51 @@ LUA_API int lua_stackspace (lua_State *L) {
LUA_API int lua_gettop (lua_State *L) {
int i;
LUA_LOCK(L);
lua_lock(L);
i = (L->top - L->Cbase);
LUA_UNLOCK(L);
lua_unlock(L);
return i;
}
LUA_API void lua_settop (lua_State *L, int index) {
LUA_LOCK(L);
lua_lock(L);
if (index >= 0)
luaD_adjusttop(L, L->Cbase, index);
else {
api_check(L, -(index+1) <= (L->top - L->Cbase));
L->top = L->top+index+1; /* index is negative */
}
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_remove (lua_State *L, int index) {
StkId p;
LUA_LOCK(L);
lua_lock(L);
p = luaA_index(L, index);
while (++p < L->top) setobj(p-1, p);
L->top--;
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_insert (lua_State *L, int index) {
StkId p;
StkId q;
LUA_LOCK(L);
lua_lock(L);
p = luaA_index(L, index);
for (q = L->top; q>p; q--) setobj(q, q-1);
setobj(p, L->top);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_pushvalue (lua_State *L, int index) {
LUA_LOCK(L);
lua_lock(L);
setobj(L->top, luaA_index(L, index));
api_incr_top(L);
LUA_UNLOCK(L);
lua_unlock(L);
}
@ -142,19 +142,19 @@ LUA_API void lua_pushvalue (lua_State *L, int index) {
LUA_API int lua_type (lua_State *L, int index) {
StkId o;
int i;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
i = (o == NULL) ? LUA_TNONE : ttype(o);
LUA_UNLOCK(L);
lua_unlock(L);
return i;
}
LUA_API const l_char *lua_typename (lua_State *L, int t) {
const l_char *s;
LUA_LOCK(L);
lua_lock(L);
s = (t == LUA_TNONE) ? l_s("no value") : basictypename(G(L), t);
LUA_UNLOCK(L);
lua_unlock(L);
return s;
}
@ -162,10 +162,10 @@ LUA_API const l_char *lua_typename (lua_State *L, int t) {
LUA_API const l_char *lua_xtype (lua_State *L, int index) {
StkId o;
const l_char *type;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
type = (o == NULL) ? l_s("no value") : luaT_typename(G(L), o);
LUA_UNLOCK(L);
lua_unlock(L);
return type;
}
@ -173,20 +173,20 @@ LUA_API const l_char *lua_xtype (lua_State *L, int index) {
LUA_API int lua_iscfunction (lua_State *L, int index) {
StkId o;
int i;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
i = (o == NULL) ? 0 : iscfunction(o);
LUA_UNLOCK(L);
lua_unlock(L);
return i;
}
LUA_API int lua_isnumber (lua_State *L, int index) {
TObject *o;
int i;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
i = (o == NULL) ? 0 : (tonumber(o) == 0);
LUA_UNLOCK(L);
lua_unlock(L);
return i;
}
@ -199,34 +199,34 @@ LUA_API int lua_isstring (lua_State *L, int index) {
LUA_API int lua_tag (lua_State *L, int index) {
StkId o;
int i;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
i = (o == NULL) ? LUA_NOTAG : luaT_tag(o);
LUA_UNLOCK(L);
lua_unlock(L);
return i;
}
LUA_API int lua_equal (lua_State *L, int index1, int index2) {
StkId o1, o2;
int i;
LUA_LOCK(L);
lua_lock(L);
o1 = luaA_indexAcceptable(L, index1);
o2 = luaA_indexAcceptable(L, index2);
i = (o1 == NULL || o2 == NULL) ? 0 /* index out-of-range */
: luaO_equalObj(o1, o2);
LUA_UNLOCK(L);
lua_unlock(L);
return i;
}
LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
StkId o1, o2;
int i;
LUA_LOCK(L);
lua_lock(L);
o1 = luaA_indexAcceptable(L, index1);
o2 = luaA_indexAcceptable(L, index2);
i = (o1 == NULL || o2 == NULL) ? 0 /* index out-of-range */
: luaV_lessthan(L, o1, o2);
LUA_UNLOCK(L);
lua_unlock(L);
return i;
}
@ -235,58 +235,58 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
LUA_API lua_Number lua_tonumber (lua_State *L, int index) {
StkId o;
lua_Number n;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
n = (o == NULL || tonumber(o)) ? 0 : nvalue(o);
LUA_UNLOCK(L);
lua_unlock(L);
return n;
}
LUA_API const l_char *lua_tostring (lua_State *L, int index) {
StkId o;
const l_char *s;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
s = (o == NULL || tostring(L, o)) ? NULL : svalue(o);
LUA_UNLOCK(L);
lua_unlock(L);
return s;
}
LUA_API size_t lua_strlen (lua_State *L, int index) {
StkId o;
size_t l;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
l = (o == NULL || tostring(L, o)) ? 0 : tsvalue(o)->len;
LUA_UNLOCK(L);
lua_unlock(L);
return l;
}
LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) {
StkId o;
lua_CFunction f;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
f = (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->f.c;
LUA_UNLOCK(L);
lua_unlock(L);
return f;
}
LUA_API void *lua_touserdata (lua_State *L, int index) {
StkId o;
void *p;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
p = (o == NULL || ttype(o) != LUA_TUSERDATA) ? NULL :
tsvalue(o)->u.d.value;
LUA_UNLOCK(L);
lua_unlock(L);
return p;
}
LUA_API const void *lua_topointer (lua_State *L, int index) {
StkId o;
const void *p;
LUA_LOCK(L);
lua_lock(L);
o = luaA_indexAcceptable(L, index);
if (o == NULL) p = NULL;
else {
@ -302,7 +302,7 @@ LUA_API const void *lua_topointer (lua_State *L, int index) {
break;
}
}
LUA_UNLOCK(L);
lua_unlock(L);
return p;
}
@ -314,26 +314,26 @@ LUA_API const void *lua_topointer (lua_State *L, int index) {
LUA_API void lua_pushnil (lua_State *L) {
LUA_LOCK(L);
lua_lock(L);
setnilvalue(L->top);
api_incr_top(L);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
LUA_LOCK(L);
lua_lock(L);
setnvalue(L->top, n);
api_incr_top(L);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_pushlstring (lua_State *L, const l_char *s, size_t len) {
LUA_LOCK(L);
lua_lock(L);
setsvalue(L->top, luaS_newlstr(L, s, len));
api_incr_top(L);
LUA_UNLOCK(L);
lua_unlock(L);
}
@ -346,19 +346,19 @@ LUA_API void lua_pushstring (lua_State *L, const l_char *s) {
LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, n);
luaV_Cclosure(L, fn, n);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API int lua_pushuserdata (lua_State *L, void *u) {
int isnew;
LUA_LOCK(L);
lua_lock(L);
isnew = luaS_createudata(L, u, L->top);
api_incr_top(L);
LUA_UNLOCK(L);
lua_unlock(L);
return isnew;
}
@ -370,54 +370,54 @@ LUA_API int lua_pushuserdata (lua_State *L, void *u) {
LUA_API void lua_getglobal (lua_State *L, const l_char *name) {
LUA_LOCK(L);
lua_lock(L);
luaV_getglobal(L, luaS_new(L, name), L->top);
api_incr_top(L);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_gettable (lua_State *L, int index) {
StkId t;
LUA_LOCK(L);
lua_lock(L);
t = luaA_index(L, index);
luaV_gettable(L, t, L->top-1, L->top-1);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_rawget (lua_State *L, int index) {
StkId t;
LUA_LOCK(L);
lua_lock(L);
t = luaA_index(L, index);
api_check(L, ttype(t) == LUA_TTABLE);
setobj(L->top - 1, luaH_get(hvalue(t), L->top - 1));
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_rawgeti (lua_State *L, int index, int n) {
StkId o;
LUA_LOCK(L);
lua_lock(L);
o = luaA_index(L, index);
api_check(L, ttype(o) == LUA_TTABLE);
setobj(L->top, luaH_getnum(hvalue(o), n));
api_incr_top(L);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_getglobals (lua_State *L) {
LUA_LOCK(L);
lua_lock(L);
sethvalue(L->top, L->gt);
api_incr_top(L);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API int lua_getref (lua_State *L, int ref) {
int status = 1;
LUA_LOCK(L);
lua_lock(L);
if (ref == LUA_REFNIL) {
setnilvalue(L->top);
api_incr_top(L);
@ -431,16 +431,16 @@ LUA_API int lua_getref (lua_State *L, int ref) {
api_incr_top(L);
}
}
LUA_UNLOCK(L);
lua_unlock(L);
return status;
}
LUA_API void lua_newtable (lua_State *L) {
LUA_LOCK(L);
lua_lock(L);
sethvalue(L->top, luaH_new(L, 0));
api_incr_top(L);
LUA_UNLOCK(L);
lua_unlock(L);
}
@ -451,63 +451,63 @@ LUA_API void lua_newtable (lua_State *L) {
LUA_API void lua_setglobal (lua_State *L, const l_char *name) {
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, 1);
luaV_setglobal(L, luaS_new(L, name), L->top - 1);
L->top--; /* remove element from the top */
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_settable (lua_State *L, int index) {
StkId t;
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, 2);
t = luaA_index(L, index);
luaV_settable(L, t, L->top - 2, L->top - 1);
L->top -= 2; /* pop index and value */
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_rawset (lua_State *L, int index) {
StkId t;
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, 2);
t = luaA_index(L, index);
api_check(L, ttype(t) == LUA_TTABLE);
setobj(luaH_set(L, hvalue(t), L->top-2), (L->top-1));
L->top -= 2;
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_rawseti (lua_State *L, int index, int n) {
StkId o;
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, 1);
o = luaA_index(L, index);
api_check(L, ttype(o) == LUA_TTABLE);
setobj(luaH_setnum(L, hvalue(o), n), (L->top-1));
L->top--;
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_setglobals (lua_State *L) {
StkId newtable;
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, 1);
newtable = --L->top;
api_check(L, ttype(newtable) == LUA_TTABLE);
L->gt = hvalue(newtable);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API int lua_ref (lua_State *L, int lock) {
int ref;
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, 1);
if (ttype(L->top-1) == LUA_TNIL)
ref = LUA_REFNIL;
@ -525,7 +525,7 @@ LUA_API int lua_ref (lua_State *L, int lock) {
G(L)->refArray[ref].st = lock ? LOCK : HOLD;
}
L->top--;
LUA_UNLOCK(L);
lua_unlock(L);
return ref;
}
@ -536,10 +536,10 @@ LUA_API int lua_ref (lua_State *L, int lock) {
*/
LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) {
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, nargs+1);
luaD_call(L, L->top-(nargs+1), nresults);
LUA_UNLOCK(L);
lua_unlock(L);
}
@ -553,28 +553,28 @@ LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) {
LUA_API int lua_getgcthreshold (lua_State *L) {
int threshold;
LUA_LOCK(L);
lua_lock(L);
threshold = GCscale(G(L)->GCthreshold);
LUA_UNLOCK(L);
lua_unlock(L);
return threshold;
}
LUA_API int lua_getgccount (lua_State *L) {
int count;
LUA_LOCK(L);
lua_lock(L);
count = GCscale(G(L)->nblocks);
LUA_UNLOCK(L);
lua_unlock(L);
return count;
}
LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
LUA_LOCK(L);
lua_lock(L);
if (newthreshold > GCscale(ULONG_MAX))
G(L)->GCthreshold = ULONG_MAX;
else
G(L)->GCthreshold = GCunscale(newthreshold);
luaC_checkGC(L);
LUA_UNLOCK(L);
lua_unlock(L);
}
@ -584,7 +584,7 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) {
int tag;
LUA_LOCK(L);
lua_lock(L);
if (basictype != LUA_TNONE &&
basictype != LUA_TTABLE &&
basictype != LUA_TUSERDATA)
@ -592,7 +592,7 @@ LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) {
tag = luaT_newtag(L, name, basictype);
if (tag == LUA_TNONE)
luaO_verror(L, l_s("type name '%.30s' already exists"), name);
LUA_UNLOCK(L);
lua_unlock(L);
return tag;
}
@ -600,7 +600,7 @@ LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) {
LUA_API int lua_type2tag (lua_State *L, const l_char *name) {
int tag;
const TObject *v;
LUA_LOCK(L);
lua_lock(L);
v = luaH_getstr(G(L)->type2tag, luaS_new(L, name));
if (ttype(v) == LUA_TNIL)
tag = LUA_TNONE;
@ -608,14 +608,14 @@ LUA_API int lua_type2tag (lua_State *L, const l_char *name) {
lua_assert(ttype(v) == LUA_TNUMBER);
tag = (int)nvalue(v);
}
LUA_UNLOCK(L);
lua_unlock(L);
return tag;
}
LUA_API void lua_settag (lua_State *L, int tag) {
int basictype;
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, 1);
if (tag < 0 || tag >= G(L)->ntag)
luaO_verror(L, l_s("%d is not a valid tag"), tag);
@ -634,25 +634,25 @@ LUA_API void lua_settag (lua_State *L, int tag) {
luaO_verror(L, l_s("cannot change the tag of a %.20s"),
luaT_typename(G(L), L->top-1));
}
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_error (lua_State *L, const l_char *s) {
LUA_LOCK(L);
lua_lock(L);
luaD_error(L, s);
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_unref (lua_State *L, int ref) {
LUA_LOCK(L);
lua_lock(L);
if (ref >= 0) {
api_check(L, ref < G(L)->nref && G(L)->refArray[ref].st < 0);
G(L)->refArray[ref].st = G(L)->refFree;
G(L)->refFree = ref;
}
LUA_UNLOCK(L);
lua_unlock(L);
}
@ -660,7 +660,7 @@ LUA_API int lua_next (lua_State *L, int index) {
StkId t;
Node *n;
int more;
LUA_LOCK(L);
lua_lock(L);
t = luaA_index(L, index);
api_check(L, ttype(t) == LUA_TTABLE);
n = luaH_next(L, hvalue(t), luaA_index(L, -1));
@ -674,7 +674,7 @@ LUA_API int lua_next (lua_State *L, int index) {
L->top -= 1; /* remove key */
more = 0;
}
LUA_UNLOCK(L);
lua_unlock(L);
return more;
}
@ -683,7 +683,7 @@ LUA_API int lua_getn (lua_State *L, int index) {
Hash *h;
const TObject *value;
int n;
LUA_LOCK(L);
lua_lock(L);
h = hvalue(luaA_index(L, index));
value = luaH_getstr(h, luaS_newliteral(L, l_s("n"))); /* = h.n */
if (ttype(value) == LUA_TNUMBER)
@ -701,13 +701,13 @@ LUA_API int lua_getn (lua_State *L, int index) {
}
n = (int)max;
}
LUA_UNLOCK(L);
lua_unlock(L);
return n;
}
LUA_API void lua_concat (lua_State *L, int n) {
LUA_LOCK(L);
lua_lock(L);
api_checknelems(L, n);
if (n >= 2) {
luaV_strconc(L, n, L->top);
@ -719,20 +719,20 @@ LUA_API void lua_concat (lua_State *L, int n) {
api_incr_top(L);
}
/* else n == 1; nothing to do */
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
TString *ts;
void *p;
LUA_LOCK(L);
lua_lock(L);
if (size == 0) size = 1;
ts = luaS_newudata(L, size, NULL);
setuvalue(L->top, ts);
api_incr_top(L);
p = ts->u.d.value;
LUA_UNLOCK(L);
lua_unlock(L);
return p;
}

View File

@ -1,5 +1,5 @@
/*
** $Id: ldebug.c,v 1.69 2001/02/23 17:17:25 roberto Exp roberto $
** $Id: ldebug.c,v 1.70 2001/02/23 20:30:52 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@ -42,20 +42,20 @@ static int isLmark (StkId o) {
LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func) {
lua_Hook oldhook;
LUA_LOCK(L);
lua_lock(L);
oldhook = L->callhook;
L->callhook = func;
LUA_UNLOCK(L);
lua_unlock(L);
return oldhook;
}
LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) {
lua_Hook oldhook;
LUA_LOCK(L);
lua_lock(L);
oldhook = L->linehook;
L->linehook = func;
LUA_UNLOCK(L);
lua_unlock(L);
return oldhook;
}
@ -76,14 +76,14 @@ static StkId aux_stackedfunction (lua_State *L, int level, StkId top) {
LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
StkId f;
int status;
LUA_LOCK(L);
lua_lock(L);
f = aux_stackedfunction(L, level, L->top);
if (f == NULL) status = 0; /* there is no such level */
else {
ar->_func = f;
status = 1;
}
LUA_UNLOCK(L);
lua_unlock(L);
return status;
}
@ -162,7 +162,7 @@ LUA_API const l_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
const l_char *name;
StkId f;
Proto *fp;
LUA_LOCK(L);
lua_lock(L);
name = NULL;
f = ar->_func;
fp = getluaproto(f);
@ -171,7 +171,7 @@ LUA_API const l_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
if (name)
luaA_pushobject(L, (f+1)+(n-1)); /* push value */
}
LUA_UNLOCK(L);
lua_unlock(L);
return name;
}
@ -180,7 +180,7 @@ LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
const l_char *name;
StkId f;
Proto *fp;
LUA_LOCK(L);
lua_lock(L);
name = NULL;
f = ar->_func;
fp = getluaproto(f);
@ -192,7 +192,7 @@ LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
else
setobj((f+1)+(n-1), L->top);
}
LUA_UNLOCK(L);
lua_unlock(L);
return name;
}
@ -272,7 +272,7 @@ LUA_API int lua_getinfo (lua_State *L, const l_char *what, lua_Debug *ar) {
StkId func;
int isactive;
int status = 1;
LUA_LOCK(L);
lua_lock(L);
isactive = (*what != l_c('>'));
if (isactive)
func = ar->_func;
@ -309,7 +309,7 @@ LUA_API int lua_getinfo (lua_State *L, const l_char *what, lua_Debug *ar) {
}
}
if (!isactive) L->top--; /* pop function */
LUA_UNLOCK(L);
lua_unlock(L);
return status;
}

18
ldo.c
View File

@ -1,5 +1,5 @@
/*
** $Id: ldo.c,v 1.128 2001/02/23 17:17:25 roberto Exp roberto $
** $Id: ldo.c,v 1.129 2001/02/23 17:28:12 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@ -94,9 +94,9 @@ static void dohook (lua_State *L, lua_Debug *ar, lua_Hook hook) {
StkId old_top = L->Cbase = L->top;
luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
L->allowhooks = 0; /* cannot call hooks inside a hook */
LUA_UNLOCK(L);
lua_unlock(L);
(*hook)(L, ar);
LUA_LOCK(L);
lua_lock(L);
lua_assert(L->allowhooks == 0);
L->allowhooks = 1;
L->top = old_top;
@ -135,9 +135,9 @@ static StkId callCclosure (lua_State *L, const struct Closure *cl, StkId base) {
luaD_checkstack(L, nup+LUA_MINSTACK); /* ensure minimum stack size */
for (n=0; n<nup; n++) /* copy upvalues as extra arguments */
setobj(L->top++, &cl->upvalue[n]);
LUA_UNLOCK(L);
lua_unlock(L);
n = (*cl->f.c)(L); /* do the actual call */
LUA_LOCK(L);
lua_lock(L);
L->Cbase = old_Cbase; /* restore old C base */
return L->top - n; /* return index of first result */
}
@ -212,13 +212,13 @@ LUA_API int lua_call (lua_State *L, int nargs, int nresults) {
StkId func;
struct CallS c;
int status;
LUA_LOCK(L);
lua_lock(L);
func = L->top - (nargs+1); /* function to be called */
c.func = func; c.nresults = nresults;
status = luaD_runprotected(L, f_call, &c);
if (status != 0) /* an error occurred? */
L->top = func; /* remove parameters from the stack */
LUA_UNLOCK(L);
lua_unlock(L);
return status;
}
@ -242,7 +242,7 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
struct SParser p;
lu_mem old_blocks;
int status;
LUA_LOCK(L);
lua_lock(L);
p.z = z; p.bin = bin;
/* before parsing, give a (good) chance to GC */
if (G(L)->nblocks/8 >= G(L)->GCthreshold/10)
@ -256,7 +256,7 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
}
else if (status == LUA_ERRRUN) /* an error occurred: correct error code */
status = LUA_ERRSYNTAX;
LUA_UNLOCK(L);
lua_unlock(L);
return status;
}

14
lgc.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 1.91 2001/02/22 18:59:59 roberto Exp roberto $
** $Id: lgc.c,v 1.92 2001/02/23 17:17:25 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@ -21,12 +21,12 @@
** optional lock for GC
** (when Lua calls GC tag methods it unlocks the regular lock)
*/
#ifndef LUA_LOCKGC
#define LUA_LOCKGC(L) {
#ifndef lua_lockgc
#define lua_lockgc(L) {
#endif
#ifndef LUA_UNLOCKGC
#define LUA_UNLOCKGC(L) }
#ifndef lua_unlockgc
#define lua_unlockgc(L) }
#endif
@ -369,14 +369,14 @@ static void callgcTMudata (lua_State *L) {
void luaC_collect (lua_State *L, int all) {
LUA_LOCKGC(L);
lua_lockgc(L);
collectudata(L, all);
callgcTMudata(L);
collectstrings(L, all);
collecttable(L);
collectproto(L);
collectclosure(L);
LUA_UNLOCKGC(L);
lua_unlockgc(L);
}

View File

@ -1,5 +1,5 @@
/*
** $Id: lobject.h,v 1.98 2001/02/23 17:17:25 roberto Exp roberto $
** $Id: lobject.h,v 1.99 2001/02/23 20:32:32 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@ -117,7 +117,7 @@ union L_UTString {
#define getstr(ts) ((l_char *)((lu_byte *)(ts) + sizeof(union L_UTString)))
#define getstr(ts) ((l_char *)((union L_UTString *)(ts) + 1))
#define svalue(o) getstr(tsvalue(o))

View File

@ -1,5 +1,5 @@
/*
** $Id: lstate.c,v 1.56 2001/02/02 15:13:05 roberto Exp roberto $
** $Id: lstate.c,v 1.57 2001/02/23 17:17:25 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@ -93,7 +93,7 @@ static void f_luaopen (lua_State *L, void *ud) {
LUA_API lua_State *lua_open (lua_State *OL, int stacksize) {
struct Sopen so;
lua_State *L;
if (OL) LUA_LOCK(OL);
if (OL) lua_lock(OL);
L = luaM_new(OL, lua_State);
if (L) { /* allocation OK? */
L->G = NULL;
@ -112,7 +112,7 @@ LUA_API lua_State *lua_open (lua_State *OL, int stacksize) {
L = NULL;
}
}
if (OL) LUA_UNLOCK(OL);
if (OL) lua_unlock(OL);
return L;
}
@ -141,11 +141,11 @@ static void close_state (lua_State *L, lua_State *OL) {
LUA_API void lua_close (lua_State *L) {
lua_State *OL;
lua_assert(L != lua_state || lua_gettop(L) == 0);
LUA_LOCK(L);
lua_lock(L);
OL = L->next; /* any surviving thread (if there is one) */
if (OL == L) OL = NULL; /* no surviving threads */
close_state(L, OL);
if (OL) LUA_UNLOCK(OL); /* cannot unlock over a freed state */
if (OL) lua_unlock(OL); /* cannot unlock over a freed state */
lua_assert(L != lua_state || memdebug_numblocks == 0);
lua_assert(L != lua_state || memdebug_total == 0);
}

View File

@ -1,5 +1,5 @@
/*
** $Id: lstate.h,v 1.52 2001/02/23 17:17:25 roberto Exp roberto $
** $Id: lstate.h,v 1.53 2001/02/23 20:30:01 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@ -16,12 +16,12 @@
** macros that control all entries and exits from Lua core machine
** (mainly for thread syncronization)
*/
#ifndef LUA_LOCK
#define LUA_LOCK(L) ((void) 0)
#ifndef lua_lock
#define lua_lock(L) ((void) 0)
#endif
#ifndef LUA_UNLOCK
#define LUA_UNLOCK(L) ((void) 0)
#ifndef lua_unlock
#define lua_unlock(L) ((void) 0)
#endif
/*

View File

@ -1,5 +1,5 @@
/*
** $Id: ltests.c,v 1.71 2001/02/22 18:59:59 roberto Exp roberto $
** $Id: ltests.c,v 1.72 2001/02/23 17:17:25 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@ -432,7 +432,7 @@ static int loadlib (lua_State *L) {
static int closestate (lua_State *L) {
lua_State *L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1);
lua_close(L1);
LUA_UNLOCK(L); /* close cannot unlock that */
lua_unlock(L); /* close cannot unlock that */
return 0;
}

View File

@ -1,5 +1,5 @@
/*
** $Id: ltests.h,v 1.4 2001/02/06 18:18:58 roberto Exp roberto $
** $Id: ltests.h,v 1.5 2001/02/12 15:42:44 roberto Exp roberto $
** Internal Header for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@ -41,8 +41,8 @@ void *debug_realloc (void *block, size_t oldsize, size_t size);
/* test for lock/unlock */
#define LUA_USERSTATE int *lock;
extern int islocked;
#define LUA_LOCK(L) lua_assert((**((int **)L))++ == 0)
#define LUA_UNLOCK(L) lua_assert(--(**((int **)L)) == 0)
#define lua_lock(L) lua_assert((**((int **)L))++ == 0)
#define lua_unlock(L) lua_assert(--(**((int **)L)) == 0)
extern lua_State *lua_state;

14
ltm.c
View File

@ -1,5 +1,5 @@
/*
** $Id: ltm.c,v 1.68 2001/02/22 18:59:59 roberto Exp roberto $
** $Id: ltm.c,v 1.69 2001/02/23 17:17:25 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@ -111,14 +111,14 @@ static void checktag (lua_State *L, int tag) {
LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) {
int e;
LUA_LOCK(L);
lua_lock(L);
checktag(L, tagto);
checktag(L, tagfrom);
for (e=0; e<TM_N; e++) {
if (luaT_validevent(tagto, e))
luaT_gettm(G(L), tagto, e) = luaT_gettm(G(L), tagfrom, e);
}
LUA_UNLOCK(L);
lua_unlock(L);
return tagto;
}
@ -156,7 +156,7 @@ const l_char *luaT_typename (global_State *G, const TObject *o) {
LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) {
int e;
LUA_LOCK(L);
lua_lock(L);
e = luaI_checkevent(L, event, t);
checktag(L, t);
if (luaT_validevent(t, e) && luaT_gettm(G(L), t, e)) {
@ -165,13 +165,13 @@ LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) {
else
setnilvalue(L->top);
incr_top;
LUA_UNLOCK(L);
lua_unlock(L);
}
LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
int e;
LUA_LOCK(L);
lua_lock(L);
e = luaI_checkevent(L, event, t);
checktag(L, t);
if (!luaT_validevent(t, e))
@ -190,6 +190,6 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
luaD_error(L, l_s("tag method must be a function (or nil)"));
}
L->top--;
LUA_UNLOCK(L);
lua_unlock(L);
}