aboutsummaryrefslogtreecommitdiff
path: root/iolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-09 14:29:45 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-09 14:29:45 -0300
commit33ace03b5a1cde68445f5718ecc42619e46a6644 (patch)
tree7f8e975b16ff572fe67a60b02b474a51bac030c7 /iolib.c
parent085181a08a78244d20177a40cbe223d6ad0a2ff6 (diff)
downloadlua-33ace03b5a1cde68445f5718ecc42619e46a6644.tar.gz
lua-33ace03b5a1cde68445f5718ecc42619e46a6644.tar.bz2
lua-33ace03b5a1cde68445f5718ecc42619e46a6644.zip
udata is just void * again, so there is no point for function "getbyte".
Diffstat (limited to 'iolib.c')
-rw-r--r--iolib.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/iolib.c b/iolib.c
index e79356bd..43adfd6e 100644
--- a/iolib.c
+++ b/iolib.c
@@ -276,49 +276,6 @@ static void errorfb (void)
276} 276}
277 277
278 278
279/* --------------------------------------------
280* functions to manipulate userdata
281*/
282static void getbyte (void)
283{
284 lua_Object ud = lua_getparam(1);
285 int i = luaL_opt_number(2, -1);
286 luaL_arg_check(lua_isuserdata(ud), 1, "userdata expected");
287 if (i == -1)
288 lua_pushnumber(lua_getbindatasize(ud));
289 else {
290 i--;
291 if (0 <= i && i < lua_getbindatasize(ud))
292 lua_pushnumber(*(((char *)lua_getbindata(ud))+i));
293 else
294 lua_pushnil();
295 }
296}
297
298static void newuserdata (void)
299{
300 lua_Object t = lua_getparam(1);
301 int tag = luaL_opt_number(2, 0);
302 int i;
303 luaI_emptybuff();
304 luaL_arg_check(lua_istable(t), 1, "table expected");
305 for (i=0; ; i++) {
306 lua_Object o;
307 lua_beginblock();
308 lua_pushobject(t);
309 lua_pushnumber(i+1);
310 o = lua_rawgettable();
311 if (lua_isnil(o)) {
312 lua_endblock();
313 break;
314 }
315 luaL_arg_check(lua_isnumber(o), 1, "table values must be numbers");
316 luaI_addchar(lua_getnumber(o));
317 lua_endblock();
318 }
319 lua_pushbindata(luaI_addchar(0), i, tag);
320}
321
322 279
323static struct luaL_reg iolib[] = { 280static struct luaL_reg iolib[] = {
324{"readfrom", io_readfrom}, 281{"readfrom", io_readfrom},
@@ -334,8 +291,6 @@ static struct luaL_reg iolib[] = {
334{"date", io_date}, 291{"date", io_date},
335{"exit", io_exit}, 292{"exit", io_exit},
336{"debug", io_debug}, 293{"debug", io_debug},
337{"getbyte", getbyte},
338{"userdata", newuserdata},
339{"print_stack", errorfb} 294{"print_stack", errorfb}
340}; 295};
341 296