lua-users home
lua-l archive

Re: Wrapping existing FILE *s as Lua file objects

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2007年1月14日 07:27:42 -0000, Mark Edgar <medgar@student.gc.maricopa.edu> wrote:
The ex implementations do this for the io.pipe() function, which returns two Lua file objects.
http://lua-users.org/wiki/ExtensionProposal
 FILE **pf = lua_newuserdata(L, sizeof *pf);
 *pf = 0;
 luaL_getmetatable(L, LUA_FILEHANDLE);
 lua_setmetatable(L, -2);
 *pf = /* your FILE* here */
Thanks, that's great. It looks then as though this is made available without being blessed. Wrapping the above as lua_pushfile is easy; having it blessed and in liolib.c would be nice.
--
http://rrt.sc3d.org/

AltStyle によって変換されたページ (->オリジナル) /