diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-11 15:02:40 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-11 15:02:40 -0200 |
commit | 573372665ab47bb6c0451ee7ca3ff5fce9b370e0 (patch) | |
tree | 248cfe8ec057fb301145fea58387b752435d3be3 | |
parent | a6755e2f1a6b9993cfd9e94c4165c76adafbdc31 (diff) | |
download | lua-573372665ab47bb6c0451ee7ca3ff5fce9b370e0.tar.gz lua-573372665ab47bb6c0451ee7ca3ff5fce9b370e0.tar.bz2 lua-573372665ab47bb6c0451ee7ca3ff5fce9b370e0.zip |
new API function `lua_equalobj'
-rw-r--r-- | lapi.c | 15 | ||||
-rw-r--r-- | lbuiltin.c | 6 | ||||
-rw-r--r-- | lua.h | 4 |
3 files changed, 18 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.54 1999/10/14 19:13:31 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.55 1999/11/04 17:22:26 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 | */ |
@@ -209,15 +209,15 @@ const char *lua_type (lua_Object o) { | |||
209 | } | 209 | } |
210 | 210 | ||
211 | int lua_isnil (lua_Object o) { | 211 | int lua_isnil (lua_Object o) { |
212 | return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_NIL); | 212 | return (o != LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_NIL); |
213 | } | 213 | } |
214 | 214 | ||
215 | int lua_istable (lua_Object o) { | 215 | int lua_istable (lua_Object o) { |
216 | return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_ARRAY); | 216 | return (o != LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_ARRAY); |
217 | } | 217 | } |
218 | 218 | ||
219 | int lua_isuserdata (lua_Object o) { | 219 | int lua_isuserdata (lua_Object o) { |
220 | return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_USERDATA); | 220 | return (o != LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_USERDATA); |
221 | } | 221 | } |
222 | 222 | ||
223 | int lua_iscfunction (lua_Object o) { | 223 | int lua_iscfunction (lua_Object o) { |
@@ -225,7 +225,7 @@ int lua_iscfunction (lua_Object o) { | |||
225 | } | 225 | } |
226 | 226 | ||
227 | int lua_isnumber (lua_Object o) { | 227 | int lua_isnumber (lua_Object o) { |
228 | return (o!= LUA_NOOBJECT) && (tonumber(Address(o)) == 0); | 228 | return (o != LUA_NOOBJECT) && (tonumber(Address(o)) == 0); |
229 | } | 229 | } |
230 | 230 | ||
231 | int lua_isstring (lua_Object o) { | 231 | int lua_isstring (lua_Object o) { |
@@ -238,6 +238,11 @@ int lua_isfunction (lua_Object o) { | |||
238 | return (t == LUA_T_PROTO) || (t == LUA_T_CPROTO); | 238 | return (t == LUA_T_PROTO) || (t == LUA_T_CPROTO); |
239 | } | 239 | } |
240 | 240 | ||
241 | int lua_equalobj (lua_Object o1, lua_Object o2) { | ||
242 | if (o1 == LUA_NOOBJECT || o2 == LUA_NOOBJECT) return 0; | ||
243 | else return luaO_equalObj(Address(o1), Address(o2)); | ||
244 | } | ||
245 | |||
241 | 246 | ||
242 | double lua_getnumber (lua_Object object) { | 247 | double lua_getnumber (lua_Object object) { |
243 | if (object == LUA_NOOBJECT) return 0.0; | 248 | if (object == LUA_NOOBJECT) return 0.0; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuiltin.c,v 1.70 1999/11/04 17:22:26 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.71 1999/11/10 15:41:11 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 | */ |
@@ -741,6 +741,10 @@ static void testC (void) { | |||
741 | n=lua_next(reg[n], (int)lua_getnumber(reg[getnum(s)])); | 741 | n=lua_next(reg[n], (int)lua_getnumber(reg[getnum(s)])); |
742 | lua_pushnumber(n); break; | 742 | lua_pushnumber(n); break; |
743 | } | 743 | } |
744 | case 'q' : { int n1=getnum(s); int n2=getnum(s); | ||
745 | lua_pushnumber(lua_equalobj(reg[n1], reg[n2])); | ||
746 | break; | ||
747 | } | ||
744 | default: luaL_verror("unknown command in `testC': %c", *(s-1)); | 748 | default: luaL_verror("unknown command in `testC': %c", *(s-1)); |
745 | } | 749 | } |
746 | if (*s == 0) return; | 750 | if (*s == 0) return; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.35 1999/09/29 12:56:22 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.36 1999/10/07 19:04:30 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 |
@@ -68,6 +68,8 @@ int lua_isnumber (lua_Object object); | |||
68 | int lua_isstring (lua_Object object); | 68 | int lua_isstring (lua_Object object); |
69 | int lua_isfunction (lua_Object object); | 69 | int lua_isfunction (lua_Object object); |
70 | 70 | ||
71 | int lua_equalobj (lua_Object o1, lua_Object o2); | ||
72 | |||
71 | double lua_getnumber (lua_Object object); | 73 | double lua_getnumber (lua_Object object); |
72 | const char *lua_getstring (lua_Object object); | 74 | const char *lua_getstring (lua_Object object); |
73 | long lua_strlen (lua_Object object); | 75 | long lua_strlen (lua_Object object); |