/** \return Returns a LuaStackObject describing the current value. **/ LuaStackObject LuaStackTableIterator::GetValue() { // This function is only active if Reset() has been called head. luaplus_assert( IsValid() ); return LuaStackObject( m_tableObj.GetState(), m_startStackIndex + 2 ); }
LuaStackObject LuaState::PushCClosure(int (*f)(LuaState*), int n) { unsigned char* buffer = (unsigned char*)lua_newuserdata(m_state, sizeof(f)); memcpy(buffer, &f, sizeof(f)); Insert(-n-1); lua_pushcclosure(m_state, LPCD::LuaStateFunctionDispatcher, n + 1); return LuaStackObject(this, lua_gettop(m_state)); }
LuaStackObject LuaState::PushVFString(const char *fmt, va_list argp) { lua_State* L = LuaState_to_lua_State(this); lua_lock(L); luaC_checkGC(L); luaO_pushvfstring(L, fmt, argp); lua_unlock(L); return LuaStackObject(this, lua_gettop(LuaState_to_lua_State(this))); }
LuaStackObject LuaState::PushFString(const char *fmt, ...) { lua_State* L = m_state; va_list argp; lua_lock(L); luaC_checkGC(L); va_start(argp, fmt); luaO_pushvfstring(L, fmt, argp); va_end(argp); lua_unlock(L); return LuaStackObject(this, lua_gettop(m_state)); }
LuaState::LuaState(LuaState* parentState, bool initStandardLibrary) { m_state = lua_newthread(*parentState); m_ownState = false; // Threads are not closeable. GetHeadObject()->m_prev = NULL; GetHeadObject()->m_next = GetTailObject(); GetTailObject()->m_prev = GetHeadObject(); GetTailObject()->m_next = NULL; m_threadObj = LuaStackObject(parentState, parentState->GetTop()); parentState->Pop(); SetupStateEx(); }
LuaStackObject LuaCall::operator<<(const LuaRun& run) { int resultsStackPos = m_state->GetTop() - m_numArgs; int err = m_state->PCall(m_numArgs, run.m_numResults, run.m_alertStackPos); if (err != 0) { LuaStackObject errObj(m_state, -1); if (errObj.IsString()) { // Does this string persist long enough? luaplus_throw(errObj.GetString()); } else { char buf[200]; sprintf(buf, "unknown lua error, code: %d", err); luaplus_throw(buf); } } return LuaStackObject(m_state, resultsStackPos); }
LuaStackObject LuaState::StackTop() { return LuaStackObject(this, GetTop()); }
LuaStackObject LuaState::Stack(int index) { return LuaStackObject(this, index); }
int LuaState::Where(int lvl) { luaL_where(m_state, lvl); return LuaStackObject(this, GetTop()); }
LuaStackObject LuaState::NewMetaTable(const char* tname) { luaL_newmetatable(m_state, tname); return LuaStackObject(this, GetTop()); }