[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua Lanes with package.preload and package.loader
- From: Greg <tghill@...>
- Date: Thu, 17 Nov 2011 01:50:24 +0000 (UTC)
> I the problem is that you go through C to load some native functions.
> Because of this, Lanes doesn't have knowledge of them, therefore
> cannot transfer them from one Lua state to another.
I previously got older versions of lanes to work by doing this:
local p = package.preload["socket.core"]
local f = lanes.gen("*", function()
package.preload["socket.core"] = p
local socket = require("socket")
)
f()
where "socket.core" was loaded with this code:
lua_getfield(lua, LUA_GLOBALSINDEX, "package");
lua_getfield(lua, -1, "preload");
lua_pushcfunction(lua, luaopen_socket_core);
lua_setfield(lua, -2, "socket.core");
Unfortunately I don't know how to do this for "lua51-lanes" which is loaded with
similar code.
lua_getfield(lua, LUA_GLOBALSINDEX, "package");
lua_getfield(lua, -1, "preload");
lua_pushcfunction(lua, luaopen_lanes);
lua_setfield(lua, -2, "lua51-lanes");
Could there be an easy way to do something similar for "lua51-lanes"?