aboutsummaryrefslogtreecommitdiff
path: root/inout.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-07 14:34:44 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-07 14:34:44 -0200
commitd95a8b312166752e2211678b33514edb1d68a0a6 (patch)
tree87a7180705c1c5e6db71831fb8cb49ce8980f4d0 /inout.c
parent9ffba7a3dbdfa68595cd8cec26bd99689ce5fd08 (diff)
downloadlua-d95a8b312166752e2211678b33514edb1d68a0a6.tar.gz
lua-d95a8b312166752e2211678b33514edb1d68a0a6.tar.bz2
lua-d95a8b312166752e2211678b33514edb1d68a0a6.zip
new API: lua_Object now is an integer
Diffstat (limited to 'inout.c')
-rw-r--r--inout.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/inout.c b/inout.c
index 3c63c638..711193fa 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.6 1994/11/02 20:29:39 roberto Exp roberto $"; 8char *rcs_inout="$Id: inout.c,v 2.7 1994/11/03 22:34:29 roberto Exp roberto $";
9 9
10#include <stdio.h> 10#include <stdio.h>
11#include <stdlib.h> 11#include <stdlib.h>
@@ -32,15 +32,6 @@ static int nfuncstack=0;
32 32
33static FILE *fp; 33static FILE *fp;
34static char *st; 34static char *st;
35static void (*usererror) (char *s);
36
37/*
38** Function to set user function to handle errors.
39*/
40void lua_errorfunction (void (*fn) (char *s))
41{
42 usererror = fn;
43}
44 35
45/* 36/*
46** Function to get the next character from the input file 37** Function to get the next character from the input file
@@ -202,16 +193,16 @@ void lua_internaldofile (void)
202void lua_print (void) 193void lua_print (void)
203{ 194{
204 int i=1; 195 int i=1;
205 Object *obj; 196 lua_Object obj;
206 while ((obj=lua_getparam (i++)) != NULL) 197 while ((obj=lua_getparam (i++)) != 0)
207 { 198 {
208 if (lua_isnumber(obj)) printf("%g\n",lua_getnumber (obj)); 199 if (lua_isnumber(obj)) printf("%g\n",lua_getnumber(obj));
209 else if (lua_isstring(obj)) printf("%s\n",lua_getstring (obj)); 200 else if (lua_isstring(obj)) printf("%s\n",lua_getstring(obj));
210 else if (lua_isfunction(obj)) printf("function: %p\n",bvalue(obj)); 201 else if (lua_isfunction(obj)) printf("function: %p\n",bvalue(luaI_Address(obj)));
211 else if (lua_iscfunction(obj)) printf("cfunction: %p\n",lua_getcfunction (obj) 202 else if (lua_iscfunction(obj)) printf("cfunction: %p\n",lua_getcfunction(obj)
212); 203);
213 else if (lua_isuserdata(obj)) printf("userdata: %p\n",lua_getuserdata (obj)); 204 else if (lua_isuserdata(obj)) printf("userdata: %p\n",lua_getuserdata(obj));
214 else if (lua_istable(obj)) printf("table: %p\n",avalue(obj)); 205 else if (lua_istable(obj)) printf("table: %p\n",avalue(luaI_Address(obj)));
215 else if (lua_isnil(obj)) printf("nil\n"); 206 else if (lua_isnil(obj)) printf("nil\n");
216 else printf("invalid value to print\n"); 207 else printf("invalid value to print\n");
217 } 208 }
@@ -223,10 +214,10 @@ void lua_print (void)
223*/ 214*/
224void luaI_type (void) 215void luaI_type (void)
225{ 216{
226 Object *o = lua_getparam(1); 217 lua_Object o = lua_getparam(1);
227 if (o == NULL) 218 if (o == 0)
228 lua_error("no parameter to function 'type'"); 219 lua_error("no parameter to function 'type'");
229 switch (tag(o)) 220 switch (lua_type(o))
230 { 221 {
231 case LUA_T_NIL : 222 case LUA_T_NIL :
232 lua_pushstring("nil"); 223 lua_pushstring("nil");