Changeset 197


Ignore:
Timestamp:
08/11/13 13:32:41 (12 years ago)
Author:
epyon
Message:
  • clang compilation fixed
  • gcc compilation fixed
  • warning cleanup will follow
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/flags.hh

    r178 r197  
    1515
    1616#include <nv/common.hh>
     17#include <nv/type_traits.hh>
    1718#include <bitset>
    18 #include <type_traits>
    1919
    2020namespace nv
     
    2929        struct base_underlying_type_helper< T, std::true_type >
    3030        {
    31                 typedef typename std::underlying_type<T>::type type;
     31                typedef typename nv::underlying_type<T>::type type;
    3232        };
    3333
     
    6767
    6868                private:
    69                         reference() : m_flags( nullptr ), m_position( 0 ) {}
     69                        reference() : m_flags( nullptr ), m_index( 0 ) {}
    7070
    7171                        reference( flags<SIZE,T>* a_flags, index_type a_index )
     
    112112                {
    113113                        raw_index_type idx = static_cast< raw_index_type >( i ) / data_type_size;
    114                         raw_index_type pos = < raw_index_type >( i ) % data_type_size;
     114                        raw_index_type pos = static_cast< raw_index_type >( i ) % data_type_size;
    115115                        m_data[ idx ] |= 1 << static_cast< data_type >( pos );
    116116                }
  • trunk/nv/lua/lua_state.hh

    r188 r197  
    4343                };
    4444
    45                 class table_guard
    46                 {
    47                 public:
    48                         table_guard( state* lstate, const path& p, bool global = true );
    49                         table_guard( const table_guard& parent, const path& p );
    50                         size_t get_size();
    51                         bool has_field( const std::string& element );
    52                         std::string get_string( const std::string& element, const std::string& defval = "" );
    53                         char get_char( const std::string& element, char defval = ' ' );
    54                         int get_integer( const std::string& element, int defval = 0 );
    55                         unsigned get_unsigned( const std::string& element, unsigned defval = 0 );
    56                         double get_double( const std::string& element, double defval = 0.0 );
    57                         bool get_boolean( const std::string& element, bool defval = false );
    58                         bool is_defined( const path& p );
    59 
    60                         template< typename R, typename T >
    61                         R get( const T& key )
    62                         {
    63                                 detail::push_value( L->L, key );
    64                                 call_get();
    65                                 return detail::pop_return_value( L->L )
    66                         }
    67 
    68                         template< typename R, typename T >
    69                         R raw_get( const T& key )
    70                         {
    71                                 detail::push_value( L->L, key );
    72                                 call_get_raw();
    73                                 return detail::pop_return_value( L->L )
    74                         }
    75 
    76                         template< uint32 SIZE, typename T >
    77                         flags< SIZE, T > get_flags( const std::string& element )
    78                         {
    79                                 flags< SIZE, T > result;
    80                                 get_raw_flags( element, result.data(), result.size() );
    81                                 return result;
    82                         }
    83 
    84                         template< uint32 SIZE, typename T >
    85                         void load_flags( const std::string& element, flags< SIZE, T >& flags )
    86                         {
    87                                 get_raw_flags( element, flags.data(), flags.size() );
    88                         }
    89 
    90                         template < typename R >
    91                         R call( const path& p )
    92                         {
    93                                 if ( L->push_function( p, false ) )
    94                                 {
    95                                         if ( call_function( 0, detail::return_count< R >::value ) == 0 )
    96                                         {
    97                                                 return detail::pop_return_value<R>( L );
    98                                         }
    99                                 }
    100                                 return R();
    101                         }
    102                         template < typename R, typename T1 >
    103                         R call( const path& p, const T1& p1 )
    104                         {
    105                                 if ( L->push_function( p, false ) )
    106                                 {
    107                                         detail::push_value( L, p1 );
    108                                         if ( L->call_function( 1, detail::return_count< R >::value ) == 0 )
    109                                         {
    110                                                 return detail::pop_return_value<R>( L );
    111                                         }
    112                                 }
    113                                 return R();
    114                         }
    115                         template < typename R, typename T1, typename T2 >
    116                         R call( const path& p, const T1& p1, const T2& p2 )
    117                         {
    118                                 if ( L->push_function( p, false ) )
    119                                 {
    120                                         detail::push_values( L, p1, p2 );
    121                                         if ( L->call_function( 2, detail::return_count< R >::value ) == 0 )
    122                                         {
    123                                                 return detail::pop_return_value<R>( L );
    124                                         }
    125                                 }
    126                                 return R();
    127                         }
    128                         template < typename R, typename T1, typename T2, typename T3 >
    129                         R call( const path& p, const T1& p1, const T2& p2, const T3& p3 )
    130                         {
    131                                 if ( L->push_function( p, false ) )
    132                                 {
    133                                         detail::push_values( L, p1, p2, p3 );
    134                                         if ( L->call_function( 3, detail::return_count< R >::value ) == 0 )
    135                                         {
    136                                                 return detail::pop_return_value<R>( L );
    137                                         }
    138                                 }
    139                                 return R();
    140                         }
    141                         template < typename R, typename T1, typename T2, typename T3, typename T4 >
    142                         R call( const path& p, const T1& p1, const T2& p2, const T3& p3, const T4& p4 )
    143                         {
    144                                 if ( L->push_function( p, false ) )
    145                                 {
    146                                         detail::push_value( L, p1, p2, p3, p4 );
    147                                         if ( L->call_function( 4, detail::return_count< R >::value ) == 0 )
    148                                         {
    149                                                 return detail::pop_return_value<R>( L );
    150                                         }
    151                                 }
    152                                 return R();
    153                         }
    154 
    155                 private:
    156                         bool push_function( const path& p );
    157                         int call_function( int nargs, int nresults );
    158                         void call_get();
    159                         void call_get_raw();
    160                         void get_raw_flags( const std::string& element, uint8* data, uint32 count );
    161 
    162                         state* L;
    163                         stack_guard m_guard;
    164                 };
    165 
     45                class table_guard;
    16646                class state
    16747                {
     
    264144                };
    265145
     146                class table_guard
     147                {
     148                public:
     149                        table_guard( state* lstate, const path& p, bool global = true );
     150                        table_guard( const table_guard& parent, const path& p );
     151                        size_t get_size();
     152                        bool has_field( const std::string& element );
     153                        std::string get_string( const std::string& element, const std::string& defval = "" );
     154                        char get_char( const std::string& element, char defval = ' ' );
     155                        int get_integer( const std::string& element, int defval = 0 );
     156                        unsigned get_unsigned( const std::string& element, unsigned defval = 0 );
     157                        double get_double( const std::string& element, double defval = 0.0 );
     158                        bool get_boolean( const std::string& element, bool defval = false );
     159                        bool is_defined( const path& p );
     160
     161                        template< typename R, typename T >
     162                        R get( const T& key )
     163                        {
     164                                detail::push_value( L->L, key );
     165                                call_get();
     166                                return detail::pop_return_value<R>( L->L );
     167                        }
     168
     169                        template< typename R, typename T >
     170                        R raw_get( const T& key )
     171                        {
     172                                detail::push_value( L->L, key );
     173                                call_get_raw();
     174                                return detail::pop_return_value<R>( L->L );
     175                        }
     176
     177                        template< uint32 SIZE, typename T >
     178                        flags< SIZE, T > get_flags( const std::string& element )
     179                        {
     180                                flags< SIZE, T > result;
     181                                get_raw_flags( element, result.data(), result.size() );
     182                                return result;
     183                        }
     184
     185                        template< uint32 SIZE, typename T >
     186                        void load_flags( const std::string& element, flags< SIZE, T >& flags )
     187                        {
     188                                get_raw_flags( element, flags.data(), flags.size() );
     189                        }
     190
     191                        template < typename R >
     192                        R call( const path& p )
     193                        {
     194                                if ( L->push_function( p, false ) )
     195                                {
     196                                        if ( call_function( 0, detail::return_count< R >::value ) == 0 )
     197                                        {
     198                                                return detail::pop_return_value<R>( L );
     199                                        }
     200                                }
     201                                return R();
     202                        }
     203                        template < typename R, typename T1 >
     204                        R call( const path& p, const T1& p1 )
     205                        {
     206                                if ( L->push_function( p, false ) )
     207                                {
     208                                        detail::push_value( L, p1 );
     209                                        if ( L->call_function( 1, detail::return_count< R >::value ) == 0 )
     210                                        {
     211                                                return detail::pop_return_value<R>( L );
     212                                        }
     213                                }
     214                                return R();
     215                        }
     216                        template < typename R, typename T1, typename T2 >
     217                        R call( const path& p, const T1& p1, const T2& p2 )
     218                        {
     219                                if ( L->push_function( p, false ) )
     220                                {
     221                                        detail::push_values( L, p1, p2 );
     222                                        if ( L->call_function( 2, detail::return_count< R >::value ) == 0 )
     223                                        {
     224                                                return detail::pop_return_value<R>( L );
     225                                        }
     226                                }
     227                                return R();
     228                        }
     229                        template < typename R, typename T1, typename T2, typename T3 >
     230                        R call( const path& p, const T1& p1, const T2& p2, const T3& p3 )
     231                        {
     232                                if ( L->push_function( p, false ) )
     233                                {
     234                                        detail::push_values( L, p1, p2, p3 );
     235                                        if ( L->call_function( 3, detail::return_count< R >::value ) == 0 )
     236                                        {
     237                                                return detail::pop_return_value<R>( L );
     238                                        }
     239                                }
     240                                return R();
     241                        }
     242                        template < typename R, typename T1, typename T2, typename T3, typename T4 >
     243                        R call( const path& p, const T1& p1, const T2& p2, const T3& p3, const T4& p4 )
     244                        {
     245                                if ( L->push_function( p, false ) )
     246                                {
     247                                        detail::push_value( L, p1, p2, p3, p4 );
     248                                        if ( L->call_function( 4, detail::return_count< R >::value ) == 0 )
     249                                        {
     250                                                return detail::pop_return_value<R>( L );
     251                                        }
     252                                }
     253                                return R();
     254                        }
     255
     256                private:
     257                        bool push_function( const path& p );
     258                        int call_function( int nargs, int nresults );
     259                        void call_get();
     260                        void call_get_raw();
     261                        void get_raw_flags( const std::string& element, uint8* data, uint32 count );
     262
     263                        state* L;
     264                        stack_guard m_guard;
     265                };
     266
     267
     268
    266269        } // namespace lua
    267270
  • trunk/nv/lua/lua_values.hh

    r186 r197  
    2121                {
    2222                        virtual void push( lua_State *L ) const = 0;
     23                        virtual ~passer(){}
    2324                };
    2425
     
    2627                {
    2728                        virtual void pop( lua_State *L ) = 0;
     29                        virtual ~returner_base(){}
    2830                };
    2931
  • trunk/nv/string.hh

    r195 r197  
    132132        struct string_length
    133133        {
    134                 static const size_t get( T ) { return 0; }
     134                static size_t get( T ) { return 0; }
    135135        };
    136136        template< size_t S >
    137137        struct string_length< const char[S] >
    138138        {
    139                 static const size_t get( const char* ) { return S-1; }
     139                static size_t get( const char* ) { return S-1; }
    140140        };
    141141        template<>
    142142        struct string_length< const char* >
    143143        {
    144                 static const size_t get( const char* s ) { return std::strlen( s ); }
     144                static size_t get( const char* s ) { return std::strlen( s ); }
    145145        };
    146146        template<>
    147147        struct string_length< std::string >
    148148        {
    149                 static const size_t get( const std::string& s ) { return s.length(); }
     149                static size_t get( const std::string& s ) { return s.length(); }
    150150        };
    151151
  • trunk/nv/type_traits.hh

    r196 r197  
    1818namespace nv
    1919{
     20
     21        // Just for once, MSVC is the good guy, and everybody else sucks.
     22        // Remove, once requiring standard-compliant CLANG/GCC versions.
    2023#if NV_COMPILER == NV_MSVC
    2124        using std::underlying_type;
  • trunk/src/formats/md5_loader.cc

    r192 r197  
    276276        auto normal   = m->add_attribute< vec3 >( "nv_normal" );
    277277        auto texcoord = m->add_attribute< vec2 >( "nv_texcoord" );
    278         auto tangent  = m->add_attribute< vec2 >( "nv_tangent" );
     278        auto tangent  = m->add_attribute< vec3 >( "nv_tangent" );
    279279        auto indices  = m->add_indices< uint32 >();
    280280
Note: See TracChangeset for help on using the changeset viewer.