aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-10-07 17:04:30 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-10-07 17:04:30 -0200
commit63ccf42397c30d89497d5f1e1e953ce879bef724 (patch)
tree5d705102d981c84410af463b9fd8a2335b848b1f
parent1942b5860981bc6398fe7db2479885fe41297c92 (diff)
downloadlua-63ccf42397c30d89497d5f1e1e953ce879bef724.tar.gz
lua-63ccf42397c30d89497d5f1e1e953ce879bef724.tar.bz2
lua-63ccf42397c30d89497d5f1e1e953ce879bef724.zip
new API function 'lua_type'.
-rw-r--r--lapi.c5
-rw-r--r--lbuiltin.c16
-rw-r--r--lua.h8
3 files changed, 15 insertions, 14 deletions
diff --git a/lapi.c b/lapi.c
index 1f63dbc5..9048d5af 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.50 1999/09/21 16:10:13 roberto Exp roberto $ 2** $Id: lapi.c,v 1.51 1999/10/04 17:51:04 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*/
@@ -216,6 +216,9 @@ void lua_rawsetglobal (const char *name) {
216} 216}
217 217
218 218
219const char *lua_type (lua_Object o) {
220 return (o == LUA_NOOBJECT) ? "NOOBJECT" : luaO_typename(Address(o));
221}
219 222
220int lua_isnil (lua_Object o) { 223int lua_isnil (lua_Object o) {
221 return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_NIL); 224 return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_NIL);
diff --git a/lbuiltin.c b/lbuiltin.c
index b4bdcfd3..2e5f1fb1 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.63 1999/09/20 14:57:29 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.64 1999/10/04 17:51:04 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*/
@@ -247,6 +247,13 @@ static void luaB_collectgarbage (void) {
247 lua_pushnumber(lua_collectgarbage(luaL_opt_int(1, 0))); 247 lua_pushnumber(lua_collectgarbage(luaL_opt_int(1, 0)));
248} 248}
249 249
250
251static void luaB_type (void) {
252 lua_Object o = luaL_nonnullarg(1);
253 lua_pushstring(lua_type(o));
254 lua_pushnumber(lua_tag(o));
255}
256
250/* }====================================================== */ 257/* }====================================================== */
251 258
252 259
@@ -371,13 +378,6 @@ static void luaB_tostring (void) {
371 lua_pushstring(buff); 378 lua_pushstring(buff);
372} 379}
373 380
374
375static void luaB_type (void) {
376 lua_Object o = luaL_nonnullarg(1);
377 lua_pushstring(luaO_typename(luaA_Address(o)));
378 lua_pushnumber(lua_tag(o));
379}
380
381/* }====================================================== */ 381/* }====================================================== */
382 382
383 383
diff --git a/lua.h b/lua.h
index b999ad71..2ba27c50 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.34 1999/08/16 20:52:00 roberto Exp roberto $ 2** $Id: lua.h,v 1.35 1999/09/29 12:56:22 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
@@ -58,6 +58,8 @@ lua_Object lua_lua2C (int number);
58#define lua_getparam(_) lua_lua2C(_) 58#define lua_getparam(_) lua_lua2C(_)
59#define lua_getresult(_) lua_lua2C(_) 59#define lua_getresult(_) lua_lua2C(_)
60 60
61const char *lua_type (lua_Object object);
62
61int lua_isnil (lua_Object object); 63int lua_isnil (lua_Object object);
62int lua_istable (lua_Object object); 64int lua_istable (lua_Object object);
63int lua_isuserdata (lua_Object object); 65int lua_isuserdata (lua_Object object);
@@ -136,10 +138,8 @@ lua_Object lua_seterrormethod (void); /* In: new method */
136#ifdef LUA_COMPAT2_5 138#ifdef LUA_COMPAT2_5
137 139
138 140
139lua_Object lua_setfallback (char *event, lua_CFunction fallback);
140 141
141#define lua_storeglobal lua_setglobal 142#define lua_storeglobal lua_setglobal
142#define lua_type lua_tag
143 143
144#define lua_lockobject(o) lua_refobject(o,1) 144#define lua_lockobject(o) lua_refobject(o,1)
145#define lua_lock() lua_ref(1) 145#define lua_lock() lua_ref(1)
@@ -152,8 +152,6 @@ lua_Object lua_setfallback (char *event, lua_CFunction fallback);
152#define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_gettable()) 152#define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_gettable())
153#define lua_getfield(o,f) (lua_pushobject(o), lua_pushstring(f), lua_gettable()) 153#define lua_getfield(o,f) (lua_pushobject(o), lua_pushstring(f), lua_gettable())
154 154
155#define lua_copystring(o) (strdup(lua_getstring(o)))
156
157#define lua_getsubscript lua_gettable 155#define lua_getsubscript lua_gettable
158#define lua_storesubscript lua_settable 156#define lua_storesubscript lua_settable
159 157