OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkTArray_DEFINED | 8 #ifndef SkTArray_DEFINED |
9 #define SkTArray_DEFINED | 9 #define SkTArray_DEFINED |
10 | 10 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 // Use the below macro (SkNEW_APPEND_TO_TARRAY) rather than calling this directl
y | 446 // Use the below macro (SkNEW_APPEND_TO_TARRAY) rather than calling this directl
y |
447 template <typename T, bool MEM_COPY> | 447 template <typename T, bool MEM_COPY> |
448 void* operator new(size_t, SkTArray<T, MEM_COPY>* array, int atIndex) { | 448 void* operator new(size_t, SkTArray<T, MEM_COPY>* array, int atIndex) { |
449 // Currently, we only support adding to the end of the array. When the array
class itself | 449 // Currently, we only support adding to the end of the array. When the array
class itself |
450 // supports random insertion then this should be updated. | 450 // supports random insertion then this should be updated. |
451 // SkASSERT(atIndex >= 0 && atIndex <= array->count()); | 451 // SkASSERT(atIndex >= 0 && atIndex <= array->count()); |
452 SkASSERT(atIndex == array->count()); | 452 SkASSERT(atIndex == array->count()); |
453 return array->push_back_raw(1); | 453 return array->push_back_raw(1); |
454 } | 454 } |
455 | 455 |
| 456 // Skia doesn't use C++ exceptions but it may be compiled with them enabled. Hav
ing an op delete |
| 457 // to match the op new silences warnings about missing op delete when a construc
tor throws an |
| 458 // exception. |
| 459 template <typename T> void operator delete(void*, SkTArray<T, MEM_COPY>* array,
int atIndex) { |
| 460 SK_CRASH(); |
| 461 } |
| 462 |
456 // Constructs a new object as the last element of an SkTArray. | 463 // Constructs a new object as the last element of an SkTArray. |
457 #define SkNEW_APPEND_TO_TARRAY(array_ptr, type_name, args) \ | 464 #define SkNEW_APPEND_TO_TARRAY(array_ptr, type_name, args) \ |
458 (new ((array_ptr), (array_ptr)->count()) type_name args) | 465 (new ((array_ptr), (array_ptr)->count()) type_name args) |
459 | 466 |
460 | 467 |
461 /** | 468 /** |
462 * Subclass of SkTArray that contains a preallocated memory block for the array. | 469 * Subclass of SkTArray that contains a preallocated memory block for the array. |
463 */ | 470 */ |
464 template <int N, typename T, bool MEM_COPY = false> | 471 template <int N, typename T, bool MEM_COPY = false> |
465 class SkSTArray : public SkTArray<T, MEM_COPY> { | 472 class SkSTArray : public SkTArray<T, MEM_COPY> { |
(...skipping 23 matching lines...) Expand all Loading... |
489 SkSTArray& operator= (const INHERITED& array) { | 496 SkSTArray& operator= (const INHERITED& array) { |
490 INHERITED::operator=(array); | 497 INHERITED::operator=(array); |
491 return *this; | 498 return *this; |
492 } | 499 } |
493 | 500 |
494 private: | 501 private: |
495 SkAlignedSTStorage<N,T> fStorage; | 502 SkAlignedSTStorage<N,T> fStorage; |
496 }; | 503 }; |
497 | 504 |
498 #endif | 505 #endif |
OLD | NEW |