diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-03-17 17:42:20 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-03-17 17:42:20 -0300 |
commit | 36b6fdda833d4dd4a866d2c96ac42062b2b29af9 (patch) | |
tree | 36dd42e18490bc432602d3cfa21c76eb7b6832d8 | |
parent | 3c67d2595bedb5d951d8bd62a55f1e24aa128202 (diff) | |
download | lua-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.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -5,7 +5,7 @@ | |||
5 | ** Also provides some predefined lua functions. | 5 | ** Also provides some predefined lua functions. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | char *rcs_inout="$Id: inout.c,v 2.16 1994/12/20 21:20:36 roberto Exp celes $"; | 8 | char *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) | |||
235 | void luaI_type (void) | 235 | void 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 | /* |