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 | 333a4f13d084b99c3729414c9c2d66222a8a1fc7 (patch) | |
tree | f5ecc29ad2a9c3a86250708b30a9afcefae5cbe4 | |
parent | 73664eb7399655e7cf65132c91a1aa16191a1667 (diff) | |
download | lua-333a4f13d084b99c3729414c9c2d66222a8a1fc7.tar.gz lua-333a4f13d084b99c3729414c9c2d66222a8a1fc7.tar.bz2 lua-333a4f13d084b99c3729414c9c2d66222a8a1fc7.zip |
lua_lock receives its parameter via stack
-rw-r--r-- | fallback.c | 10 | ||||
-rw-r--r-- | fallback.h | 3 | ||||
-rw-r--r-- | mathlib.c | 4 |
3 files changed, 9 insertions, 8 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_fallback="$Id: fallback.c,v 1.5 1994/11/10 17:36:54 roberto Exp roberto $"; | 6 | char *rcs_fallback="$Id: fallback.c,v 1.6 1994/11/16 17:38:08 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | 9 | ||
@@ -112,16 +112,16 @@ static void GDFB (void) { } | |||
112 | static Object *lockArray = NULL; | 112 | static Object *lockArray = NULL; |
113 | static int lockSize = 0; | 113 | static int lockSize = 0; |
114 | 114 | ||
115 | int lua_lock (lua_Object object) | 115 | int luaI_lock (Object *object) |
116 | { | 116 | { |
117 | int i; | 117 | int i; |
118 | int oldSize; | 118 | int oldSize; |
119 | if (lua_isnil(object)) | 119 | if (tag(object) == LUA_T_NIL) |
120 | return -1; | 120 | return -1; |
121 | for (i=0; i<lockSize; i++) | 121 | for (i=0; i<lockSize; i++) |
122 | if (tag(&lockArray[i]) == LUA_T_NIL) | 122 | if (tag(&lockArray[i]) == LUA_T_NIL) |
123 | { | 123 | { |
124 | lockArray[i] = *luaI_Address(object); | 124 | lockArray[i] = *object; |
125 | return i; | 125 | return i; |
126 | } | 126 | } |
127 | /* no more empty spaces */ | 127 | /* no more empty spaces */ |
@@ -138,7 +138,7 @@ int lua_lock (lua_Object object) | |||
138 | } | 138 | } |
139 | for (i=oldSize; i<lockSize; i++) | 139 | for (i=oldSize; i<lockSize; i++) |
140 | tag(&lockArray[i]) = LUA_T_NIL; | 140 | tag(&lockArray[i]) = LUA_T_NIL; |
141 | lockArray[oldSize] = *luaI_Address(object); | 141 | lockArray[oldSize] = *object; |
142 | return oldSize; | 142 | return oldSize; |
143 | } | 143 | } |
144 | 144 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: fallback.h,v 1.3 1994/11/10 17:11:52 roberto Exp roberto $ | 2 | ** $Id: fallback.h,v 1.4 1994/11/10 17:36:54 roberto Exp roberto $ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef fallback_h | 5 | #ifndef fallback_h |
@@ -23,6 +23,7 @@ extern struct FB { | |||
23 | #define FB_GC 8 | 23 | #define FB_GC 8 |
24 | 24 | ||
25 | void luaI_setfallback (void); | 25 | void luaI_setfallback (void); |
26 | int luaI_lock (Object *object); | ||
26 | Object *luaI_getlocked (int ref); | 27 | Object *luaI_getlocked (int ref); |
27 | void luaI_travlock (void (*fn)(Object *)); | 28 | void luaI_travlock (void (*fn)(Object *)); |
28 | 29 | ||
@@ -3,7 +3,7 @@ | |||
3 | ** Mathematics library to LUA | 3 | ** Mathematics library to LUA |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_mathlib="$Id: mathlib.c,v 1.4 1994/10/11 13:06:47 celes Exp roberto $"; | 6 | char *rcs_mathlib="$Id: mathlib.c,v 1.5 1994/11/17 19:43:34 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <stdio.h> /* NULL */ | 8 | #include <stdio.h> /* NULL */ |
9 | #include <math.h> | 9 | #include <math.h> |
@@ -310,5 +310,5 @@ void mathlib_open (void) | |||
310 | lua_register ("exp", math_exp); | 310 | lua_register ("exp", math_exp); |
311 | lua_register ("deg", math_deg); | 311 | lua_register ("deg", math_deg); |
312 | lua_register ("rad", math_rad); | 312 | lua_register ("rad", math_rad); |
313 | old_pow = lua_lock(lua_setfallback("arith", math_pow)); | 313 | old_pow = lua_lockobject(lua_setfallback("arith", math_pow)); |
314 | } | 314 | } |