new API function `lua_equalobj'

This commit is contained in:
Roberto Ierusalimschy 1999-11-11 15:02:40 -02:00
parent a6755e2f1a
commit 573372665a
3 changed files with 18 additions and 7 deletions

15
lapi.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 1.54 1999/10/14 19:13:31 roberto Exp roberto $
** $Id: lapi.c,v 1.55 1999/11/04 17:22:26 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@ -209,15 +209,15 @@ const char *lua_type (lua_Object o) {
}
int lua_isnil (lua_Object o) {
return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_NIL);
return (o != LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_NIL);
}
int lua_istable (lua_Object o) {
return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_ARRAY);
return (o != LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_ARRAY);
}
int lua_isuserdata (lua_Object o) {
return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_USERDATA);
return (o != LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_USERDATA);
}
int lua_iscfunction (lua_Object o) {
@ -225,7 +225,7 @@ int lua_iscfunction (lua_Object o) {
}
int lua_isnumber (lua_Object o) {
return (o!= LUA_NOOBJECT) && (tonumber(Address(o)) == 0);
return (o != LUA_NOOBJECT) && (tonumber(Address(o)) == 0);
}
int lua_isstring (lua_Object o) {
@ -238,6 +238,11 @@ int lua_isfunction (lua_Object o) {
return (t == LUA_T_PROTO) || (t == LUA_T_CPROTO);
}
int lua_equalobj (lua_Object o1, lua_Object o2) {
if (o1 == LUA_NOOBJECT || o2 == LUA_NOOBJECT) return 0;
else return luaO_equalObj(Address(o1), Address(o2));
}
double lua_getnumber (lua_Object object) {
if (object == LUA_NOOBJECT) return 0.0;

View File

@ -1,5 +1,5 @@
/*
** $Id: lbuiltin.c,v 1.70 1999/11/04 17:22:26 roberto Exp roberto $
** $Id: lbuiltin.c,v 1.71 1999/11/10 15:41:11 roberto Exp roberto $
** Built-in functions
** See Copyright Notice in lua.h
*/
@ -741,6 +741,10 @@ static void testC (void) {
n=lua_next(reg[n], (int)lua_getnumber(reg[getnum(s)]));
lua_pushnumber(n); break;
}
case 'q' : { int n1=getnum(s); int n2=getnum(s);
lua_pushnumber(lua_equalobj(reg[n1], reg[n2]));
break;
}
default: luaL_verror("unknown command in `testC': %c", *(s-1));
}
if (*s == 0) return;

4
lua.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lua.h,v 1.35 1999/09/29 12:56:22 roberto Exp roberto $
** $Id: lua.h,v 1.36 1999/10/07 19:04:30 roberto Exp roberto $
** Lua - An Extensible Extension Language
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
** e-mail: lua@tecgraf.puc-rio.br
@ -68,6 +68,8 @@ int lua_isnumber (lua_Object object);
int lua_isstring (lua_Object object);
int lua_isfunction (lua_Object object);
int lua_equalobj (lua_Object o1, lua_Object o2);
double lua_getnumber (lua_Object object);
const char *lua_getstring (lua_Object object);
long lua_strlen (lua_Object object);