- Timestamp:
- 08/04/13 06:37:00 (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/lua/lua_path.hh
r181 r188 35 35 36 36 template < typename T1, typename T2 > 37 path( const T1& p1, const T2& p2 ) 37 path( const T1& p1, const T2& p2 ) : m_count( 0 ) 38 38 { 39 39 const size_t l1 = string_length<T1>::get( p1 ); -
trunk/nv/lua/lua_state.hh
r187 r188 48 48 table_guard( state* lstate, const path& p, bool global = true ); 49 49 table_guard( const table_guard& parent, const path& p ); 50 size_t get_size(); 50 51 bool has_field( const std::string& element ); 51 52 std::string get_string( const std::string& element, const std::string& defval = "" ); 52 53 char get_char( const std::string& element, char defval = ' ' ); 53 54 int get_integer( const std::string& element, int defval = 0 ); 55 unsigned get_unsigned( const std::string& element, unsigned defval = 0 ); 54 56 double get_double( const std::string& element, double defval = 0.0 ); 55 57 bool get_boolean( const std::string& element, bool defval = false ); 58 bool is_defined( const path& p ); 56 59 57 60 template< typename R, typename T > … … 173 176 int get_stack_size(); 174 177 void log_stack(); 178 bool is_defined( const path& p, bool global = true ); 175 179 lua_State* get_raw(); 176 180 reference register_object( object * o ); -
trunk/src/lua/lua_state.cc
r187 r188 216 216 } 217 217 218 size_t lua::table_guard::get_size() 219 { 220 return lua_rawlen( L->get_raw(), -1 ); 221 } 222 223 218 224 bool lua::table_guard::has_field( const string& element ) 219 225 { … … 248 254 } 249 255 256 unsigned lua::table_guard::get_unsigned( const string& element, unsigned defval /*= "" */ ) 257 { 258 lua_getfield( L->L, -1, element.c_str() ); 259 int result = lua_type( L->L, -1 ) == LUA_TNUMBER ? lua_tounsigned( L->L, -1 ) : defval; 260 lua_pop( L->L, 1 ); 261 return result; 262 } 263 250 264 double lua::table_guard::get_double( const string& element, double defval /*= "" */ ) 251 265 { … … 274 288 } 275 289 290 bool nv::lua::table_guard::is_defined( const path& p ) 291 { 292 return L->is_defined( p, false ); 293 } 276 294 277 295 void lua::table_guard::get_raw_flags( const std::string& element, uint8* data, uint32 count ) … … 393 411 } 394 412 413 414 bool nv::lua::state::is_defined( const path& p, bool global ) 415 { 416 if ( !p.resolve( L, global ) ) 417 { 418 return false; 419 } 420 bool result = !lua_isnil( L, -1 ); 421 lua_pop( L, 1 ); 422 return result; 423 } 424 395 425 int lua::state::call_function( int nargs, int nresults ) 396 426 {
Note: See TracChangeset
for help on using the changeset viewer.