commit 63ccf42397c30d89497d5f1e1e953ce879bef724
parent 1942b5860981bc6398fe7db2479885fe41297c92
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 7 Oct 1999 17:04:08 -0200
new API function 'lua_type'.
Diffstat:
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/lapi.c b/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 1.50 1999/09/21 16:10:13 roberto Exp roberto $
+** $Id: lapi.c,v 1.51 1999/10/04 17:51:04 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -216,6 +216,9 @@ void lua_rawsetglobal (const char *name) {
}
+const char *lua_type (lua_Object o) {
+ return (o == LUA_NOOBJECT) ? "NOOBJECT" : luaO_typename(Address(o));
+}
int lua_isnil (lua_Object o) {
return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_NIL);
diff --git a/lbuiltin.c b/lbuiltin.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbuiltin.c,v 1.63 1999/09/20 14:57:29 roberto Exp roberto $
+** $Id: lbuiltin.c,v 1.64 1999/10/04 17:51:04 roberto Exp roberto $
** Built-in functions
** See Copyright Notice in lua.h
*/
@@ -247,6 +247,13 @@ static void luaB_collectgarbage (void) {
lua_pushnumber(lua_collectgarbage(luaL_opt_int(1, 0)));
}
+
+static void luaB_type (void) {
+ lua_Object o = luaL_nonnullarg(1);
+ lua_pushstring(lua_type(o));
+ lua_pushnumber(lua_tag(o));
+}
+
/* }====================================================== */
@@ -371,13 +378,6 @@ static void luaB_tostring (void) {
lua_pushstring(buff);
}
-
-static void luaB_type (void) {
- lua_Object o = luaL_nonnullarg(1);
- lua_pushstring(luaO_typename(luaA_Address(o)));
- lua_pushnumber(lua_tag(o));
-}
-
/* }====================================================== */
diff --git a/lua.h b/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.34 1999/08/16 20:52:00 roberto Exp roberto $
+** $Id: lua.h,v 1.35 1999/09/29 12:56:22 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
@@ -58,6 +58,8 @@ lua_Object lua_lua2C (int number);
#define lua_getparam(_) lua_lua2C(_)
#define lua_getresult(_) lua_lua2C(_)
+const char *lua_type (lua_Object object);
+
int lua_isnil (lua_Object object);
int lua_istable (lua_Object object);
int lua_isuserdata (lua_Object object);
@@ -136,10 +138,8 @@ lua_Object lua_seterrormethod (void); /* In: new method */
#ifdef LUA_COMPAT2_5
-lua_Object lua_setfallback (char *event, lua_CFunction fallback);
#define lua_storeglobal lua_setglobal
-#define lua_type lua_tag
#define lua_lockobject(o) lua_refobject(o,1)
#define lua_lock() lua_ref(1)
@@ -152,8 +152,6 @@ lua_Object lua_setfallback (char *event, lua_CFunction fallback);
#define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_gettable())
#define lua_getfield(o,f) (lua_pushobject(o), lua_pushstring(f), lua_gettable())
-#define lua_copystring(o) (strdup(lua_getstring(o)))
-
#define lua_getsubscript lua_gettable
#define lua_storesubscript lua_settable