Changeset 365 for trunk/src/lua


Ignore:
Timestamp:
05/16/15 17:40:16 (10 years ago)
Author:
epyon
Message:
  • overhaul of logging: no longer stream operated no longer using STL no memory allocation shorthand macros fast file and console I/O
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:global-ignores set to
      vs2012
      vs2013
      gmake
      gmake-clang
  • trunk/src/lua/lua_handle.cc

    r364 r365  
    77#include "nv/lua/lua_handle.hh"
    88
     9#include "nv/core/logging.hh"
    910#include "nv/lua/lua_state.hh"
    1011#include "nv/lua/lua_raw.hh"
     
    1819        if ( !lua_istable( L, -1 ) )
    1920        {
    20                 NV_LOG( nv::LOG_ERROR, "NIL" );
     21                NV_LOG_ERROR( "NIL" );
    2122                lua_pop( L, 2 );
    2223                lua_pushnil( L );
  • trunk/src/lua/lua_state.cc

    r361 r365  
    111111        if ( !p.resolve( m_state, global ) )
    112112        {
    113                 NV_LOG( LOG_ERROR, "Lua error : not a valid path - " + p.to_string() );
     113                NV_LOG_ERROR( "Lua error : not a valid path - ", p.to_string() );
    114114                return false;
    115115        }
     
    118118        {
    119119                lua_pop( m_state, 1 );
    120                 NV_LOG( LOG_ERROR, "Lua error : not a valid function - " + p.to_string() );
     120                NV_LOG_ERROR( "Lua error : not a valid function - ", p.to_string() );
    121121                return false;
    122122        }
     
    129129        if ( status != 0 )
    130130        {
    131                 NV_LOG( LOG_ERROR, "Lua error : " << lua_tostring( m_state, -1 ) );
     131                NV_LOG_ERROR( "Lua error : ", lua_tostring( m_state, -1 ) );
    132132                lua_pop( m_state, 1 );
    133133        }
     
    144144        if ( !p.resolve( m_state, global ) || lua_type(m_state, -1) != LUA_TTABLE )
    145145        {
    146                 NV_LOG( LOG_ERROR, "Could not resolve table!" );
     146                NV_LOG_ERROR( "Could not resolve table!" );
    147147                // TODO : error handling
    148148        }
     
    156156        if ( !p.resolve( m_state, false ) || lua_type(m_state, -1) != LUA_TTABLE )
    157157        {
    158                 NV_LOG( LOG_ERROR, "Could not resolve table!" );
     158                NV_LOG_ERROR( "Could not resolve table!" );
    159159                // TODO : error handling
    160160        }
     
    347347        }
    348348
    349         NV_LOG( nv::LOG_TRACE, "Lua state created" );
     349        NV_LOG_TRACE( "Lua state created" );
    350350}
    351351
    352352int lua::state::load_string( string_ref code, string_ref name )
    353353{
    354         NV_LOG( nv::LOG_TRACE, "Loading Lua string '" << name << "'");
     354        NV_LOG_TRACE( "Loading Lua string '", name, "'");
    355355        return luaL_loadbuffer( m_state, code.data(), code.length(), name.data() );
    356356}
     
    358358int lua::state::load_stream( std::istream& stream, string_ref name )
    359359{
    360         NV_LOG( nv::LOG_NOTICE, "Loading Lua stream '" << name << "'");
     360        NV_LOG_NOTICE( "Loading Lua stream '", name, "'");
    361361        return load_string( std::string(
    362362                (std::istreambuf_iterator<char>(stream)),
     
    366366int lua::state::load_file( string_ref filename )
    367367{
    368         NV_LOG( nv::LOG_NOTICE, "Loading Lua file '" << filename << "'");
     368        NV_LOG_NOTICE( "Loading Lua file '", filename, "'");
    369369        return luaL_loadfile( m_state, filename.data() );
    370370}
     
    376376        if (result)
    377377        {
    378                 NV_LOG( nv::LOG_WARNING, "Failed to load string " << name << ": " << lua_tostring(m_state, -1));
     378                NV_LOG_WARNING( "Failed to load string ", name, ": ", lua_tostring(m_state, -1));
    379379                return false;
    380380        }
     
    388388        if (result)
    389389        {
    390                 NV_LOG( nv::LOG_WARNING, "Failed to open stream " << name << ": " << lua_tostring(m_state, -1));
     390                NV_LOG_WARNING( "Failed to open stream ", name, ": ", lua_tostring( m_state, -1 ) );
    391391                return false;
    392392        }
     
    400400        if (result)
    401401        {
    402                 NV_LOG( nv::LOG_WARNING, "Failed to open file " << filename << ": " << lua_tostring(m_state, -1));
     402                NV_LOG_WARNING( "Failed to open file ", filename, ": ", lua_tostring( m_state, -1 ) );
    403403                return false;
    404404        }
     
    411411        if (result)
    412412        {
    413                 NV_LOG( nv::LOG_WARNING, "Failed to run script " << name << ": " << lua_tostring(m_state, -1));
     413                NV_LOG_WARNING( "Failed to run script ", name, ": ", lua_tostring( m_state, -1 ) );
    414414                lua_pop( m_state, 1 );
    415415        }
     
    425425{
    426426        int top = lua_gettop(m_state);
    427         NV_LOG( LOG_DEBUG, "Stack dump (" << top << ")");
     427        NV_LOG_DEBUG( "Stack dump (", top, ")");
    428428        for ( int i = 0; i < top; ++i )
    429429        {
    430                 NV_LOG( LOG_DEBUG, "#" << i+1 << " - " << lua_typename(m_state, lua_type(m_state, i+1) ) << " = " << nlua_typecontent(m_state, i+1) );
     430                NV_LOG_DEBUG( "#", i+1, " - ", lua_typename(m_state, lua_type(m_state, i+1) ), " = ", nlua_typecontent(m_state, i+1) );
    431431        }
    432432}
Note: See TracChangeset for help on using the changeset viewer.