diff --git a/luprex/core/cpp/source.cpp b/luprex/core/cpp/source.cpp index 3436c5b2..9d1c730d 100644 --- a/luprex/core/cpp/source.cpp +++ b/luprex/core/cpp/source.cpp @@ -77,6 +77,7 @@ static void source_install_builtins(lua_State *L) { load_builtin_class(L, "string", luaopen_string); load_builtin_class(L, "math", luaopen_math); load_builtin_class(L, "debug", luaopen_debug); + load_builtin_class(L, "coroutine", luaopen_coroutine); // Nuke a few of the builtin functions for sandboxing reasons. LS.getglobaltable(globtab); @@ -352,3 +353,21 @@ void SourceDB::init(lua_State *L) { } } +// These should go away eventually. They're for debugging. +LuaDefine(coroutine_setnextid, "c") { + LuaArg co, lid; + LuaStack LS(L, co, lid); + lua_State *CO = LS.ckthread(co); + lua_Number id = LS.ckinteger(lid); + lua_setnextid(CO, id); + return LS.result(); +} + +LuaDefine(coroutine_getnextid, "c") { + LuaArg co; + LuaRet lid; + LuaStack LS(L, co, lid); + lua_State *CO = LS.ckthread(co); + LS.set(lid, lua_getnextid(CO)); + return LS.result(); +}