Changeset 256
- Timestamp:
- 06/14/14 21:06:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/exception.hh
r3 r256 14 14 #define NV_EXCEPTION_HH 15 15 16 #include <nv/common.hh> 17 #include <string> 16 18 #include <exception> 17 19 #include <stdexcept> 18 #include <string>19 20 20 21 namespace nv … … 28 29 { 29 30 public: 30 explicit logic_error( const std::string& __arg) : std::logic_error( __arg ) {}31 explicit logic_error( const std::string& msg ) : std::logic_error( msg ) {} 31 32 }; 32 33 … … 39 40 { 40 41 public: 41 explicit runtime_error( const std::string& __arg) : std::runtime_error( __arg ) {}42 explicit runtime_error( const std::string& msg ) : std::runtime_error( msg ) {} 42 43 }; 43 44 } -
trunk/nv/gfx/texture_font.hh
r132 r256 9 9 10 10 #include <nv/common.hh> 11 #include < string>11 #include <nv/string.hh> 12 12 #include <unordered_map> 13 13 #include <nv/math.hh> … … 45 45 texture_font( texture_atlas* atlas, const char * filename, float size ); 46 46 const texture_glyph* get_glyph( uint16 charcode ) const; 47 bool load_glyphs( const st d::string& codes );47 bool load_glyphs( const string& codes ); 48 48 float get_size() const { return m_size; } 49 49 ~texture_font(); … … 54 54 55 55 texture_atlas* m_atlas; //!< Atlas Image object for this font. 56 st d::string m_filename; //!< Name of the file.56 string m_filename; //!< Name of the file. 57 57 float m_size; //!< Font size. 58 58 float m_height; //!< Height of the font. (x-height?) -
trunk/nv/interface/vertex_buffer.hh
r239 r256 18 18 #include <nv/interface/mesh_data.hh> 19 19 #include <unordered_map> 20 #include <string>21 20 22 21 namespace nv -
trunk/nv/library.hh
r166 r256 15 15 16 16 #include <nv/exception.hh> 17 #include < string>17 #include <nv/string.hh> 18 18 19 19 namespace nv … … 37 37 * Throws library_error on failure 38 38 */ 39 void open( const st d::string& name );39 void open( const string& name ); 40 40 41 41 /** … … 44 44 * returns true if succeeded, false otherwise 45 45 */ 46 bool try_open( const st d::string& name );46 bool try_open( const string& name ); 47 47 48 48 /** … … 54 54 * Returns library name 55 55 */ 56 const st d::string& get_name() const;56 const string& get_name() const; 57 57 58 58 /** … … 61 61 * Throws on symbol not found 62 62 */ 63 void* get( const st d::string& symbol );63 void* get( const string& symbol ); 64 64 65 65 /** … … 68 68 * Returns null if symbol not found 69 69 */ 70 void* try_get( const st d::string& symbol );70 void* try_get( const string& symbol ); 71 71 72 72 /** … … 82 82 * Exact implementation depends on platform/compiler. 83 83 */ 84 static st d::string get_error();84 static string get_error(); 85 85 86 86 protected: … … 107 107 108 108 /// Library name 109 st d::string m_name;109 string m_name; 110 110 111 111 }; // class Library … … 114 114 { 115 115 /// Library name 116 st d::string m_name;116 string m_name; 117 117 public: 118 118 /** 119 119 * Constructor 120 120 */ 121 library_error( const st d::string& message, const std::string& name )121 library_error( const string& message, const string& name ) 122 122 : runtime_error( "Library (" + name + ") : " + message + " [ " + library::get_error() + " ]"), m_name( name ) 123 123 { … … 134 134 * Returns library name 135 135 */ 136 const st d::string& get_name()136 const string& get_name() 137 137 { 138 138 return m_name; -
trunk/nv/logger.hh
r121 r256 14 14 #define NV_LOGGER_HH 15 15 16 #include <string> 16 #include <nv/string.hh> 17 #include <nv/logging.hh> 17 18 #include <iosfwd> 18 19 #include <list> 19 #include <nv/logging.hh>20 20 21 21 namespace nv -
trunk/nv/logging.hh
r121 r256 16 16 #include <nv/common.hh> 17 17 #include <nv/singleton.hh> 18 #include <string> 18 19 #include <sstream> 19 #include <string>20 20 21 21 namespace nv -
trunk/nv/lua/lua_state.hh
r253 r256 142 142 register_native_function( detail::function_wrapper< F, f >, name ); 143 143 } 144 145 template < typename C, typename F, F f > 146 struct register_member 147 { 148 register_member( const char* ) { } 149 }; 144 150 145 151 template < typename C, typename F, F f > … … 211 217 212 218 void store_metadata( object* o, const std::string& metaname, void* pointer ); 213 void unregister_object( object * o ); 219 void unregister_object( object * o ); // DELETE ME 220 void unregister_object( int index ); 214 221 void register_native_object_method( const char* lua_name, const char* name, lfunction f ); 215 222 template < typename F, F f > -
trunk/nv/object.hh
r217 r256 12 12 namespace nv 13 13 { 14 14 15 /** 15 16 * Implements a object tree-like structure. … … 18 19 { 19 20 public: 21 friend class root; 22 20 23 /** 21 24 * Register the object type in the type database. 22 25 */ 23 static void register_type( type_database* db );26 //static void register_type( type_database* db ); 24 27 25 28 /// List type -
trunk/nv/root.hh
r215 r256 22 22 virtual void child_added( object* ) {} 23 23 virtual void child_removed( object* ) {} 24 virtual void object_created( object* o ); 25 virtual void object_destroyed( object* o ); 24 26 lua::state* get_lua_state() const { return m_lua_state; } 25 27 uid_store* get_uid_store() const { return m_uid_store; } 26 virtual ~root() { destroy_children(); } 28 virtual ~root() 29 { 30 object_destroyed( this ); 31 destroy_children(); 32 m_root = nullptr; 33 } 27 34 protected: 28 35 lua::state* m_lua_state; -
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.