OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 } | 537 } |
538 V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT | 538 V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT |
539 Copy(that); | 539 Copy(that); |
540 return *this; | 540 return *this; |
541 } | 541 } |
542 template <class S, class M2> | 542 template <class S, class M2> |
543 V8_INLINE(Persistent& operator=(const Persistent<S, M2>& that)) { // NOLINT | 543 V8_INLINE(Persistent& operator=(const Persistent<S, M2>& that)) { // NOLINT |
544 Copy(that); | 544 Copy(that); |
545 return *this; | 545 return *this; |
546 } | 546 } |
| 547 /** |
| 548 * The destructor will dispose the Persistent based on the |
| 549 * kResetInDestructor flags in the traits class. Since not calling dispose |
| 550 * can result in a memory leak, it is recommended to always set this flag. |
| 551 */ |
| 552 V8_INLINE(~Persistent()) { |
| 553 if (M::kResetInDestructor) Reset(); |
| 554 } |
547 | 555 |
548 /** | 556 /** |
549 * If non-empty, destroy the underlying storage cell | 557 * If non-empty, destroy the underlying storage cell |
550 * IsEmpty() will return true after this call. | 558 * IsEmpty() will return true after this call. |
551 */ | 559 */ |
552 V8_INLINE(void Reset()); | 560 V8_INLINE(void Reset()); |
553 template <class S> | 561 template <class S> |
554 /** | 562 /** |
555 * If non-empty, destroy the underlying storage cell | 563 * If non-empty, destroy the underlying storage cell |
556 * and create a new one with the contents of other if other is non empty | 564 * and create a new one with the contents of other if other is non empty |
(...skipping 5862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6419 */ | 6427 */ |
6420 | 6428 |
6421 | 6429 |
6422 } // namespace v8 | 6430 } // namespace v8 |
6423 | 6431 |
6424 | 6432 |
6425 #undef TYPE_CHECK | 6433 #undef TYPE_CHECK |
6426 | 6434 |
6427 | 6435 |
6428 #endif // V8_H_ | 6436 #endif // V8_H_ |
OLD | NEW |