Commit c0bb18d0 authored by Jack's avatar Jack
Browse files

working coroutine support with lua_loadlibs

parent 5791b3ee
......@@ -61,8 +61,9 @@ function yield()
coroutine.yield()
end
function coresume(f, ...)
coroutine.resume(f, table.unpack(arg))
-- TODO: missing vararg
function coresume(f)
coroutine.resume(f)
end
function costatus()
......
......@@ -41,15 +41,15 @@
*/
static const luaL_Reg loadedlibs[] = {
{"_G", luaopen_base},
{LUA_LOADLIBNAME, luaopen_package},
//{LUA_LOADLIBNAME, luaopen_package},
{LUA_COLIBNAME, luaopen_coroutine},
{LUA_TABLIBNAME, luaopen_table},
{LUA_IOLIBNAME, luaopen_io},
{LUA_OSLIBNAME, luaopen_os},
{LUA_STRLIBNAME, luaopen_string},
{LUA_MATHLIBNAME, luaopen_math},
{LUA_UTF8LIBNAME, luaopen_utf8},
{LUA_DBLIBNAME, luaopen_debug},
//{LUA_IOLIBNAME, luaopen_io},
//{LUA_OSLIBNAME, luaopen_os},
//{LUA_STRLIBNAME, luaopen_string},
//{LUA_MATHLIBNAME, luaopen_math},
//{LUA_UTF8LIBNAME, luaopen_utf8},
//{LUA_DBLIBNAME, luaopen_debug},
#if defined(LUA_COMPAT_BITLIB)
{LUA_BITLIBNAME, luaopen_bit32},
#endif
......
......@@ -943,9 +943,10 @@ void Code::loadAPI()
L = luaL_newstate();
}
luaopen_base(L);
luaL_openlibs(L);
/*luaopen_base(L);
luaopen_table(L);
luaopen_coroutine(L);
luaopen_coroutine(L);*/
std::ifstream apiFile("api.lua");
std::string api((std::istreambuf_iterator<char>(apiFile)), std::istreambuf_iterator<char>());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment