Changeset 383
- Timestamp:
- 06/02/15 20:56:15 (10 years ago)
- Location:
- trunk
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv.lua
r368 r383 147 147 148 148 configuration "vs*" 149 defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1" }149 defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1", "_ITERATOR_DEBUG_LEVEL=0", "_HAS_ITERATOR_DEBUGGING=0" } 150 150 151 151 if _ACTION == "gmake-clang" then -
trunk/nv/core/common.hh
r382 r383 6 6 #ifndef NV_CORE_COMMON_HH 7 7 #define NV_CORE_COMMON_HH 8 9 #define _ITERATOR_DEBUG_LEVEL 0 8 10 9 11 // NV Library version -
trunk/nv/core/profiler.hh
r371 r383 21 21 #if NV_PROFILER 22 22 #define NV_PROFILE( tag ) nv::profiler_guard __profile( tag ) 23 #define NV_PROFILE_IF( tag, condition ) nv::profiler_condition_guard __profile( tag, condition ) 23 24 #else 24 25 #define NV_PROFILE( tag ) 26 #define NV_PROFILE_IF( tag, condition ) 25 27 #endif 28 26 29 27 30 namespace nv … … 68 71 friend class auto_singleton< profiler >; 69 72 friend class profiler_guard; 73 friend class profiler_condition_guard; 70 74 void log_report(); 71 75 private: … … 89 93 }; 90 94 95 class profiler_condition_guard 96 { 97 public: 98 profiler_condition_guard( string_ref tag, bool condition ) 99 : m_active( condition ) 100 { 101 if ( m_active ) profiler::pointer()->start_profile( tag ); 102 } 103 104 ~profiler_condition_guard() 105 { 106 if ( m_active ) profiler::pointer()->stop_profile(); 107 } 108 private: 109 bool m_active; 110 }; 111 91 112 } // namespace nv 92 113 -
trunk/nv/formats/assimp_loader.hh
r379 r383 31 31 private: 32 32 mesh_nodes_data* release_merged_bones( mesh_data* meshes ); 33 bool load_bones( size_t index, std::vector< mesh_node_data >&bones );33 bool load_bones( size_t index, array_ref< mesh_node_data > bones ); 34 34 void load_mesh_data( mesh_data* data, size_t index ); 35 35 sint16 load_node( uint32 anim_id, mesh_node_data* nodes, const void* vnode, sint16 this_id, sint16 parent_id ); -
trunk/nv/formats/md2_loader.hh
r368 r383 15 15 16 16 #include <nv/core/common.hh> 17 #include <unordered_map>18 17 #include <nv/stl/array.hh> 19 18 #include <nv/interface/mesh_loader.hh> … … 37 36 private: 38 37 void* m_md2; 39 std::vector< uint16 > m_new_indexes;40 std::vector< uint16 > m_new_vindexes;41 std::vector< uint16 > m_new_tindexes;38 vector< uint16 > m_new_indexes; 39 vector< uint16 > m_new_vindexes; 40 vector< uint16 > m_new_tindexes; 42 41 }; 43 42 -
trunk/nv/formats/md3_loader.hh
r368 r383 43 43 private: 44 44 void release_mesh_frame( mesh_data* data, sint32 frame, sint32 surface ); 45 key_raw_channel* load_tags( const st d::string& tag );45 key_raw_channel* load_tags( const string_ref& tag ); 46 46 bool m_merge_all; 47 47 void* m_md3; -
trunk/nv/formats/md5_loader.hh
r374 r383 83 83 protected: 84 84 void reset(); 85 void build_frame_skeleton( mesh_node_data* nodes, uint32 index, const std::vector<md5_joint_info>& joint_info, const std::vector<transform>& base_frames, const std::vector<float>& frame_data );85 void build_frame_skeleton( mesh_node_data* nodes, uint32 index, const const_array_ref<md5_joint_info>& joint_info, const const_array_ref<transform>& base_frames, const const_array_ref<float>& frame_data ); 86 86 bool prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info ); 87 87 protected: -
trunk/nv/formats/obj_loader.hh
r319 r383 31 31 ~obj_loader(); 32 32 private: 33 vertex_descriptor 34 bool 35 bool 36 std::vector< mesh_data* > m_meshes;33 vertex_descriptor m_descriptor; 34 bool m_normals; 35 bool m_tangents; 36 vector< mesh_data* > m_meshes; 37 37 }; 38 38 -
trunk/nv/interface/context.hh
r350 r383 297 297 { 298 298 vertex_array va = create_vertex_array(); 299 const std::vector< mesh_raw_channel* >&channels = data->get_raw_channels();299 const_array_ref< mesh_raw_channel* > channels = data->get_raw_channels(); 300 300 for ( uint32 ch = 0; ch < channels.size(); ++ch ) 301 301 { -
trunk/nv/interface/mesh_data.hh
r379 r383 107 107 } 108 108 109 const std::vector< mesh_raw_channel* >& get_raw_channels()const { return m_channels; }110 const mesh_raw_channel* get_index_channel() const { return m_index_channel; }109 const_array_ref< mesh_raw_channel* > get_raw_channels() const { return m_channels; } 110 const mesh_raw_channel* get_index_channel() const { return m_index_channel; } 111 111 size_t get_channel_count() const { return m_channels.size(); } 112 112 const mesh_raw_channel* get_channel( size_t index ) const … … 214 214 } 215 215 private: 216 std::string 217 std::vector< mesh_raw_channel* > m_channels;218 mesh_raw_channel* 216 std::string m_name; 217 vector< mesh_raw_channel* > m_channels; 218 mesh_raw_channel* m_index_channel; 219 219 }; 220 220 -
trunk/nv/lua/lua_dispatch.hh
r368 r383 4 4 // This file is part of NV Libraries. 5 5 // For conditions of distribution and use, see copyright notice in nv.hh 6 //7 // TODO: the calls are supported only up to 4 parameters because:8 // -- if you have more than 4 params, you're doing something wrong9 // -- once the Variadic Templates cometh, for great justice we will win!10 //11 // TODO: this is a job for std::forward, but I'll take care of it later12 6 13 7 #ifndef NV_LUA_DISPATCH_HH … … 38 32 static void do_call(lua_State* L, R(*func)(Args...), Vs&&... vs) 39 33 { 40 push_value(L, func( std::forward<Vs>(vs)...));34 push_value(L, func( nv::forward<Vs>(vs)...)); 41 35 } 42 36 template <class C, typename... Args, typename... Vs> 43 37 static void do_call(lua_State* L, C* c, R(C::*func)(Args...), Vs&&... vs) 44 38 { 45 push_value(L, (*c.*func)( std::forward<Vs>(vs)...));39 push_value(L, (*c.*func)( nv::forward<Vs>(vs)...)); 46 40 } 47 41 template <class C, typename... Args, typename... Vs> 48 42 static void do_call( lua_State* L, C const * c, R( C::*func )( Args... ) const, Vs&&... vs ) 49 43 { 50 push_value( L, ( *c.*func )( std::forward<Vs>( vs )... ) );44 push_value( L, ( *c.*func )( nv::forward<Vs>( vs )... ) ); 51 45 } 52 46 }; … … 58 52 static void do_call(lua_State*, void(*func)(Args...), Vs&&... vs) 59 53 { 60 func( std::forward<Vs>(vs)...);54 func( nv::forward<Vs>(vs)...); 61 55 } 62 56 template <class C, typename... Args, typename... Vs> 63 57 static void do_call(lua_State*, C* c, void(C::*func)(Args...), Vs&&... vs) 64 58 { 65 (*c.*func)( std::forward<Vs>(vs)...);59 (*c.*func)( nv::forward<Vs>(vs)...); 66 60 } 67 61 template <class C, typename... Args, typename... Vs> 68 62 static void do_call( lua_State*, C const * c, void( C::*func )( Args... ) const, Vs&&... vs ) 69 63 { 70 ( *c.*func )( std::forward<Vs>( vs )... );64 ( *c.*func )( nv::forward<Vs>( vs )... ); 71 65 } 72 66 }; … … 75 69 int do_call(lua_State* L, int index, R(*func)(Args...), types<Head, Tail...>, Vs&&... vs) 76 70 { 77 do_call(L, index + 1, func, types < Tail... > {}, std::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1;71 do_call(L, index + 1, func, types < Tail... > {}, nv::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1; 78 72 } 79 73 … … 81 75 int do_call(lua_State* L, int index, C* c, R(C::*func)(Args...), types<Head, Tail...>, Vs&&... vs) 82 76 { 83 do_call(L, index + 1, c, func, types < Tail... > {}, std::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1;77 do_call(L, index + 1, c, func, types < Tail... > {}, nv::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1; 84 78 } 85 79 … … 87 81 int do_call( lua_State* L, int index, C const * c, R( C::*func )( Args... ) const, types<Head, Tail...>, Vs&&... vs ) 88 82 { 89 do_call( L, index + 1, c, func, types < Tail... > {}, std::forward<Vs>( vs )..., get_value<Head>( L, index ) ); return 1;83 do_call( L, index + 1, c, func, types < Tail... > {}, nv::forward<Vs>( vs )..., get_value<Head>( L, index ) ); return 1; 90 84 } 91 85 … … 93 87 int do_call(lua_State* L, int, R(*func)(Args...), types<>, Vs&&... vs) 94 88 { 95 call_and_push<R>::do_call(L, func, std::forward<Vs>(vs)...);89 call_and_push<R>::do_call(L, func, nv::forward<Vs>(vs)...); 96 90 return 1; 97 91 } … … 100 94 int do_call(lua_State* L, int, C* c, R(C::*func)(Args...), types<>, Vs&&... vs) 101 95 { 102 call_and_push<R>::do_call(L, c, func, std::forward<Vs>(vs)...);96 call_and_push<R>::do_call(L, c, func, nv::forward<Vs>(vs)...); 103 97 return 1; 104 98 } … … 107 101 int do_call( lua_State* L, int, C const * c, R( C::*func )( Args... ) const, types<>, Vs&&... vs ) 108 102 { 109 call_and_push<R>::do_call( L, c, func, std::forward<Vs>( vs )... );103 call_and_push<R>::do_call( L, c, func, nv::forward<Vs>( vs )... ); 110 104 return 1; 111 105 } -
trunk/nv/lua/lua_raw.hh
r368 r383 24 24 void nlua_tokeyset( lua_State *L, int index ); 25 25 26 std::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index );26 nv::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index ); 27 27 28 28 void nlua_register( lua_State *L, const char* fname, lua_CFunction func, int index ); -
trunk/nv/stl/algorithm.hh
r376 r383 18 18 #include <nv/stl/utility.hh> 19 19 #include <nv/stl/iterator.hh> 20 #include <nv/stl/capi.hh> 20 21 21 22 namespace nv … … 185 186 } 186 187 188 template< typename T > 189 T* raw_copy( const T* first, const T* last, T* out ) 190 { 191 return (T*)nvmemcpy( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first ); 192 } 193 194 template< typename T > 195 T* raw_copy_n( const T* ptr, size_t n, T* out ) 196 { 197 return (T*)nvmemcpy( out, ptr, n * sizeof(T) ) + n; 198 } 199 200 template< typename T > 201 T* raw_alias_copy( const T* first, const T* last, T* out ) 202 { 203 return (T*)nvmemmove( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first ); 204 } 205 206 template< typename T > 207 T* raw_alias_copy_n( const T* ptr, size_t n, T* out ) 208 { 209 return (T*)nvmemmove( out, ptr, n * sizeof( T ) ) + n; 210 } 211 212 template< typename T > 213 T* raw_zero( T* first, T* last ) 214 { 215 return (T*)nvmemset( first, 0, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first ); 216 } 217 218 template< typename T > 219 T* raw_zero_n( T* ptr, size_t n ) 220 { 221 return (T*)nvmemset( ptr, 0, n * sizeof( T ) ) + n; 222 } 223 224 template< typename T > 225 T* raw_fill( T* first, T* last, unsigned char value ) 226 { 227 return (T*)nvmemset( first, value, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first ); 228 } 229 230 template< typename T > 231 T* raw_fill_n( T* ptr, size_t n, unsigned char value ) 232 { 233 return (T*)nvmemset( ptr, value, n * sizeof( T ) ) + n; 234 } 235 187 236 namespace detail 188 237 { 189 template < typename ForwardIterator, typename T > 190 void fill_impl( ForwardIterator first, ForwardIterator last, const T& value, false_type ) 191 { 238 template < typename ForwardIterator, typename T, typename AnyType > 239 void fill_impl( ForwardIterator first, ForwardIterator last, const T& value, AnyType, forward_iterator_tag ) 240 { 241 // TODO: version with T temp = value for scalars 192 242 for (; first != last; ++first ) 193 243 *first = value; 194 244 } 195 245 196 template < typename ForwardIterator, typename T > 197 void fill_impl( ForwardIterator first, ForwardIterator last, const T& value, true_type ) 198 { 199 memset( first, value, last - first ); 200 } 201 202 template < typename ForwardIterator, typename T > 203 ForwardIterator fill_n_impl( ForwardIterator first, size_t count, const T& value, false_type ) 204 { 246 template < typename BlockAccessIterator, typename T > 247 void fill_impl( BlockAccessIterator first, BlockAccessIterator last, T value, true_type, block_access_iterator_tag ) 248 { 249 raw_fill( first, last, (unsigned char)value ); 250 } 251 252 template < typename ForwardIterator, typename T, typename AnyType > 253 ForwardIterator fill_n_impl( ForwardIterator first, size_t count, const T& value, AnyType, forward_iterator_tag ) 254 { 255 // TODO: version with T temp = T() for scalars 205 256 for ( ; count-- > 0; ++first ) *first = value; 206 257 return first; 207 258 } 208 259 209 template < typename ForwardIterator, typename T > 210 ForwardIterator fill_n_impl( ForwardIterator first, size_t count, const T& value, true_type ) 211 { 212 return ForwardIterator( memset( first, value, count ) + count ); 260 template < typename BlockAccessIterator, typename T > 261 BlockAccessIterator fill_n_impl( BlockAccessIterator first, size_t count, T value, true_type, block_access_iterator_tag ) 262 { 263 return BlockAccessIterator( raw_fill_n( first, count, (unsigned char)value ) ); 264 } 265 266 template < typename ForwardIterator, typename T, typename AnyType > 267 void fill_default_impl( ForwardIterator first, ForwardIterator last, AnyType, forward_iterator_tag ) 268 { 269 // TODO: version with T temp = T() for scalars 270 for ( ; first != last; ++first ) 271 *first = T(); 272 } 273 274 template < typename BlockAccessIterator, typename T > 275 void fill_default_impl( BlockAccessIterator first, BlockAccessIterator last, true_type, block_access_iterator_tag ) 276 { 277 raw_zero( first, last ); 278 } 279 280 template < typename ForwardIterator, typename T, typename AnyType > 281 ForwardIterator fill_default_n_impl( ForwardIterator first, size_t n, AnyType, forward_iterator_tag ) 282 { 283 // TODO: version with T temp = T() for scalars 284 for ( ; n-- > 0; ++first ) *first = value; 285 return first; 286 } 287 288 template < typename BlockAccessIterator, typename T > 289 BlockAccessIterator fill_default_n_impl( BlockAccessIterator first, size_t count, true_type, block_access_iterator_tag ) 290 { 291 return BlockAccessIterator( raw_zero_n( first, count, (unsigned char)value ) ); 213 292 } 214 293 } … … 218 297 inline void fill( ForwardIterator first, ForwardIterator last, const T& value ) 219 298 { 220 detail::fill_impl( first, last, value, 221 bool_constant< sizeof( T ) == 1 && has_trivial_assign<T>::value >() ); 299 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 300 typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category; 301 detail::fill_impl( first, last, static_cast<value_type>( value ), 302 bool_constant< sizeof( value_type ) == 1 && 303 has_trivial_assign<value_type>::value >(), iterator_category() ); 222 304 } 223 305 … … 225 307 inline ForwardIterator fill_n( ForwardIterator first, size_t count, const T& value ) 226 308 { 227 return detail::fill_n_impl( first, count, value, 228 bool_constant< sizeof( T ) == 1 && has_trivial_assign<T>::value >() ); 309 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 310 typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category; 311 return detail::fill_n_impl( first, count, static_cast<value_type>( value ), 312 bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() ); 229 313 } 230 314 … … 232 316 inline void fill_default( ForwardIterator first, ForwardIterator last ) 233 317 { 234 // TODO: implement235 318 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 236 detail::fill_impl( first, last, value_type(), 237 bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() ); 319 typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category; 320 detail::fill_default_impl( first, last, 321 bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() ); 238 322 } 239 323 … … 241 325 inline ForwardIterator fill_default_n( ForwardIterator first, size_t count ) 242 326 { 243 // TODO: implement244 327 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 245 return detail::fill_n_impl( first, count, value_type(), 246 bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() ); 328 typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category; 329 return detail::fill_default_n_impl( first, count, 330 bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() ); 331 } 332 333 namespace detail 334 { 335 template< typename InputIterator, typename OutputIterator, typename AnyType > 336 inline OutputIterator copy_impl( InputIterator first, InputIterator last, OutputIterator out, AnyType, input_iterator_tag, forward_iterator_tag ) 337 { 338 for ( ; first != last; ++first, ++out ) 339 *first = *out; 340 return out; 341 } 342 343 template< typename BlockAccessIterator, typename OutputIterator > 344 inline BlockAccessIterator copy_impl( BlockAccessIterator first, BlockAccessIterator last, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag ) 345 { 346 return raw_alias_copy( first, last, out ) 347 } 348 349 template< typename InputIterator, typename OutputIterator, typename AnyType > 350 inline OutputIterator copy_n_impl( InputIterator first, size_t n, OutputIterator out, AnyType, input_iterator_tag, forward_iterator_tag ) 351 { 352 for ( ; n-- > 0; ++first, ++out ) *first = *out; 353 return out; 354 } 355 356 template< typename BlockAccessIterator, typename OutputIterator > 357 inline BlockAccessIterator copy_n_impl( BlockAccessIterator first, BlockAccessIterator n, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag ) 358 { 359 return raw_alias_copy_n( first, n, out ) 360 } 361 } 362 363 template< class InputIterator, class OutputIterator > 364 inline OutputIterator copy( InputIterator first, InputIterator last, OutputIterator out ) 365 { 366 typedef typename iterator_traits< InputIterator >::value_type value_type; 367 typedef typename iterator_traits< InputIterator >::iterator_category input_iterator_category; 368 typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category; 369 return detail::copy_impl( first, last, out, 370 has_trivial_copy<value_type>::value, iterator_category(), output_iterator_category() ); 371 } 372 373 template< class InputIterator, class OutputIterator > 374 inline OutputIterator copy_n( InputIterator first, size_t n, OutputIterator out ) 375 { 376 typedef typename iterator_traits< InputIterator >::value_type value_type; 377 typedef typename iterator_traits< InputIterator >::iterator_category input_iterator_category; 378 typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category; 379 return detail::copy_n_impl( first, n, out, 380 has_trivial_copy<value_type>::value, iterator_category(), output_iterator_category() ); 247 381 } 248 382 -
trunk/nv/stl/array.hh
r382 r383 24 24 namespace nv 25 25 { 26 using ::std::vector; 26 27 struct default_init 28 { 29 30 }; 31 32 template< typename SizeType > 33 struct default_next_capacity 34 { 35 static SizeType get( SizeType requested, SizeType capacity, SizeType max_size ) 36 { 37 SizeType remaining = max_size - capacity; 38 if ( remaining < requested ) return 0; 39 SizeType additional = nv::max( requested, capacity ); 40 return ( remaining < additional ? max_size : capacity + additional ); 41 } 42 }; 43 44 struct policy_initialize_always 45 { 46 template < typename ForwardIterator > 47 inline static void initialize( ForwardIterator first, ForwardIterator last ) 48 { 49 uninitialized_construct( first, last ); 50 } 51 template < typename InputIterator, typename ForwardIterator > 52 inline static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out ) 53 { 54 return uninitialized_copy( first, last, out ); 55 } 56 template < typename ForwardIterator > 57 inline static void destroy( ForwardIterator first, ForwardIterator last ) 58 { 59 uninitialized_destroy( first, last ); 60 } 61 template < typename ForwardIterator > 62 inline static void destroy( ForwardIterator first ) 63 { 64 destroy_object( first ); 65 } 66 }; 67 68 struct policy_initialize_never 69 { 70 template < typename ForwardIterator > 71 inline static void initialize( ForwardIterator, ForwardIterator ) 72 { 73 } 74 template < typename InputIterator, typename ForwardIterator > 75 inline static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out ) 76 { 77 return detail::uninitialized_copy( first, last, out, true_type ); 78 } 79 template < typename ForwardIterator > 80 inline static void destroy( ForwardIterator, ForwardIterator ) 81 { 82 } 83 template < typename ForwardIterator > 84 inline static void destroy( ForwardIterator ) 85 { 86 } 87 }; 88 89 struct policy_initialize_standard 90 { 91 template < typename ForwardIterator > 92 inline static void initialize( ForwardIterator first, ForwardIterator last ) 93 { 94 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 95 if ( !has_trivial_constructor<value_type>() ) 96 detail::uninitialized_construct_impl( first, last, false_type() ); 97 } 98 template < typename InputIterator, typename ForwardIterator > 99 inline static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out ) 100 { 101 return uninitialized_copy( first, last, out ); 102 } 103 template < typename ForwardIterator > 104 inline static void destroy( ForwardIterator first, ForwardIterator last ) 105 { 106 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 107 if ( !has_trivial_destructor<value_type>() ) 108 detail::uninitialized_destroy_impl( first, last, false_type() ); 109 } 110 template < typename ForwardIterator > 111 inline static void destroy( ForwardIterator first ) 112 { 113 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 114 if ( !has_trivial_destructor<value_type>() ) 115 destroy_object( first ); 116 } 117 }; 118 119 template< typename T > 120 class dynamic_storage 121 { 122 public: 123 typedef T value_type; 124 125 static constexpr bool is_static = false; 126 static constexpr bool is_const = false; 127 128 constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); } 129 inline value_type* data() { return reinterpret_cast<T*>( m_data ); } 130 constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); } 131 inline char* raw_data() { return reinterpret_cast<char*>( m_data ); } 132 133 protected: 134 constexpr dynamic_storage() : m_data( nullptr ) {} 135 // prevent copying 136 dynamic_storage( const dynamic_storage& ) = delete; 137 dynamic_storage& operator=( const dynamic_storage& ) = delete; 138 // allow move 139 inline dynamic_storage( dynamic_storage&& other ) 140 : m_data( other.m_data ) 141 { 142 other.m_data = nullptr; 143 } 144 inline dynamic_storage& operator=( dynamic_storage&& other ) 145 { 146 if ( this != &other ) 147 { 148 reallocate( 0, false ); 149 m_data = other.m_data; 150 } 151 return *this; 152 } 153 ~dynamic_storage() = default; 154 155 bool reallocate( size_t new_size, bool copy_needed ) 156 { 157 if ( copy_needed ) 158 m_data = (uint8*)nvrealloc( m_data, new_size * sizeof( value_type ) ); 159 else 160 { 161 nvfree( m_data ); 162 m_data = ( new_size > 0 ? (uint8*)nvmalloc( new_size * sizeof( value_type ) ) : nullptr ); 163 } 164 return true; // TODO : alloc check? 165 } 166 protected: 167 uint8* m_data; 168 }; 169 170 template< typename T, size_t N > 171 class static_storage 172 { 173 public: 174 typedef T value_type; 175 176 static constexpr bool is_static = true; 177 static constexpr bool is_const = false; 178 179 constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); } 180 inline value_type* data() { return reinterpret_cast<T*>( m_data ); } 181 constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); } 182 inline char* raw_data() { return reinterpret_cast<char*>( m_data ); } 183 184 protected: 185 static constexpr bool reallocate( size_t new_size, bool /*copy_needed*/ ) { return new_size <= N; } 186 187 static_storage() = default; 188 189 // prevent copying 190 static_storage( const static_storage& ) = delete; 191 static_storage& operator=( const static_storage& ) = delete; 192 // allow move 193 static_storage( static_storage&& other ) = default; 194 static_storage& operator=( static_storage&& other ) = default; 195 196 ~static_storage() = default; 197 protected: 198 typedef aligned_array_t<T, N, alignof( T ) > storage_type; 199 storage_type m_data; 200 }; 201 202 template< typename Storage, size_t N > 203 class fixed_storage : public Storage 204 { 205 public: 206 typedef size_t size_type; 207 typedef typename Storage::value_type value_type; 208 209 static constexpr bool is_fixed = true; 210 211 fixed_storage() 212 { 213 Storage::reallocate( N, false ); 214 } 215 ~fixed_storage() 216 { 217 Storage::reallocate( 0, false ); 218 } 219 static constexpr size_type max_size() { return N; } 220 static constexpr size_type capacity() { return N; } 221 static constexpr size_type size() { return N; } 222 static constexpr bool empty() { return N == 0; } 223 static constexpr size_type raw_size() { return sizeof( value_type ) * N; } 224 225 operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); } 226 operator const_array_ref< value_type >() const { return const_array_ref< value_type >( Storage::data(), size() ); } 227 228 // allow move 229 fixed_storage( fixed_storage&& ) = default; 230 fixed_storage& operator=( fixed_storage&& ) = default; 231 }; 232 233 template< typename Storage > 234 class resizable_storage : public Storage 235 { 236 public: 237 typedef size_t size_type; 238 typedef typename Storage::value_type value_type; 239 240 static constexpr bool is_fixed = false; 241 242 ~resizable_storage() 243 { 244 if ( m_size > 0 ) reallocate( 0, false ); 245 } 246 static constexpr size_type max_size() { return size_type( 0x80000000 ); } 247 constexpr size_t capacity() { return m_size; } 248 constexpr size_t size() const { return m_size; } 249 constexpr bool empty() const { return m_size == 0; } 250 constexpr size_t raw_size() const { return sizeof( value_type ) * m_size; } 251 252 operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); } 253 operator const_array_ref< value_type >() const { return const_array_ref< value_type >( Storage::data(), size() ); } 254 protected: 255 constexpr resizable_storage() : m_size( 0 ) {} 256 257 // allow move 258 inline resizable_storage( resizable_storage&& other ) 259 : Storage( nv::move( other ) ), m_size( other.m_size ) 260 { 261 other.m_size = 0; 262 } 263 inline resizable_storage& operator=( resizable_storage&& other ) 264 { 265 m_size = other.m_size; 266 Storage::operator=( nv::move( o ) ); 267 other.m_size = 0; 268 return *this; 269 } 270 271 // TODO: return type error checking 272 bool try_resize( size_t new_size, bool copy_needed ) 273 { 274 if ( new_size != m_size ) 275 { 276 if ( reallocate( new_size, copy_needed ) ) 277 { 278 m_size = new_size; 279 return true; 280 } 281 return false; 282 } 283 return true; 284 } 285 protected: 286 size_type m_size; 287 }; 288 289 template< typename Storage, typename NextCapacity = default_next_capacity< size_t > > 290 class growable_storage : public Storage 291 { 292 public: 293 typedef size_t size_type; 294 typedef typename Storage::value_type value_type; 295 296 static constexpr bool is_fixed = false; 297 298 ~growable_storage() 299 { 300 if ( m_capacity > 0 ) reallocate( 0, false ); 301 } 302 static constexpr size_type max_size() { return size_type( 0x80000000 ); } 303 constexpr size_t capacity() { return m_capacity; } 304 constexpr size_t size() const { return m_size; } 305 constexpr bool empty() const { return m_size == 0; } 306 constexpr size_t raw_size() const { return sizeof( value_type ) * m_size; } 307 308 operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); } 309 operator const_array_ref< value_type >() const { return const_array_ref< value_type >( Storage::data(), size() ); } 310 protected: 311 constexpr growable_storage() : m_size( 0 ), m_capacity( 0 ) {} 312 313 // allow move 314 inline growable_storage( growable_storage&& other ) 315 : Storage( nv::move( other ) ), m_size( other.m_size ), m_capacity( other.m_capacity ) 316 { 317 other.m_size = 0; 318 other.m_capacity = 0; 319 } 320 inline growable_storage& operator=( growable_storage&& other ) 321 { 322 m_size = other.m_size; 323 m_capacity = other.m_capacity; 324 Storage::operator=( nv::move( other ) ); 325 other.m_size = 0; 326 other.m_capacity = 0; 327 return *this; 328 } 329 330 // TODO: return type error checking 331 bool try_grow( size_t amount ) 332 { 333 size_type new_size = amount + m_size; 334 if ( new_size > m_capacity ) 335 { 336 size_type new_capacity = NextCapacity::get( new_size - m_capacity, m_capacity, max_size() ); 337 if ( new_capacity > 0 && reallocate( new_capacity, true ) ) 338 { 339 m_capacity = new_capacity; 340 m_size = new_size; 341 } 342 else return false; 343 } 344 m_size = new_size; 345 return true; 346 } 347 // TODO: return type error checking 348 bool try_reserve( size_t new_capacity, bool copy_needed ) 349 { 350 if ( new_capacity > m_capacity ) 351 { 352 if ( reallocate( new_capacity, copy_needed ) ) 353 { 354 m_capacity = new_capacity; 355 } 356 else return false; 357 } 358 return true; 359 } 360 // TODO: return type error checking 361 bool try_resize( size_t new_size, bool copy_needed ) 362 { 363 if ( new_size > m_size ) 364 { 365 if ( try_reserve( new_size, copy_needed ) ) 366 { 367 m_size = new_size; 368 return true; 369 } 370 return false; 371 } 372 m_size = new_size; 373 return true; 374 } 375 protected: 376 size_type m_size; 377 size_type m_capacity; 378 }; 379 380 381 template< typename T, size_t N > 382 using fixed_static_storage = fixed_storage< static_storage< T, N >, N >; 383 384 template< typename T, size_t N > 385 using fixed_dynamic_storage = fixed_storage< dynamic_storage< T >, N >; 386 387 template< typename T > 388 using resizable_dynamic_storage = resizable_storage< dynamic_storage< T > >; 389 390 template< typename T, size_t N > 391 using resizable_static_storage = resizable_storage< static_storage< T, N > >; 392 393 template< typename T > 394 using growable_dynamic_storage = growable_storage< dynamic_storage< T > >; 395 396 template< typename T, size_t N > 397 using growable_static_storage = growable_storage< static_storage< T, N > >; 398 399 template < 400 typename Storage, 401 typename InitializePolicy = policy_initialize_standard 402 > 403 class fixed_container_allocator : public Storage 404 { 405 public: 406 typedef typename Storage::value_type value_type; 407 typedef typename Storage::size_type size_type; 408 409 fixed_container_allocator() 410 { 411 InitializePolicy::initialize( data(), data() + Storage::capacity() ); 412 } 413 414 explicit fixed_container_allocator( default_init ) 415 { 416 uninitialized_construct( data(), data() + Storage::capacity() ); 417 } 418 419 explicit fixed_container_allocator( const value_type& v ) 420 { 421 uninitialized_fill( data(), data() + Storage::capacity(), v ); 422 } 423 424 ~fixed_container_allocator() 425 { 426 InitializePolicy::destroy( data(), data() + Storage::capacity() ); 427 } 428 429 // prevent copying 430 fixed_container_allocator( const fixed_container_allocator& ) = delete; 431 fixed_container_allocator& operator=( const fixed_container_allocator& ) = delete; 432 // allow move 433 fixed_container_allocator( fixed_container_allocator&& ) = default; 434 fixed_container_allocator& operator=( fixed_container_allocator&& ) = default; 435 }; 436 437 template < 438 typename Storage, 439 typename InitializePolicy = policy_initialize_standard 440 > 441 class sized_container_allocator : public Storage 442 { 443 public: 444 typedef typename Storage::value_type value_type; 445 typedef typename Storage::size_type size_type; 446 447 inline sized_container_allocator() {} 448 inline explicit sized_container_allocator( size_type new_size ) { resize( new_size ); } 449 inline explicit sized_container_allocator( default_init ) { resize( default_init() ); } 450 inline sized_container_allocator( size_type new_size, const value_type& v ) { resize( new_size, v ); } 451 452 // prevent copying 453 sized_container_allocator( const sized_container_allocator& ) = delete; 454 sized_container_allocator& operator=( const sized_container_allocator& ) = delete; 455 // allow move 456 sized_container_allocator( sized_container_allocator&& ) = default; 457 sized_container_allocator& operator=( sized_container_allocator&& ) = default; 458 459 460 inline void resize( size_type new_size ) 461 { 462 size_type old_size = Storage::size(); 463 resize_impl( new_size ); 464 initialize_range( old_size, Storage::size() ); 465 } 466 467 inline void resize( size_type new_size, default_init ) 468 { 469 size_type old_size = Storage::size(); 470 resize_impl( new_size ); 471 initialize_range( old_size, Storage::size(), default_init() ); 472 } 473 474 inline void resize( size_type new_size, const value_type& value ) 475 { 476 size_type old_size = Storage::size(); 477 resize_impl( new_size ); 478 initialize_range( old_size, Storage::size(), value ); 479 } 480 481 inline void assign( const value_type* ptr, size_type sz ) 482 { 483 if ( Storage::size() > 0 ) InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() ); 484 if ( ptr != nullptr && sz > 0 ) 485 { 486 if ( sz != Storage::size() && Storage::try_resize( sz, false ) ) 487 InitializePolicy::copy( ptr, ptr + sz, Storage::data() ); 488 } 489 else Storage::try_resize( 0, false ); 490 } 491 492 template< typename InputIterator > 493 inline void assign( InputIterator first, InputIterator last ) 494 { 495 size_type d = distance( first, last ); 496 if ( d != Storage::size() && Storage::try_resize( sz, false ) ) 497 InitializePolicy::copy( first, last, Storage::data() ); 498 } 499 500 // explicit copy 501 inline void assign( const sized_container_allocator& other ) 502 { 503 assign( other.data(), other.size() ); 504 } 505 506 inline void clear() 507 { 508 if ( Storage::size() > 0 ) 509 { 510 InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() ); 511 Storage::try_resize( 0, false ); 512 } 513 } 514 515 ~sized_container_allocator() 516 { 517 if ( Storage::size() > 0 ) clear(); 518 } 519 520 protected: 521 522 inline void initialize_range( size_type old_size, size_type new_size ) 523 { 524 if ( new_size > old_size ) InitializePolicy::initialize( Storage::data() + old_size, Storage::data() + new_size ); 525 } 526 inline void initialize_range( size_type old_size, size_type new_size, default_init ) 527 { 528 if ( new_size > old_size ) uninitialized_construct( Storage::data() + old_size, Storage::data() + new_size ); 529 } 530 inline void initialize_range( size_type old_size, size_type new_size, const value_type& value ) 531 { 532 if ( new_size > old_size ) uninitialized_fill( Storage::data() + old_size, Storage::data() + new_size, value ); 533 } 534 inline void resize_impl( size_type new_size ) 535 { 536 size_type old_size = Storage::size(); 537 if ( new_size != old_size ) 538 { 539 if ( new_size < old_size ) 540 { 541 InitializePolicy::destroy( Storage::data() + new_size, Storage::data() + old_size ); 542 } 543 if ( Storage::try_resize( new_size, true ) ) 544 { 545 // TODO: error checking 546 } 547 } 548 } 549 550 }; 551 552 template < 553 typename Storage, 554 typename InitializePolicy = policy_initialize_standard 555 > 556 class growing_container_allocator : public sized_container_allocator< Storage, InitializePolicy > 557 { 558 typedef sized_container_allocator< Storage, InitializePolicy > inherited; 559 public: 560 typedef typename Storage::value_type value_type; 561 typedef typename Storage::size_type size_type; 562 563 using sized_container_allocator< Storage, InitializePolicy >::sized_container_allocator; 564 565 void reserve( size_type new_capacity ) 566 { 567 Storage::try_reserve( new_capacity, true ); 568 } 569 void push_back( const value_type& e ) 570 { 571 if ( Storage::try_grow( 1 ) ) copy_construct_object( data() + size() - 1, e ); 572 } 573 void push_back( value_type&& e ) 574 { 575 if ( Storage::try_grow( 1 ) ) move_construct_object( data() + size() - 1, forward<value_type>( e ) ); 576 } 577 template < typename... Args > 578 void emplace_back( Args&&... args ) 579 { 580 if ( Storage::try_grow( 1 ) ) construct_object( data() + size() - 1, forward<Args>( args )... ); 581 } 582 void pop_back() 583 { 584 try_resize( size() - 1, true ); 585 } 586 587 }; 588 27 589 28 590 template < typename ContainerAllocator > 29 using array_base = detail::add_random_access< detail::add_iterators < ContainerAllocator > >; 30 591 using array_base_t = detail::add_random_access< detail::add_iterators < ContainerAllocator > >; 31 592 32 593 template< typename T, size_t N > 33 using array = array_base < fixed_container_allocator < fixed_static_storage< T, N > > >;594 using array = array_base_t < fixed_container_allocator < fixed_static_storage< T, N > > >; 34 595 35 596 template< typename T > 36 using dynamic_array = array_base < sized_container_allocator< resizable_dynamic_storage< T > > >; 597 using dynamic_array = array_base_t < sized_container_allocator< resizable_dynamic_storage< T > > >; 598 599 template< typename T > 600 using vector = array_base_t < growing_container_allocator< growable_dynamic_storage< T > > >; 37 601 38 602 // template < typename T, typename ContainerAllocator > -
trunk/nv/stl/array2d.hh
r368 r383 95 95 for ( sint32 i = 0; i < min(new_size.y, m_size.y); i++ ) 96 96 { 97 std::copy( m_data + m_size.x * i, m_data + m_size.x * i +min( new_size.x, m_size.x ), new_data + m_size.x * i );97 raw_copy_n( m_data + m_size.x * i, nv::min( new_size.x, m_size.x ), new_data + m_size.x * i ); 98 98 } 99 99 } … … 193 193 for ( sint32 i = 0; i < m_size.y; i++ ) 194 194 { 195 std::copy( m_data + m_size.x * i, m_data + m_size.x * i +m_size.x, m_size.x * i );195 raw_copy_n( m_data + m_size.x * i, m_size.x, m_size.x * i ); 196 196 } 197 197 return temp; … … 229 229 // Destination is the start of the destination row. 230 230 // Start End Destination 231 std::copy( m_data + m_size().x * i + start_x, m_data + m_size().x * i + start_x +size_x, temp.m_data + temp.m_size().x * ( i - start_y ) );231 raw_copy_n( m_data + m_size().x * i + start_x, size_x, temp.m_data + temp.m_size().x * ( i - start_y ) ); 232 232 } 233 233 return temp; … … 331 331 // The end position is either the size limit or the end of either array, whichever is smaller. 332 332 // Destination start is the beginning of the current destination row (which is dest_start_y + i), offset by dest_start_x. 333 std::copy( source.m_data + ( source_start_y + i ) * source.m_size.x + source_start_x, // Source Start 334 source.m_data + ( source_start_y + i ) * source.m_size.x + min( source.m_size.x, min( source_start_x + size_x, source_start_x + m_size.x - dest_start_x ) ), // Source End 333 pointer base = source.m_data + ( source_start_y + i ) * source.m_size.x; 334 raw_copy( base + source_start_x, // Source Start 335 base + min( source.m_size.x, min( source_start_x + size_x, source_start_x + m_size.x - dest_start_x ) ), // Source End 335 336 m_data + (dest_start_y + i) * m_size.x + dest_start_x ); // Destination Start 336 337 } -
trunk/nv/stl/capi.hh
r382 r383 73 73 inline void nvfree( void* p ) 74 74 { 75 NV_CAPI_CALL( free )( p );75 if ( p ) NV_CAPI_CALL( free )( p ); 76 76 } 77 77 -
trunk/nv/stl/flags.hh
r377 r383 16 16 #include <nv/core/common.hh> 17 17 #include <nv/stl/traits/transforms.hh> 18 #include <nv/stl/a rray.hh>18 #include <nv/stl/algorithm.hh> 19 19 20 20 namespace nv … … 144 144 void assign( const data_type* a_data ) 145 145 { 146 std::copy( a_data, a_data +data_size, m_data );146 raw_copy_n( a_data, data_size, m_data ); 147 147 } 148 148 149 149 void reset() 150 150 { 151 std::fill( m_data, m_data + data_size, 0);151 raw_zero_n( m_data, data_size ); 152 152 } 153 153 -
trunk/nv/stl/handle.hh
r376 r383 43 43 bool is_valid() const { return !is_nil(); } 44 44 T index() const { return m_index; } 45 size_t hash() const { return std::hash<T>()( T( m_counter << IBITS | m_index ) ); } 45 //size_t hash() const { return std::hash<T>()( T( m_counter << IBITS | m_index ) ); } 46 size_t hash() const { NV_ASSERT( false, "UNIMPLEMENTED!" ); return 0; } 46 47 protected: 47 48 T m_index : IBITS; … … 139 140 index_type m_first_free; 140 141 index_type m_last_free; 141 std::vector< index_entry > m_entries;142 vector< index_entry > m_entries; 142 143 }; 143 144 … … 146 147 { 147 148 public: 148 typedef HANDLE 149 typedef TINDEX 150 typedef std::vector< T > storage;151 typedef T 149 typedef HANDLE handle; 150 typedef TINDEX index_type; 151 typedef vector< T > storage; 152 typedef T value_type; 152 153 typedef typename storage::iterator iterator; 153 154 typedef typename storage::const_iterator const_iterator; … … 241 242 } 242 243 243 std::vector< T > m_data;244 std::vector< handle > m_handles;245 std::vector< index_type > m_indexes;244 vector< T > m_data; 245 vector< handle > m_handles; 246 vector< index_type > m_indexes; 246 247 }; 247 248 … … 251 252 { 252 253 public: 253 typedef HANDLE 254 typedef TINDEX 255 typedef std::vector< T >storage;256 typedef T 254 typedef HANDLE handle; 255 typedef TINDEX index_type; 256 typedef vector< T > storage; 257 typedef T value_type; 257 258 typedef typename storage::iterator iterator; 258 259 typedef typename storage::const_iterator const_iterator; … … 315 316 } 316 317 317 namespace std318 {319 template <320 typename T,321 unsigned IBITS,322 unsigned CBITS,323 typename TAG324 >325 struct hash<nv::handle<T,IBITS,CBITS,TAG>>326 {327 size_t operator()(const nv::handle<T,IBITS,CBITS,TAG>& h) const328 {329 return h.hash();330 }331 };332 }333 334 318 #endif // NV_CORE_HANDLE_HH -
trunk/nv/stl/memory.hh
r382 r383 72 72 static constexpr bool is_fixed = false; 73 73 static constexpr bool is_const = false; 74 static constexpr size_t type_size = sizeof( value_type );75 74 76 75 constexpr storage_view() … … 106 105 static constexpr bool is_fixed = false; 107 106 static constexpr bool is_const = true; 108 static constexpr size_t type_size = sizeof( value_type );109 107 110 108 constexpr const_storage_view() … … 112 110 constexpr const_storage_view( const value_type* a_data, size_type a_size ) 113 111 : m_data( a_data ), m_size( a_size ) {} 112 constexpr const_storage_view( const storage_view<T>& view ) 113 : m_data( view.data() ), m_size( view.size() ) {} 114 114 115 115 void assign( const value_type* a_data, size_type a_size ) … … 142 142 } 143 143 144 template < typename T > 145 inline void raw_move_construct_object( void* object, T&& original ) 146 { 147 new ( object )T( move( original ) ); 148 } 149 150 template < typename T > 151 inline void raw_copy_construct_object( void* object, const T& original ) 152 { 153 new ( object )T( original ); 154 } 155 144 156 template < typename T, typename ...Args > 145 157 inline void construct_object( T* object, Args&&... params ) 146 158 { 147 159 new ( object )T( forward<Args>( params )... ); 160 } 161 162 template < typename T > 163 inline void move_construct_object( T* object, T&& original ) 164 { 165 new ( object )T( move( original ) ); 166 } 167 168 template < typename T > 169 inline void copy_construct_object( T* object, const T& original ) 170 { 171 new ( object )T( original ); 148 172 } 149 173 … … 257 281 inline ForwardIterator uninitialized_copy_impl( InputIterator first, InputIterator last, ForwardIterator out, false_type ) 258 282 { 259 typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;283 typedef typename iterator_traits<ForwardIterator>::value_type value_type; 260 284 InputIterator src( first ); 261 285 ForwardIterator dest( out ); 262 for ( ; first!= last; ++src, ++dest )286 for ( ; src != last; ++src, ++dest ) 263 287 { 264 288 ::new ( static_cast<void*>( addressof( *dest ) ) ) value_type( *src ); … … 276 300 inline ForwardIterator uninitialized_copy_n_impl( InputIterator first, size_t count, ForwardIterator out, false_type ) 277 301 { 278 typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;302 typedef typename iterator_traits<ForwardIterator>::value_type value_type; 279 303 InputIterator src( first ); 280 304 ForwardIterator dest( out ); … … 289 313 inline ForwardIterator uninitialized_copy_n_impl( InputIterator first, size_t count, ForwardIterator out, true_type ) 290 314 { 291 typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;315 typedef typename iterator_traits<ForwardIterator>::value_type value_type; 292 316 return ForwardIterator( nvmemmove( out, first, count * sizeof( value_type ) ) ); 293 317 } … … 299 323 { 300 324 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 301 detail::uninitialized_fill_impl( first, last, value, has_trivial_ assign<value_type>() );325 detail::uninitialized_fill_impl( first, last, value, has_trivial_destructor<value_type>() ); 302 326 } 303 327 … … 306 330 { 307 331 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 308 return detail::uninitialized_fill_n_impl( first, count, value, has_trivial_ assign<value_type>() );332 return detail::uninitialized_fill_n_impl( first, count, value, has_trivial_destructor<value_type>() ); 309 333 } 310 334 … … 322 346 { 323 347 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 324 detail::uninitialized_construct_impl( first, last, has_trivial_ constructor<value_type>() );348 detail::uninitialized_construct_impl( first, last, has_trivial_destructor<value_type>() ); 325 349 } 326 350 … … 329 353 { 330 354 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 331 return detail::uninitialized_construct_n_impl( first, count, has_trivial_ constructor<value_type>() );355 return detail::uninitialized_construct_n_impl( first, count, has_trivial_destructor<value_type>() ); 332 356 } 333 357 … … 428 452 typedef const value_type& const_reference; 429 453 454 using Super::Super; 455 430 456 inline const_reference front() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[0]; } 431 457 inline const_reference back() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[Super::size() - 1]; } … … 449 475 typedef const value_type& const_reference; 450 476 477 using Super::Super; 478 451 479 inline reference front() { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[0]; } 452 480 inline const_reference front() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[0]; } … … 475 503 } 476 504 477 class const_mem_ref : public detail::add_iterators< const_storage_view< char > > 478 { 479 typedef detail::add_iterators< const_storage_view< char > > inherited; 480 public: 481 typedef char value_type; 482 typedef value_type* pointer; 483 typedef const value_type* const_pointer; 484 typedef value_type& reference; 485 typedef const value_type& const_reference; 486 typedef size_t size_type; 487 typedef ptrdiff_t difference_type; 488 typedef const_pointer const_iterator; 489 public: 490 inline const_mem_ref() : inherited() {} 491 inline const_mem_ref( const void* p, size_type n ) : inherited( (const char*)p, n ) {} 492 inline const_mem_ref( const const_mem_ref& l ) : inherited( l.data(), l.size() ) {} 493 }; 494 495 class mem_ref : public detail::add_iterators< storage_view< char > > 496 { 497 typedef detail::add_iterators< storage_view< char > > inherited; 498 public: 499 typedef char value_type; 500 typedef value_type* pointer; 501 typedef const value_type* const_pointer; 502 typedef value_type& reference; 503 typedef const value_type& const_reference; 504 typedef size_t size_type; 505 typedef ptrdiff_t difference_type; 506 typedef pointer iterator; 507 typedef const_pointer const_iterator; 508 public: 509 inline mem_ref() : inherited() {} 510 inline mem_ref( void* p, size_type n ) : inherited( (char*)p, n ) {} 511 inline mem_ref( const mem_ref& l ) : inherited( const_cast< char* >( l.data() ), l.size() ) {} 512 }; 513 514 template< typename SizeType > 515 struct default_next_capacity 516 { 517 static SizeType get( SizeType requested, SizeType capacity ) 518 { 519 SizeType additional = nv::max( requested, capacity ); 520 return capacity + additional; 521 } 522 }; 523 524 struct policy_initialize_always 525 { 526 template < typename ForwardIterator > 527 static void initialize( ForwardIterator first, ForwardIterator last ) 528 { 529 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 530 uninitialized_construct( first, last, value_type() ); 531 } 532 template < typename InputIterator, typename ForwardIterator > 533 static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out ) 534 { 535 return uninitialized_copy( first, last, out ); 536 } 537 template < typename ForwardIterator > 538 static void destroy( ForwardIterator first, ForwardIterator last ) 539 { 540 uninitialized_destroy( first, last ); 541 } 542 }; 543 544 struct policy_initialize_never 545 { 546 template < typename ForwardIterator > 547 static void initialize( ForwardIterator, ForwardIterator ) 548 { 549 } 550 template < typename InputIterator, typename ForwardIterator > 551 static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out ) 552 { 553 return detail::uninitialized_copy( first, last, out, true_type ); 554 } 555 template < typename ForwardIterator > 556 static void destroy( ForwardIterator, ForwardIterator ) 557 { 558 } 559 }; 560 561 struct policy_initialize_standard 562 { 563 template < typename ForwardIterator > 564 static void initialize( ForwardIterator first, ForwardIterator last ) 565 { 566 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 567 if ( !has_trivial_constructor<value_type>() ) 568 detail::uninitialized_construct_impl( first, last, false_type() ); 569 } 570 template < typename InputIterator, typename ForwardIterator > 571 static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out ) 572 { 573 return uninitialized_copy( first, last, out ); 574 } 575 template < typename ForwardIterator > 576 static void destroy( ForwardIterator first, ForwardIterator last ) 577 { 578 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 579 if ( !has_trivial_destructor<value_type>() ) 580 detail::uninitialized_destroy_impl( first, last, false_type() ); 581 } 582 }; 583 584 template< typename T > 585 class dynamic_storage 586 { 587 public: 588 typedef T value_type; 589 590 static constexpr bool is_static = false; 591 static constexpr bool is_const = false; 592 static constexpr size_t type_size = sizeof( value_type ); 593 594 constexpr dynamic_storage() : m_data( nullptr ) {} 595 596 constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); } 597 inline value_type* data() { return reinterpret_cast<T*>( m_data ); } 598 constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); } 599 inline char* raw_data() { return reinterpret_cast<char*>( m_data ); } 600 protected: 601 bool reallocate( size_t new_size ) 602 { 603 if ( m_data != 0 || new_size != 0 ) 604 m_data = (uint8*)nvrealloc( m_data, new_size * sizeof( value_type ) ); 605 return true; // TODO : alloc check? 606 } 607 protected: 608 uint8* m_data; 609 }; 610 611 template< typename T, size_t N > 612 class static_storage 613 { 614 public: 615 typedef T value_type; 616 617 static constexpr bool is_static = true; 618 static constexpr bool is_const = false; 619 static constexpr size_t type_size = sizeof( value_type ); 620 621 constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); } 622 inline value_type* data() { return reinterpret_cast<T*>( m_data ); } 623 constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); } 624 inline char* raw_data() { return reinterpret_cast<char*>( m_data ); } 625 protected: 626 static constexpr bool reallocate( size_t new_size ) { return new_size <= N; } 627 protected: 628 typedef aligned_array_t<T, N, alignof( T ) > storage_type; 629 storage_type m_data; 630 }; 631 632 template< typename Storage, size_t N > 633 class fixed_storage : public Storage 634 { 635 public: 636 typedef size_t size_type; 637 638 static constexpr bool is_fixed = true; 639 640 fixed_storage() 641 { 642 Storage::reallocate( N ); 643 } 644 ~fixed_storage() 645 { 646 Storage::reallocate( 0 ); 647 } 648 static constexpr size_t capacity() { return N; } 649 static constexpr size_t size() { return N; } 650 static constexpr bool empty() { return N != 0; } 651 static constexpr size_t raw_size() { return sizeof( T ) * N; } 652 }; 653 654 template< typename Storage > 655 class resizable_storage : public Storage 656 { 657 public: 658 typedef size_t size_type; 659 660 static constexpr bool is_fixed = false; 661 662 ~resizable_storage() 663 { 664 if ( m_size > 0 ) reallocate( 0 ); 665 } 666 constexpr size_t capacity() { return m_size; } 667 constexpr size_t size() const { return m_size; } 668 constexpr bool empty() const { return m_size != 0; } 669 constexpr size_t raw_size() const { return sizeof( value_type ) * m_size; } 670 protected: 671 constexpr resizable_storage() : m_size( 0 ) {} 672 // TODO: return type error checking 673 bool resize( size_t new_size ) 674 { 675 if ( new_size != m_size ) 676 { 677 m_size = new_size; 678 return reallocate( m_size ); 679 } 680 return true; 681 } 682 protected: 683 size_type m_size; 684 }; 685 686 687 template< typename T, size_t N > 688 using fixed_static_storage = fixed_storage< static_storage< T, N >, N >; 689 690 template< typename T, size_t N > 691 using fixed_dynamic_storage = fixed_storage< dynamic_storage< T >, N >; 692 693 template< typename T > 694 using resizable_dynamic_storage = resizable_storage< dynamic_storage< T > >; 695 696 // TODO: 697 // template< typename T, size_t N > 698 // using resizable_static_storage = resizable_storage< static_storage< T, N > >; 699 700 // TODO: 701 // template< typename Storage, typename NextCapacity = default_next_capacity > 702 // class growable_storage : Storage; 703 704 template < 705 typename Storage, 706 typename InitializePolicy = policy_initialize_standard 707 > 708 class fixed_container_allocator : public Storage 709 { 710 public: 711 typedef typename Storage::value_type value_type; 712 typedef typename Storage::size_type size_type; 713 714 fixed_container_allocator() 715 { 716 InitializePolicy::initialize( data(), data() + Storage::capacity() ); 717 } 718 719 ~fixed_container_allocator() 720 { 721 InitializePolicy::destroy( data(), data() + Storage::capacity() ); 722 } 723 }; 724 725 template < 726 typename Storage, 727 typename InitializePolicy = policy_initialize_standard 728 > 729 class sized_container_allocator : public Storage 730 { 731 public: 732 typedef typename Storage::value_type value_type; 733 typedef typename Storage::size_type size_type; 734 735 sized_container_allocator() {} 736 explicit sized_container_allocator( size_type new_size ) { resize( new_size ); } 737 738 void resize( size_type new_size ) 739 { 740 size_type old_size = Storage::size(); 741 if ( new_size != old_size ) 742 { 743 if ( new_size < old_size ) 744 { 745 InitializePolicy::destroy( Storage::data() + new_size, Storage::data() + old_size ); 746 } 747 Storage::resize( new_size ); 748 if ( new_size > old_size ) 749 { 750 InitializePolicy::initialize( Storage::data() + old_size, Storage::data() + new_size ); 751 } 752 } 753 } 754 755 void assign( const value_type* ptr, size_type sz ) 756 { 757 if ( Storage::size() > 0 ) InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() ); 758 if ( ptr != nullptr && sz > 0 ) 759 { 760 if ( sz != Storage::size() ) 761 { 762 Storage::resize( 0 ); 763 Storage::resize( sz ); 764 } 765 InitializePolicy::copy( ptr, ptr + sz, Storage::data() ); 766 } 767 else Storage::resize( 0 ); 768 } 769 770 void clear() 771 { 772 if ( Storage::size() > 0 ) 773 { 774 InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() ); 775 Storage::resize( 0 ); 776 } 777 } 778 779 ~sized_container_allocator() 780 { 781 if ( Storage::size() > 0 ) clear(); 782 } 783 784 }; 505 template < typename T > 506 using const_array_ref = detail::add_random_access< detail::add_iterators < const_storage_view< T > > >; 507 template < typename T > 508 using array_ref = detail::add_random_access< detail::add_iterators < storage_view< T > > >; 509 using const_mem_ref = const_array_ref< char >; 510 using mem_ref = array_ref< char >; 785 511 786 512 } -
trunk/nv/stl/range.hh
r377 r383 15 15 #include <nv/core/common.hh> 16 16 #include <nv/stl/math.hh> 17 #include <nv/stl/iterator.hh> 17 18 #include <nv/stl/traits/transforms.hh> 18 #include <iterator>19 19 20 20 namespace nv … … 25 25 26 26 template < typename T > 27 class forward_iterator_base : public std::iterator< std::input_iterator_tag, T >27 class forward_iterator_base : public iterator< input_iterator_tag, T > 28 28 { 29 29 public: -
trunk/src/formats/assimp_loader.cc
r382 r383 188 188 } 189 189 190 bool nv::assimp_loader::load_bones( size_t index, std::vector< mesh_node_data >&bones )190 bool nv::assimp_loader::load_bones( size_t index, array_ref< mesh_node_data > bones ) 191 191 { 192 192 if ( m_scene == nullptr ) return false; … … 285 285 { 286 286 const aiScene* scene = (const aiScene*)m_scene; 287 std::vector< mesh_node_data > final_bones;287 vector< mesh_node_data > final_bones; 288 288 std::unordered_map< std::string, uint16 > names; 289 289 for ( unsigned int m = 0; m < m_mesh_count; ++m ) 290 290 { 291 291 uint16 translate[MAX_BONES]; 292 std::vector< mesh_node_data > bones;292 vector< mesh_node_data > bones; 293 293 const aiMesh* mesh = scene->mMeshes[ m ]; 294 294 if ( mesh->mNumBones != 0 ) … … 334 334 } 335 335 mesh_node_data* bones = new mesh_node_data[ final_bones.size() ]; 336 std::copy( final_bones.begin(), final_bones.end(), bones );336 nv::raw_copy( final_bones.begin(), final_bones.end(), bones ); 337 337 return new mesh_nodes_data( "bones", final_bones.size(), bones ); 338 338 } -
trunk/src/formats/md2_loader.cc
r376 r383 251 251 uint32 stats_collision = 0; 252 252 253 std::vector< sint32 > index_translation( static_cast< uint32 >( md2->header.num_vertices ), -1 );253 vector< sint32 > index_translation( static_cast< uint32 >( md2->header.num_vertices ), -1 ); 254 254 255 255 m_new_indexes.clear(); … … 364 364 { 365 365 uint16* icp = (uint16*)ic->data; 366 std::copy_n( m_new_indexes.data(), m_new_indexes.size(), icp );366 raw_copy_n( m_new_indexes.data(), m_new_indexes.size(), icp ); 367 367 } 368 368 -
trunk/src/formats/md3_loader.cc
r376 r383 198 198 md3->tags = new md3_tag_t [ md3->header.num_tags * md3->header.num_frames ]; 199 199 md3->surfaces = new md3_surface_t[ md3->header.num_surfaces ]; 200 std::memset( md3->surfaces, 0, static_cast< nv::size_t >( md3->header.num_surfaces ) * sizeof( md3_surface_t) );200 nv::raw_zero_n( md3->surfaces, static_cast< nv::size_t >( md3->header.num_surfaces ) ); 201 201 202 202 source.seek( md3->header.ofs_frames, origin::SET ); … … 285 285 } 286 286 287 nv::key_raw_channel* nv::md3_loader::load_tags( const st d::string& tag )287 nv::key_raw_channel* nv::md3_loader::load_tags( const string_ref& tag ) 288 288 { 289 289 md3_t* md3 = (md3_t*)m_md3; … … 295 295 { 296 296 const md3_tag_t& rtag = md3->tags[i + md3->header.num_tags * f]; 297 st d::stringrname((char*)(rtag.name));297 string_ref rname((char*)(rtag.name)); 298 298 if (rname == tag) 299 299 { … … 421 421 md3_t* md3 = (md3_t*)m_md3; 422 422 uint32 node_count = (uint32)md3->header.num_tags; 423 if ( node_count == 0 ) return nullptr; ;423 if ( node_count == 0 ) return nullptr; 424 424 mesh_node_data* nodes = new mesh_node_data[ node_count ]; 425 425 for ( uint32 i = 0; i < node_count; ++i ) 426 426 { 427 427 const md3_tag_t& rtag = md3->tags[i]; 428 st d::stringname( (char*)(rtag.name) );428 string_ref name( (char*)(rtag.name) ); 429 429 430 430 nodes[i].transform = mat4(); 431 nodes[i].name = name ;431 nodes[i].name = name.to_string(); 432 432 nodes[i].parent_id = -1; 433 433 nodes[i].target_id = -1; -
trunk/src/formats/md5_loader.cc
r376 r383 48 48 49 49 // MESH data 50 std::vector<md5_joint_info> joint_infos;51 std::vector<transform>base_frames;50 dynamic_array< md5_joint_info > joint_infos; 51 vector< transform > base_frames; 52 52 size_t num_animated_components = 0; 53 53 size_t frame_rate = 0; … … 301 301 else if ( command == "frame" ) 302 302 { 303 std::vector<float> frame;303 vector<float> frame; 304 304 uint32 frame_id; 305 305 sstream >> frame_id; … … 454 454 } 455 455 456 void md5_loader::build_frame_skeleton( mesh_node_data* nodes, uint32 index, const std::vector<md5_joint_info>& joint_infos, const std::vector<transform>& base_frames, const std::vector<float>& frame_data )456 void md5_loader::build_frame_skeleton( mesh_node_data* nodes, uint32 index, const const_array_ref<md5_joint_info>& joint_infos, const const_array_ref<transform>& base_frames, const const_array_ref<float>& frame_data ) 457 457 { 458 458 assert( m_type == ANIMATION ); -
trunk/src/formats/nmd_loader.cc
r368 r383 162 162 static void nmd_dump_mesh( const mesh_data* mesh, stream& stream_out ) 163 163 { 164 const std::vector< mesh_raw_channel* >&data = mesh->get_raw_channels();164 const_array_ref< mesh_raw_channel* > data = mesh->get_raw_channels(); 165 165 166 166 uint32 size = sizeof( nmd_element_header ); -
trunk/src/formats/obj_loader.cc
r382 r383 44 44 struct obj_reader 45 45 { 46 std::vector< vec3 > v;47 std::vector< vec3 > n;48 std::vector< vec2 > t;46 vector< vec3 > v; 47 vector< vec3 > n; 48 vector< vec2 > t; 49 49 50 50 std::string line; … … 204 204 } 205 205 bool m_normals; 206 std::vector< VTX > m_data;206 vector< VTX > m_data; 207 207 virtual void reset() { m_data.clear(); } 208 208 virtual nv::size_t raw_size() const { return m_data.size() * sizeof( VTX ); } … … 228 228 void calculate_tangents() 229 229 { 230 // const std::vector< vec3 >& vp = m_mesh->get_positions();231 // const std::vector< vec2 >& vt = m_mesh->get_texcoords();232 // const std::vector< vec3 >& vn = m_mesh->get_normals();233 // std::vector< vec3 >& tg = m_mesh->get_tangents();234 235 230 nv::size_t count = m_data.size(); 236 231 nv::size_t tcount = count / 3; 237 232 238 std::vector< vec3 > tan1( count );239 std::vector< vec3 > tan2( count );233 vector< vec3 > tan1( count ); 234 vector< vec3 > tan2( count ); 240 235 241 236 for ( nv::size_t a = 0; a < tcount; ++a ) … … 335 330 { 336 331 data = new uint8[ reader->raw_size() ]; 337 std::copy_n( reader->raw_pointer(), reader->raw_size(), data );332 raw_copy_n( reader->raw_pointer(), reader->raw_size(), data ); 338 333 } 339 334 channel->data = data; -
trunk/src/gfx/image.cc
r376 r383 4 4 5 5 #include "nv/gfx/image.hh" 6 #include "nv/stl/algorithm.hh" 6 7 7 8 using namespace nv; … … 31 32 for( int i = 0; i < m_size.y; ++i ) 32 33 { 33 std::copy( data + i * bline, data + (i + 1) * bline, m_data + bsize - ( i + 1 ) * bline );34 raw_copy( data + i * bline, data + (i + 1) * bline, m_data + bsize - ( i + 1 ) * bline ); 34 35 } 35 36 … … 37 38 else 38 39 { 39 std::copy( data, data + bsize, m_data );40 raw_copy( data, data + bsize, m_data ); 40 41 } 41 42 } … … 43 44 void image::fill( uint8 value ) 44 45 { 45 std::fill( m_data, m_data + m_size.x * m_size.y * (int)m_depth, value );46 raw_fill( m_data, m_data + m_size.x * m_size.y * (int)m_depth, value ); 46 47 } 47 48 … … 56 57 { 57 58 // TODO: test 58 std::fill( m_data + bpos + bline * i, m_data + bpos + bline * i + stride, value );59 raw_fill( m_data + bpos + bline * i, m_data + bpos + bline * i + stride, value ); 59 60 } 60 61 } … … 73 74 // memcpy( m_data+((r.pos.y+i)*m_size.x + r.pos.x ) * m_depth, 74 75 // data + (i*stride), r.size.x * m_depth ); 75 std::copy( data + i*stride, data + (i+1)*stride, m_data + bpos + bline * i );76 raw_copy( data + i*stride, data + (i+1)*stride, m_data + bpos + bline * i ); 76 77 } 77 78 } -
trunk/src/gfx/mesh_creator.cc
r323 r383 350 350 for ( uint32 i = 0; i < count; ++i ) 351 351 { 352 std::copy_n( a->data + i * adesc.size, adesc.size, data + i*desc.size );353 std::copy_n( b->data + i * bdesc.size, bdesc.size, data + i*desc.size + adesc.size );352 raw_copy_n( a->data + i * adesc.size, adesc.size, data + i*desc.size ); 353 raw_copy_n( b->data + i * bdesc.size, bdesc.size, data + i*desc.size + adesc.size ); 354 354 } 355 355 mesh_raw_channel* result = new mesh_raw_channel; … … 373 373 { 374 374 size_t a_size = vtx_size * a->count; 375 std::copy_n( a->data, a_size, data );376 std::copy_n( b->data, vtx_size * b->count, data + a_size );375 raw_copy_n( a->data, a_size, data ); 376 raw_copy_n( b->data, vtx_size * b->count, data + a_size ); 377 377 } 378 378 else … … 385 385 for ( size_t i = 0; i < frame_count; ++i ) 386 386 { 387 std::copy_n( a->data + pos_a, frame_size_a, data + pos );388 std::copy_n( b->data + pos_b, frame_size_b, data + pos + frame_size_a ); pos_a += frame_size_a;387 raw_copy_n( a->data + pos_a, frame_size_a, data + pos ); 388 raw_copy_n( b->data + pos_b, frame_size_b, data + pos + frame_size_a ); pos_a += frame_size_a; 389 389 pos_b += frame_size_b; 390 390 pos += frame_size_a + frame_size_b; -
trunk/src/gfx/skeletal_mesh.cc
r367 r383 43 43 } 44 44 45 std::fill( m_pntdata.raw_data(), m_pntdata.raw_data() + m_pntdata.raw_size(), 0 );45 fill( m_pntdata.raw_data(), m_pntdata.raw_data() + m_pntdata.raw_size(), 0 ); 46 46 for ( unsigned int i = 0; i < vertex_count; ++i ) 47 47 { -
trunk/src/gl/gl_device.cc
r380 r383 221 221 const gl_program_info* info = m_programs.get( p ); 222 222 { 223 uniform_map::const_iterator i = info->m_uniform_map.find( name );223 nv::uniform_map::const_iterator i = info->m_uniform_map.find( name ); 224 224 if ( i != info->m_uniform_map.end() ) 225 225 { -
trunk/src/io/string_table.cc
r281 r383 6 6 7 7 #include "nv/io/string_table.hh" 8 #include <array> 8 9 9 10 nv::string_table_creator::string_table_creator() -
trunk/src/lua/lua_map_tile.cc
r378 r383 118 118 new_tile->ascii = new nv::uchar8[ size ]; 119 119 } 120 std::copy( old_tile->data, old_tile->data +size, new_tile->data );121 if ( old_tile->ascii ) std::copy( old_tile->ascii, old_tile->ascii +size, new_tile->ascii );120 nv::raw_copy_n( old_tile->data, size, new_tile->data ); 121 if ( old_tile->ascii ) nv::raw_copy_n( old_tile->ascii, size, new_tile->ascii ); 122 122 123 123 luaL_getmetatable( L, NLUA_MAP_TILE_METATABLE ); … … 237 237 map_tile* tile = nlua_to_pmap_tile( L, 1 ); 238 238 // assert( tile^.ascii == nullptr ); 239 std::vector< nv::uint8 > sizes_x = nlua_tobytearray( L, 2 ); 240 std::vector< nv::uint8 > sizes_y = ( lua_istable( L, 3 ) ? nlua_tobytearray( L, 3 ) : sizes_x ); 239 nv::vector< nv::uint8 > sizes_x = nlua_tobytearray( L, 2 ); 240 nv::vector< nv::uint8 > sizes_y; 241 if ( lua_istable( L, 3 ) ) 242 sizes_y = nlua_tobytearray( L, 2 ); 243 else 244 sizes_y.assign( sizes_x ); 241 245 242 246 nv::uint16 org_x = tile->size_x; -
trunk/src/lua/lua_raw.cc
r380 r383 262 262 } 263 263 264 std::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index )265 { 266 index = lua_absindex( L, index ); 267 std::vector<nv::uint8> result;264 nv::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index ) 265 { 266 index = lua_absindex( L, index ); 267 nv::vector<nv::uint8> result; 268 268 if ( lua_istable( L, index ) ) 269 269 {
Note: See TracChangeset
for help on using the changeset viewer.