Changeset 511 for trunk


Ignore:
Timestamp:
07/28/16 20:31:39 (9 years ago)
Author:
epyon
Message:
  • RTTI upgrades
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/core/random.hh

    r509 r511  
    480480}
    481481
     482NV_RTTI_DECLARE( nv::random_dist )
     483
    482484#endif // NV_CORE_RANDOM_HH
  • trunk/nv/core/types.hh

    r503 r511  
    8585        {
    8686                shash64 name;
     87                shash64 desc;
    8788                sint32  value;
    8889        };
     
    124125                type_creator union_field( const string_view& aname, TFIELD TOBJECT::*field, const string_view& control_name, ENUM_VALUE control_value, typename enable_if< !is_container<TFIELD>::value, void* >::type = nullptr );
    125126
    126                 type_creator value( const string_view& aname, sint32 value );
     127                type_creator value( const string_view& aname, sint32 value, const string_view& desc = string_view() );
    127128        private:
    128129                type_database* m_database;
     
    287288        }
    288289
    289         inline type_creator type_creator::value( const string_view& aname, sint32 value )
     290        inline type_creator type_creator::value( const string_view& aname, sint32 value, const string_view& desc )
    290291        {
    291292                NV_ASSERT( m_entry->field_list.empty(), "Type cannot have both enums and fields!" );
    292293                type_enum e;
    293294                e.name = m_database->m_names.insert( aname );
     295                if ( !desc.empty() )
     296                        e.desc = m_database->m_names.insert( desc );
    294297                e.value = value;
    295298                m_entry->enum_list.push_back( e );
  • trunk/nv/engine/default_resource_manager.hh

    r509 r511  
    5555                        return m_mesh_datas->resolve( h );
    5656                }
     57                lua::state* get_lua() { return m_lua; }
     58                const type_database* get_type_db() { return m_lua->get_type_data()->get_type_database(); }
    5759
    5860                void reload_data();
  • trunk/nv/engine/model_manager.hh

    r510 r511  
    9595        };
    9696
     97        NV_RTTI_DECLARE_NAME( model_node_choice, "random_dist" )
    9798        NV_RTTI_DECLARE_NAME( model, "model" )
    9899
  • trunk/nv/lua/lua_state.hh

    r509 r511  
    262262                        void unregister_object( ref object_index );
    263263
     264                        template <typename E>
     265                        void register_enum()
     266                        {
     267                                register_enum( m_lua_types->get_type_database()->get_type<E>() );
     268                        }
     269                        void register_enum( const type_entry* type );
    264270                        void register_enum( string_view name, int value );
    265271                        void register_singleton( string_view name, void* o );
  • trunk/src/lua/lua_state.cc

    r509 r511  
    750750}
    751751
     752void nv::lua::state::register_enum( const type_entry* type )
     753{
     754        NV_ASSERT_ALWAYS( type, "type not found!" );
     755        NV_ASSERT_ALWAYS( !type->enum_list.empty(), "type not enum!" );
     756        type_database* db = type->type_db;
     757        for ( auto e : type->enum_list )
     758        {
     759                lua_pushinteger( m_state, e.value );
     760                lua_setglobal( m_state, db->resolve_name( e.name ).data() );
     761        }
     762}
     763
    752764void nv::lua::state::register_rtti_type( thash64 tid, lua_rtti_push_function p, lua_rtti_read_function r )
    753765{
Note: See TracChangeset for help on using the changeset viewer.