diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-06-09 14:29:45 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-06-09 14:29:45 -0300 |
| commit | 33ace03b5a1cde68445f5718ecc42619e46a6644 (patch) | |
| tree | 7f8e975b16ff572fe67a60b02b474a51bac030c7 | |
| parent | 085181a08a78244d20177a40cbe223d6ad0a2ff6 (diff) | |
| download | lua-33ace03b5a1cde68445f5718ecc42619e46a6644.tar.gz lua-33ace03b5a1cde68445f5718ecc42619e46a6644.tar.bz2 lua-33ace03b5a1cde68445f5718ecc42619e46a6644.zip | |
udata is just void * again, so there is no point for function "getbyte".
| -rw-r--r-- | iolib.c | 45 |
1 files changed, 0 insertions, 45 deletions
| @@ -276,49 +276,6 @@ static void errorfb (void) | |||
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | 278 | ||
| 279 | /* -------------------------------------------- | ||
| 280 | * functions to manipulate userdata | ||
| 281 | */ | ||
| 282 | static 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 | |||
| 298 | static 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 | ||
| 323 | static struct luaL_reg iolib[] = { | 280 | static 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 | ||
