Changeset 256 for trunk/src


Ignore:
Timestamp:
06/14/14 21:06:00 (11 years ago)
Author:
epyon
Message:
  • various minor fixes
Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gfx/texture_font.cc

    r121 r256  
    9292}
    9393
    94 bool texture_font::load_glyphs( const std::string& codes )
     94bool texture_font::load_glyphs( const string& codes )
    9595{
    9696        FT_Face face     = (FT_Face)(m_rface);
  • trunk/src/library.cc

    r166 r256  
    44#include "nv/common.hh"
    55#include "nv/library.hh"
    6 
    7 #include <string.h>
    86
    97#if NV_PLATFORM == NV_WINDOWS
     
    4139}
    4240
    43 void library::open( const std::string& name )
     41void library::open( const string& name )
    4442{
    4543        m_name = name;
     
    5149}
    5250
    53 bool nv::library::try_open( const std::string& name )
     51bool nv::library::try_open( const string& name )
    5452{
    5553        m_name = name;
     
    6260}
    6361
    64 const std::string& library::get_name() const
     62const string& library::get_name() const
    6563{
    6664    return m_name;
     
    7573    NV_LOG( LOG_NOTICE, "library : loading '" + m_name + "'..." );
    7674
    77     std::string name = m_name;
    78     std::string ext  = NV_LIB_EXT;
     75    string name = m_name;
     76    string ext  = NV_LIB_EXT;
    7977    size_t ext_len   = ext.length();
    8078
     
    9593}
    9694
    97 void* library::get( const std::string& symbol )
     95void* library::get( const string& symbol )
    9896{
    9997        void* result = (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.c_str() );
     
    105103}
    106104
    107 void* nv::library::try_get( const std::string& symbol )
     105void* nv::library::try_get( const string& symbol )
    108106{
    109107        return (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.c_str() );
     
    133131}
    134132
    135 std::string library::get_error()
     133string library::get_error()
    136134{
    137135#if NV_PLATFORM == NV_WINDOWS
     
    140138    FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
    141139        NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &buffer, 0, NULL );
    142     std::string msg( (char*)buffer );
     140    string msg( (char*)buffer );
    143141    LocalFree( buffer );
    144142    return msg;
    145143#elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
    146     return std::string(dlerror());
     144    return string(dlerror());
    147145#else
    148     return std::string("");
     146    return string("");
    149147#endif
    150148}
  • trunk/src/lua/lua_state.cc

    r228 r256  
    383383{
    384384        if (!o) return;
     385        unregister_object( o->get_lua_index() );
     386}
     387
     388void lua::state::unregister_object( int index )
     389{
    385390        stack_guard guard( this );
    386         lua_rawgeti( m_state, LUA_REGISTRYINDEX, o->get_lua_index() );
     391        lua_rawgeti( m_state, LUA_REGISTRYINDEX, index );
    387392        lua_pushstring( m_state, "__ptr" );
    388393        lua_pushboolean( m_state, false );
    389394        lua_rawset( m_state, -3 );
    390395        lua_pop( m_state, 1 );
    391         luaL_unref( m_state, LUA_REGISTRYINDEX, o->get_lua_index() );
    392 }
     396        luaL_unref( m_state, LUA_REGISTRYINDEX, index );
     397}
     398
    393399
    394400void lua::state::deep_pointer_copy( int index, void* obj )
  • trunk/src/object.cc

    r217 r256  
    4141        if ( m_root )
    4242        {
    43                 uid_store*  store = get_root()->get_uid_store();
    44                 if (store)
    45                 {
    46                         m_uid = store->insert( this );
    47                 }
    48         }
    49 
     43                m_root->object_created( this );
     44        }
    5045}
    5146
     
    10499object::~object()
    105100{
    106         if ( m_lua_index != lua::ref_none )
    107         {
    108                 lua::state* state = get_root()->get_lua_state();
    109                 state->unregister_object( this );
    110         }
    111         if ( m_uid != 0 && m_root )
    112         {
    113                 uid_store* store = get_root()->get_uid_store();
    114                 if (store) store->remove( m_uid );
     101        if ( m_root )
     102        {
     103                m_root->object_destroyed( this );
    115104        }
    116105        detach();
     
    194183}
    195184
    196 void object::register_type( type_database* db )
    197 {
    198         type_field fields[] = {
    199                 type_field("id",          &object::m_id),
    200                 type_field("uid",         &object::m_uid).flag( TF_READONLY ),
    201                 type_field("lua_index",   &object::m_lua_index).flag( TF_READONLY | TF_NOSERIALIZE ),
    202                 type_field("parent",      &object::m_parent).flag( TF_READONLY | TF_NOSERIALIZE ),
    203                 type_field("child_count", &object::m_child_count).flag( TF_READONLY ),
    204                 type_field("children"   , &object::m_children).flag( TF_READONLY ),
    205         };
    206         db->create_type<object>("object").fields(fields);
    207 }
     185// void object::register_type( type_database* db )
     186// {
     187//      type_field fields[] = {
     188//              type_field("id",          &object::m_id),
     189//              type_field("uid",         &object::m_uid).flag( TF_READONLY ),
     190//              type_field("lua_index",   &object::m_lua_index).flag( TF_READONLY | TF_NOSERIALIZE ),
     191//              type_field("parent",      &object::m_parent).flag( TF_READONLY | TF_NOSERIALIZE ),
     192//              type_field("child_count", &object::m_child_count).flag( TF_READONLY ),
     193//              type_field("children"   , &object::m_children).flag( TF_READONLY ),
     194//      };
     195//      db->create_type<object>("object").fields(fields);
     196// }
    208197
    209198void nv::object::register_with_lua( const char* lua_name, const char* storage )
  • trunk/src/root.cc

    r64 r256  
     1// Copyright (C) 2012-2014 ChaosForge Ltd
     2// http://chaosforge.org/
     3//
     4// This file is part of NV Libraries.
     5// For conditions of distribution and use, see copyright notice in nv.hh
     6
     7#include "nv/root.hh"
     8
     9#include "nv/uid.hh"
     10#include "nv/lua/lua_state.hh"
     11
     12void nv::root::object_created( object* o )
     13{
     14        if ( m_uid_store )
     15        {
     16                o->m_uid = m_uid_store->insert( o );
     17        }
     18}
     19
     20void nv::root::object_destroyed( object* o )
     21{
     22        if ( m_lua_state && o->m_lua_index != lua::ref_none )
     23        {
     24                m_lua_state->unregister_object( o );
     25        }
     26        if ( m_uid_store && o->m_uid != 0 )
     27        {
     28                m_uid_store->remove( o->m_uid );
     29        }
     30}
Note: See TracChangeset for help on using the changeset viewer.