Changeset 364


Ignore:
Timestamp:
05/15/15 12:52:52 (10 years ago)
Author:
epyon
Message:
  • fixed compilation on clang
  • cleared all clang warnings (except fix_me's)
Location:
trunk
Files:
14 edited

Legend:

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

    r350 r364  
    6767        };
    6868
    69         template < typename HANDLE >
     69        template < typename HANDLE, typename INDEX = sint32 >
    7070        class handle_manager
    7171        {
    72                 static const sint32 NONE = -1;
    73                 static const sint32 USED = -2;
     72                typedef INDEX index_type;
     73                static const index_type NONE = index_type(-1);
     74                static const index_type USED = index_type(-2);
    7475        public:
    7576
     
    9899                        if ( m_last_free == NONE )
    99100                        {
    100                                 m_first_free = m_last_free = index;
     101                                m_first_free = m_last_free = (index_type)index;
    101102                                return;
    102103                        }
    103                         m_entries[(unsigned)m_last_free].next_free = index;
    104                         m_last_free = index;
     104                        m_entries[(value_type)m_last_free].next_free = (index_type)index;
     105                        m_last_free = (index_type)index;
    105106                }
    106107
     
    118119                {
    119120                        value_type counter;
    120                         sint32    next_free;
     121                        index_type next_free;
    121122
    122123                        index_entry() : counter( 0 ), next_free( NONE ) {}
     
    137138                }
    138139
    139                 sint32 m_first_free;
    140                 sint32 m_last_free;
     140                index_type m_first_free;
     141                index_type m_last_free;
    141142                std::vector< index_entry > m_entries;
    142143        };
  • trunk/nv/core/string.hh

    r363 r364  
    328328                }
    329329
    330                 inline NV_CONSTEXPR const char front()  const { return m_data[0]; }
    331                 inline NV_CONSTEXPR const char back()   const { return m_data[m_size - 1]; }
     330                inline NV_CONSTEXPR char front()  const { return m_data[0]; }
     331                inline NV_CONSTEXPR char back()   const { return m_data[m_size - 1]; }
    332332                inline NV_CONSTEXPR const char* data()  const { return m_data; }
    333333
     
    351351                {
    352352                        if ( pos >= m_size ) return npos;
    353                         const_iterator it = std::search( this->cbegin() + pos, this->cend(), s.cbegin(), s.cend() );
    354                         return it == this->cend() ? npos : std::distance( this->cbegin(), it );
     353                        const_iterator it = std::search( this->cbegin() + ( difference_type ) pos, this->cend(), s.cbegin(), s.cend() );
     354                        return it == this->cend() ? npos : ( size_type )std::distance( this->cbegin(), it );
    355355                }
    356356                size_type find( char c, size_type pos = 0 ) const
    357357                {
    358358                        if ( pos >= m_size ) return npos;
    359                         const_iterator it = std::find_if( this->cbegin() + pos, this->cend(), [=] ( char val ) { return val == c; } );
    360                         return it == this->cend() ? npos : std::distance( this->cbegin(), it );
     359                        const_iterator it = std::find_if( this->cbegin() + ( difference_type ) pos, this->cend(), [=] ( char val ) { return val == c; } );
     360                        return it == this->cend() ? npos : ( size_type )std::distance( this->cbegin(), it );
    361361                }
    362362                size_type rfind( const string_base& s, size_type pos = 0 ) const
    363363                {
    364364                        if ( pos >= m_size ) return npos;
    365                         const_reverse_iterator it = std::search( this->crbegin() + pos, this->crend(), s.crbegin(), s.crend() );
    366                         return it == this->crend() ? npos : m_size - 1 - std::distance( this->crbegin(), it );
     365                        const_reverse_iterator it = std::search( this->crbegin() + ( difference_type ) pos, this->crend(), s.crbegin(), s.crend() );
     366                        return it == this->crend() ? npos : m_size - 1 - ( size_type )std::distance( this->crbegin(), it );
    367367                }
    368368                size_type rfind( char c, size_type pos = 0 ) const
    369369                {
    370370                        if ( pos >= m_size ) return npos;
    371                         const_reverse_iterator it = std::find_if( this->crbegin() + pos, this->crend(), [=] ( char val ) { return val == c; } );
    372                         return it == this->crend() ? npos : m_size - 1 - std::distance( this->crbegin(), it );
     371                        const_reverse_iterator it = std::find_if( this->crbegin() + ( difference_type ) pos, this->crend(), [=] ( char val ) { return val == c; } );
     372                        return it == this->crend() ? npos : m_size - 1 - ( size_type )std::distance( this->crbegin(), it );
    373373                }
    374374                size_type find_first_of( char c ) const { return find( c ); }
     
    376376                {
    377377                        const_iterator it = std::find_first_of( this->cbegin(), this->cend(), s.cbegin(), s.cend() );
    378                         return it == this->cend() ? npos : std::distance( this->cbegin(), it );
     378                        return it == this->cend() ? npos : ( size_type )std::distance( this->cbegin(), it );
    379379                }
    380380                size_type find_last_of( char c )  const { return rfind( c ); }
     
    382382                {
    383383                        const_reverse_iterator it = std::find_first_of( this->crbegin(), this->crend(), s.cbegin(), s.cend() );
    384                         return it == this->crend() ? npos : m_size - 1 - std::distance( this->crbegin(), it );
     384                        return it == this->crend() ? npos : m_size - 1 - ( size_type )std::distance( this->crbegin(), it );
    385385                }
    386386                size_type find_first_not_of( const string_base& s ) const
     
    388388                        for ( const_iterator it = this->cbegin(); it != this->cend(); ++it )
    389389                                if ( 0 == std::memchr( s.m_data, *it, s.m_size ) )
    390                                         return std::distance( this->cbegin(), it );
     390                                        return ( size_type )std::distance( this->cbegin(), it );
    391391                        return npos;
    392392                }
     
    395395                        for ( const_iterator it = this->cbegin(); it != this->cend(); ++it )
    396396                                if ( c != *it )
    397                                         return std::distance( this->cbegin(), it );
     397                                        return ( size_type )std::distance( this->cbegin(), it );
    398398                        return npos;
    399399                }
     
    402402                        for ( const_reverse_iterator it = this->crbegin(); it != this->crend(); ++it )
    403403                                if ( 0 == std::memchr( s.m_data, *it, s.m_size ) )
    404                                         return m_size - 1 - std::distance( this->crbegin(), it );;
     404                                        return m_size - 1 - ( size_type )std::distance( this->crbegin(), it );;
    405405                        return npos;
    406406                }
     
    409409                        for ( const_reverse_iterator it = this->crbegin(); it != this->crend(); ++it )
    410410                                if ( c != *it )
    411                                         return m_size - 1 - std::distance( this->crbegin(), it );
     411                                        return m_size - 1 - ( size_type )std::distance( this->crbegin(), it );
    412412                        return npos;
    413413                }
     
    618618                if ( os.good() )
    619619                {
    620                         os.write( str.data(), str.size() );
     620                        os.write( str.data(), static_cast<std::streamsize>( str.size() ) );
    621621                }
    622622                return os;
  • trunk/nv/engine/program_manager.hh

    r319 r364  
    2424        public:
    2525                program_manager( context* a_context );
    26                 virtual const char* get_storage_name() const { return "programs"; }
    27                 virtual const char* get_resource_name() const { return "program"; }
     26                virtual string_ref get_storage_name() const { return "programs"; }
     27                virtual string_ref get_resource_name() const { return "program"; }
    2828        protected:
    2929                virtual resource_id load_resource( lua::table_guard& table );
  • trunk/nv/engine/resource_system.hh

    r323 r364  
    3232                resource_manager_base() : m_lua( nullptr ) {}
    3333                void initialize( lua::state* state );
    34                 virtual const char* get_storage_name() const = 0;
    35                 virtual const char* get_resource_name() const = 0;
     34                virtual string_ref get_storage_name() const = 0;
     35                virtual string_ref get_resource_name() const = 0;
    3636                virtual void clear() { m_names.clear(); }
    3737                void load_all();
  • trunk/nv/gl/gl_window.hh

    r343 r364  
    3232                virtual string get_title() const  { return std::string(); }
    3333                // TODO : implement?
    34                 virtual void set_swap_control( bool ) {};
     34                virtual void set_swap_control( bool ) {}
    3535
    3636                virtual bool is_event_pending()            { return m_input->is_event_pending(); }
  • trunk/nv/interface/input.hh

    r326 r364  
    2424                virtual bool is_event_pending() = 0;
    2525                virtual bool poll_event( io_event& event ) = 0;
    26                 virtual ~input() {};
     26                virtual ~input() {}
    2727        };
    2828
  • trunk/nv/interface/window_manager.hh

    r326 r364  
    3030                virtual void sleep( uint32 ms ) = 0;
    3131                virtual uint32 get_ticks() = 0;
     32                virtual ~window_manager() {}
    3233        };
    3334
  • trunk/nv/lua/lua_handle.hh

    r333 r364  
    6868                {
    6969                        typedef handle_operator<H> hop;
    70                         detail::handle_struct h = detail::to_handle_impl( L, index, hop::get_index( handle ), hop::get_counter( handle ) );
     70                        detail::handle_struct h = detail::to_handle_impl( L, index, hop::get_index( def ), hop::get_counter( def ) );
    7171                        return hop::create( h.index, h.counter );
    7272                };
  • trunk/src/engine/resource_system.cc

    r361 r364  
    1212{
    1313        m_lua = a_lua_state;
    14         std::string constructor_name( get_resource_name() );
    15         constructor_name = "register_"+constructor_name;
    16         int correct = 0;
    17         lua::register_storage( m_lua, get_storage_name(), constructor_name );
     14        lua::register_storage( m_lua, get_storage_name(), "register_" + get_resource_name().to_string() );
    1815}
    1916
  • trunk/src/gl/gl_context.cc

    r342 r364  
    734734                if ( slots[i] > OUTPUT_7 ) buffers[i] = 0;
    735735        }
    736         glDrawBuffers( count, buffers );
     736        glDrawBuffers( (GLsizei)count, buffers );
    737737}
    738738
  • trunk/src/gl/gl_device.cc

    r361 r364  
    5656{
    5757        load_sdl_image_library();
    58         SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( (void*)data, size ), 1, "tga" );
     58        SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( (void*)data, (int)size ), 1, "png" );
    5959        if ( !image )
    6060        {
     
    402402
    403403        const char* pc = shader_code.data();
    404         int l = shader_code.length();
     404        int l = (int)shader_code.length();
    405405
    406406        glShaderSource( glid, 1, &pc, &l );
  • trunk/src/gui/gui_ascii_renderer.cc

    r356 r364  
    8080                for ( int x = 0; x < abs.get_width(); ++x )
    8181                {
    82                         m_terminal->print( position( abs.ul.y, abs.ul.x + x ), er->border_color, er->border_chars[0] );
    83                         m_terminal->print( position( abs.lr.y, abs.ul.x + x ), er->border_color, er->border_chars[1] );
     82                        m_terminal->print( position( abs.ul.y, abs.ul.x + x ), er->border_color, (unsigned char)er->border_chars[0] );
     83                        m_terminal->print( position( abs.lr.y, abs.ul.x + x ), er->border_color, (unsigned char)er->border_chars[1] );
    8484                }
    8585
    8686                for ( int y = 0; y < abs.get_height(); ++y )
    8787                {
    88                         m_terminal->print( position( abs.ul.y + y, abs.ul.x ), er->border_color, er->border_chars[2] );
    89                         m_terminal->print( position( abs.ul.y + y, abs.lr.x ), er->border_color, er->border_chars[3] );
     88                        m_terminal->print( position( abs.ul.y + y, abs.ul.x ), er->border_color, (unsigned char)er->border_chars[2] );
     89                        m_terminal->print( position( abs.ul.y + y, abs.lr.x ), er->border_color, (unsigned char)er->border_chars[3] );
    9090                }
    9191
    92                 m_terminal->print( abs.ul,   er->border_color, er->border_chars[4] );
    93                 m_terminal->print( abs.ur(), er->border_color, er->border_chars[5] );
    94                 m_terminal->print( abs.ll(), er->border_color, er->border_chars[6] );
    95                 m_terminal->print( abs.lr,   er->border_color, er->border_chars[7] );
     92                m_terminal->print( abs.ul,   er->border_color, (unsigned char)er->border_chars[4] );
     93                m_terminal->print( abs.ur(), er->border_color, (unsigned char)er->border_chars[5] );
     94                m_terminal->print( abs.ll(), er->border_color, (unsigned char)er->border_chars[6] );
     95                m_terminal->print( abs.lr,   er->border_color, (unsigned char)er->border_chars[7] );
    9696        }
    9797        if ( !e->m_text.empty() )
     
    100100                for ( char c : e->m_text )
    101101                {
    102                         m_terminal->print( p, er->text_color, c );
     102                        m_terminal->print( p, er->text_color, (unsigned char)c );
    103103                        ++p.x;
    104104                }
     
    111111}
    112112
    113 void nv::gui::ascii_renderer::on_hover_change( element* e, bool hover )
     113void nv::gui::ascii_renderer::on_hover_change( element* e, bool /*hover*/ )
    114114{
    115115        // TODO: FIX
     116        int fix_me;
    116117        NV_LOG( nv::LOG_DEBUG, "on_hover_change" );
    117118        e->m_flags[DIRTY] = true;
    118119}
    119120
    120 void nv::gui::ascii_renderer::on_select_change( element* e, bool select )
     121void nv::gui::ascii_renderer::on_select_change( element* e, bool /*select*/ )
    121122{
    122123        // TODO: FIX
     124        int fix_me;
    123125        NV_LOG( nv::LOG_DEBUG, "on_select_change" );
    124126        e->m_flags[DIRTY] = true;
  • trunk/src/gui/gui_gfx_renderer.cc

    r354 r364  
    266266                                vec2 tsize32 = ( image->t2 - image->t1 ) * ( 2.0f / 3.0f );
    267267                                vec2 tsizex = vec2( tsize.x, 0.0f );
    268                                 vec2 tsizey = vec2( 0.0f, tsize.y );
     268                                //vec2 tsizey = vec2( 0.0f, tsize.y );
    269269                                vec2 tsize3x = vec2( tsize3.x, 0.0f );
    270270                                vec2 tsize3y = vec2( 0.0f, tsize3.y );
     
    343343}
    344344
    345 void gfx_renderer::on_hover_change( element* e, bool hover )
     345void gfx_renderer::on_hover_change( element* e, bool /*hover*/ )
    346346{
    347347        // TODO: FIX
     348        int fix_me;
    348349        NV_LOG( nv::LOG_DEBUG, "on_hover_change" );
    349350        e->m_flags[DIRTY] = true;
    350351}
    351352
    352 void gfx_renderer::on_select_change( element* e, bool select )
     353void gfx_renderer::on_select_change( element* e, bool /*select*/ )
    353354{
    354355        // TODO: FIX
     356        int fix_me;
    355357        NV_LOG( nv::LOG_DEBUG, "on_select_change" );
    356358        e->m_flags[DIRTY] = true;
  • trunk/src/lua/lua_handle.cc

    r335 r364  
    1515        NV_LUA_STACK_ASSERT( L, +1 );
    1616        lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
    17         lua_rawgeti( L, -1, index );                      // table, entry
     17        lua_rawgeti( L, -1, (int)index );                 // table, entry
    1818        if ( !lua_istable( L, -1 ) )
    1919        {
     
    5757        lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex );
    5858        lua_insert( L, -2 );
    59         lua_rawseti( L, -2, index );
     59        lua_rawseti( L, -2, (int)index );
    6060        lua_pop( L, 1 );
    6161}
     
    6666        lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
    6767        lua_pushinteger( L, 0 );
    68         lua_rawseti( L, -2, index );
     68        lua_rawseti( L, -2, (int)index );
    6969        lua_pop( L, 1 );
    7070}
Note: See TracChangeset for help on using the changeset viewer.