| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 V8_INLINE(T* operator->() const) { return val_; } | 296 V8_INLINE(T* operator->() const) { return val_; } |
| 297 | 297 |
| 298 V8_INLINE(T* operator*() const) { return val_; } | 298 V8_INLINE(T* operator*() const) { return val_; } |
| 299 | 299 |
| 300 /** | 300 /** |
| 301 * Checks whether two handles are the same. | 301 * Checks whether two handles are the same. |
| 302 * Returns true if both are empty, or if the objects | 302 * Returns true if both are empty, or if the objects |
| 303 * to which they refer are identical. | 303 * to which they refer are identical. |
| 304 * The handles' references are not checked. | 304 * The handles' references are not checked. |
| 305 */ | 305 */ |
| 306 template <class S> V8_INLINE(bool operator==(const Handle<S> that) const) { | 306 template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const) { |
| 307 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 307 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 308 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 308 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 309 if (a == 0) return b == 0; | 309 if (a == 0) return b == 0; |
| 310 if (b == 0) return false; | 310 if (b == 0) return false; |
| 311 return *a == *b; | 311 return *a == *b; |
| 312 } | 312 } |
| 313 | 313 |
| 314 #ifndef V8_USE_UNSAFE_HANDLES | 314 #ifndef V8_USE_UNSAFE_HANDLES |
| 315 template <class S> V8_INLINE( | 315 template <class S> V8_INLINE( |
| 316 bool operator==(const Persistent<S>& that) const) { | 316 bool operator==(const Persistent<S>& that) const) { |
| 317 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 317 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 318 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 318 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 319 if (a == 0) return b == 0; | 319 if (a == 0) return b == 0; |
| 320 if (b == 0) return false; | 320 if (b == 0) return false; |
| 321 return *a == *b; | 321 return *a == *b; |
| 322 } | 322 } |
| 323 #endif | 323 #endif |
| 324 | 324 |
| 325 /** | 325 /** |
| 326 * Checks whether two handles are different. | 326 * Checks whether two handles are different. |
| 327 * Returns true if only one of the handles is empty, or if | 327 * Returns true if only one of the handles is empty, or if |
| 328 * the objects to which they refer are different. | 328 * the objects to which they refer are different. |
| 329 * The handles' references are not checked. | 329 * The handles' references are not checked. |
| 330 */ | 330 */ |
| 331 template <class S> V8_INLINE(bool operator!=(Handle<S> that) const) { | 331 template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const) { |
| 332 return !operator==(that); | 332 return !operator==(that); |
| 333 } | 333 } |
| 334 | 334 |
| 335 #ifndef V8_USE_UNSAFE_HANDLES |
| 336 template <class S> V8_INLINE( |
| 337 bool operator!=(const Persistent<S>& that) const) { |
| 338 return !operator==(that); |
| 339 } |
| 340 #endif |
| 341 |
| 335 template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) { | 342 template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) { |
| 336 #ifdef V8_ENABLE_CHECKS | 343 #ifdef V8_ENABLE_CHECKS |
| 337 // If we're going to perform the type check then we have to check | 344 // If we're going to perform the type check then we have to check |
| 338 // that the handle isn't empty before doing the checked cast. | 345 // that the handle isn't empty before doing the checked cast. |
| 339 if (that.IsEmpty()) return Handle<T>(); | 346 if (that.IsEmpty()) return Handle<T>(); |
| 340 #endif | 347 #endif |
| 341 return Handle<T>(T::Cast(*that)); | 348 return Handle<T>(T::Cast(*that)); |
| 342 } | 349 } |
| 343 | 350 |
| 344 template <class S> V8_INLINE(Handle<S> As()) { | 351 template <class S> V8_INLINE(Handle<S> As()) { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 #ifndef V8_USE_UNSAFE_HANDLES | 618 #ifndef V8_USE_UNSAFE_HANDLES |
| 612 template <class S> V8_INLINE( | 619 template <class S> V8_INLINE( |
| 613 bool operator==(const Persistent<S>& that) const) { | 620 bool operator==(const Persistent<S>& that) const) { |
| 614 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 621 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 615 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 622 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 616 if (a == 0) return b == 0; | 623 if (a == 0) return b == 0; |
| 617 if (b == 0) return false; | 624 if (b == 0) return false; |
| 618 return *a == *b; | 625 return *a == *b; |
| 619 } | 626 } |
| 620 | 627 |
| 621 template <class S> V8_INLINE(bool operator==(const Handle<S> that) const) { | 628 template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const) { |
| 622 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 629 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 623 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 630 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 624 if (a == 0) return b == 0; | 631 if (a == 0) return b == 0; |
| 625 if (b == 0) return false; | 632 if (b == 0) return false; |
| 626 return *a == *b; | 633 return *a == *b; |
| 627 } | 634 } |
| 635 |
| 636 template <class S> V8_INLINE( |
| 637 bool operator!=(const Persistent<S>& that) const) { |
| 638 return !operator==(that); |
| 639 } |
| 640 |
| 641 template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const) { |
| 642 return !operator==(that); |
| 643 } |
| 628 #endif | 644 #endif |
| 629 | 645 |
| 630 V8_INLINE(void Dispose()); | 646 V8_INLINE(void Dispose()); |
| 631 | 647 |
| 632 /** | 648 /** |
| 633 * Releases the storage cell referenced by this persistent handle. | 649 * Releases the storage cell referenced by this persistent handle. |
| 634 * Does not remove the reference to the cell from any handles. | 650 * Does not remove the reference to the cell from any handles. |
| 635 * This handle's reference, and any other references to the storage | 651 * This handle's reference, and any other references to the storage |
| 636 * cell remain and IsEmpty will still return false. | 652 * cell remain and IsEmpty will still return false. |
| 637 */ | 653 */ |
| (...skipping 5948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6586 */ | 6602 */ |
| 6587 | 6603 |
| 6588 | 6604 |
| 6589 } // namespace v8 | 6605 } // namespace v8 |
| 6590 | 6606 |
| 6591 | 6607 |
| 6592 #undef TYPE_CHECK | 6608 #undef TYPE_CHECK |
| 6593 | 6609 |
| 6594 | 6610 |
| 6595 #endif // V8_H_ | 6611 #endif // V8_H_ |
| OLD | NEW |