- Timestamp:
- 07/30/13 04:44:15 (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/lua/lua_state.hh
r163 r181 12 12 #include <nv/common.hh> 13 13 #include <nv/flags.hh> 14 #include <nv/lua/lua_path.hh> 14 15 #include <string> 15 16 … … 42 43 { 43 44 public: 44 table_guard( state* lstate, const std::string& table, bool global = true ); 45 table_guard( state* lstate, const std::string& table, int index, bool global = true ); 46 table_guard( state* lstate, const std::string& table, const std::string& index, bool global = true ); 47 table_guard( const table_guard& parent, const std::string& index ); 48 table_guard( const table_guard& parent, int index ); 45 table_guard( state* lstate, const path& p, bool global = true ); 46 table_guard( const table_guard& parent, const path& p ); 49 47 bool has_field( const std::string& element ); 50 48 std::string get_string( const std::string& element, const std::string& defval = "" ); -
trunk/nv/string.hh
r133 r181 7 7 8 8 #include <string> 9 #include <cstring> 9 10 #include <sstream> 10 11 #include <fstream> … … 119 120 } 120 121 122 template< typename T > 123 struct string_length 124 { 125 static const size_t get( T ) { return 0; } 126 }; 127 template< size_t S > 128 struct string_length< const char[S] > 129 { 130 static const size_t get( const char* ) { return S-1; } 131 }; 132 template<> 133 struct string_length< const char* > 134 { 135 static const size_t get( const char* s ) { return std::strlen( s ); } 136 }; 137 template<> 138 struct string_length< std::string > 139 { 140 static const size_t get( const std::string& s ) { return s.length(); } 141 }; 142 121 143 122 144 } -
trunk/src/lua/lua_state.cc
r163 r181 198 198 } 199 199 200 lua::table_guard::table_guard( lua::state* lstate, const std::string& table, bool global )200 lua::table_guard::table_guard( lua::state* lstate, const path& p, bool global ) 201 201 : L(lstate), m_guard(lstate) 202 202 { 203 L->push( table, global ); 204 } 205 206 lua::table_guard::table_guard( lua::state* lstate, const std::string& table, int index, bool global ) 207 : L(lstate), m_guard(lstate) 208 { 209 L->push( table, global ); 210 lua_rawgeti( L->L, -1, index ); 211 } 212 213 lua::table_guard::table_guard( lua::state* lstate, const std::string& table, const std::string& index, bool global /*= true */ ) 214 : L(lstate), m_guard(lstate) 215 { 216 L->push( table, global ); 217 lua_pushstring( L->L, index.c_str() ); 218 lua_rawget( L->L, -2 ); 219 } 220 221 lua::table_guard::table_guard( const table_guard& parent, const std::string& index ) 203 if ( !p.resolve( L->get_raw(), global ) ) 204 { 205 // TODO : error handling 206 } 207 } 208 209 lua::table_guard::table_guard( const table_guard& parent, const path& p ) 222 210 : L( parent.L ), m_guard( parent.L ) 223 211 { 224 lua_getfield( L->L, -1, index.c_str() ); 225 } 226 227 lua::table_guard::table_guard( const table_guard& parent, int index ) 228 : L( parent.L ), m_guard( parent.L ) 229 { 230 lua_rawgeti( L->L, -1, index ); 212 if ( !p.resolve( L->get_raw(), false ) ) 213 { 214 // TODO : error handling 215 } 231 216 } 232 217
Note: See TracChangeset
for help on using the changeset viewer.