Commit c0bb18d0 authored by Jack's avatar Jack
Browse files

working coroutine support with lua_loadlibs

parent 5791b3ee
...@@ -61,8 +61,9 @@ function yield() ...@@ -61,8 +61,9 @@ function yield()
coroutine.yield() coroutine.yield()
end end
function coresume(f, ...) -- TODO: missing vararg
coroutine.resume(f, table.unpack(arg)) function coresume(f)
coroutine.resume(f)
end end
function costatus() function costatus()
......
...@@ -41,15 +41,15 @@ ...@@ -41,15 +41,15 @@
*/ */
static const luaL_Reg loadedlibs[] = { static const luaL_Reg loadedlibs[] = {
{"_G", luaopen_base}, {"_G", luaopen_base},
{LUA_LOADLIBNAME, luaopen_package}, //{LUA_LOADLIBNAME, luaopen_package},
{LUA_COLIBNAME, luaopen_coroutine}, {LUA_COLIBNAME, luaopen_coroutine},
{LUA_TABLIBNAME, luaopen_table}, {LUA_TABLIBNAME, luaopen_table},
{LUA_IOLIBNAME, luaopen_io}, //{LUA_IOLIBNAME, luaopen_io},
{LUA_OSLIBNAME, luaopen_os}, //{LUA_OSLIBNAME, luaopen_os},
{LUA_STRLIBNAME, luaopen_string}, //{LUA_STRLIBNAME, luaopen_string},
{LUA_MATHLIBNAME, luaopen_math}, //{LUA_MATHLIBNAME, luaopen_math},
{LUA_UTF8LIBNAME, luaopen_utf8}, //{LUA_UTF8LIBNAME, luaopen_utf8},
{LUA_DBLIBNAME, luaopen_debug}, //{LUA_DBLIBNAME, luaopen_debug},
#if defined(LUA_COMPAT_BITLIB) #if defined(LUA_COMPAT_BITLIB)
{LUA_BITLIBNAME, luaopen_bit32}, {LUA_BITLIBNAME, luaopen_bit32},
#endif #endif
......
...@@ -943,9 +943,10 @@ void Code::loadAPI() ...@@ -943,9 +943,10 @@ void Code::loadAPI()
L = luaL_newstate(); L = luaL_newstate();
} }
luaopen_base(L); luaL_openlibs(L);
/*luaopen_base(L);
luaopen_table(L); luaopen_table(L);
luaopen_coroutine(L); luaopen_coroutine(L);*/
std::ifstream apiFile("api.lua"); std::ifstream apiFile("api.lua");
std::string api((std::istreambuf_iterator<char>(apiFile)), std::istreambuf_iterator<char>()); 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