MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / resumeThread

Method resumeThread

source/core/StarLua.hpp:2017–2048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2015
2016template <typename... Args>
2017Maybe<LuaDetail::LuaFunctionReturn> LuaEngine::resumeThread(int handleIndex, Args const&... args) {
2018 lua_checkstack(m_state, 1);
2019
2020 pushHandle(m_state, handleIndex);
2021 lua_State* threadState = lua_tothread(m_state, -1);
2022 lua_pop(m_state, 1);
2023
2024 if (lua_status(threadState) != LUA_YIELD && lua_gettop(threadState) == 0) {
2025 throw LuaException("cannot resume a dead or errored thread");
2026 }
2027
2028 size_t argSize = pushArguments(threadState, args...);
2029 incrementRecursionLevel();
2030 int res = lua_resume(threadState, nullptr, argSize);
2031 decrementRecursionLevel();
2032 if (res != LUA_OK && res != LUA_YIELD) {
2033 propagateErrorWithTraceback(threadState, m_state);
2034 handleError(m_state, res);
2035 }
2036
2037 int returnValues = lua_gettop(threadState);
2038 if (returnValues == 0) {
2039 return LuaDetail::LuaFunctionReturn();
2040 } else if (returnValues == 1) {
2041 return LuaDetail::LuaFunctionReturn(popLuaValue(threadState));
2042 } else {
2043 LuaVariadic<LuaValue> ret(returnValues);
2044 for (int i = returnValues - 1; i >= 0; --i)
2045 ret[i] = popLuaValue(threadState);
2046 return LuaDetail::LuaFunctionReturn(std::move(ret));
2047 }
2048}
2049
2050template <typename T>
2051void LuaEngine::registerUserDataType() {

Callers 1

resumeMethod · 0.80

Calls 5

lua_checkstackFunction · 0.85
lua_tothreadFunction · 0.85
lua_statusFunction · 0.85
lua_gettopFunction · 0.85
lua_resumeFunction · 0.85

Tested by

no test coverage detected