Changeset 207 for trunk/src/lua/lua_state.cc
- Timestamp:
- 08/19/13 07:42:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_state.cc
r206 r207 142 142 } 143 143 144 bool lua::state::push( const std::string& path, bool global )145 {146 size_t point = path.find('.');147 148 if (point == std::string::npos)149 {150 if (global)151 {152 lua_getglobal( m_state, path.c_str() );153 }154 else155 {156 lua_getfield( m_state, -1, path.c_str() );157 }158 return !lua_isnil( m_state, -1 );159 }160 161 size_t idx = 0;162 size_t start = 0;163 164 while( point != std::string::npos )165 {166 if (idx == 0)167 {168 if (global)169 {170 lua_getglobal( m_state, path.substr(start,point-start).c_str() );171 }172 else173 {174 lua_getfield( m_state, -1, path.substr(start,point-start).c_str() );175 }176 }177 else178 {179 if ( lua_istable( m_state, -1 ) )180 {181 lua_pushstring( m_state, path.substr(start,point-start).c_str() );182 lua_gettable( m_state, -2 );183 lua_insert( m_state, -2 );184 lua_pop( m_state, 1 );185 }186 else187 {188 lua_pop(m_state, 1);189 lua_pushnil(m_state);190 return false;191 }192 }193 start = point+1;194 point = path.find( '.', start );195 }196 return true;197 }198 199 200 144 int lua::state::get_stack_size() 201 145 {
Note: See TracChangeset
for help on using the changeset viewer.