diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-07-02 08:38:13 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-07-02 08:38:13 -0300 |
| commit | 7192afafeeb1a96b3de60af90a72cd8762b09d94 (patch) | |
| tree | d1e7e061822f755c33cc497d98ea451c7e7e32e8 /liolib.c | |
| parent | a139e2e003e0b62b7d34eeda20dd2354e74885f9 (diff) | |
| download | lua-7192afafeeb1a96b3de60af90a72cd8762b09d94.tar.gz lua-7192afafeeb1a96b3de60af90a72cd8762b09d94.tar.bz2 lua-7192afafeeb1a96b3de60af90a72cd8762b09d94.zip | |
new module policy: C modules do not create globals and do not register
themselves with 'require' (let 'require' do its work); new auxiliary
functions luaL_newlib/luaL_newlibtable/luaL_setfuncs/luaL_requiref.
Old luaL_register will be deprecated.
Diffstat (limited to 'liolib.c')
| -rw-r--r-- | liolib.c | 7 |
1 files changed, 4 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 2.87 2010/03/17 21:37:37 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.88 2010/03/26 20:58:11 roberto Exp roberto $ |
| 3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -615,8 +615,9 @@ LUAMOD_API int luaopen_io (lua_State *L) { | |||
| 615 | createmeta(L); | 615 | createmeta(L); |
| 616 | /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ | 616 | /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ |
| 617 | newenv(L, io_fclose); /* upvalue for all io functions at index 1 */ | 617 | newenv(L, io_fclose); /* upvalue for all io functions at index 1 */ |
| 618 | lua_pushvalue(L, -1); /* copy to be consumed by 'openlib' */ | 618 | luaL_newlibtable(L, iolib); /* new module at index 2 */ |
| 619 | luaL_openlib(L, LUA_IOLIBNAME, iolib, 1); /* new module at index 2 */ | 619 | lua_pushvalue(L, 1); /* copy of env to be consumed by 'setfuncs' */ |
| 620 | luaL_setfuncs(L, iolib, 1); | ||
| 620 | /* create (and set) default files */ | 621 | /* create (and set) default files */ |
| 621 | newenv(L, io_noclose); /* environment for default files at index 3 */ | 622 | newenv(L, io_noclose); /* environment for default files at index 3 */ |
| 622 | createstdfile(L, stdin, IO_INPUT, "stdin"); | 623 | createstdfile(L, stdin, IO_INPUT, "stdin"); |
