- Timestamp:
- 06/14/14 21:06:00 (11 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/texture_font.cc
r121 r256 92 92 } 93 93 94 bool texture_font::load_glyphs( const st d::string& codes )94 bool texture_font::load_glyphs( const string& codes ) 95 95 { 96 96 FT_Face face = (FT_Face)(m_rface); -
trunk/src/library.cc
r166 r256 4 4 #include "nv/common.hh" 5 5 #include "nv/library.hh" 6 7 #include <string.h>8 6 9 7 #if NV_PLATFORM == NV_WINDOWS … … 41 39 } 42 40 43 void library::open( const st d::string& name )41 void library::open( const string& name ) 44 42 { 45 43 m_name = name; … … 51 49 } 52 50 53 bool nv::library::try_open( const st d::string& name )51 bool nv::library::try_open( const string& name ) 54 52 { 55 53 m_name = name; … … 62 60 } 63 61 64 const st d::string& library::get_name() const62 const string& library::get_name() const 65 63 { 66 64 return m_name; … … 75 73 NV_LOG( LOG_NOTICE, "library : loading '" + m_name + "'..." ); 76 74 77 st d::string name = m_name;78 st d::string ext = NV_LIB_EXT;75 string name = m_name; 76 string ext = NV_LIB_EXT; 79 77 size_t ext_len = ext.length(); 80 78 … … 95 93 } 96 94 97 void* library::get( const st d::string& symbol )95 void* library::get( const string& symbol ) 98 96 { 99 97 void* result = (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.c_str() ); … … 105 103 } 106 104 107 void* nv::library::try_get( const st d::string& symbol )105 void* nv::library::try_get( const string& symbol ) 108 106 { 109 107 return (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.c_str() ); … … 133 131 } 134 132 135 st d::string library::get_error()133 string library::get_error() 136 134 { 137 135 #if NV_PLATFORM == NV_WINDOWS … … 140 138 FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 141 139 NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &buffer, 0, NULL ); 142 st d::string msg( (char*)buffer );140 string msg( (char*)buffer ); 143 141 LocalFree( buffer ); 144 142 return msg; 145 143 #elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE 146 return st d::string(dlerror());144 return string(dlerror()); 147 145 #else 148 return st d::string("");146 return string(""); 149 147 #endif 150 148 } -
trunk/src/lua/lua_state.cc
r228 r256 383 383 { 384 384 if (!o) return; 385 unregister_object( o->get_lua_index() ); 386 } 387 388 void lua::state::unregister_object( int index ) 389 { 385 390 stack_guard guard( this ); 386 lua_rawgeti( m_state, LUA_REGISTRYINDEX, o->get_lua_index());391 lua_rawgeti( m_state, LUA_REGISTRYINDEX, index ); 387 392 lua_pushstring( m_state, "__ptr" ); 388 393 lua_pushboolean( m_state, false ); 389 394 lua_rawset( m_state, -3 ); 390 395 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 393 399 394 400 void lua::state::deep_pointer_copy( int index, void* obj ) -
trunk/src/object.cc
r217 r256 41 41 if ( m_root ) 42 42 { 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 } 50 45 } 51 46 … … 104 99 object::~object() 105 100 { 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 ); 115 104 } 116 105 detach(); … … 194 183 } 195 184 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 // } 208 197 209 198 void 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 12 void 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 20 void 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.