Changeset 399 for trunk/src/lua


Ignore:
Timestamp:
06/13/15 11:47:09 (10 years ago)
Author:
epyon
Message:
  • naming cleanup
  • string_ref -> string_view (compatible with C++17 standard!)
  • *_ref and const_*_ref, renamed to _ref and _view for consistency
Location:
trunk/src/lua
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lua/lua_nova.cc

    r395 r399  
    810810}
    811811
    812 void nv::lua::register_storage( state* a_state, string_ref name, string_ref constructor_name )
     812void nv::lua::register_storage( state* a_state, string_view name, string_view constructor_name )
    813813{
    814814        // TODO: error checking
  • trunk/src/lua/lua_path.cc

    r395 r399  
    1414{
    1515        if ( m_elements[0].length == 0 || m_elements[0].str == nullptr ) return;
    16         string_ref spath( m_elements[0].str, m_elements[0].length );
     16        string_view spath( m_elements[0].str, m_elements[0].length );
    1717        m_count = 0;
    1818        size_t point = spath.find( '.' );
    1919
    20         while ( point != string_ref::npos )
     20        while ( point != string_view::npos )
    2121        {
    2222                m_elements[m_count].str    = spath.data();
     
    3939}
    4040
    41 void nv::lua::path::push( string_ref p )
     41void nv::lua::path::push( string_view p )
    4242{
    4343        m_elements[ m_count ].str    = p.data();
  • trunk/src/lua/lua_state.cc

    r395 r399  
    8080}
    8181
    82 void lua::state_wrapper::register_native_function( lfunction f, string_ref name )
     82void lua::state_wrapper::register_native_function( lfunction f, string_view name )
    8383{
    8484        if ( m_global ) push_global_table();
     
    171171}
    172172
    173 bool lua::table_guard::has_field( string_ref element )
     173bool lua::table_guard::has_field( string_view element )
    174174{
    175175        lua_getfield( m_state, -1, element.data() );
     
    179179}
    180180
    181 std::string lua::table_guard::get_std_string( string_ref element, string_ref defval /*= string_ref() */ )
     181std::string lua::table_guard::get_std_string( string_view element, string_view defval /*= string_view() */ )
    182182{
    183183        lua_getfield( m_state, -1, element.data() );
     
    198198}
    199199
    200 const_string lua::table_guard::get_string( string_ref element, string_ref defval /*= string_ref() */ )
     200const_string lua::table_guard::get_string( string_view element, string_view defval /*= string_view() */ )
    201201{
    202202        lua_getfield( m_state, -1, element.data() );
     
    217217}
    218218
    219 char lua::table_guard::get_char( string_ref element, char defval /*= "" */ )
     219char lua::table_guard::get_char( string_view element, char defval /*= "" */ )
    220220{
    221221        lua_getfield( m_state, -1, element.data() );
     
    225225}
    226226
    227 int lua::table_guard::get_integer( string_ref element, int defval /*= "" */ )
     227int lua::table_guard::get_integer( string_view element, int defval /*= "" */ )
    228228{
    229229        lua_getfield( m_state, -1, element.data() );
     
    233233}
    234234
    235 unsigned lua::table_guard::get_unsigned( string_ref element, unsigned defval /*= "" */ )
     235unsigned lua::table_guard::get_unsigned( string_view element, unsigned defval /*= "" */ )
    236236{
    237237        lua_getfield( m_state, -1, element.data() );
     
    241241}
    242242
    243 double lua::table_guard::get_double( string_ref element, double defval /*= "" */ )
     243double lua::table_guard::get_double( string_view element, double defval /*= "" */ )
    244244{
    245245        lua_getfield( m_state, -1, element.data() );
     
    250250
    251251
    252 float nv::lua::table_guard::get_float( string_ref element, float defval /*= 0.0 */ )
     252float nv::lua::table_guard::get_float( string_view element, float defval /*= 0.0 */ )
    253253{
    254254        lua_getfield( m_state, -1, element.data() );
     
    258258}
    259259
    260 bool lua::table_guard::get_boolean( string_ref element, bool defval /*= "" */ )
     260bool lua::table_guard::get_boolean( string_view element, bool defval /*= "" */ )
    261261{
    262262        lua_getfield( m_state, -1, element.data() );
     
    266266}
    267267
    268 bool nv::lua::table_guard::is_table( string_ref element )
     268bool nv::lua::table_guard::is_table( string_view element )
    269269{
    270270        lua_getfield( m_state, -1, element.data() );
     
    274274}
    275275
    276 bool nv::lua::table_guard::is_number( string_ref element )
     276bool nv::lua::table_guard::is_number( string_view element )
    277277{
    278278        lua_getfield( m_state, -1, element.data() );
     
    282282}
    283283
    284 bool nv::lua::table_guard::is_boolean( string_ref element )
     284bool nv::lua::table_guard::is_boolean( string_view element )
    285285{
    286286        lua_getfield( m_state, -1, element.data() );
     
    290290}
    291291
    292 bool nv::lua::table_guard::is_string( string_ref element )
     292bool nv::lua::table_guard::is_string( string_view element )
    293293{
    294294        lua_getfield( m_state, -1, element.data() );
     
    350350}
    351351
    352 int lua::state::load_string( string_ref code, string_ref name )
     352int lua::state::load_string( string_view code, string_view name )
    353353{
    354354        NV_LOG_TRACE( "Loading Lua string '", name, "'");
     
    356356}
    357357
    358 int lua::state::load_file( string_ref filename )
     358int lua::state::load_file( string_view filename )
    359359{
    360360        NV_LOG_NOTICE( "Loading Lua file '", filename, "'");
     
    362362}
    363363
    364 bool lua::state::do_string( string_ref code, string_ref name, int rvalues )
     364bool lua::state::do_string( string_view code, string_view name, int rvalues )
    365365{
    366366        lua::stack_guard( this );
     
    374374}
    375375
    376 bool lua::state::do_file( string_ref filename )
     376bool lua::state::do_file( string_view filename )
    377377{
    378378        lua::stack_guard( this );
     
    386386}
    387387
    388 int lua::state::do_current( string_ref name, int rvalues )
     388int lua::state::do_current( string_view name, int rvalues )
    389389{
    390390        int result = lua_pcall(m_state, 0, rvalues, 0);
     
    417417}
    418418
    419 lua::ref lua::state::register_object( void* o, string_ref lua_name )
     419lua::ref lua::state::register_object( void* o, string_view lua_name )
    420420{
    421421        if ( o == nullptr ) return lua::ref( lua::ref::none );
     
    430430}
    431431
    432 lua::ref lua::state::register_proto( string_ref id, string_ref storage )
     432lua::ref lua::state::register_proto( string_view id, string_view storage )
    433433{
    434434        stack_guard guard( this );
     
    446446}
    447447
    448 void lua::state::register_native_object_method( string_ref lua_name, string_ref name, lfunction f )
     448void lua::state::register_native_object_method( string_view lua_name, string_view name, lfunction f )
    449449{
    450450        stack_guard guard( this );
     
    508508}
    509509
    510 void nv::lua::state::store_metadata( ref object_index, string_ref metaname, void* pointer )
     510void nv::lua::state::store_metadata( ref object_index, string_view metaname, void* pointer )
    511511{
    512512        if ( !object_index.is_valid() ) return;
     
    518518}
    519519
    520 void nv::lua::state::register_enum( string_ref name, int value )
     520void nv::lua::state::register_enum( string_view name, int value )
    521521{
    522522        lua_pushinteger( m_state, value );
     
    524524}
    525525
    526 nv::lua::ref nv::lua::state::register_handle_component_impl( string_ref id, bool empty )
     526nv::lua::ref nv::lua::state::register_handle_component_impl( string_view id, bool empty )
    527527{
    528528        int args = empty ? 1 : 2;
     
    547547}
    548548
    549 void nv::lua::state::unregister_handle_component_impl( string_ref id )
     549void nv::lua::state::unregister_handle_component_impl( string_view id )
    550550{
    551551        NV_LUA_STACK_ASSERT( m_state, -1 );
     
    562562}
    563563
    564 void nv::lua::state::register_singleton( string_ref name, void* o )
     564void nv::lua::state::register_singleton( string_view name, void* o )
    565565{
    566566        if ( o == nullptr ) return;
  • trunk/src/lua/lua_values.cc

    r395 r399  
    7575}
    7676
    77 void nv::lua::detail::push_string_ref( lua_State *L, string_ref s )
     77void nv::lua::detail::push_string_view( lua_State *L, string_view s )
    7878{
    7979        lua_pushlstring( L, s.data(), s.size() );
     
    123123}
    124124
    125 nv::string_ref nv::lua::detail::to_string_ref( lua_State *L, int index )
     125nv::string_view nv::lua::detail::to_string_view( lua_State *L, int index )
    126126{
    127127        size_t length = 0;
    128128        const char* result = lua_tolstring( L, index, &length );
    129         return string_ref( result, length );
     129        return string_view( result, length );
    130130}
    131131
Note: See TracChangeset for help on using the changeset viewer.