lua-users home
lua-l archive

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


luaposix makes Lua file handles by setting their metatable to the
FILE* entry from the registry. This is enough to make PUC-Rio Lua
recognise them as Lua file handles, but not LuaJIT 2.0.0-beta7, which
has its own internal userdata types system.

I am unclear from the Lua reference manual whether I ought to expect
this technique to work or not, that is:

luaL_getmetatable(L, LUA_FILEHANDLE); /* LUA_FILEHANDLE is exported
but undocumented */
lua_setmetatable(L, n); /* ??? Should this work ??? */

In LuaJIT, io.type will not return true unless the userdata's private
udtype field is UDTYPE_IO_FILE, and the only way to get that setting
is to use a normal Lua io library call which returns a handle
(AFAICS).

-- 
http://rrt.sc3d.org