| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 class Symbol; | 116 class Symbol; |
| 117 class SymbolObject; | 117 class SymbolObject; |
| 118 class Private; | 118 class Private; |
| 119 class Uint32; | 119 class Uint32; |
| 120 class Utils; | 120 class Utils; |
| 121 class Value; | 121 class Value; |
| 122 template <class T> class Handle; | 122 template <class T> class Handle; |
| 123 template <class T> class Local; | 123 template <class T> class Local; |
| 124 template <class T> class Eternal; | 124 template <class T> class Eternal; |
| 125 template<class T> class NonCopyablePersistentTraits; | 125 template<class T> class NonCopyablePersistentTraits; |
| 126 template<class T> class PersistentBase; |
| 126 template<class T, | 127 template<class T, |
| 127 class M = NonCopyablePersistentTraits<T> > class Persistent; | 128 class M = NonCopyablePersistentTraits<T> > class Persistent; |
| 129 template<class T> class UniquePersistent; |
| 128 template<class T, class P> class WeakCallbackObject; | 130 template<class T, class P> class WeakCallbackObject; |
| 129 class FunctionTemplate; | 131 class FunctionTemplate; |
| 130 class ObjectTemplate; | 132 class ObjectTemplate; |
| 131 class Data; | 133 class Data; |
| 132 template<typename T> class PropertyCallbackInfo; | 134 template<typename T> class PropertyCallbackInfo; |
| 133 class StackTrace; | 135 class StackTrace; |
| 134 class StackFrame; | 136 class StackFrame; |
| 135 class Isolate; | 137 class Isolate; |
| 136 class DeclaredAccessorDescriptor; | 138 class DeclaredAccessorDescriptor; |
| 137 class ObjectOperationDescriptor; | 139 class ObjectOperationDescriptor; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 252 |
| 251 V8_INLINE T* operator*() const { return val_; } | 253 V8_INLINE T* operator*() const { return val_; } |
| 252 | 254 |
| 253 /** | 255 /** |
| 254 * Checks whether two handles are the same. | 256 * Checks whether two handles are the same. |
| 255 * Returns true if both are empty, or if the objects | 257 * Returns true if both are empty, or if the objects |
| 256 * to which they refer are identical. | 258 * to which they refer are identical. |
| 257 * The handles' references are not checked. | 259 * The handles' references are not checked. |
| 258 */ | 260 */ |
| 259 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const { | 261 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const { |
| 260 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 262 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); |
| 261 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 263 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); |
| 262 if (a == 0) return b == 0; | 264 if (a == 0) return b == 0; |
| 263 if (b == 0) return false; | 265 if (b == 0) return false; |
| 264 return *a == *b; | 266 return *a == *b; |
| 265 } | 267 } |
| 266 | 268 |
| 267 template <class S> V8_INLINE bool operator==( | 269 template <class S> V8_INLINE bool operator==( |
| 268 const Persistent<S>& that) const { | 270 const PersistentBase<S>& that) const { |
| 269 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 271 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); |
| 270 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 272 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); |
| 271 if (a == 0) return b == 0; | 273 if (a == 0) return b == 0; |
| 272 if (b == 0) return false; | 274 if (b == 0) return false; |
| 273 return *a == *b; | 275 return *a == *b; |
| 274 } | 276 } |
| 275 | 277 |
| 276 /** | 278 /** |
| 277 * Checks whether two handles are different. | 279 * Checks whether two handles are different. |
| 278 * Returns true if only one of the handles is empty, or if | 280 * Returns true if only one of the handles is empty, or if |
| 279 * the objects to which they refer are different. | 281 * the objects to which they refer are different. |
| 280 * The handles' references are not checked. | 282 * The handles' references are not checked. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 297 return Handle<T>(T::Cast(*that)); | 299 return Handle<T>(T::Cast(*that)); |
| 298 } | 300 } |
| 299 | 301 |
| 300 template <class S> V8_INLINE Handle<S> As() { | 302 template <class S> V8_INLINE Handle<S> As() { |
| 301 return Handle<S>::Cast(*this); | 303 return Handle<S>::Cast(*this); |
| 302 } | 304 } |
| 303 | 305 |
| 304 V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) { | 306 V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) { |
| 305 return New(isolate, that.val_); | 307 return New(isolate, that.val_); |
| 306 } | 308 } |
| 307 V8_INLINE static Handle<T> New(Isolate* isolate, const Persistent<T>& that) { | 309 V8_INLINE static Handle<T> New(Isolate* isolate, |
| 310 const PersistentBase<T>& that) { |
| 308 return New(isolate, that.val_); | 311 return New(isolate, that.val_); |
| 309 } | 312 } |
| 310 | 313 |
| 311 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 314 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 312 | 315 |
| 313 private: | 316 private: |
| 314 #endif | 317 #endif |
| 315 /** | 318 /** |
| 316 * Creates a new handle for the specified value. | 319 * Creates a new handle for the specified value. |
| 317 */ | 320 */ |
| 318 V8_INLINE explicit Handle(T* val) : val_(val) {} | 321 V8_INLINE explicit Handle(T* val) : val_(val) {} |
| 319 | 322 |
| 320 private: | 323 private: |
| 321 friend class Utils; | 324 friend class Utils; |
| 322 template<class F, class M> friend class Persistent; | 325 template<class F, class M> friend class Persistent; |
| 326 template<class F> friend class PersistentBase; |
| 327 template<class F> friend class Handle; |
| 323 template<class F> friend class Local; | 328 template<class F> friend class Local; |
| 324 template<class F> friend class FunctionCallbackInfo; | 329 template<class F> friend class FunctionCallbackInfo; |
| 325 template<class F> friend class PropertyCallbackInfo; | 330 template<class F> friend class PropertyCallbackInfo; |
| 326 template<class F> friend class internal::CustomArguments; | 331 template<class F> friend class internal::CustomArguments; |
| 327 friend Handle<Primitive> Undefined(Isolate* isolate); | 332 friend Handle<Primitive> Undefined(Isolate* isolate); |
| 328 friend Handle<Primitive> Null(Isolate* isolate); | 333 friend Handle<Primitive> Null(Isolate* isolate); |
| 329 friend Handle<Boolean> True(Isolate* isolate); | 334 friend Handle<Boolean> True(Isolate* isolate); |
| 330 friend Handle<Boolean> False(Isolate* isolate); | 335 friend Handle<Boolean> False(Isolate* isolate); |
| 331 friend class Context; | 336 friend class Context; |
| 332 friend class HandleScope; | 337 friend class HandleScope; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 template <class S> V8_INLINE Local<S> As() { | 381 template <class S> V8_INLINE Local<S> As() { |
| 377 return Local<S>::Cast(*this); | 382 return Local<S>::Cast(*this); |
| 378 } | 383 } |
| 379 | 384 |
| 380 /** | 385 /** |
| 381 * Create a local handle for the content of another handle. | 386 * Create a local handle for the content of another handle. |
| 382 * The referee is kept alive by the local handle even when | 387 * The referee is kept alive by the local handle even when |
| 383 * the original handle is destroyed/disposed. | 388 * the original handle is destroyed/disposed. |
| 384 */ | 389 */ |
| 385 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that); | 390 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that); |
| 386 template<class M> | |
| 387 V8_INLINE static Local<T> New(Isolate* isolate, | 391 V8_INLINE static Local<T> New(Isolate* isolate, |
| 388 const Persistent<T, M>& that); | 392 const PersistentBase<T>& that); |
| 389 | 393 |
| 390 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 394 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 391 | 395 |
| 392 private: | 396 private: |
| 393 #endif | 397 #endif |
| 394 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { } | 398 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { } |
| 395 | 399 |
| 396 private: | 400 private: |
| 397 friend class Utils; | 401 friend class Utils; |
| 398 template<class F> friend class Eternal; | 402 template<class F> friend class Eternal; |
| 403 template<class F> friend class PersistentBase; |
| 399 template<class F, class M> friend class Persistent; | 404 template<class F, class M> friend class Persistent; |
| 400 template<class F> friend class Handle; | 405 template<class F> friend class Handle; |
| 406 template<class F> friend class Local; |
| 401 template<class F> friend class FunctionCallbackInfo; | 407 template<class F> friend class FunctionCallbackInfo; |
| 402 template<class F> friend class PropertyCallbackInfo; | 408 template<class F> friend class PropertyCallbackInfo; |
| 403 friend class String; | 409 friend class String; |
| 404 friend class Object; | 410 friend class Object; |
| 405 friend class Context; | 411 friend class Context; |
| 406 template<class F> friend class internal::CustomArguments; | 412 template<class F> friend class internal::CustomArguments; |
| 407 friend class HandleScope; | 413 friend class HandleScope; |
| 408 friend class EscapableHandleScope; | 414 friend class EscapableHandleScope; |
| 409 | 415 |
| 410 V8_INLINE static Local<T> New(Isolate* isolate, T* that); | 416 V8_INLINE static Local<T> New(Isolate* isolate, T* that); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 typename M = NonCopyablePersistentTraits<T> > | 461 typename M = NonCopyablePersistentTraits<T> > |
| 456 class WeakReferenceCallbacks { | 462 class WeakReferenceCallbacks { |
| 457 public: | 463 public: |
| 458 typedef void (*Revivable)(Isolate* isolate, | 464 typedef void (*Revivable)(Isolate* isolate, |
| 459 Persistent<T, M>* object, | 465 Persistent<T, M>* object, |
| 460 P* parameter); | 466 P* parameter); |
| 461 }; | 467 }; |
| 462 | 468 |
| 463 | 469 |
| 464 /** | 470 /** |
| 471 * An object reference that is independent of any handle scope. Where |
| 472 * a Local handle only lives as long as the HandleScope in which it was |
| 473 * allocated, a PersistentBase handle remains valid until it is explicitly |
| 474 * disposed. |
| 475 * |
| 476 * A persistent handle contains a reference to a storage cell within |
| 477 * the v8 engine which holds an object value and which is updated by |
| 478 * the garbage collector whenever the object is moved. A new storage |
| 479 * cell can be created using the constructor or PersistentBase::Reset and |
| 480 * existing handles can be disposed using PersistentBase::Reset. |
| 481 * |
| 482 */ |
| 483 template <class T> class PersistentBase { |
| 484 public: |
| 485 /** |
| 486 * If non-empty, destroy the underlying storage cell |
| 487 * IsEmpty() will return true after this call. |
| 488 */ |
| 489 V8_INLINE void Reset(); |
| 490 /** |
| 491 * If non-empty, destroy the underlying storage cell |
| 492 * and create a new one with the contents of other if other is non empty |
| 493 */ |
| 494 template <class S> |
| 495 V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other); |
| 496 |
| 497 /** |
| 498 * If non-empty, destroy the underlying storage cell |
| 499 * and create a new one with the contents of other if other is non empty |
| 500 */ |
| 501 template <class S> |
| 502 V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other); |
| 503 |
| 504 V8_INLINE bool IsEmpty() const { return val_ == 0; } |
| 505 |
| 506 template <class S> |
| 507 V8_INLINE bool operator==(const PersistentBase<S>& that) const { |
| 508 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); |
| 509 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); |
| 510 if (a == 0) return b == 0; |
| 511 if (b == 0) return false; |
| 512 return *a == *b; |
| 513 } |
| 514 |
| 515 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const { |
| 516 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); |
| 517 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); |
| 518 if (a == 0) return b == 0; |
| 519 if (b == 0) return false; |
| 520 return *a == *b; |
| 521 } |
| 522 |
| 523 template <class S> |
| 524 V8_INLINE bool operator!=(const PersistentBase<S>& that) const { |
| 525 return !operator==(that); |
| 526 } |
| 527 |
| 528 template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const { |
| 529 return !operator==(that); |
| 530 } |
| 531 |
| 532 template<typename P> |
| 533 V8_INLINE void SetWeak( |
| 534 P* parameter, |
| 535 typename WeakCallbackData<T, P>::Callback callback); |
| 536 |
| 537 template<typename S, typename P> |
| 538 V8_INLINE void SetWeak( |
| 539 P* parameter, |
| 540 typename WeakCallbackData<S, P>::Callback callback); |
| 541 |
| 542 V8_INLINE void ClearWeak(); |
| 543 |
| 544 /** |
| 545 * Marks the reference to this object independent. Garbage collector is free |
| 546 * to ignore any object groups containing this object. Weak callback for an |
| 547 * independent handle should not assume that it will be preceded by a global |
| 548 * GC prologue callback or followed by a global GC epilogue callback. |
| 549 */ |
| 550 V8_INLINE void MarkIndependent(); |
| 551 |
| 552 /** |
| 553 * Marks the reference to this object partially dependent. Partially dependent |
| 554 * handles only depend on other partially dependent handles and these |
| 555 * dependencies are provided through object groups. It provides a way to build |
| 556 * smaller object groups for young objects that represent only a subset of all |
| 557 * external dependencies. This mark is automatically cleared after each |
| 558 * garbage collection. |
| 559 */ |
| 560 V8_INLINE void MarkPartiallyDependent(); |
| 561 |
| 562 V8_INLINE bool IsIndependent() const; |
| 563 |
| 564 /** Checks if the handle holds the only reference to an object. */ |
| 565 V8_INLINE bool IsNearDeath() const; |
| 566 |
| 567 /** Returns true if the handle's reference is weak. */ |
| 568 V8_INLINE bool IsWeak() const; |
| 569 |
| 570 /** |
| 571 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface |
| 572 * description in v8-profiler.h for details. |
| 573 */ |
| 574 V8_INLINE void SetWrapperClassId(uint16_t class_id); |
| 575 |
| 576 /** |
| 577 * Returns the class ID previously assigned to this handle or 0 if no class ID |
| 578 * was previously assigned. |
| 579 */ |
| 580 V8_INLINE uint16_t WrapperClassId() const; |
| 581 |
| 582 private: |
| 583 friend class Isolate; |
| 584 friend class Utils; |
| 585 template<class F> friend class Handle; |
| 586 template<class F> friend class Local; |
| 587 template<class F1, class F2> friend class Persistent; |
| 588 template<class F> friend class UniquePersistent; |
| 589 template<class F> friend class PersistentBase; |
| 590 template<class F> friend class ReturnValue; |
| 591 |
| 592 explicit V8_INLINE PersistentBase(T* val) : val_(val) {} |
| 593 PersistentBase(PersistentBase& other); // NOLINT |
| 594 void operator=(PersistentBase&); |
| 595 V8_INLINE static T* New(Isolate* isolate, T* that); |
| 596 |
| 597 T* val_; |
| 598 }; |
| 599 |
| 600 |
| 601 /** |
| 465 * Default traits for Persistent. This class does not allow | 602 * Default traits for Persistent. This class does not allow |
| 466 * use of the copy constructor or assignment operator. | 603 * use of the copy constructor or assignment operator. |
| 467 * At present kResetInDestructor is not set, but that will change in a future | 604 * At present kResetInDestructor is not set, but that will change in a future |
| 468 * version. | 605 * version. |
| 469 */ | 606 */ |
| 470 template<class T> | 607 template<class T> |
| 471 class NonCopyablePersistentTraits { | 608 class NonCopyablePersistentTraits { |
| 472 public: | 609 public: |
| 473 typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent; | 610 typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent; |
| 474 static const bool kResetInDestructor = false; | 611 static const bool kResetInDestructor = false; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 494 static const bool kResetInDestructor = true; | 631 static const bool kResetInDestructor = true; |
| 495 template<class S, class M> | 632 template<class S, class M> |
| 496 static V8_INLINE void Copy(const Persistent<S, M>& source, | 633 static V8_INLINE void Copy(const Persistent<S, M>& source, |
| 497 CopyablePersistent* dest) { | 634 CopyablePersistent* dest) { |
| 498 // do nothing, just allow copy | 635 // do nothing, just allow copy |
| 499 } | 636 } |
| 500 }; | 637 }; |
| 501 | 638 |
| 502 | 639 |
| 503 /** | 640 /** |
| 504 * An object reference that is independent of any handle scope. Where | 641 * A PersistentBase which allows copy and assignment. |
| 505 * a Local handle only lives as long as the HandleScope in which it was | |
| 506 * allocated, a Persistent handle remains valid until it is explicitly | |
| 507 * disposed. | |
| 508 * | |
| 509 * A persistent handle contains a reference to a storage cell within | |
| 510 * the v8 engine which holds an object value and which is updated by | |
| 511 * the garbage collector whenever the object is moved. A new storage | |
| 512 * cell can be created using the constructor or Persistent::Reset and | |
| 513 * existing handles can be disposed using Persistent::Reset. | |
| 514 * | 642 * |
| 515 * Copy, assignment and destructor bevavior is controlled by the traits | 643 * Copy, assignment and destructor bevavior is controlled by the traits |
| 516 * class M. | 644 * class M. |
| 645 * |
| 646 * Note: Persistent class hierarchy is subject to future changes. |
| 517 */ | 647 */ |
| 518 template <class T, class M> class Persistent { | 648 template <class T, class M> class Persistent : public PersistentBase<T> { |
| 519 public: | 649 public: |
| 520 /** | 650 /** |
| 521 * A Persistent with no storage cell. | 651 * A Persistent with no storage cell. |
| 522 */ | 652 */ |
| 523 V8_INLINE Persistent() : val_(0) { } | 653 V8_INLINE Persistent() : PersistentBase<T>(0) { } |
| 524 /** | 654 /** |
| 525 * Construct a Persistent from a Handle. | 655 * Construct a Persistent from a Handle. |
| 526 * When the Handle is non-empty, a new storage cell is created | 656 * When the Handle is non-empty, a new storage cell is created |
| 527 * pointing to the same object, and no flags are set. | 657 * pointing to the same object, and no flags are set. |
| 528 */ | 658 */ |
| 529 template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that) | 659 template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that) |
| 530 : val_(New(isolate, *that)) { | 660 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) { |
| 531 TYPE_CHECK(T, S); | 661 TYPE_CHECK(T, S); |
| 532 } | 662 } |
| 533 /** | 663 /** |
| 534 * Construct a Persistent from a Persistent. | 664 * Construct a Persistent from a Persistent. |
| 535 * When the Persistent is non-empty, a new storage cell is created | 665 * When the Persistent is non-empty, a new storage cell is created |
| 536 * pointing to the same object, and no flags are set. | 666 * pointing to the same object, and no flags are set. |
| 537 */ | 667 */ |
| 538 template <class S, class M2> | 668 template <class S, class M2> |
| 539 V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that) | 669 V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that) |
| 540 : val_(New(isolate, *that)) { | 670 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) { |
| 541 TYPE_CHECK(T, S); | 671 TYPE_CHECK(T, S); |
| 542 } | 672 } |
| 543 /** | 673 /** |
| 544 * The copy constructors and assignment operator create a Persistent | 674 * The copy constructors and assignment operator create a Persistent |
| 545 * exactly as the Persistent constructor, but the Copy function from the | 675 * exactly as the Persistent constructor, but the Copy function from the |
| 546 * traits class is called, allowing the setting of flags based on the | 676 * traits class is called, allowing the setting of flags based on the |
| 547 * copied Persistent. | 677 * copied Persistent. |
| 548 */ | 678 */ |
| 549 V8_INLINE Persistent(const Persistent& that) : val_(0) { | 679 V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(0) { |
| 550 Copy(that); | 680 Copy(that); |
| 551 } | 681 } |
| 552 template <class S, class M2> | 682 template <class S, class M2> |
| 553 V8_INLINE Persistent(const Persistent<S, M2>& that) : val_(0) { | 683 V8_INLINE Persistent(const Persistent<S, M2>& that) : PersistentBase<T>(0) { |
| 554 Copy(that); | 684 Copy(that); |
| 555 } | 685 } |
| 556 V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT | 686 V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT |
| 557 Copy(that); | 687 Copy(that); |
| 558 return *this; | 688 return *this; |
| 559 } | 689 } |
| 560 template <class S, class M2> | 690 template <class S, class M2> |
| 561 V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT | 691 V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT |
| 562 Copy(that); | 692 Copy(that); |
| 563 return *this; | 693 return *this; |
| 564 } | 694 } |
| 565 /** | 695 /** |
| 566 * The destructor will dispose the Persistent based on the | 696 * The destructor will dispose the Persistent based on the |
| 567 * kResetInDestructor flags in the traits class. Since not calling dispose | 697 * kResetInDestructor flags in the traits class. Since not calling dispose |
| 568 * can result in a memory leak, it is recommended to always set this flag. | 698 * can result in a memory leak, it is recommended to always set this flag. |
| 569 */ | 699 */ |
| 570 V8_INLINE ~Persistent() { | 700 V8_INLINE ~Persistent() { |
| 571 if (M::kResetInDestructor) Reset(); | 701 if (M::kResetInDestructor) this->Reset(); |
| 572 } | 702 } |
| 573 | 703 |
| 574 /** | |
| 575 * If non-empty, destroy the underlying storage cell | |
| 576 * IsEmpty() will return true after this call. | |
| 577 */ | |
| 578 V8_INLINE void Reset(); | |
| 579 /** | |
| 580 * If non-empty, destroy the underlying storage cell | |
| 581 * and create a new one with the contents of other if other is non empty | |
| 582 */ | |
| 583 template <class S> | |
| 584 V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other); | |
| 585 /** | |
| 586 * If non-empty, destroy the underlying storage cell | |
| 587 * and create a new one with the contents of other if other is non empty | |
| 588 */ | |
| 589 template <class S, class M2> | |
| 590 V8_INLINE void Reset(Isolate* isolate, const Persistent<S, M2>& other); | |
| 591 | |
| 592 V8_DEPRECATED("Use Reset instead", | 704 V8_DEPRECATED("Use Reset instead", |
| 593 V8_INLINE void Dispose()) { Reset(); } | 705 V8_INLINE void Dispose()) { this->Reset(); } |
| 594 | |
| 595 V8_INLINE bool IsEmpty() const { return val_ == 0; } | |
| 596 | 706 |
| 597 // TODO(dcarney): this is pretty useless, fix or remove | 707 // TODO(dcarney): this is pretty useless, fix or remove |
| 598 template <class S> | 708 template <class S> |
| 599 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT | 709 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT |
| 600 #ifdef V8_ENABLE_CHECKS | 710 #ifdef V8_ENABLE_CHECKS |
| 601 // If we're going to perform the type check then we have to check | 711 // If we're going to perform the type check then we have to check |
| 602 // that the handle isn't empty before doing the checked cast. | 712 // that the handle isn't empty before doing the checked cast. |
| 603 if (!that.IsEmpty()) T::Cast(*that); | 713 if (!that.IsEmpty()) T::Cast(*that); |
| 604 #endif | 714 #endif |
| 605 return reinterpret_cast<Persistent<T>&>(that); | 715 return reinterpret_cast<Persistent<T>&>(that); |
| 606 } | 716 } |
| 607 | 717 |
| 608 // TODO(dcarney): this is pretty useless, fix or remove | 718 // TODO(dcarney): this is pretty useless, fix or remove |
| 609 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT | 719 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT |
| 610 return Persistent<S>::Cast(*this); | 720 return Persistent<S>::Cast(*this); |
| 611 } | 721 } |
| 612 | 722 |
| 613 template <class S, class M2> | |
| 614 V8_INLINE bool operator==(const Persistent<S, M2>& that) const { | |
| 615 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | |
| 616 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | |
| 617 if (a == 0) return b == 0; | |
| 618 if (b == 0) return false; | |
| 619 return *a == *b; | |
| 620 } | |
| 621 | |
| 622 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const { | |
| 623 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | |
| 624 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | |
| 625 if (a == 0) return b == 0; | |
| 626 if (b == 0) return false; | |
| 627 return *a == *b; | |
| 628 } | |
| 629 | |
| 630 template <class S, class M2> | |
| 631 V8_INLINE bool operator!=(const Persistent<S, M2>& that) const { | |
| 632 return !operator==(that); | |
| 633 } | |
| 634 | |
| 635 template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const { | |
| 636 return !operator==(that); | |
| 637 } | |
| 638 | |
| 639 template<typename P> | |
| 640 V8_INLINE void SetWeak( | |
| 641 P* parameter, | |
| 642 typename WeakCallbackData<T, P>::Callback callback); | |
| 643 | |
| 644 template<typename S, typename P> | |
| 645 V8_INLINE void SetWeak( | |
| 646 P* parameter, | |
| 647 typename WeakCallbackData<S, P>::Callback callback); | |
| 648 | |
| 649 template<typename S, typename P> | 723 template<typename S, typename P> |
| 650 V8_DEPRECATED( | 724 V8_DEPRECATED( |
| 651 "Use SetWeak instead", | 725 "Use SetWeak instead", |
| 652 V8_INLINE void MakeWeak( | 726 V8_INLINE void MakeWeak( |
| 653 P* parameter, | 727 P* parameter, |
| 654 typename WeakReferenceCallbacks<S, P>::Revivable callback)); | 728 typename WeakReferenceCallbacks<S, P>::Revivable callback)); |
| 655 | 729 |
| 656 template<typename P> | 730 template<typename P> |
| 657 V8_DEPRECATED( | 731 V8_DEPRECATED( |
| 658 "Use SetWeak instead", | 732 "Use SetWeak instead", |
| 659 V8_INLINE void MakeWeak( | 733 V8_INLINE void MakeWeak( |
| 660 P* parameter, | 734 P* parameter, |
| 661 typename WeakReferenceCallbacks<T, P>::Revivable callback)); | 735 typename WeakReferenceCallbacks<T, P>::Revivable callback)); |
| 662 | 736 |
| 663 V8_INLINE void ClearWeak(); | 737 // This will be removed. |
| 664 | 738 V8_INLINE T* ClearAndLeak(); |
| 665 /** | |
| 666 * Marks the reference to this object independent. Garbage collector is free | |
| 667 * to ignore any object groups containing this object. Weak callback for an | |
| 668 * independent handle should not assume that it will be preceded by a global | |
| 669 * GC prologue callback or followed by a global GC epilogue callback. | |
| 670 */ | |
| 671 V8_INLINE void MarkIndependent(); | |
| 672 | |
| 673 /** | |
| 674 * Marks the reference to this object partially dependent. Partially dependent | |
| 675 * handles only depend on other partially dependent handles and these | |
| 676 * dependencies are provided through object groups. It provides a way to build | |
| 677 * smaller object groups for young objects that represent only a subset of all | |
| 678 * external dependencies. This mark is automatically cleared after each | |
| 679 * garbage collection. | |
| 680 */ | |
| 681 V8_INLINE void MarkPartiallyDependent(); | |
| 682 | |
| 683 V8_INLINE bool IsIndependent() const; | |
| 684 | |
| 685 /** Checks if the handle holds the only reference to an object. */ | |
| 686 V8_INLINE bool IsNearDeath() const; | |
| 687 | |
| 688 /** Returns true if the handle's reference is weak. */ | |
| 689 V8_INLINE bool IsWeak() const; | |
| 690 | |
| 691 /** | |
| 692 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface | |
| 693 * description in v8-profiler.h for details. | |
| 694 */ | |
| 695 V8_INLINE void SetWrapperClassId(uint16_t class_id); | |
| 696 | |
| 697 /** | |
| 698 * Returns the class ID previously assigned to this handle or 0 if no class ID | |
| 699 * was previously assigned. | |
| 700 */ | |
| 701 V8_INLINE uint16_t WrapperClassId() const; | |
| 702 | 739 |
| 703 V8_DEPRECATED("This will be removed", | 740 V8_DEPRECATED("This will be removed", |
| 704 V8_INLINE T* ClearAndLeak()); | 741 V8_INLINE void Clear()) { this->val_ = 0; } |
| 705 | |
| 706 V8_DEPRECATED("This will be removed", | |
| 707 V8_INLINE void Clear()) { val_ = 0; } | |
| 708 | 742 |
| 709 // TODO(dcarney): remove | 743 // TODO(dcarney): remove |
| 710 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 744 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 711 | 745 |
| 712 private: | 746 private: |
| 713 #endif | 747 #endif |
| 714 template <class S> V8_INLINE Persistent(S* that) : val_(that) { } | 748 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { } |
| 715 | 749 |
| 716 V8_INLINE T* operator*() const { return val_; } | 750 V8_INLINE T* operator*() const { return this->val_; } |
| 717 | 751 |
| 718 private: | 752 private: |
| 719 friend class Isolate; | 753 friend class Isolate; |
| 720 friend class Utils; | 754 friend class Utils; |
| 721 template<class F> friend class Handle; | 755 template<class F> friend class Handle; |
| 722 template<class F> friend class Local; | 756 template<class F> friend class Local; |
| 723 template<class F1, class F2> friend class Persistent; | 757 template<class F1, class F2> friend class Persistent; |
| 724 template<class F> friend class ReturnValue; | 758 template<class F> friend class ReturnValue; |
| 725 | 759 |
| 726 V8_INLINE static T* New(Isolate* isolate, T* that); | |
| 727 template<class S, class M2> | 760 template<class S, class M2> |
| 728 V8_INLINE void Copy(const Persistent<S, M2>& that); | 761 V8_INLINE void Copy(const Persistent<S, M2>& that); |
| 762 }; |
| 729 | 763 |
| 730 T* val_; | 764 |
| 765 /** |
| 766 * A PersistentBase which has move semantics. |
| 767 * |
| 768 * Note: Persistent class hierarchy is subject to future changes. |
| 769 */ |
| 770 template<class T> |
| 771 class UniquePersistent : public PersistentBase<T> { |
| 772 struct RValue { |
| 773 V8_INLINE explicit RValue(UniquePersistent* object) : object(object) {} |
| 774 UniquePersistent* object; |
| 775 }; |
| 776 |
| 777 public: |
| 778 /** |
| 779 * A UniquePersistent with no storage cell. |
| 780 */ |
| 781 V8_INLINE UniquePersistent() : PersistentBase<T>(0) { } |
| 782 /** |
| 783 * Construct a UniquePersistent from a Handle. |
| 784 * When the Handle is non-empty, a new storage cell is created |
| 785 * pointing to the same object, and no flags are set. |
| 786 */ |
| 787 template <class S> |
| 788 V8_INLINE UniquePersistent(Isolate* isolate, Handle<S> that) |
| 789 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) { |
| 790 TYPE_CHECK(T, S); |
| 791 } |
| 792 /** |
| 793 * Construct a UniquePersistent from a PersistentBase. |
| 794 * When the Persistent is non-empty, a new storage cell is created |
| 795 * pointing to the same object, and no flags are set. |
| 796 */ |
| 797 template <class S> |
| 798 V8_INLINE UniquePersistent(Isolate* isolate, const PersistentBase<S>& that) |
| 799 : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) { |
| 800 TYPE_CHECK(T, S); |
| 801 } |
| 802 /** |
| 803 * Move constructor. |
| 804 */ |
| 805 V8_INLINE UniquePersistent(RValue rvalue) |
| 806 : PersistentBase<T>(rvalue.object->val_) { |
| 807 rvalue.object->val_ = 0; |
| 808 } |
| 809 V8_INLINE ~UniquePersistent() { this->Reset(); } |
| 810 /** |
| 811 * Move via assignment. |
| 812 */ |
| 813 template<class S> |
| 814 V8_INLINE UniquePersistent& operator=(UniquePersistent<S> rhs) { |
| 815 TYPE_CHECK(T, S); |
| 816 this->val_ = rhs.val_; |
| 817 rhs.val_ = 0; |
| 818 return *this; |
| 819 } |
| 820 /** |
| 821 * Cast operator for moves. |
| 822 */ |
| 823 V8_INLINE operator RValue() { return RValue(this); } |
| 824 /** |
| 825 * Pass allows returning uniques from functions, etc. |
| 826 */ |
| 827 V8_INLINE UniquePersistent Pass() { return UniquePersistent(RValue(this)); } |
| 828 |
| 829 private: |
| 830 UniquePersistent(UniquePersistent&); |
| 831 void operator=(UniquePersistent&); |
| 731 }; | 832 }; |
| 732 | 833 |
| 834 |
| 733 /** | 835 /** |
| 734 * A stack-allocated class that governs a number of local handles. | 836 * A stack-allocated class that governs a number of local handles. |
| 735 * After a handle scope has been created, all local handles will be | 837 * After a handle scope has been created, all local handles will be |
| 736 * allocated within that handle scope until either the handle scope is | 838 * allocated within that handle scope until either the handle scope is |
| 737 * deleted or another handle scope is created. If there is already a | 839 * deleted or another handle scope is created. If there is already a |
| 738 * handle scope and a new one is created, all allocations will take | 840 * handle scope and a new one is created, all allocations will take |
| 739 * place in the new handle scope until it is deleted. After that, | 841 * place in the new handle scope until it is deleted. After that, |
| 740 * new handles will again be allocated in the original handle scope. | 842 * new handles will again be allocated in the original handle scope. |
| 741 * | 843 * |
| 742 * After the handle scope of a local handle has been deleted the | 844 * After the handle scope of a local handle has been deleted the |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 */ | 1232 */ |
| 1131 int GetEndColumn() const; | 1233 int GetEndColumn() const; |
| 1132 | 1234 |
| 1133 /** | 1235 /** |
| 1134 * Passes on the value set by the embedder when it fed the script from which | 1236 * Passes on the value set by the embedder when it fed the script from which |
| 1135 * this Message was generated to V8. | 1237 * this Message was generated to V8. |
| 1136 */ | 1238 */ |
| 1137 bool IsSharedCrossOrigin() const; | 1239 bool IsSharedCrossOrigin() const; |
| 1138 | 1240 |
| 1139 // TODO(1245381): Print to a string instead of on a FILE. | 1241 // TODO(1245381): Print to a string instead of on a FILE. |
| 1140 static void PrintCurrentStackTrace(FILE* out); | 1242 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out); |
| 1243 V8_DEPRECATED("Will be removed", |
| 1244 static void PrintCurrentStackTrace(FILE* out)); |
| 1141 | 1245 |
| 1142 static const int kNoLineNumberInfo = 0; | 1246 static const int kNoLineNumberInfo = 0; |
| 1143 static const int kNoColumnInfo = 0; | 1247 static const int kNoColumnInfo = 0; |
| 1144 static const int kNoScriptIdInfo = 0; | 1248 static const int kNoScriptIdInfo = 0; |
| 1145 }; | 1249 }; |
| 1146 | 1250 |
| 1147 | 1251 |
| 1148 /** | 1252 /** |
| 1149 * Representation of a JavaScript stack trace. The information collected is a | 1253 * Representation of a JavaScript stack trace. The information collected is a |
| 1150 * snapshot of the execution stack and the information remains valid after | 1254 * snapshot of the execution stack and the information remains valid after |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 Local<Array> AsArray(); | 1289 Local<Array> AsArray(); |
| 1186 | 1290 |
| 1187 /** | 1291 /** |
| 1188 * Grab a snapshot of the current JavaScript execution stack. | 1292 * Grab a snapshot of the current JavaScript execution stack. |
| 1189 * | 1293 * |
| 1190 * \param frame_limit The maximum number of stack frames we want to capture. | 1294 * \param frame_limit The maximum number of stack frames we want to capture. |
| 1191 * \param options Enumerates the set of things we will capture for each | 1295 * \param options Enumerates the set of things we will capture for each |
| 1192 * StackFrame. | 1296 * StackFrame. |
| 1193 */ | 1297 */ |
| 1194 static Local<StackTrace> CurrentStackTrace( | 1298 static Local<StackTrace> CurrentStackTrace( |
| 1299 Isolate* isolate, |
| 1195 int frame_limit, | 1300 int frame_limit, |
| 1196 StackTraceOptions options = kOverview); | 1301 StackTraceOptions options = kOverview); |
| 1302 V8_DEPRECATED("Will be removed", |
| 1303 static Local<StackTrace> CurrentStackTrace( |
| 1304 int frame_limit, StackTraceOptions options = kOverview)); |
| 1197 }; | 1305 }; |
| 1198 | 1306 |
| 1199 | 1307 |
| 1200 /** | 1308 /** |
| 1201 * A single JavaScript stack frame. | 1309 * A single JavaScript stack frame. |
| 1202 */ | 1310 */ |
| 1203 class V8_EXPORT StackFrame { | 1311 class V8_EXPORT StackFrame { |
| 1204 public: | 1312 public: |
| 1205 /** | 1313 /** |
| 1206 * Returns the number, 1-based, of the line for the associate function call. | 1314 * Returns the number, 1-based, of the line for the associate function call. |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 class V8_EXPORT Primitive : public Value { }; | 1625 class V8_EXPORT Primitive : public Value { }; |
| 1518 | 1626 |
| 1519 | 1627 |
| 1520 /** | 1628 /** |
| 1521 * A primitive boolean value (ECMA-262, 4.3.14). Either the true | 1629 * A primitive boolean value (ECMA-262, 4.3.14). Either the true |
| 1522 * or false value. | 1630 * or false value. |
| 1523 */ | 1631 */ |
| 1524 class V8_EXPORT Boolean : public Primitive { | 1632 class V8_EXPORT Boolean : public Primitive { |
| 1525 public: | 1633 public: |
| 1526 bool Value() const; | 1634 bool Value() const; |
| 1527 V8_INLINE static Handle<Boolean> New(bool value); | 1635 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value); |
| 1636 V8_DEPRECATED("Will be removed", |
| 1637 V8_INLINE static Handle<Boolean> New(bool value)); |
| 1528 }; | 1638 }; |
| 1529 | 1639 |
| 1530 | 1640 |
| 1531 /** | 1641 /** |
| 1532 * A JavaScript string value (ECMA-262, 4.3.17). | 1642 * A JavaScript string value (ECMA-262, 4.3.17). |
| 1533 */ | 1643 */ |
| 1534 class V8_EXPORT String : public Primitive { | 1644 class V8_EXPORT String : public Primitive { |
| 1535 public: | 1645 public: |
| 1536 enum Encoding { | 1646 enum Encoding { |
| 1537 UNKNOWN_ENCODING = 0x1, | 1647 UNKNOWN_ENCODING = 0x1, |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1785 static Local<String> Concat(Handle<String> left, Handle<String> right); | 1895 static Local<String> Concat(Handle<String> left, Handle<String> right); |
| 1786 | 1896 |
| 1787 /** | 1897 /** |
| 1788 * Creates a new external string using the data defined in the given | 1898 * Creates a new external string using the data defined in the given |
| 1789 * resource. When the external string is no longer live on V8's heap the | 1899 * resource. When the external string is no longer live on V8's heap the |
| 1790 * resource will be disposed by calling its Dispose method. The caller of | 1900 * resource will be disposed by calling its Dispose method. The caller of |
| 1791 * this function should not otherwise delete or modify the resource. Neither | 1901 * this function should not otherwise delete or modify the resource. Neither |
| 1792 * should the underlying buffer be deallocated or modified except through the | 1902 * should the underlying buffer be deallocated or modified except through the |
| 1793 * destructor of the external string resource. | 1903 * destructor of the external string resource. |
| 1794 */ | 1904 */ |
| 1795 static Local<String> NewExternal(ExternalStringResource* resource); | 1905 static Local<String> NewExternal(Isolate* isolate, |
| 1906 ExternalStringResource* resource); |
| 1907 V8_DEPRECATED("Will be removed", static Local<String> NewExternal( |
| 1908 ExternalStringResource* resource)); |
| 1796 | 1909 |
| 1797 /** | 1910 /** |
| 1798 * Associate an external string resource with this string by transforming it | 1911 * Associate an external string resource with this string by transforming it |
| 1799 * in place so that existing references to this string in the JavaScript heap | 1912 * in place so that existing references to this string in the JavaScript heap |
| 1800 * will use the external string resource. The external string resource's | 1913 * will use the external string resource. The external string resource's |
| 1801 * character contents need to be equivalent to this string. | 1914 * character contents need to be equivalent to this string. |
| 1802 * Returns true if the string has been changed to be an external string. | 1915 * Returns true if the string has been changed to be an external string. |
| 1803 * The string is not modified if the operation fails. See NewExternal for | 1916 * The string is not modified if the operation fails. See NewExternal for |
| 1804 * information on the lifetime of the resource. | 1917 * information on the lifetime of the resource. |
| 1805 */ | 1918 */ |
| 1806 bool MakeExternal(ExternalStringResource* resource); | 1919 bool MakeExternal(ExternalStringResource* resource); |
| 1807 | 1920 |
| 1808 /** | 1921 /** |
| 1809 * Creates a new external string using the ASCII data defined in the given | 1922 * Creates a new external string using the ASCII data defined in the given |
| 1810 * resource. When the external string is no longer live on V8's heap the | 1923 * resource. When the external string is no longer live on V8's heap the |
| 1811 * resource will be disposed by calling its Dispose method. The caller of | 1924 * resource will be disposed by calling its Dispose method. The caller of |
| 1812 * this function should not otherwise delete or modify the resource. Neither | 1925 * this function should not otherwise delete or modify the resource. Neither |
| 1813 * should the underlying buffer be deallocated or modified except through the | 1926 * should the underlying buffer be deallocated or modified except through the |
| 1814 * destructor of the external string resource. | 1927 * destructor of the external string resource. |
| 1815 */ | 1928 */ |
| 1816 static Local<String> NewExternal(ExternalAsciiStringResource* resource); | 1929 static Local<String> NewExternal(Isolate* isolate, |
| 1930 ExternalAsciiStringResource* resource); |
| 1931 V8_DEPRECATED("Will be removed", static Local<String> NewExternal( |
| 1932 ExternalAsciiStringResource* resource)); |
| 1817 | 1933 |
| 1818 /** | 1934 /** |
| 1819 * Associate an external string resource with this string by transforming it | 1935 * Associate an external string resource with this string by transforming it |
| 1820 * in place so that existing references to this string in the JavaScript heap | 1936 * in place so that existing references to this string in the JavaScript heap |
| 1821 * will use the external string resource. The external string resource's | 1937 * will use the external string resource. The external string resource's |
| 1822 * character contents need to be equivalent to this string. | 1938 * character contents need to be equivalent to this string. |
| 1823 * Returns true if the string has been changed to be an external string. | 1939 * Returns true if the string has been changed to be an external string. |
| 1824 * The string is not modified if the operation fails. See NewExternal for | 1940 * The string is not modified if the operation fails. See NewExternal for |
| 1825 * information on the lifetime of the resource. | 1941 * information on the lifetime of the resource. |
| 1826 */ | 1942 */ |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 Private(); | 2075 Private(); |
| 1960 }; | 2076 }; |
| 1961 | 2077 |
| 1962 | 2078 |
| 1963 /** | 2079 /** |
| 1964 * A JavaScript number value (ECMA-262, 4.3.20) | 2080 * A JavaScript number value (ECMA-262, 4.3.20) |
| 1965 */ | 2081 */ |
| 1966 class V8_EXPORT Number : public Primitive { | 2082 class V8_EXPORT Number : public Primitive { |
| 1967 public: | 2083 public: |
| 1968 double Value() const; | 2084 double Value() const; |
| 2085 static Local<Number> New(Isolate* isolate, double value); |
| 2086 // Will be deprecated soon. |
| 1969 static Local<Number> New(double value); | 2087 static Local<Number> New(double value); |
| 1970 static Local<Number> New(Isolate* isolate, double value); | |
| 1971 V8_INLINE static Number* Cast(v8::Value* obj); | 2088 V8_INLINE static Number* Cast(v8::Value* obj); |
| 1972 private: | 2089 private: |
| 1973 Number(); | 2090 Number(); |
| 1974 static void CheckCast(v8::Value* obj); | 2091 static void CheckCast(v8::Value* obj); |
| 1975 }; | 2092 }; |
| 1976 | 2093 |
| 1977 | 2094 |
| 1978 /** | 2095 /** |
| 1979 * A JavaScript value representing a signed integer. | 2096 * A JavaScript value representing a signed integer. |
| 1980 */ | 2097 */ |
| 1981 class V8_EXPORT Integer : public Number { | 2098 class V8_EXPORT Integer : public Number { |
| 1982 public: | 2099 public: |
| 2100 static Local<Integer> New(Isolate* isolate, int32_t value); |
| 2101 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value); |
| 2102 // Will be deprecated soon. |
| 2103 static Local<Integer> New(int32_t value, Isolate*); |
| 2104 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); |
| 1983 static Local<Integer> New(int32_t value); | 2105 static Local<Integer> New(int32_t value); |
| 1984 static Local<Integer> NewFromUnsigned(uint32_t value); | 2106 static Local<Integer> NewFromUnsigned(uint32_t value); |
| 1985 static Local<Integer> New(int32_t value, Isolate*); | |
| 1986 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); | |
| 1987 int64_t Value() const; | 2107 int64_t Value() const; |
| 1988 V8_INLINE static Integer* Cast(v8::Value* obj); | 2108 V8_INLINE static Integer* Cast(v8::Value* obj); |
| 1989 private: | 2109 private: |
| 1990 Integer(); | 2110 Integer(); |
| 1991 static void CheckCast(v8::Value* obj); | 2111 static void CheckCast(v8::Value* obj); |
| 1992 }; | 2112 }; |
| 1993 | 2113 |
| 1994 | 2114 |
| 1995 /** | 2115 /** |
| 1996 * A JavaScript value representing a 32-bit signed integer. | 2116 * A JavaScript value representing a 32-bit signed integer. |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 int argc, | 2449 int argc, |
| 2330 Handle<Value> argv[]); | 2450 Handle<Value> argv[]); |
| 2331 | 2451 |
| 2332 /** | 2452 /** |
| 2333 * Call an Object as a constructor if a callback is set by the | 2453 * Call an Object as a constructor if a callback is set by the |
| 2334 * ObjectTemplate::SetCallAsFunctionHandler method. | 2454 * ObjectTemplate::SetCallAsFunctionHandler method. |
| 2335 * Note: This method behaves like the Function::NewInstance method. | 2455 * Note: This method behaves like the Function::NewInstance method. |
| 2336 */ | 2456 */ |
| 2337 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); | 2457 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); |
| 2338 | 2458 |
| 2459 static Local<Object> New(Isolate* isolate); |
| 2460 // Will be deprecated soon. |
| 2339 static Local<Object> New(); | 2461 static Local<Object> New(); |
| 2340 V8_INLINE static Object* Cast(Value* obj); | 2462 V8_INLINE static Object* Cast(Value* obj); |
| 2341 | 2463 |
| 2342 private: | 2464 private: |
| 2343 Object(); | 2465 Object(); |
| 2344 static void CheckCast(Value* obj); | 2466 static void CheckCast(Value* obj); |
| 2345 Local<Value> SlowGetInternalField(int index); | 2467 Local<Value> SlowGetInternalField(int index); |
| 2346 void* SlowGetAlignedPointerFromInternalField(int index); | 2468 void* SlowGetAlignedPointerFromInternalField(int index); |
| 2347 }; | 2469 }; |
| 2348 | 2470 |
| 2349 | 2471 |
| 2350 /** | 2472 /** |
| 2351 * An instance of the built-in array constructor (ECMA-262, 15.4.2). | 2473 * An instance of the built-in array constructor (ECMA-262, 15.4.2). |
| 2352 */ | 2474 */ |
| 2353 class V8_EXPORT Array : public Object { | 2475 class V8_EXPORT Array : public Object { |
| 2354 public: | 2476 public: |
| 2355 uint32_t Length() const; | 2477 uint32_t Length() const; |
| 2356 | 2478 |
| 2357 /** | 2479 /** |
| 2358 * Clones an element at index |index|. Returns an empty | 2480 * Clones an element at index |index|. Returns an empty |
| 2359 * handle if cloning fails (for any reason). | 2481 * handle if cloning fails (for any reason). |
| 2360 */ | 2482 */ |
| 2361 Local<Object> CloneElementAt(uint32_t index); | 2483 Local<Object> CloneElementAt(uint32_t index); |
| 2362 | 2484 |
| 2363 /** | 2485 /** |
| 2364 * Creates a JavaScript array with the given length. If the length | 2486 * Creates a JavaScript array with the given length. If the length |
| 2365 * is negative the returned array will have length 0. | 2487 * is negative the returned array will have length 0. |
| 2366 */ | 2488 */ |
| 2367 static Local<Array> New(int length = 0); | 2489 static Local<Array> New(Isolate* isolate, int length = 0); |
| 2490 V8_DEPRECATED("Will be removed", static Local<Array> New(int length = 0)); |
| 2368 | 2491 |
| 2369 V8_INLINE static Array* Cast(Value* obj); | 2492 V8_INLINE static Array* Cast(Value* obj); |
| 2370 private: | 2493 private: |
| 2371 Array(); | 2494 Array(); |
| 2372 static void CheckCast(Value* obj); | 2495 static void CheckCast(Value* obj); |
| 2373 }; | 2496 }; |
| 2374 | 2497 |
| 2375 | 2498 |
| 2376 template<typename T> | 2499 template<typename T> |
| 2377 class ReturnValue { | 2500 class ReturnValue { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2620 * Data length in bytes. | 2743 * Data length in bytes. |
| 2621 */ | 2744 */ |
| 2622 size_t ByteLength() const; | 2745 size_t ByteLength() const; |
| 2623 | 2746 |
| 2624 /** | 2747 /** |
| 2625 * Create a new ArrayBuffer. Allocate |byte_length| bytes. | 2748 * Create a new ArrayBuffer. Allocate |byte_length| bytes. |
| 2626 * Allocated memory will be owned by a created ArrayBuffer and | 2749 * Allocated memory will be owned by a created ArrayBuffer and |
| 2627 * will be deallocated when it is garbage-collected, | 2750 * will be deallocated when it is garbage-collected, |
| 2628 * unless the object is externalized. | 2751 * unless the object is externalized. |
| 2629 */ | 2752 */ |
| 2630 static Local<ArrayBuffer> New(size_t byte_length); | 2753 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length); |
| 2754 V8_DEPRECATED("Will be removed", |
| 2755 static Local<ArrayBuffer> New(size_t byte_length)); |
| 2631 | 2756 |
| 2632 /** | 2757 /** |
| 2633 * Create a new ArrayBuffer over an existing memory block. | 2758 * Create a new ArrayBuffer over an existing memory block. |
| 2634 * The created array buffer is immediately in externalized state. | 2759 * The created array buffer is immediately in externalized state. |
| 2635 * The memory block will not be reclaimed when a created ArrayBuffer | 2760 * The memory block will not be reclaimed when a created ArrayBuffer |
| 2636 * is garbage-collected. | 2761 * is garbage-collected. |
| 2637 */ | 2762 */ |
| 2638 static Local<ArrayBuffer> New(void* data, size_t byte_length); | 2763 static Local<ArrayBuffer> New(Isolate* isolate, void* data, |
| 2764 size_t byte_length); |
| 2765 V8_DEPRECATED("Will be removed", |
| 2766 static Local<ArrayBuffer> New(void* data, size_t byte_length)); |
| 2639 | 2767 |
| 2640 /** | 2768 /** |
| 2641 * Returns true if ArrayBuffer is extrenalized, that is, does not | 2769 * Returns true if ArrayBuffer is extrenalized, that is, does not |
| 2642 * own its memory block. | 2770 * own its memory block. |
| 2643 */ | 2771 */ |
| 2644 bool IsExternal() const; | 2772 bool IsExternal() const; |
| 2645 | 2773 |
| 2646 /** | 2774 /** |
| 2647 * Neuters this ArrayBuffer and all its views (typed arrays). | 2775 * Neuters this ArrayBuffer and all its views (typed arrays). |
| 2648 * Neutering sets the byte length of the buffer and all typed arrays to zero, | 2776 * Neutering sets the byte length of the buffer and all typed arrays to zero, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2888 DataView(); | 3016 DataView(); |
| 2889 static void CheckCast(Value* obj); | 3017 static void CheckCast(Value* obj); |
| 2890 }; | 3018 }; |
| 2891 | 3019 |
| 2892 | 3020 |
| 2893 /** | 3021 /** |
| 2894 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 3022 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
| 2895 */ | 3023 */ |
| 2896 class V8_EXPORT Date : public Object { | 3024 class V8_EXPORT Date : public Object { |
| 2897 public: | 3025 public: |
| 2898 static Local<Value> New(double time); | 3026 static Local<Value> New(Isolate* isolate, double time); |
| 3027 V8_DEPRECATED("Will be removed", static Local<Value> New(double time)); |
| 2899 | 3028 |
| 2900 V8_DEPRECATED( | 3029 V8_DEPRECATED( |
| 2901 "Use ValueOf instead", | 3030 "Use ValueOf instead", |
| 2902 double NumberValue() const) { return ValueOf(); } | 3031 double NumberValue() const) { return ValueOf(); } |
| 2903 | 3032 |
| 2904 /** | 3033 /** |
| 2905 * A specialization of Value::NumberValue that is more efficient | 3034 * A specialization of Value::NumberValue that is more efficient |
| 2906 * because we know the structure of this object. | 3035 * because we know the structure of this object. |
| 2907 */ | 3036 */ |
| 2908 double ValueOf() const; | 3037 double ValueOf() const; |
| 2909 | 3038 |
| 2910 V8_INLINE static Date* Cast(v8::Value* obj); | 3039 V8_INLINE static Date* Cast(v8::Value* obj); |
| 2911 | 3040 |
| 2912 /** | 3041 /** |
| 2913 * Notification that the embedder has changed the time zone, | 3042 * Notification that the embedder has changed the time zone, |
| 2914 * daylight savings time, or other date / time configuration | 3043 * daylight savings time, or other date / time configuration |
| 2915 * parameters. V8 keeps a cache of various values used for | 3044 * parameters. V8 keeps a cache of various values used for |
| 2916 * date / time computation. This notification will reset | 3045 * date / time computation. This notification will reset |
| 2917 * those cached values for the current context so that date / | 3046 * those cached values for the current context so that date / |
| 2918 * time configuration changes would be reflected in the Date | 3047 * time configuration changes would be reflected in the Date |
| 2919 * object. | 3048 * object. |
| 2920 * | 3049 * |
| 2921 * This API should not be called more than needed as it will | 3050 * This API should not be called more than needed as it will |
| 2922 * negatively impact the performance of date operations. | 3051 * negatively impact the performance of date operations. |
| 2923 */ | 3052 */ |
| 2924 static void DateTimeConfigurationChangeNotification(); | 3053 static void DateTimeConfigurationChangeNotification(Isolate* isolate); |
| 3054 V8_DEPRECATED("Will be removed", |
| 3055 static void DateTimeConfigurationChangeNotification()); |
| 2925 | 3056 |
| 2926 private: | 3057 private: |
| 2927 static void CheckCast(v8::Value* obj); | 3058 static void CheckCast(v8::Value* obj); |
| 2928 }; | 3059 }; |
| 2929 | 3060 |
| 2930 | 3061 |
| 2931 /** | 3062 /** |
| 2932 * A Number object (ECMA-262, 4.3.21). | 3063 * A Number object (ECMA-262, 4.3.21). |
| 2933 */ | 3064 */ |
| 2934 class V8_EXPORT NumberObject : public Object { | 3065 class V8_EXPORT NumberObject : public Object { |
| 2935 public: | 3066 public: |
| 2936 static Local<Value> New(double value); | 3067 static Local<Value> New(Isolate* isolate, double value); |
| 3068 V8_DEPRECATED("Will be removed", static Local<Value> New(double value)); |
| 2937 | 3069 |
| 2938 V8_DEPRECATED( | 3070 V8_DEPRECATED( |
| 2939 "Use ValueOf instead", | 3071 "Use ValueOf instead", |
| 2940 double NumberValue() const) { return ValueOf(); } | 3072 double NumberValue() const) { return ValueOf(); } |
| 2941 | 3073 |
| 2942 /** | 3074 /** |
| 2943 * Returns the Number held by the object. | 3075 * Returns the Number held by the object. |
| 2944 */ | 3076 */ |
| 2945 double ValueOf() const; | 3077 double ValueOf() const; |
| 2946 | 3078 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3087 | 3219 |
| 3088 | 3220 |
| 3089 /** | 3221 /** |
| 3090 * The superclass of object and function templates. | 3222 * The superclass of object and function templates. |
| 3091 */ | 3223 */ |
| 3092 class V8_EXPORT Template : public Data { | 3224 class V8_EXPORT Template : public Data { |
| 3093 public: | 3225 public: |
| 3094 /** Adds a property to each instance created by this template.*/ | 3226 /** Adds a property to each instance created by this template.*/ |
| 3095 void Set(Handle<String> name, Handle<Data> value, | 3227 void Set(Handle<String> name, Handle<Data> value, |
| 3096 PropertyAttribute attributes = None); | 3228 PropertyAttribute attributes = None); |
| 3097 V8_INLINE void Set(const char* name, Handle<Data> value); | 3229 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value); |
| 3230 V8_DEPRECATED("Will be removed", |
| 3231 V8_INLINE void Set(const char* name, Handle<Data> value)); |
| 3098 | 3232 |
| 3099 void SetAccessorProperty( | 3233 void SetAccessorProperty( |
| 3100 Local<String> name, | 3234 Local<String> name, |
| 3101 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), | 3235 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), |
| 3102 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), | 3236 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), |
| 3103 PropertyAttribute attribute = None, | 3237 PropertyAttribute attribute = None, |
| 3104 AccessControl settings = DEFAULT); | 3238 AccessControl settings = DEFAULT); |
| 3105 | 3239 |
| 3106 /** | 3240 /** |
| 3107 * Whenever the property with the given name is accessed on objects | 3241 * Whenever the property with the given name is accessed on objects |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3370 * \code | 3504 * \code |
| 3371 * child_func.prototype.__proto__ == function.prototype; | 3505 * child_func.prototype.__proto__ == function.prototype; |
| 3372 * child_instance.instance_accessor calls 'InstanceAccessorCallback' | 3506 * child_instance.instance_accessor calls 'InstanceAccessorCallback' |
| 3373 * child_instance.instance_property == 3; | 3507 * child_instance.instance_property == 3; |
| 3374 * \endcode | 3508 * \endcode |
| 3375 */ | 3509 */ |
| 3376 class V8_EXPORT FunctionTemplate : public Template { | 3510 class V8_EXPORT FunctionTemplate : public Template { |
| 3377 public: | 3511 public: |
| 3378 /** Creates a function template.*/ | 3512 /** Creates a function template.*/ |
| 3379 static Local<FunctionTemplate> New( | 3513 static Local<FunctionTemplate> New( |
| 3514 Isolate* isolate, |
| 3515 FunctionCallback callback = 0, |
| 3516 Handle<Value> data = Handle<Value>(), |
| 3517 Handle<Signature> signature = Handle<Signature>(), |
| 3518 int length = 0); |
| 3519 // Will be deprecated soon. |
| 3520 static Local<FunctionTemplate> New( |
| 3380 FunctionCallback callback = 0, | 3521 FunctionCallback callback = 0, |
| 3381 Handle<Value> data = Handle<Value>(), | 3522 Handle<Value> data = Handle<Value>(), |
| 3382 Handle<Signature> signature = Handle<Signature>(), | 3523 Handle<Signature> signature = Handle<Signature>(), |
| 3383 int length = 0); | 3524 int length = 0); |
| 3384 | 3525 |
| 3385 /** Returns the unique function instance in the current execution context.*/ | 3526 /** Returns the unique function instance in the current execution context.*/ |
| 3386 Local<Function> GetFunction(); | 3527 Local<Function> GetFunction(); |
| 3387 | 3528 |
| 3388 /** | 3529 /** |
| 3389 * Set the call-handler callback for a FunctionTemplate. This | 3530 * Set the call-handler callback for a FunctionTemplate. This |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3456 | 3597 |
| 3457 /** | 3598 /** |
| 3458 * An ObjectTemplate is used to create objects at runtime. | 3599 * An ObjectTemplate is used to create objects at runtime. |
| 3459 * | 3600 * |
| 3460 * Properties added to an ObjectTemplate are added to each object | 3601 * Properties added to an ObjectTemplate are added to each object |
| 3461 * created from the ObjectTemplate. | 3602 * created from the ObjectTemplate. |
| 3462 */ | 3603 */ |
| 3463 class V8_EXPORT ObjectTemplate : public Template { | 3604 class V8_EXPORT ObjectTemplate : public Template { |
| 3464 public: | 3605 public: |
| 3465 /** Creates an ObjectTemplate. */ | 3606 /** Creates an ObjectTemplate. */ |
| 3607 static Local<ObjectTemplate> New(Isolate* isolate); |
| 3608 // Will be deprecated soon. |
| 3466 static Local<ObjectTemplate> New(); | 3609 static Local<ObjectTemplate> New(); |
| 3467 | 3610 |
| 3468 /** Creates a new instance of this template.*/ | 3611 /** Creates a new instance of this template.*/ |
| 3469 Local<Object> NewInstance(); | 3612 Local<Object> NewInstance(); |
| 3470 | 3613 |
| 3471 /** | 3614 /** |
| 3472 * Sets an accessor on the object template. | 3615 * Sets an accessor on the object template. |
| 3473 * | 3616 * |
| 3474 * Whenever the property with the given name is accessed on objects | 3617 * Whenever the property with the given name is accessed on objects |
| 3475 * created from this ObjectTemplate the getter and setter callbacks | 3618 * created from this ObjectTemplate the getter and setter callbacks |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3597 int InternalFieldCount(); | 3740 int InternalFieldCount(); |
| 3598 | 3741 |
| 3599 /** | 3742 /** |
| 3600 * Sets the number of internal fields for objects generated from | 3743 * Sets the number of internal fields for objects generated from |
| 3601 * this template. | 3744 * this template. |
| 3602 */ | 3745 */ |
| 3603 void SetInternalFieldCount(int value); | 3746 void SetInternalFieldCount(int value); |
| 3604 | 3747 |
| 3605 private: | 3748 private: |
| 3606 ObjectTemplate(); | 3749 ObjectTemplate(); |
| 3607 static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor); | 3750 static Local<ObjectTemplate> New(internal::Isolate* isolate, |
| 3751 Handle<FunctionTemplate> constructor); |
| 3608 friend class FunctionTemplate; | 3752 friend class FunctionTemplate; |
| 3609 }; | 3753 }; |
| 3610 | 3754 |
| 3611 | 3755 |
| 3612 /** | 3756 /** |
| 3613 * A Signature specifies which receivers and arguments are valid | 3757 * A Signature specifies which receivers and arguments are valid |
| 3614 * parameters to a function. | 3758 * parameters to a function. |
| 3615 */ | 3759 */ |
| 3616 class V8_EXPORT Signature : public Data { | 3760 class V8_EXPORT Signature : public Data { |
| 3617 public: | 3761 public: |
| 3618 static Local<Signature> New(Handle<FunctionTemplate> receiver = | 3762 static Local<Signature> New(Isolate* isolate, |
| 3763 Handle<FunctionTemplate> receiver = |
| 3619 Handle<FunctionTemplate>(), | 3764 Handle<FunctionTemplate>(), |
| 3620 int argc = 0, | 3765 int argc = 0, |
| 3621 Handle<FunctionTemplate> argv[] = 0); | 3766 Handle<FunctionTemplate> argv[] = 0); |
| 3767 V8_DEPRECATED("Will be removed", |
| 3768 static Local<Signature> New(Handle<FunctionTemplate> receiver = |
| 3769 Handle<FunctionTemplate>(), |
| 3770 int argc = 0, |
| 3771 Handle<FunctionTemplate> argv[] = |
| 3772 0)); |
| 3773 |
| 3622 private: | 3774 private: |
| 3623 Signature(); | 3775 Signature(); |
| 3624 }; | 3776 }; |
| 3625 | 3777 |
| 3626 | 3778 |
| 3627 /** | 3779 /** |
| 3628 * An AccessorSignature specifies which receivers are valid parameters | 3780 * An AccessorSignature specifies which receivers are valid parameters |
| 3629 * to an accessor callback. | 3781 * to an accessor callback. |
| 3630 */ | 3782 */ |
| 3631 class V8_EXPORT AccessorSignature : public Data { | 3783 class V8_EXPORT AccessorSignature : public Data { |
| 3632 public: | 3784 public: |
| 3633 static Local<AccessorSignature> New(Handle<FunctionTemplate> receiver = | 3785 static Local<AccessorSignature> New(Isolate* isolate, |
| 3786 Handle<FunctionTemplate> receiver = |
| 3634 Handle<FunctionTemplate>()); | 3787 Handle<FunctionTemplate>()); |
| 3788 V8_DEPRECATED("Will be removed", static Local<AccessorSignature> New( |
| 3789 Handle<FunctionTemplate> receiver = |
| 3790 Handle<FunctionTemplate>())); |
| 3791 |
| 3635 private: | 3792 private: |
| 3636 AccessorSignature(); | 3793 AccessorSignature(); |
| 3637 }; | 3794 }; |
| 3638 | 3795 |
| 3639 | 3796 |
| 3640 class V8_EXPORT DeclaredAccessorDescriptor : public Data { | 3797 class V8_EXPORT DeclaredAccessorDescriptor : public Data { |
| 3641 private: | 3798 private: |
| 3642 DeclaredAccessorDescriptor(); | 3799 DeclaredAccessorDescriptor(); |
| 3643 }; | 3800 }; |
| 3644 | 3801 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3728 class V8_EXPORT Extension { // NOLINT | 3885 class V8_EXPORT Extension { // NOLINT |
| 3729 public: | 3886 public: |
| 3730 // Note that the strings passed into this constructor must live as long | 3887 // Note that the strings passed into this constructor must live as long |
| 3731 // as the Extension itself. | 3888 // as the Extension itself. |
| 3732 Extension(const char* name, | 3889 Extension(const char* name, |
| 3733 const char* source = 0, | 3890 const char* source = 0, |
| 3734 int dep_count = 0, | 3891 int dep_count = 0, |
| 3735 const char** deps = 0, | 3892 const char** deps = 0, |
| 3736 int source_length = -1); | 3893 int source_length = -1); |
| 3737 virtual ~Extension() { } | 3894 virtual ~Extension() { } |
| 3738 virtual v8::Handle<v8::FunctionTemplate> | 3895 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 3739 GetNativeFunction(v8::Handle<v8::String> name) { | 3896 v8::Isolate* isolate, v8::Handle<v8::String> name) { |
| 3897 #if defined(V8_DEPRECATION_WARNINGS) |
| 3898 return v8::Handle<v8::FunctionTemplate>(); |
| 3899 #else |
| 3900 return GetNativeFunction(name); |
| 3901 #endif |
| 3902 } |
| 3903 |
| 3904 V8_DEPRECATED("Will be removed", |
| 3905 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
| 3906 v8::Handle<v8::String> name)) { |
| 3740 return v8::Handle<v8::FunctionTemplate>(); | 3907 return v8::Handle<v8::FunctionTemplate>(); |
| 3741 } | 3908 } |
| 3742 | 3909 |
| 3743 const char* name() const { return name_; } | 3910 const char* name() const { return name_; } |
| 3744 size_t source_length() const { return source_length_; } | 3911 size_t source_length() const { return source_length_; } |
| 3745 const String::ExternalAsciiStringResource* source() const { | 3912 const String::ExternalAsciiStringResource* source() const { |
| 3746 return &source_; } | 3913 return &source_; } |
| 3747 int dependency_count() { return dep_count_; } | 3914 int dependency_count() { return dep_count_; } |
| 3748 const char** dependencies() { return deps_; } | 3915 const char** dependencies() { return deps_; } |
| 3749 void set_auto_enable(bool value) { auto_enable_ = value; } | 3916 void set_auto_enable(bool value) { auto_enable_ = value; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3772 class V8_EXPORT DeclareExtension { | 3939 class V8_EXPORT DeclareExtension { |
| 3773 public: | 3940 public: |
| 3774 V8_INLINE DeclareExtension(Extension* extension) { | 3941 V8_INLINE DeclareExtension(Extension* extension) { |
| 3775 RegisterExtension(extension); | 3942 RegisterExtension(extension); |
| 3776 } | 3943 } |
| 3777 }; | 3944 }; |
| 3778 | 3945 |
| 3779 | 3946 |
| 3780 // --- Statics --- | 3947 // --- Statics --- |
| 3781 | 3948 |
| 3782 | |
| 3783 Handle<Primitive> V8_EXPORT Undefined(); | |
| 3784 Handle<Primitive> V8_EXPORT Null(); | |
| 3785 Handle<Boolean> V8_EXPORT True(); | |
| 3786 Handle<Boolean> V8_EXPORT False(); | |
| 3787 | |
| 3788 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate); | 3949 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate); |
| 3789 V8_INLINE Handle<Primitive> Null(Isolate* isolate); | 3950 V8_INLINE Handle<Primitive> Null(Isolate* isolate); |
| 3790 V8_INLINE Handle<Boolean> True(Isolate* isolate); | 3951 V8_INLINE Handle<Boolean> True(Isolate* isolate); |
| 3791 V8_INLINE Handle<Boolean> False(Isolate* isolate); | 3952 V8_INLINE Handle<Boolean> False(Isolate* isolate); |
| 3792 | 3953 |
| 3954 V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Undefined()); |
| 3955 V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Null()); |
| 3956 V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT True()); |
| 3957 V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT False()); |
| 3958 |
| 3793 | 3959 |
| 3794 /** | 3960 /** |
| 3795 * A set of constraints that specifies the limits of the runtime's memory use. | 3961 * A set of constraints that specifies the limits of the runtime's memory use. |
| 3796 * You must set the heap size before initializing the VM - the size cannot be | 3962 * You must set the heap size before initializing the VM - the size cannot be |
| 3797 * adjusted after the VM is initialized. | 3963 * adjusted after the VM is initialized. |
| 3798 * | 3964 * |
| 3799 * If you are using threads then you should hold the V8::Locker lock while | 3965 * If you are using threads then you should hold the V8::Locker lock while |
| 3800 * setting the stack limit and you must set a non-default stack limit separately | 3966 * setting the stack limit and you must set a non-default stack limit separately |
| 3801 * for each thread. | 3967 * for each thread. |
| 3802 */ | 3968 */ |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4047 * Requires: this == Isolate::GetCurrent(). | 4213 * Requires: this == Isolate::GetCurrent(). |
| 4048 */ | 4214 */ |
| 4049 void Exit(); | 4215 void Exit(); |
| 4050 | 4216 |
| 4051 /** | 4217 /** |
| 4052 * Disposes the isolate. The isolate must not be entered by any | 4218 * Disposes the isolate. The isolate must not be entered by any |
| 4053 * thread to be disposable. | 4219 * thread to be disposable. |
| 4054 */ | 4220 */ |
| 4055 void Dispose(); | 4221 void Dispose(); |
| 4056 | 4222 |
| 4057 /** | 4223 V8_DEPRECATED("Use SetData(0, data) instead.", |
| 4058 * Associate embedder-specific data with the isolate. This legacy method | 4224 V8_INLINE void SetData(void* data)); |
| 4059 * puts the data in the 0th slot. It will be deprecated soon. | 4225 V8_DEPRECATED("Use GetData(0) instead.", V8_INLINE void* GetData()); |
| 4060 */ | |
| 4061 V8_INLINE void SetData(void* data); | |
| 4062 | 4226 |
| 4063 /** | 4227 /** |
| 4064 * Associate embedder-specific data with the isolate. |slot| has to be | 4228 * Associate embedder-specific data with the isolate. |slot| has to be |
| 4065 * between 0 and GetNumberOfDataSlots() - 1. | 4229 * between 0 and GetNumberOfDataSlots() - 1. |
| 4066 */ | 4230 */ |
| 4067 V8_INLINE void SetData(uint32_t slot, void* data); | 4231 V8_INLINE void SetData(uint32_t slot, void* data); |
| 4068 | 4232 |
| 4069 /** | 4233 /** |
| 4070 * Retrieve embedder-specific data from the isolate. This legacy method | |
| 4071 * retrieves the data from slot 0. It will be deprecated soon. | |
| 4072 * Returns NULL if SetData has never been called. | |
| 4073 */ | |
| 4074 V8_INLINE void* GetData(); | |
| 4075 | |
| 4076 /** | |
| 4077 * Retrieve embedder-specific data from the isolate. | 4234 * Retrieve embedder-specific data from the isolate. |
| 4078 * Returns NULL if SetData has never been called for the given |slot|. | 4235 * Returns NULL if SetData has never been called for the given |slot|. |
| 4079 */ | 4236 */ |
| 4080 V8_INLINE void* GetData(uint32_t slot); | 4237 V8_INLINE void* GetData(uint32_t slot); |
| 4081 | 4238 |
| 4082 /** | 4239 /** |
| 4083 * Returns the maximum number of available embedder data slots. Valid slots | 4240 * Returns the maximum number of available embedder data slots. Valid slots |
| 4084 * are in the range of 0 - GetNumberOfDataSlots() - 1. | 4241 * are in the range of 0 - GetNumberOfDataSlots() - 1. |
| 4085 */ | 4242 */ |
| 4086 V8_INLINE static uint32_t GetNumberOfDataSlots(); | 4243 V8_INLINE static uint32_t GetNumberOfDataSlots(); |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4826 RevivableCallback weak_reference_callback); | 4983 RevivableCallback weak_reference_callback); |
| 4827 static void ClearWeak(internal::Object** global_handle); | 4984 static void ClearWeak(internal::Object** global_handle); |
| 4828 static void Eternalize(Isolate* isolate, | 4985 static void Eternalize(Isolate* isolate, |
| 4829 Value* handle, | 4986 Value* handle, |
| 4830 int* index); | 4987 int* index); |
| 4831 static Local<Value> GetEternal(Isolate* isolate, int index); | 4988 static Local<Value> GetEternal(Isolate* isolate, int index); |
| 4832 | 4989 |
| 4833 template <class T> friend class Handle; | 4990 template <class T> friend class Handle; |
| 4834 template <class T> friend class Local; | 4991 template <class T> friend class Local; |
| 4835 template <class T> friend class Eternal; | 4992 template <class T> friend class Eternal; |
| 4993 template <class T> friend class PersistentBase; |
| 4836 template <class T, class M> friend class Persistent; | 4994 template <class T, class M> friend class Persistent; |
| 4837 friend class Context; | 4995 friend class Context; |
| 4838 }; | 4996 }; |
| 4839 | 4997 |
| 4840 | 4998 |
| 4841 /** | 4999 /** |
| 4842 * An external exception handler. | 5000 * An external exception handler. |
| 4843 */ | 5001 */ |
| 4844 class V8_EXPORT TryCatch { | 5002 class V8_EXPORT TryCatch { |
| 4845 public: | 5003 public: |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5618 template <class T> | 5776 template <class T> |
| 5619 Local<T>::Local() : Handle<T>() { } | 5777 Local<T>::Local() : Handle<T>() { } |
| 5620 | 5778 |
| 5621 | 5779 |
| 5622 template <class T> | 5780 template <class T> |
| 5623 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { | 5781 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { |
| 5624 return New(isolate, that.val_); | 5782 return New(isolate, that.val_); |
| 5625 } | 5783 } |
| 5626 | 5784 |
| 5627 template <class T> | 5785 template <class T> |
| 5628 template <class M> | 5786 Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) { |
| 5629 Local<T> Local<T>::New(Isolate* isolate, const Persistent<T, M>& that) { | |
| 5630 return New(isolate, that.val_); | 5787 return New(isolate, that.val_); |
| 5631 } | 5788 } |
| 5632 | 5789 |
| 5633 template <class T> | 5790 template <class T> |
| 5634 Handle<T> Handle<T>::New(Isolate* isolate, T* that) { | 5791 Handle<T> Handle<T>::New(Isolate* isolate, T* that) { |
| 5635 if (that == NULL) return Handle<T>(); | 5792 if (that == NULL) return Handle<T>(); |
| 5636 T* that_ptr = that; | 5793 T* that_ptr = that; |
| 5637 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | 5794 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); |
| 5638 return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( | 5795 return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( |
| 5639 reinterpret_cast<internal::Isolate*>(isolate), *p))); | 5796 reinterpret_cast<internal::Isolate*>(isolate), *p))); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5657 V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_); | 5814 V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_); |
| 5658 } | 5815 } |
| 5659 | 5816 |
| 5660 | 5817 |
| 5661 template<class T> | 5818 template<class T> |
| 5662 Local<T> Eternal<T>::Get(Isolate* isolate) { | 5819 Local<T> Eternal<T>::Get(Isolate* isolate) { |
| 5663 return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_))); | 5820 return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_))); |
| 5664 } | 5821 } |
| 5665 | 5822 |
| 5666 | 5823 |
| 5667 template <class T, class M> | 5824 template <class T> |
| 5668 T* Persistent<T, M>::New(Isolate* isolate, T* that) { | 5825 T* PersistentBase<T>::New(Isolate* isolate, T* that) { |
| 5669 if (that == NULL) return NULL; | 5826 if (that == NULL) return NULL; |
| 5670 internal::Object** p = reinterpret_cast<internal::Object**>(that); | 5827 internal::Object** p = reinterpret_cast<internal::Object**>(that); |
| 5671 return reinterpret_cast<T*>( | 5828 return reinterpret_cast<T*>( |
| 5672 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), | 5829 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), |
| 5673 p)); | 5830 p)); |
| 5674 } | 5831 } |
| 5675 | 5832 |
| 5676 | 5833 |
| 5677 template <class T, class M> | 5834 template <class T, class M> |
| 5678 template <class S, class M2> | 5835 template <class S, class M2> |
| 5679 void Persistent<T, M>::Copy(const Persistent<S, M2>& that) { | 5836 void Persistent<T, M>::Copy(const Persistent<S, M2>& that) { |
| 5680 TYPE_CHECK(T, S); | 5837 TYPE_CHECK(T, S); |
| 5681 Reset(); | 5838 this->Reset(); |
| 5682 if (that.IsEmpty()) return; | 5839 if (that.IsEmpty()) return; |
| 5683 internal::Object** p = reinterpret_cast<internal::Object**>(that.val_); | 5840 internal::Object** p = reinterpret_cast<internal::Object**>(that.val_); |
| 5684 this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p)); | 5841 this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p)); |
| 5685 M::Copy(that, this); | 5842 M::Copy(that, this); |
| 5686 } | 5843 } |
| 5687 | 5844 |
| 5688 | 5845 |
| 5689 template <class T, class M> | 5846 template <class T> |
| 5690 bool Persistent<T, M>::IsIndependent() const { | 5847 bool PersistentBase<T>::IsIndependent() const { |
| 5691 typedef internal::Internals I; | 5848 typedef internal::Internals I; |
| 5692 if (this->IsEmpty()) return false; | 5849 if (this->IsEmpty()) return false; |
| 5693 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_), | 5850 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_), |
| 5694 I::kNodeIsIndependentShift); | 5851 I::kNodeIsIndependentShift); |
| 5695 } | 5852 } |
| 5696 | 5853 |
| 5697 | 5854 |
| 5698 template <class T, class M> | 5855 template <class T> |
| 5699 bool Persistent<T, M>::IsNearDeath() const { | 5856 bool PersistentBase<T>::IsNearDeath() const { |
| 5700 typedef internal::Internals I; | 5857 typedef internal::Internals I; |
| 5701 if (this->IsEmpty()) return false; | 5858 if (this->IsEmpty()) return false; |
| 5702 uint8_t node_state = | 5859 uint8_t node_state = |
| 5703 I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)); | 5860 I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)); |
| 5704 return node_state == I::kNodeStateIsNearDeathValue || | 5861 return node_state == I::kNodeStateIsNearDeathValue || |
| 5705 node_state == I::kNodeStateIsPendingValue; | 5862 node_state == I::kNodeStateIsPendingValue; |
| 5706 } | 5863 } |
| 5707 | 5864 |
| 5708 | 5865 |
| 5709 template <class T, class M> | 5866 template <class T> |
| 5710 bool Persistent<T, M>::IsWeak() const { | 5867 bool PersistentBase<T>::IsWeak() const { |
| 5711 typedef internal::Internals I; | 5868 typedef internal::Internals I; |
| 5712 if (this->IsEmpty()) return false; | 5869 if (this->IsEmpty()) return false; |
| 5713 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) == | 5870 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) == |
| 5714 I::kNodeStateIsWeakValue; | 5871 I::kNodeStateIsWeakValue; |
| 5715 } | 5872 } |
| 5716 | 5873 |
| 5717 | 5874 |
| 5718 template <class T, class M> | 5875 template <class T> |
| 5719 void Persistent<T, M>::Reset() { | 5876 void PersistentBase<T>::Reset() { |
| 5720 if (this->IsEmpty()) return; | 5877 if (this->IsEmpty()) return; |
| 5721 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_)); | 5878 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_)); |
| 5722 val_ = 0; | 5879 val_ = 0; |
| 5723 } | 5880 } |
| 5724 | 5881 |
| 5725 | 5882 |
| 5726 template <class T, class M> | 5883 template <class T> |
| 5727 template <class S> | 5884 template <class S> |
| 5728 void Persistent<T, M>::Reset(Isolate* isolate, const Handle<S>& other) { | 5885 void PersistentBase<T>::Reset(Isolate* isolate, const Handle<S>& other) { |
| 5729 TYPE_CHECK(T, S); | 5886 TYPE_CHECK(T, S); |
| 5730 Reset(); | 5887 Reset(); |
| 5731 if (other.IsEmpty()) return; | 5888 if (other.IsEmpty()) return; |
| 5732 this->val_ = New(isolate, other.val_); | 5889 this->val_ = New(isolate, other.val_); |
| 5733 } | 5890 } |
| 5734 | 5891 |
| 5735 | 5892 |
| 5736 template <class T, class M> | 5893 template <class T> |
| 5737 template <class S, class M2> | 5894 template <class S> |
| 5738 void Persistent<T, M>::Reset(Isolate* isolate, | 5895 void PersistentBase<T>::Reset(Isolate* isolate, |
| 5739 const Persistent<S, M2>& other) { | 5896 const PersistentBase<S>& other) { |
| 5740 TYPE_CHECK(T, S); | 5897 TYPE_CHECK(T, S); |
| 5741 Reset(); | 5898 Reset(); |
| 5742 if (other.IsEmpty()) return; | 5899 if (other.IsEmpty()) return; |
| 5743 this->val_ = New(isolate, other.val_); | 5900 this->val_ = New(isolate, other.val_); |
| 5744 } | 5901 } |
| 5745 | 5902 |
| 5746 | 5903 |
| 5747 template <class T, class M> | 5904 template <class T> |
| 5748 template <typename S, typename P> | 5905 template <typename S, typename P> |
| 5749 void Persistent<T, M>::SetWeak( | 5906 void PersistentBase<T>::SetWeak( |
| 5750 P* parameter, | 5907 P* parameter, |
| 5751 typename WeakCallbackData<S, P>::Callback callback) { | 5908 typename WeakCallbackData<S, P>::Callback callback) { |
| 5752 TYPE_CHECK(S, T); | 5909 TYPE_CHECK(S, T); |
| 5753 typedef typename WeakCallbackData<Value, void>::Callback Callback; | 5910 typedef typename WeakCallbackData<Value, void>::Callback Callback; |
| 5754 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), | 5911 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), |
| 5755 parameter, | 5912 parameter, |
| 5756 reinterpret_cast<Callback>(callback), | 5913 reinterpret_cast<Callback>(callback), |
| 5757 NULL); | 5914 NULL); |
| 5758 } | 5915 } |
| 5759 | 5916 |
| 5760 | 5917 |
| 5761 template <class T, class M> | 5918 template <class T> |
| 5762 template <typename P> | 5919 template <typename P> |
| 5763 void Persistent<T, M>::SetWeak( | 5920 void PersistentBase<T>::SetWeak( |
| 5764 P* parameter, | 5921 P* parameter, |
| 5765 typename WeakCallbackData<T, P>::Callback callback) { | 5922 typename WeakCallbackData<T, P>::Callback callback) { |
| 5766 SetWeak<T, P>(parameter, callback); | 5923 SetWeak<T, P>(parameter, callback); |
| 5767 } | 5924 } |
| 5768 | 5925 |
| 5769 | 5926 |
| 5770 template <class T, class M> | 5927 template <class T, class M> |
| 5771 template <typename S, typename P> | 5928 template <typename S, typename P> |
| 5772 void Persistent<T, M>::MakeWeak( | 5929 void Persistent<T, M>::MakeWeak( |
| 5773 P* parameters, | 5930 P* parameters, |
| 5774 typename WeakReferenceCallbacks<S, P>::Revivable callback) { | 5931 typename WeakReferenceCallbacks<S, P>::Revivable callback) { |
| 5775 TYPE_CHECK(S, T); | 5932 TYPE_CHECK(S, T); |
| 5776 typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable; | 5933 typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable; |
| 5777 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), | 5934 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), |
| 5778 parameters, | 5935 parameters, |
| 5779 NULL, | 5936 NULL, |
| 5780 reinterpret_cast<Revivable>(callback)); | 5937 reinterpret_cast<Revivable>(callback)); |
| 5781 } | 5938 } |
| 5782 | 5939 |
| 5783 | 5940 |
| 5784 template <class T, class M> | 5941 template <class T, class M> |
| 5785 template <typename P> | 5942 template <typename P> |
| 5786 void Persistent<T, M>::MakeWeak( | 5943 void Persistent<T, M>::MakeWeak( |
| 5787 P* parameters, | 5944 P* parameters, |
| 5788 typename WeakReferenceCallbacks<T, P>::Revivable callback) { | 5945 typename WeakReferenceCallbacks<T, P>::Revivable callback) { |
| 5789 MakeWeak<T, P>(parameters, callback); | 5946 MakeWeak<T, P>(parameters, callback); |
| 5790 } | 5947 } |
| 5791 | 5948 |
| 5792 | 5949 |
| 5793 template <class T, class M> | 5950 template <class T> |
| 5794 void Persistent<T, M>::ClearWeak() { | 5951 void PersistentBase<T>::ClearWeak() { |
| 5795 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); | 5952 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); |
| 5796 } | 5953 } |
| 5797 | 5954 |
| 5798 | 5955 |
| 5799 template <class T, class M> | 5956 template <class T> |
| 5800 void Persistent<T, M>::MarkIndependent() { | 5957 void PersistentBase<T>::MarkIndependent() { |
| 5801 typedef internal::Internals I; | 5958 typedef internal::Internals I; |
| 5802 if (this->IsEmpty()) return; | 5959 if (this->IsEmpty()) return; |
| 5803 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), | 5960 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), |
| 5804 true, | 5961 true, |
| 5805 I::kNodeIsIndependentShift); | 5962 I::kNodeIsIndependentShift); |
| 5806 } | 5963 } |
| 5807 | 5964 |
| 5808 | 5965 |
| 5809 template <class T, class M> | 5966 template <class T> |
| 5810 void Persistent<T, M>::MarkPartiallyDependent() { | 5967 void PersistentBase<T>::MarkPartiallyDependent() { |
| 5811 typedef internal::Internals I; | 5968 typedef internal::Internals I; |
| 5812 if (this->IsEmpty()) return; | 5969 if (this->IsEmpty()) return; |
| 5813 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), | 5970 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), |
| 5814 true, | 5971 true, |
| 5815 I::kNodeIsPartiallyDependentShift); | 5972 I::kNodeIsPartiallyDependentShift); |
| 5816 } | 5973 } |
| 5817 | 5974 |
| 5818 | 5975 |
| 5819 template <class T, class M> | 5976 template <class T, class M> |
| 5820 T* Persistent<T, M>::ClearAndLeak() { | 5977 T* Persistent<T, M>::ClearAndLeak() { |
| 5821 T* old; | 5978 T* old; |
| 5822 old = val_; | 5979 old = this->val_; |
| 5823 val_ = NULL; | 5980 this->val_ = NULL; |
| 5824 return old; | 5981 return old; |
| 5825 } | 5982 } |
| 5826 | 5983 |
| 5827 | 5984 |
| 5828 template <class T, class M> | 5985 template <class T> |
| 5829 void Persistent<T, M>::SetWrapperClassId(uint16_t class_id) { | 5986 void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) { |
| 5830 typedef internal::Internals I; | 5987 typedef internal::Internals I; |
| 5831 if (this->IsEmpty()) return; | 5988 if (this->IsEmpty()) return; |
| 5832 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); | 5989 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); |
| 5833 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; | 5990 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; |
| 5834 *reinterpret_cast<uint16_t*>(addr) = class_id; | 5991 *reinterpret_cast<uint16_t*>(addr) = class_id; |
| 5835 } | 5992 } |
| 5836 | 5993 |
| 5837 | 5994 |
| 5838 template <class T, class M> | 5995 template <class T> |
| 5839 uint16_t Persistent<T, M>::WrapperClassId() const { | 5996 uint16_t PersistentBase<T>::WrapperClassId() const { |
| 5840 typedef internal::Internals I; | 5997 typedef internal::Internals I; |
| 5841 if (this->IsEmpty()) return 0; | 5998 if (this->IsEmpty()) return 0; |
| 5842 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); | 5999 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); |
| 5843 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; | 6000 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; |
| 5844 return *reinterpret_cast<uint16_t*>(addr); | 6001 return *reinterpret_cast<uint16_t*>(addr); |
| 5845 } | 6002 } |
| 5846 | 6003 |
| 5847 | 6004 |
| 5848 template<typename T> | 6005 template<typename T> |
| 5849 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} | 6006 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6033 | 6190 |
| 6034 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { | 6191 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { |
| 6035 return resource_column_offset_; | 6192 return resource_column_offset_; |
| 6036 } | 6193 } |
| 6037 | 6194 |
| 6038 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const { | 6195 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const { |
| 6039 return resource_is_shared_cross_origin_; | 6196 return resource_is_shared_cross_origin_; |
| 6040 } | 6197 } |
| 6041 | 6198 |
| 6042 | 6199 |
| 6200 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) { |
| 6201 return value ? True(isolate) : False(isolate); |
| 6202 } |
| 6203 |
| 6204 |
| 6043 Handle<Boolean> Boolean::New(bool value) { | 6205 Handle<Boolean> Boolean::New(bool value) { |
| 6044 Isolate* isolate = Isolate::GetCurrent(); | 6206 return Boolean::New(Isolate::GetCurrent(), value); |
| 6045 return value ? True(isolate) : False(isolate); | 6207 } |
| 6208 |
| 6209 |
| 6210 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) { |
| 6211 Set(v8::String::NewFromUtf8(isolate, name), value); |
| 6046 } | 6212 } |
| 6047 | 6213 |
| 6048 | 6214 |
| 6049 void Template::Set(const char* name, v8::Handle<Data> value) { | 6215 void Template::Set(const char* name, v8::Handle<Data> value) { |
| 6050 Set(v8::String::NewFromUtf8(Isolate::GetCurrent(), name), value); | 6216 Set(Isolate::GetCurrent(), name, value); |
| 6051 } | 6217 } |
| 6052 | 6218 |
| 6053 | 6219 |
| 6054 Local<Value> Object::GetInternalField(int index) { | 6220 Local<Value> Object::GetInternalField(int index) { |
| 6055 #ifndef V8_ENABLE_CHECKS | 6221 #ifndef V8_ENABLE_CHECKS |
| 6056 typedef internal::Object O; | 6222 typedef internal::Object O; |
| 6057 typedef internal::HeapObject HO; | 6223 typedef internal::HeapObject HO; |
| 6058 typedef internal::Internals I; | 6224 typedef internal::Internals I; |
| 6059 O* obj = *reinterpret_cast<O**>(this); | 6225 O* obj = *reinterpret_cast<O**>(this); |
| 6060 // Fast path: If the object is a plain JSObject, which is the common case, we | 6226 // Fast path: If the object is a plain JSObject, which is the common case, we |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6593 */ | 6759 */ |
| 6594 | 6760 |
| 6595 | 6761 |
| 6596 } // namespace v8 | 6762 } // namespace v8 |
| 6597 | 6763 |
| 6598 | 6764 |
| 6599 #undef TYPE_CHECK | 6765 #undef TYPE_CHECK |
| 6600 | 6766 |
| 6601 | 6767 |
| 6602 #endif // V8_H_ | 6768 #endif // V8_H_ |
| OLD | NEW |