aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-03-17 17:42:20 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-03-17 17:42:20 -0300
commit36b6fdda833d4dd4a866d2c96ac42062b2b29af9 (patch)
tree36dd42e18490bc432602d3cfa21c76eb7b6832d8
parent3c67d2595bedb5d951d8bd62a55f1e24aa128202 (diff)
downloadlua-36b6fdda833d4dd4a866d2c96ac42062b2b29af9.tar.gz
lua-36b6fdda833d4dd4a866d2c96ac42062b2b29af9.tar.bz2
lua-36b6fdda833d4dd4a866d2c96ac42062b2b29af9.zip
function "type" now returns a second result: the tag of the type,
so lua can discriminate different kinds of user data.
-rw-r--r--inout.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/inout.c b/inout.c
index ac89a1b7..b6c4e768 100644
--- a/inout.c
+++ b/inout.c
@@ -5,7 +5,7 @@
5** Also provides some predefined lua functions. 5** Also provides some predefined lua functions.
6*/ 6*/
7 7
8char *rcs_inout="$Id: inout.c,v 2.16 1994/12/20 21:20:36 roberto Exp celes $"; 8char *rcs_inout="$Id: inout.c,v 2.17 1995/03/17 20:27:11 celes Exp roberto $";
9 9
10#include <stdio.h> 10#include <stdio.h>
11#include <stdlib.h> 11#include <stdlib.h>
@@ -235,9 +235,11 @@ void lua_print (void)
235void luaI_type (void) 235void luaI_type (void)
236{ 236{
237 lua_Object o = lua_getparam(1); 237 lua_Object o = lua_getparam(1);
238 int t;
238 if (o == LUA_NOOBJECT) 239 if (o == LUA_NOOBJECT)
239 lua_error("no parameter to function 'type'"); 240 lua_error("no parameter to function 'type'");
240 switch (lua_type(o)) 241 t = lua_type(o);
242 switch (t)
241 { 243 {
242 case LUA_T_NIL : 244 case LUA_T_NIL :
243 lua_pushliteral("nil"); 245 lua_pushliteral("nil");
@@ -261,6 +263,7 @@ void luaI_type (void)
261 lua_pushliteral("userdata"); 263 lua_pushliteral("userdata");
262 break; 264 break;
263 } 265 }
266 lua_pushnumber(t);
264} 267}
265 268
266/* 269/*