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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 556 |
557 /** | 557 /** |
558 * "Casts" a plain handle which is known to be a persistent handle | 558 * "Casts" a plain handle which is known to be a persistent handle |
559 * to a persistent handle. | 559 * to a persistent handle. |
560 */ | 560 */ |
561 template <class S> explicit V8_INLINE(Persistent(Handle<S> that)) | 561 template <class S> explicit V8_INLINE(Persistent(Handle<S> that)) |
562 : Handle<T>(*that) { } | 562 : Handle<T>(*that) { } |
563 | 563 |
564 #endif | 564 #endif |
565 | 565 |
| 566 #ifdef V8_USE_UNSAFE_HANDLES |
566 template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that)) { | 567 template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that)) { |
567 #ifdef V8_ENABLE_CHECKS | 568 #ifdef V8_ENABLE_CHECKS |
568 // If we're going to perform the type check then we have to check | 569 // If we're going to perform the type check then we have to check |
569 // that the handle isn't empty before doing the checked cast. | 570 // that the handle isn't empty before doing the checked cast. |
570 if (that.IsEmpty()) return Persistent<T>(); | 571 if (that.IsEmpty()) return Persistent<T>(); |
571 #endif | 572 #endif |
572 return Persistent<T>(T::Cast(*that)); | 573 return Persistent<T>(T::Cast(*that)); |
573 } | 574 } |
574 | 575 |
575 template <class S> V8_INLINE(Persistent<S> As()) { | 576 template <class S> V8_INLINE(Persistent<S> As()) { |
576 return Persistent<S>::Cast(*this); | 577 return Persistent<S>::Cast(*this); |
577 } | 578 } |
578 | 579 |
| 580 #else |
| 581 template <class S> |
| 582 V8_INLINE(static Persistent<T>& Cast(Persistent<S>& that)) { // NOLINT |
| 583 #ifdef V8_ENABLE_CHECKS |
| 584 // If we're going to perform the type check then we have to check |
| 585 // that the handle isn't empty before doing the checked cast. |
| 586 if (!that.IsEmpty()) T::Cast(*that); |
| 587 #endif |
| 588 return reinterpret_cast<Persistent<T>&>(that); |
| 589 } |
| 590 |
| 591 template <class S> V8_INLINE(Persistent<S>& As()) { // NOLINT |
| 592 return Persistent<S>::Cast(*this); |
| 593 } |
| 594 #endif |
| 595 |
579 V8_DEPRECATED(static Persistent<T> New(Handle<T> that)); | 596 V8_DEPRECATED(static Persistent<T> New(Handle<T> that)); |
580 | 597 |
581 /** | 598 /** |
582 * Creates a new persistent handle for an existing local or persistent handle. | 599 * Creates a new persistent handle for an existing local or persistent handle. |
583 */ | 600 */ |
584 // TODO(dcarney): remove before cutover | 601 // TODO(dcarney): remove before cutover |
585 V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that)); | 602 V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that)); |
586 #ifndef V8_USE_UNSAFE_HANDLES | 603 #ifndef V8_USE_UNSAFE_HANDLES |
587 // TODO(dcarney): remove before cutover | 604 // TODO(dcarney): remove before cutover |
588 V8_INLINE(static Persistent<T> New(Isolate* isolate, Persistent<T> that)); | 605 V8_INLINE(static Persistent<T> New(Isolate* isolate, Persistent<T> that)); |
(...skipping 5736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6325 | 6342 |
6326 | 6343 |
6327 } // namespace v8 | 6344 } // namespace v8 |
6328 | 6345 |
6329 | 6346 |
6330 #undef V8EXPORT | 6347 #undef V8EXPORT |
6331 #undef TYPE_CHECK | 6348 #undef TYPE_CHECK |
6332 | 6349 |
6333 | 6350 |
6334 #endif // V8_H_ | 6351 #endif // V8_H_ |
OLD | NEW |