| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } | 309 } |
| 310 | 310 |
| 311 V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) { | 311 V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) { |
| 312 return New(isolate, that.val_); | 312 return New(isolate, that.val_); |
| 313 } | 313 } |
| 314 V8_INLINE static Handle<T> New(Isolate* isolate, | 314 V8_INLINE static Handle<T> New(Isolate* isolate, |
| 315 const PersistentBase<T>& that) { | 315 const PersistentBase<T>& that) { |
| 316 return New(isolate, that.val_); | 316 return New(isolate, that.val_); |
| 317 } | 317 } |
| 318 | 318 |
| 319 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | |
| 320 | |
| 321 private: | |
| 322 #endif | |
| 323 /** | |
| 324 * Creates a new handle for the specified value. | |
| 325 */ | |
| 326 V8_INLINE explicit Handle(T* val) : val_(val) {} | |
| 327 | |
| 328 private: | 319 private: |
| 329 friend class Utils; | 320 friend class Utils; |
| 330 template<class F, class M> friend class Persistent; | 321 template<class F, class M> friend class Persistent; |
| 331 template<class F> friend class PersistentBase; | 322 template<class F> friend class PersistentBase; |
| 332 template<class F> friend class Handle; | 323 template<class F> friend class Handle; |
| 333 template<class F> friend class Local; | 324 template<class F> friend class Local; |
| 334 template<class F> friend class FunctionCallbackInfo; | 325 template<class F> friend class FunctionCallbackInfo; |
| 335 template<class F> friend class PropertyCallbackInfo; | 326 template<class F> friend class PropertyCallbackInfo; |
| 336 template<class F> friend class internal::CustomArguments; | 327 template<class F> friend class internal::CustomArguments; |
| 337 friend Handle<Primitive> Undefined(Isolate* isolate); | 328 friend Handle<Primitive> Undefined(Isolate* isolate); |
| 338 friend Handle<Primitive> Null(Isolate* isolate); | 329 friend Handle<Primitive> Null(Isolate* isolate); |
| 339 friend Handle<Boolean> True(Isolate* isolate); | 330 friend Handle<Boolean> True(Isolate* isolate); |
| 340 friend Handle<Boolean> False(Isolate* isolate); | 331 friend Handle<Boolean> False(Isolate* isolate); |
| 341 friend class Context; | 332 friend class Context; |
| 342 friend class HandleScope; | 333 friend class HandleScope; |
| 343 friend class Object; | 334 friend class Object; |
| 344 friend class Private; | 335 friend class Private; |
| 345 | 336 |
| 337 /** |
| 338 * Creates a new handle for the specified value. |
| 339 */ |
| 340 V8_INLINE explicit Handle(T* val) : val_(val) {} |
| 341 |
| 346 V8_INLINE static Handle<T> New(Isolate* isolate, T* that); | 342 V8_INLINE static Handle<T> New(Isolate* isolate, T* that); |
| 347 | 343 |
| 348 T* val_; | 344 T* val_; |
| 349 }; | 345 }; |
| 350 | 346 |
| 351 | 347 |
| 352 /** | 348 /** |
| 353 * A light-weight stack-allocated object handle. All operations | 349 * A light-weight stack-allocated object handle. All operations |
| 354 * that return objects from within v8 return them in local handles. They | 350 * that return objects from within v8 return them in local handles. They |
| 355 * are created within HandleScopes, and all local handles allocated within a | 351 * are created within HandleScopes, and all local handles allocated within a |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 385 |
| 390 /** | 386 /** |
| 391 * Create a local handle for the content of another handle. | 387 * Create a local handle for the content of another handle. |
| 392 * The referee is kept alive by the local handle even when | 388 * The referee is kept alive by the local handle even when |
| 393 * the original handle is destroyed/disposed. | 389 * the original handle is destroyed/disposed. |
| 394 */ | 390 */ |
| 395 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that); | 391 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that); |
| 396 V8_INLINE static Local<T> New(Isolate* isolate, | 392 V8_INLINE static Local<T> New(Isolate* isolate, |
| 397 const PersistentBase<T>& that); | 393 const PersistentBase<T>& that); |
| 398 | 394 |
| 399 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | |
| 400 | |
| 401 private: | |
| 402 #endif | |
| 403 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { } | |
| 404 | |
| 405 private: | 395 private: |
| 406 friend class Utils; | 396 friend class Utils; |
| 407 template<class F> friend class Eternal; | 397 template<class F> friend class Eternal; |
| 408 template<class F> friend class PersistentBase; | 398 template<class F> friend class PersistentBase; |
| 409 template<class F, class M> friend class Persistent; | 399 template<class F, class M> friend class Persistent; |
| 410 template<class F> friend class Handle; | 400 template<class F> friend class Handle; |
| 411 template<class F> friend class Local; | 401 template<class F> friend class Local; |
| 412 template<class F> friend class FunctionCallbackInfo; | 402 template<class F> friend class FunctionCallbackInfo; |
| 413 template<class F> friend class PropertyCallbackInfo; | 403 template<class F> friend class PropertyCallbackInfo; |
| 414 friend class String; | 404 friend class String; |
| 415 friend class Object; | 405 friend class Object; |
| 416 friend class Context; | 406 friend class Context; |
| 417 template<class F> friend class internal::CustomArguments; | 407 template<class F> friend class internal::CustomArguments; |
| 418 friend class HandleScope; | 408 friend class HandleScope; |
| 419 friend class EscapableHandleScope; | 409 friend class EscapableHandleScope; |
| 420 template<class F1, class F2, class F3> friend class PersistentValueMap; | 410 template<class F1, class F2, class F3> friend class PersistentValueMap; |
| 421 template<class F1, class F2> friend class PersistentValueVector; | 411 template<class F1, class F2> friend class PersistentValueVector; |
| 422 | 412 |
| 413 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { } |
| 423 V8_INLINE static Local<T> New(Isolate* isolate, T* that); | 414 V8_INLINE static Local<T> New(Isolate* isolate, T* that); |
| 424 }; | 415 }; |
| 425 | 416 |
| 426 | 417 |
| 427 // Eternal handles are set-once handles that live for the life of the isolate. | 418 // Eternal handles are set-once handles that live for the life of the isolate. |
| 428 template <class T> class Eternal { | 419 template <class T> class Eternal { |
| 429 public: | 420 public: |
| 430 V8_INLINE Eternal() : index_(kInitialValue) { } | 421 V8_INLINE Eternal() : index_(kInitialValue) { } |
| 431 template<class S> | 422 template<class S> |
| 432 V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) { | 423 V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 } | 713 } |
| 723 | 714 |
| 724 // TODO(dcarney): this is pretty useless, fix or remove | 715 // TODO(dcarney): this is pretty useless, fix or remove |
| 725 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT | 716 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT |
| 726 return Persistent<S>::Cast(*this); | 717 return Persistent<S>::Cast(*this); |
| 727 } | 718 } |
| 728 | 719 |
| 729 // This will be removed. | 720 // This will be removed. |
| 730 V8_INLINE T* ClearAndLeak(); | 721 V8_INLINE T* ClearAndLeak(); |
| 731 | 722 |
| 732 // TODO(dcarney): remove | |
| 733 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | |
| 734 | |
| 735 private: | |
| 736 #endif | |
| 737 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { } | |
| 738 | |
| 739 V8_INLINE T* operator*() const { return this->val_; } | |
| 740 | |
| 741 private: | 723 private: |
| 742 friend class Isolate; | 724 friend class Isolate; |
| 743 friend class Utils; | 725 friend class Utils; |
| 744 template<class F> friend class Handle; | 726 template<class F> friend class Handle; |
| 745 template<class F> friend class Local; | 727 template<class F> friend class Local; |
| 746 template<class F1, class F2> friend class Persistent; | 728 template<class F1, class F2> friend class Persistent; |
| 747 template<class F> friend class ReturnValue; | 729 template<class F> friend class ReturnValue; |
| 748 | 730 |
| 731 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { } |
| 732 V8_INLINE T* operator*() const { return this->val_; } |
| 749 template<class S, class M2> | 733 template<class S, class M2> |
| 750 V8_INLINE void Copy(const Persistent<S, M2>& that); | 734 V8_INLINE void Copy(const Persistent<S, M2>& that); |
| 751 }; | 735 }; |
| 752 | 736 |
| 753 | 737 |
| 754 /** | 738 /** |
| 755 * A PersistentBase which has move semantics. | 739 * A PersistentBase which has move semantics. |
| 756 * | 740 * |
| 757 * Note: Persistent class hierarchy is subject to future changes. | 741 * Note: Persistent class hierarchy is subject to future changes. |
| 758 */ | 742 */ |
| (...skipping 5925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6684 */ | 6668 */ |
| 6685 | 6669 |
| 6686 | 6670 |
| 6687 } // namespace v8 | 6671 } // namespace v8 |
| 6688 | 6672 |
| 6689 | 6673 |
| 6690 #undef TYPE_CHECK | 6674 #undef TYPE_CHECK |
| 6691 | 6675 |
| 6692 | 6676 |
| 6693 #endif // V8_H_ | 6677 #endif // V8_H_ |
| OLD | NEW |