| v8.h | | v8.h | |
| | | | |
| skipping to change at line 79 | | skipping to change at line 79 | |
| #define V8EXPORT __attribute__ ((visibility("default"))) | | #define V8EXPORT __attribute__ ((visibility("default"))) | |
| #else | | #else | |
| #define V8EXPORT | | #define V8EXPORT | |
| #endif | | #endif | |
| #else | | #else | |
| #define V8EXPORT | | #define V8EXPORT | |
| #endif | | #endif | |
| | | | |
| #endif // _WIN32 | | #endif // _WIN32 | |
| | | | |
|
| | | #if defined(__GNUC__) && !defined(DEBUG) | |
| | | #define V8_INLINE(declarator) inline __attribute__((always_inline)) declara | |
| | | tor | |
| | | #elif defined(_MSC_VER) && !defined(DEBUG) | |
| | | #define V8_INLINE(declarator) __forceinline declarator | |
| | | #else | |
| | | #define V8_INLINE(declarator) inline declarator | |
| | | #endif | |
| | | | |
| #if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS | | #if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS | |
|
| #define V8_DEPRECATED(func) func __attribute__ ((deprecated)) | | #define V8_DEPRECATED(declarator) declarator __attribute__ ((deprecated)) | |
| #elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS | | #elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS | |
|
| #define V8_DEPRECATED(func) __declspec(deprecated) func | | #define V8_DEPRECATED(declarator) __declspec(deprecated) declarator | |
| #else | | #else | |
|
| #define V8_DEPRECATED(func) func | | #define V8_DEPRECATED(declarator) declarator | |
| #endif | | #endif | |
| | | | |
| /** | | /** | |
| * The v8 JavaScript engine. | | * The v8 JavaScript engine. | |
| */ | | */ | |
| namespace v8 { | | namespace v8 { | |
| | | | |
| class Context; | | class Context; | |
| class String; | | class String; | |
| class StringObject; | | class StringObject; | |
| | | | |
| skipping to change at line 184 | | skipping to change at line 192 | |
| * dereferencing the handle (for instance, to extract the Object* from | | * dereferencing the handle (for instance, to extract the Object* from | |
| * a Handle<Object>); the value will still be governed by a handle | | * a Handle<Object>); the value will still be governed by a handle | |
| * behind the scenes and the same rules apply to these values as to | | * behind the scenes and the same rules apply to these values as to | |
| * their handles. | | * their handles. | |
| */ | | */ | |
| template <class T> class Handle { | | template <class T> class Handle { | |
| public: | | public: | |
| /** | | /** | |
| * Creates an empty handle. | | * Creates an empty handle. | |
| */ | | */ | |
|
| inline Handle() : val_(0) {} | | V8_INLINE(Handle()) : val_(0) {} | |
| | | | |
| /** | | /** | |
| * Creates a new handle for the specified value. | | * Creates a new handle for the specified value. | |
| */ | | */ | |
|
| inline explicit Handle(T* val) : val_(val) {} | | V8_INLINE(explicit Handle(T* val)) : val_(val) {} | |
| | | | |
| /** | | /** | |
| * Creates a handle for the contents of the specified handle. This | | * Creates a handle for the contents of the specified handle. This | |
| * constructor allows you to pass handles as arguments by value and | | * constructor allows you to pass handles as arguments by value and | |
| * to assign between handles. However, if you try to assign between | | * to assign between handles. However, if you try to assign between | |
| * incompatible handles, for instance from a Handle<String> to a | | * incompatible handles, for instance from a Handle<String> to a | |
| * Handle<Number> it will cause a compile-time error. Assigning | | * Handle<Number> it will cause a compile-time error. Assigning | |
| * between compatible handles, for instance assigning a | | * between compatible handles, for instance assigning a | |
| * Handle<String> to a variable declared as Handle<Value>, is legal | | * Handle<String> to a variable declared as Handle<Value>, is legal | |
| * because String is a subclass of Value. | | * because String is a subclass of Value. | |
| */ | | */ | |
|
| template <class S> inline Handle(Handle<S> that) | | template <class S> V8_INLINE(Handle(Handle<S> that)) | |
| : val_(reinterpret_cast<T*>(*that)) { | | : val_(reinterpret_cast<T*>(*that)) { | |
| /** | | /** | |
| * This check fails when trying to convert between incompatible | | * This check fails when trying to convert between incompatible | |
| * handles. For example, converting from a Handle<String> to a | | * handles. For example, converting from a Handle<String> to a | |
| * Handle<Number>. | | * Handle<Number>. | |
| */ | | */ | |
| TYPE_CHECK(T, S); | | TYPE_CHECK(T, S); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Returns true if the handle is empty. | | * Returns true if the handle is empty. | |
| */ | | */ | |
|
| inline bool IsEmpty() const { return val_ == 0; } | | V8_INLINE(bool IsEmpty() const) { return val_ == 0; } | |
| | | | |
| /** | | /** | |
| * Sets the handle to be empty. IsEmpty() will then return true. | | * Sets the handle to be empty. IsEmpty() will then return true. | |
| */ | | */ | |
|
| inline void Clear() { val_ = 0; } | | V8_INLINE(void Clear()) { val_ = 0; } | |
| | | | |
|
| inline T* operator->() const { return val_; } | | V8_INLINE(T* operator->() const) { return val_; } | |
| | | | |
|
| inline T* operator*() const { return val_; } | | V8_INLINE(T* operator*() const) { return val_; } | |
| | | | |
| /** | | /** | |
| * Checks whether two handles are the same. | | * Checks whether two handles are the same. | |
| * Returns true if both are empty, or if the objects | | * Returns true if both are empty, or if the objects | |
| * to which they refer are identical. | | * to which they refer are identical. | |
| * The handles' references are not checked. | | * The handles' references are not checked. | |
| */ | | */ | |
|
| template <class S> inline bool operator==(Handle<S> that) const { | | template <class S> V8_INLINE(bool operator==(Handle<S> that) const) { | |
| internal::Object** a = reinterpret_cast<internal::Object**>(**this); | | internal::Object** a = reinterpret_cast<internal::Object**>(**this); | |
| internal::Object** b = reinterpret_cast<internal::Object**>(*that); | | internal::Object** b = reinterpret_cast<internal::Object**>(*that); | |
| if (a == 0) return b == 0; | | if (a == 0) return b == 0; | |
| if (b == 0) return false; | | if (b == 0) return false; | |
| return *a == *b; | | return *a == *b; | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Checks whether two handles are different. | | * Checks whether two handles are different. | |
| * Returns true if only one of the handles is empty, or if | | * Returns true if only one of the handles is empty, or if | |
| * the objects to which they refer are different. | | * the objects to which they refer are different. | |
| * The handles' references are not checked. | | * The handles' references are not checked. | |
| */ | | */ | |
|
| template <class S> inline bool operator!=(Handle<S> that) const { | | template <class S> V8_INLINE(bool operator!=(Handle<S> that) const) { | |
| return !operator==(that); | | return !operator==(that); | |
| } | | } | |
| | | | |
|
| template <class S> static inline Handle<T> Cast(Handle<S> that) { | | template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) { | |
| #ifdef V8_ENABLE_CHECKS | | #ifdef V8_ENABLE_CHECKS | |
| // If we're going to perform the type check then we have to check | | // If we're going to perform the type check then we have to check | |
| // that the handle isn't empty before doing the checked cast. | | // that the handle isn't empty before doing the checked cast. | |
| if (that.IsEmpty()) return Handle<T>(); | | if (that.IsEmpty()) return Handle<T>(); | |
| #endif | | #endif | |
| return Handle<T>(T::Cast(*that)); | | return Handle<T>(T::Cast(*that)); | |
| } | | } | |
| | | | |
|
| template <class S> inline Handle<S> As() { | | template <class S> V8_INLINE(Handle<S> As()) { | |
| return Handle<S>::Cast(*this); | | return Handle<S>::Cast(*this); | |
| } | | } | |
| | | | |
| private: | | private: | |
| T* val_; | | T* val_; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A light-weight stack-allocated object handle. All operations | | * A light-weight stack-allocated object handle. All operations | |
| * that return objects from within v8 return them in local handles. They | | * that return objects from within v8 return them in local handles. They | |
| * are created within HandleScopes, and all local handles allocated within
a | | * are created within HandleScopes, and all local handles allocated within
a | |
| * handle scope are destroyed when the handle scope is destroyed. Hence it | | * handle scope are destroyed when the handle scope is destroyed. Hence it | |
| * is not necessary to explicitly deallocate local handles. | | * is not necessary to explicitly deallocate local handles. | |
| */ | | */ | |
| template <class T> class Local : public Handle<T> { | | template <class T> class Local : public Handle<T> { | |
| public: | | public: | |
|
| inline Local(); | | V8_INLINE(Local()); | |
| template <class S> inline Local(Local<S> that) | | template <class S> V8_INLINE(Local(Local<S> that)) | |
| : Handle<T>(reinterpret_cast<T*>(*that)) { | | : Handle<T>(reinterpret_cast<T*>(*that)) { | |
| /** | | /** | |
| * This check fails when trying to convert between incompatible | | * This check fails when trying to convert between incompatible | |
| * handles. For example, converting from a Handle<String> to a | | * handles. For example, converting from a Handle<String> to a | |
| * Handle<Number>. | | * Handle<Number>. | |
| */ | | */ | |
| TYPE_CHECK(T, S); | | TYPE_CHECK(T, S); | |
| } | | } | |
|
| template <class S> inline Local(S* that) : Handle<T>(that) { } | | template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { } | |
| template <class S> static inline Local<T> Cast(Local<S> that) { | | template <class S> V8_INLINE(static Local<T> Cast(Local<S> that)) { | |
| #ifdef V8_ENABLE_CHECKS | | #ifdef V8_ENABLE_CHECKS | |
| // If we're going to perform the type check then we have to check | | // If we're going to perform the type check then we have to check | |
| // that the handle isn't empty before doing the checked cast. | | // that the handle isn't empty before doing the checked cast. | |
| if (that.IsEmpty()) return Local<T>(); | | if (that.IsEmpty()) return Local<T>(); | |
| #endif | | #endif | |
| return Local<T>(T::Cast(*that)); | | return Local<T>(T::Cast(*that)); | |
| } | | } | |
| | | | |
|
| template <class S> inline Local<S> As() { | | template <class S> V8_INLINE(Local<S> As()) { | |
| return Local<S>::Cast(*this); | | return Local<S>::Cast(*this); | |
| } | | } | |
| | | | |
|
| /** Create a local handle for the content of another handle. | | /** | |
| * The referee is kept alive by the local handle even when | | * Create a local handle for the content of another handle. | |
| * the original handle is destroyed/disposed. | | * The referee is kept alive by the local handle even when | |
| | | * the original handle is destroyed/disposed. | |
| */ | | */ | |
|
| inline static Local<T> New(Handle<T> that); | | V8_INLINE(static Local<T> New(Handle<T> that)); | |
| | | V8_INLINE(static Local<T> New(Isolate* isolate, Handle<T> that)); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * An object reference that is independent of any handle scope. Where | | * An object reference that is independent of any handle scope. Where | |
| * a Local handle only lives as long as the HandleScope in which it was | | * a Local handle only lives as long as the HandleScope in which it was | |
| * allocated, a Persistent handle remains valid until it is explicitly | | * allocated, a Persistent handle remains valid until it is explicitly | |
| * disposed. | | * disposed. | |
| * | | * | |
| * A persistent handle contains a reference to a storage cell within | | * A persistent handle contains a reference to a storage cell within | |
| * the v8 engine which holds an object value and which is updated by | | * the v8 engine which holds an object value and which is updated by | |
| | | | |
| skipping to change at line 329 | | skipping to change at line 339 | |
| * persistent handle as an argument to a function you will not get two | | * persistent handle as an argument to a function you will not get two | |
| * different storage cells but rather two references to the same | | * different storage cells but rather two references to the same | |
| * storage cell. | | * storage cell. | |
| */ | | */ | |
| template <class T> class Persistent : public Handle<T> { | | template <class T> class Persistent : public Handle<T> { | |
| public: | | public: | |
| /** | | /** | |
| * Creates an empty persistent handle that doesn't point to any | | * Creates an empty persistent handle that doesn't point to any | |
| * storage cell. | | * storage cell. | |
| */ | | */ | |
|
| inline Persistent(); | | V8_INLINE(Persistent()); | |
| | | | |
| /** | | /** | |
| * Creates a persistent handle for the same storage cell as the | | * Creates a persistent handle for the same storage cell as the | |
| * specified handle. This constructor allows you to pass persistent | | * specified handle. This constructor allows you to pass persistent | |
| * handles as arguments by value and to assign between persistent | | * handles as arguments by value and to assign between persistent | |
| * handles. However, attempting to assign between incompatible | | * handles. However, attempting to assign between incompatible | |
| * persistent handles, for instance from a Persistent<String> to a | | * persistent handles, for instance from a Persistent<String> to a | |
| * Persistent<Number> will cause a compile-time error. Assigning | | * Persistent<Number> will cause a compile-time error. Assigning | |
| * between compatible persistent handles, for instance assigning a | | * between compatible persistent handles, for instance assigning a | |
| * Persistent<String> to a variable declared as Persistent<Value>, | | * Persistent<String> to a variable declared as Persistent<Value>, | |
| * is allowed as String is a subclass of Value. | | * is allowed as String is a subclass of Value. | |
| */ | | */ | |
|
| template <class S> inline Persistent(Persistent<S> that) | | template <class S> V8_INLINE(Persistent(Persistent<S> that)) | |
| : Handle<T>(reinterpret_cast<T*>(*that)) { | | : Handle<T>(reinterpret_cast<T*>(*that)) { | |
| /** | | /** | |
| * This check fails when trying to convert between incompatible | | * This check fails when trying to convert between incompatible | |
| * handles. For example, converting from a Handle<String> to a | | * handles. For example, converting from a Handle<String> to a | |
| * Handle<Number>. | | * Handle<Number>. | |
| */ | | */ | |
| TYPE_CHECK(T, S); | | TYPE_CHECK(T, S); | |
| } | | } | |
| | | | |
|
| template <class S> inline Persistent(S* that) : Handle<T>(that) { } | | template <class S> V8_INLINE(Persistent(S* that)) : Handle<T>(that) { } | |
| | | | |
| /** | | /** | |
| * "Casts" a plain handle which is known to be a persistent handle | | * "Casts" a plain handle which is known to be a persistent handle | |
| * to a persistent handle. | | * to a persistent handle. | |
| */ | | */ | |
|
| template <class S> explicit inline Persistent(Handle<S> that) | | template <class S> explicit V8_INLINE(Persistent(Handle<S> that)) | |
| : Handle<T>(*that) { } | | : Handle<T>(*that) { } | |
| | | | |
|
| template <class S> static inline Persistent<T> Cast(Persistent<S> that) { | | template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that
)) { | |
| #ifdef V8_ENABLE_CHECKS | | #ifdef V8_ENABLE_CHECKS | |
| // If we're going to perform the type check then we have to check | | // If we're going to perform the type check then we have to check | |
| // that the handle isn't empty before doing the checked cast. | | // that the handle isn't empty before doing the checked cast. | |
| if (that.IsEmpty()) return Persistent<T>(); | | if (that.IsEmpty()) return Persistent<T>(); | |
| #endif | | #endif | |
| return Persistent<T>(T::Cast(*that)); | | return Persistent<T>(T::Cast(*that)); | |
| } | | } | |
| | | | |
|
| template <class S> inline Persistent<S> As() { | | template <class S> V8_INLINE(Persistent<S> As()) { | |
| return Persistent<S>::Cast(*this); | | return Persistent<S>::Cast(*this); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Creates a new persistent handle for an existing local or | | * Creates a new persistent handle for an existing local or | |
| * persistent handle. | | * persistent handle. | |
| */ | | */ | |
|
| inline static Persistent<T> New(Handle<T> that); | | V8_INLINE(static Persistent<T> New(Handle<T> that)); | |
| | | | |
| /** | | /** | |
| * Releases the storage cell referenced by this persistent handle. | | * Releases the storage cell referenced by this persistent handle. | |
| * Does not remove the reference to the cell from any handles. | | * Does not remove the reference to the cell from any handles. | |
| * This handle's reference, and any other references to the storage | | * This handle's reference, and any other references to the storage | |
| * cell remain and IsEmpty will still return false. | | * cell remain and IsEmpty will still return false. | |
| */ | | */ | |
|
| inline void Dispose(); | | V8_INLINE(void Dispose()); | |
| inline void Dispose(Isolate* isolate); | | V8_INLINE(void Dispose(Isolate* isolate)); | |
| | | | |
| /** | | /** | |
| * Make the reference to this object weak. When only weak handles | | * Make the reference to this object weak. When only weak handles | |
| * refer to the object, the garbage collector will perform a | | * refer to the object, the garbage collector will perform a | |
| * callback to the given V8::WeakReferenceCallback function, passing | | * callback to the given V8::WeakReferenceCallback function, passing | |
| * it the object reference and the given parameters. | | * it the object reference and the given parameters. | |
| */ | | */ | |
|
| inline void MakeWeak(void* parameters, WeakReferenceCallback callback); | | V8_INLINE(void MakeWeak(void* parameters, WeakReferenceCallback callback) | |
| | | ); | |
| | | V8_INLINE(void MakeWeak(Isolate* isolate, | |
| | | void* parameters, | |
| | | WeakReferenceCallback callback)); | |
| | | | |
| /** Clears the weak reference to this object. */ | | /** Clears the weak reference to this object. */ | |
|
| inline void ClearWeak(); | | V8_INLINE(void ClearWeak()); | |
| | | | |
| /** | | /** | |
| * Marks the reference to this object independent. Garbage collector | | * Marks the reference to this object independent. Garbage collector | |
| * is free to ignore any object groups containing this object. | | * is free to ignore any object groups containing this object. | |
| * Weak callback for an independent handle should not | | * Weak callback for an independent handle should not | |
| * assume that it will be preceded by a global GC prologue callback | | * assume that it will be preceded by a global GC prologue callback | |
| * or followed by a global GC epilogue callback. | | * or followed by a global GC epilogue callback. | |
| */ | | */ | |
|
| inline void MarkIndependent(); | | V8_INLINE(void MarkIndependent()); | |
| inline void MarkIndependent(Isolate* isolate); | | V8_INLINE(void MarkIndependent(Isolate* isolate)); | |
| | | | |
| /** | | /** | |
| * Marks the reference to this object partially dependent. Partially | | * Marks the reference to this object partially dependent. Partially | |
| * dependent handles only depend on other partially dependent handles and | | * dependent handles only depend on other partially dependent handles and | |
| * these dependencies are provided through object groups. It provides a w
ay | | * these dependencies are provided through object groups. It provides a w
ay | |
| * to build smaller object groups for young objects that represent only a | | * to build smaller object groups for young objects that represent only a | |
| * subset of all external dependencies. This mark is automatically cleare
d | | * subset of all external dependencies. This mark is automatically cleare
d | |
| * after each garbage collection. | | * after each garbage collection. | |
| */ | | */ | |
|
| inline void MarkPartiallyDependent(); | | V8_INLINE(void MarkPartiallyDependent()); | |
| inline void MarkPartiallyDependent(Isolate* isolate); | | V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)); | |
| | | | |
| /** Returns true if this handle was previously marked as independent. */ | | /** Returns true if this handle was previously marked as independent. */ | |
|
| inline bool IsIndependent() const; | | V8_INLINE(bool IsIndependent() const); | |
| inline bool IsIndependent(Isolate* isolate) const; | | V8_INLINE(bool IsIndependent(Isolate* isolate) const); | |
| | | | |
| /** Checks if the handle holds the only reference to an object. */ | | /** Checks if the handle holds the only reference to an object. */ | |
|
| inline bool IsNearDeath() const; | | V8_INLINE(bool IsNearDeath() const); | |
| | | | |
| /** Returns true if the handle's reference is weak. */ | | /** Returns true if the handle's reference is weak. */ | |
|
| inline bool IsWeak() const; | | V8_INLINE(bool IsWeak() const); | |
| | | V8_INLINE(bool IsWeak(Isolate* isolate) const); | |
| | | | |
| /** | | /** | |
| * Assigns a wrapper class ID to the handle. See RetainedObjectInfo | | * Assigns a wrapper class ID to the handle. See RetainedObjectInfo | |
| * interface description in v8-profiler.h for details. | | * interface description in v8-profiler.h for details. | |
| */ | | */ | |
|
| inline void SetWrapperClassId(uint16_t class_id); | | V8_INLINE(void SetWrapperClassId(uint16_t class_id)); | |
| | | | |
| /** | | /** | |
| * Returns the class ID previously assigned to this handle or 0 if no cla
ss | | * Returns the class ID previously assigned to this handle or 0 if no cla
ss | |
| * ID was previously assigned. | | * ID was previously assigned. | |
| */ | | */ | |
|
| inline uint16_t WrapperClassId() const; | | V8_INLINE(uint16_t WrapperClassId() const); | |
| | | | |
| private: | | private: | |
| friend class ImplementationUtilities; | | friend class ImplementationUtilities; | |
| friend class ObjectTemplate; | | friend class ObjectTemplate; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A stack-allocated class that governs a number of local handles. | | * A stack-allocated class that governs a number of local handles. | |
| * After a handle scope has been created, all local handles will be | | * After a handle scope has been created, all local handles will be | |
| * allocated within that handle scope until either the handle scope is | | * allocated within that handle scope until either the handle scope is | |
| | | | |
| skipping to change at line 483 | | skipping to change at line 497 | |
| | | | |
| /** | | /** | |
| * Counts the number of allocated handles. | | * Counts the number of allocated handles. | |
| */ | | */ | |
| static int NumberOfHandles(); | | static int NumberOfHandles(); | |
| | | | |
| /** | | /** | |
| * Creates a new handle with the given value. | | * Creates a new handle with the given value. | |
| */ | | */ | |
| static internal::Object** CreateHandle(internal::Object* value); | | static internal::Object** CreateHandle(internal::Object* value); | |
|
| | | static internal::Object** CreateHandle(internal::Isolate* isolate, | |
| | | internal::Object* value); | |
| // Faster version, uses HeapObject to obtain the current Isolate. | | // Faster version, uses HeapObject to obtain the current Isolate. | |
| static internal::Object** CreateHandle(internal::HeapObject* value); | | static internal::Object** CreateHandle(internal::HeapObject* value); | |
| | | | |
| private: | | private: | |
| // Make it hard to create heap-allocated or illegal handle scopes by | | // Make it hard to create heap-allocated or illegal handle scopes by | |
| // disallowing certain operations. | | // disallowing certain operations. | |
| HandleScope(const HandleScope&); | | HandleScope(const HandleScope&); | |
| void operator=(const HandleScope&); | | void operator=(const HandleScope&); | |
| void* operator new(size_t size); | | void* operator new(size_t size); | |
| void operator delete(void*, size_t); | | void operator delete(void*, size_t); | |
| | | | |
| // This Data class is accessible internally as HandleScopeData through a | | // This Data class is accessible internally as HandleScopeData through a | |
| // typedef in the ImplementationUtilities class. | | // typedef in the ImplementationUtilities class. | |
| class V8EXPORT Data { | | class V8EXPORT Data { | |
| public: | | public: | |
| internal::Object** next; | | internal::Object** next; | |
| internal::Object** limit; | | internal::Object** limit; | |
| int level; | | int level; | |
|
| inline void Initialize() { | | V8_INLINE(void Initialize()) { | |
| next = limit = NULL; | | next = limit = NULL; | |
| level = 0; | | level = 0; | |
| } | | } | |
| }; | | }; | |
| | | | |
| void Leave(); | | void Leave(); | |
| | | | |
| internal::Isolate* isolate_; | | internal::Isolate* isolate_; | |
| internal::Object** prev_next_; | | internal::Object** prev_next_; | |
| internal::Object** prev_limit_; | | internal::Object** prev_limit_; | |
| | | | |
| skipping to change at line 590 | | skipping to change at line 606 | |
| * Returns true if the source code could not be parsed. | | * Returns true if the source code could not be parsed. | |
| */ | | */ | |
| virtual bool HasError() = 0; | | virtual bool HasError() = 0; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * The origin, within a file, of a script. | | * The origin, within a file, of a script. | |
| */ | | */ | |
| class ScriptOrigin { | | class ScriptOrigin { | |
| public: | | public: | |
|
| inline ScriptOrigin( | | V8_INLINE(ScriptOrigin( | |
| Handle<Value> resource_name, | | Handle<Value> resource_name, | |
| Handle<Integer> resource_line_offset = Handle<Integer>(), | | Handle<Integer> resource_line_offset = Handle<Integer>(), | |
|
| Handle<Integer> resource_column_offset = Handle<Integer>()) | | Handle<Integer> resource_column_offset = Handle<Integer>())) | |
| : resource_name_(resource_name), | | : resource_name_(resource_name), | |
| resource_line_offset_(resource_line_offset), | | resource_line_offset_(resource_line_offset), | |
| resource_column_offset_(resource_column_offset) { } | | resource_column_offset_(resource_column_offset) { } | |
|
| inline Handle<Value> ResourceName() const; | | V8_INLINE(Handle<Value> ResourceName() const); | |
| inline Handle<Integer> ResourceLineOffset() const; | | V8_INLINE(Handle<Integer> ResourceLineOffset() const); | |
| inline Handle<Integer> ResourceColumnOffset() const; | | V8_INLINE(Handle<Integer> ResourceColumnOffset() const); | |
| private: | | private: | |
| Handle<Value> resource_name_; | | Handle<Value> resource_name_; | |
| Handle<Integer> resource_line_offset_; | | Handle<Integer> resource_line_offset_; | |
| Handle<Integer> resource_column_offset_; | | Handle<Integer> resource_column_offset_; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A compiled JavaScript script. | | * A compiled JavaScript script. | |
| */ | | */ | |
| class V8EXPORT Script { | | class V8EXPORT Script { | |
| | | | |
| skipping to change at line 881 | | skipping to change at line 897 | |
| | | | |
| /** | | /** | |
| * The superclass of all JavaScript values and objects. | | * The superclass of all JavaScript values and objects. | |
| */ | | */ | |
| class Value : public Data { | | class Value : public Data { | |
| public: | | public: | |
| /** | | /** | |
| * Returns true if this value is the undefined value. See ECMA-262 | | * Returns true if this value is the undefined value. See ECMA-262 | |
| * 4.3.10. | | * 4.3.10. | |
| */ | | */ | |
|
| inline bool IsUndefined() const; | | V8_INLINE(bool IsUndefined() const); | |
| | | | |
| /** | | /** | |
| * Returns true if this value is the null value. See ECMA-262 | | * Returns true if this value is the null value. See ECMA-262 | |
| * 4.3.11. | | * 4.3.11. | |
| */ | | */ | |
|
| inline bool IsNull() const; | | V8_INLINE(bool IsNull() const); | |
| | | | |
| /** | | /** | |
| * Returns true if this value is true. | | * Returns true if this value is true. | |
| */ | | */ | |
| V8EXPORT bool IsTrue() const; | | V8EXPORT bool IsTrue() const; | |
| | | | |
| /** | | /** | |
| * Returns true if this value is false. | | * Returns true if this value is false. | |
| */ | | */ | |
| V8EXPORT bool IsFalse() const; | | V8EXPORT bool IsFalse() const; | |
| | | | |
| /** | | /** | |
| * Returns true if this value is an instance of the String type. | | * Returns true if this value is an instance of the String type. | |
| * See ECMA-262 8.4. | | * See ECMA-262 8.4. | |
| */ | | */ | |
|
| inline bool IsString() const; | | V8_INLINE(bool IsString() const); | |
| | | | |
| /** | | /** | |
| * Returns true if this value is a function. | | * Returns true if this value is a function. | |
| */ | | */ | |
| V8EXPORT bool IsFunction() const; | | V8EXPORT bool IsFunction() const; | |
| | | | |
| /** | | /** | |
| * Returns true if this value is an array. | | * Returns true if this value is an array. | |
| */ | | */ | |
| V8EXPORT bool IsArray() const; | | V8EXPORT bool IsArray() const; | |
| | | | |
| skipping to change at line 1001 | | skipping to change at line 1017 | |
| V8EXPORT double NumberValue() const; | | V8EXPORT double NumberValue() const; | |
| V8EXPORT int64_t IntegerValue() const; | | V8EXPORT int64_t IntegerValue() const; | |
| V8EXPORT uint32_t Uint32Value() const; | | V8EXPORT uint32_t Uint32Value() const; | |
| V8EXPORT int32_t Int32Value() const; | | V8EXPORT int32_t Int32Value() const; | |
| | | | |
| /** JS == */ | | /** JS == */ | |
| V8EXPORT bool Equals(Handle<Value> that) const; | | V8EXPORT bool Equals(Handle<Value> that) const; | |
| V8EXPORT bool StrictEquals(Handle<Value> that) const; | | V8EXPORT bool StrictEquals(Handle<Value> that) const; | |
| | | | |
| private: | | private: | |
|
| inline bool QuickIsUndefined() const; | | V8_INLINE(bool QuickIsUndefined() const); | |
| inline bool QuickIsNull() const; | | V8_INLINE(bool QuickIsNull() const); | |
| inline bool QuickIsString() const; | | V8_INLINE(bool QuickIsString() const); | |
| V8EXPORT bool FullIsUndefined() const; | | V8EXPORT bool FullIsUndefined() const; | |
| V8EXPORT bool FullIsNull() const; | | V8EXPORT bool FullIsNull() const; | |
| V8EXPORT bool FullIsString() const; | | V8EXPORT bool FullIsString() const; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * The superclass of primitive values. See ECMA-262 4.3.2. | | * The superclass of primitive values. See ECMA-262 4.3.2. | |
| */ | | */ | |
| class Primitive : public Value { }; | | class Primitive : public Value { }; | |
| | | | |
| /** | | /** | |
| * A primitive boolean value (ECMA-262, 4.3.14). Either the true | | * A primitive boolean value (ECMA-262, 4.3.14). Either the true | |
| * or false value. | | * or false value. | |
| */ | | */ | |
| class Boolean : public Primitive { | | class Boolean : public Primitive { | |
| public: | | public: | |
| V8EXPORT bool Value() const; | | V8EXPORT bool Value() const; | |
|
| static inline Handle<Boolean> New(bool value); | | V8_INLINE(static Handle<Boolean> New(bool value)); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A JavaScript string value (ECMA-262, 4.3.17). | | * A JavaScript string value (ECMA-262, 4.3.17). | |
| */ | | */ | |
| class String : public Primitive { | | class String : public Primitive { | |
| public: | | public: | |
| enum Encoding { | | enum Encoding { | |
| UNKNOWN_ENCODING = 0x1, | | UNKNOWN_ENCODING = 0x1, | |
| TWO_BYTE_ENCODING = 0x0, | | TWO_BYTE_ENCODING = 0x0, | |
| | | | |
| skipping to change at line 1105 | | skipping to change at line 1121 | |
| // UTF-8 encoded characters. | | // UTF-8 encoded characters. | |
| V8EXPORT int WriteUtf8(char* buffer, | | V8EXPORT int WriteUtf8(char* buffer, | |
| int length = -1, | | int length = -1, | |
| int* nchars_ref = NULL, | | int* nchars_ref = NULL, | |
| int options = NO_OPTIONS) const; | | int options = NO_OPTIONS) const; | |
| | | | |
| /** | | /** | |
| * A zero length string. | | * A zero length string. | |
| */ | | */ | |
| V8EXPORT static v8::Local<v8::String> Empty(); | | V8EXPORT static v8::Local<v8::String> Empty(); | |
|
| inline static v8::Local<v8::String> Empty(Isolate* isolate); | | V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate)); | |
| | | | |
| /** | | /** | |
| * Returns true if the string is external | | * Returns true if the string is external | |
| */ | | */ | |
| V8EXPORT bool IsExternal() const; | | V8EXPORT bool IsExternal() const; | |
| | | | |
| /** | | /** | |
| * Returns true if the string is both external and ASCII | | * Returns true if the string is both external and ASCII | |
| */ | | */ | |
| V8EXPORT bool IsExternalAscii() const; | | V8EXPORT bool IsExternalAscii() const; | |
| | | | |
| skipping to change at line 1201 | | skipping to change at line 1217 | |
| virtual size_t length() const = 0; | | virtual size_t length() const = 0; | |
| protected: | | protected: | |
| ExternalAsciiStringResource() {} | | ExternalAsciiStringResource() {} | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * If the string is an external string, return the ExternalStringResource
Base | | * If the string is an external string, return the ExternalStringResource
Base | |
| * regardless of the encoding, otherwise return NULL. The encoding of th
e | | * regardless of the encoding, otherwise return NULL. The encoding of th
e | |
| * string is returned in encoding_out. | | * string is returned in encoding_out. | |
| */ | | */ | |
|
| inline ExternalStringResourceBase* GetExternalStringResourceBase( | | V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase( | |
| Encoding* encoding_out) const; | | Encoding* encoding_out) const); | |
| | | | |
| /** | | /** | |
| * Get the ExternalStringResource for an external string. Returns | | * Get the ExternalStringResource for an external string. Returns | |
| * NULL if IsExternal() doesn't return true. | | * NULL if IsExternal() doesn't return true. | |
| */ | | */ | |
|
| inline ExternalStringResource* GetExternalStringResource() const; | | V8_INLINE(ExternalStringResource* GetExternalStringResource() const); | |
| | | | |
| /** | | /** | |
| * Get the ExternalAsciiStringResource for an external ASCII string. | | * Get the ExternalAsciiStringResource for an external ASCII string. | |
| * Returns NULL if IsExternalAscii() doesn't return true. | | * Returns NULL if IsExternalAscii() doesn't return true. | |
| */ | | */ | |
| V8EXPORT const ExternalAsciiStringResource* GetExternalAsciiStringResourc
e() | | V8EXPORT const ExternalAsciiStringResource* GetExternalAsciiStringResourc
e() | |
| const; | | const; | |
| | | | |
|
| static inline String* Cast(v8::Value* obj); | | V8_INLINE(static String* Cast(v8::Value* obj)); | |
| | | | |
| /** | | /** | |
| * Allocates a new string from either UTF-8 encoded or ASCII data. | | * Allocates a new string from either UTF-8 encoded or ASCII data. | |
| * The second parameter 'length' gives the buffer length. | | * The second parameter 'length' gives the buffer length. | |
| * If the data is UTF-8 encoded, the caller must | | * If the data is UTF-8 encoded, the caller must | |
| * be careful to supply the length parameter. | | * be careful to supply the length parameter. | |
| * If it is not given, the function calls | | * If it is not given, the function calls | |
| * 'strlen' to determine the buffer length, it might be | | * 'strlen' to determine the buffer length, it might be | |
| * wrong if 'data' contains a null character. | | * wrong if 'data' contains a null character. | |
| */ | | */ | |
| | | | |
| skipping to change at line 1380 | | skipping to change at line 1396 | |
| V8EXPORT static void CheckCast(v8::Value* obj); | | V8EXPORT static void CheckCast(v8::Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A JavaScript number value (ECMA-262, 4.3.20) | | * A JavaScript number value (ECMA-262, 4.3.20) | |
| */ | | */ | |
| class Number : public Primitive { | | class Number : public Primitive { | |
| public: | | public: | |
| V8EXPORT double Value() const; | | V8EXPORT double Value() const; | |
| V8EXPORT static Local<Number> New(double value); | | V8EXPORT static Local<Number> New(double value); | |
|
| static inline Number* Cast(v8::Value* obj); | | V8_INLINE(static Number* Cast(v8::Value* obj)); | |
| private: | | private: | |
| V8EXPORT Number(); | | V8EXPORT Number(); | |
| V8EXPORT static void CheckCast(v8::Value* obj); | | V8EXPORT static void CheckCast(v8::Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A JavaScript value representing a signed integer. | | * A JavaScript value representing a signed integer. | |
| */ | | */ | |
| class Integer : public Number { | | class Integer : public Number { | |
| public: | | public: | |
| V8EXPORT static Local<Integer> New(int32_t value); | | V8EXPORT static Local<Integer> New(int32_t value); | |
| V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value); | | V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value); | |
| V8EXPORT static Local<Integer> New(int32_t value, Isolate*); | | V8EXPORT static Local<Integer> New(int32_t value, Isolate*); | |
| V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); | | V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); | |
| V8EXPORT int64_t Value() const; | | V8EXPORT int64_t Value() const; | |
|
| static inline Integer* Cast(v8::Value* obj); | | V8_INLINE(static Integer* Cast(v8::Value* obj)); | |
| private: | | private: | |
| V8EXPORT Integer(); | | V8EXPORT Integer(); | |
| V8EXPORT static void CheckCast(v8::Value* obj); | | V8EXPORT static void CheckCast(v8::Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A JavaScript value representing a 32-bit signed integer. | | * A JavaScript value representing a 32-bit signed integer. | |
| */ | | */ | |
| class Int32 : public Integer { | | class Int32 : public Integer { | |
| public: | | public: | |
| | | | |
| skipping to change at line 1587 | | skipping to change at line 1603 | |
| | | | |
| /** | | /** | |
| * Returns the name of the function invoked as a constructor for this obj
ect. | | * Returns the name of the function invoked as a constructor for this obj
ect. | |
| */ | | */ | |
| V8EXPORT Local<String> GetConstructorName(); | | V8EXPORT Local<String> GetConstructorName(); | |
| | | | |
| /** Gets the number of internal fields for this Object. */ | | /** Gets the number of internal fields for this Object. */ | |
| V8EXPORT int InternalFieldCount(); | | V8EXPORT int InternalFieldCount(); | |
| | | | |
| /** Gets the value from an internal field. */ | | /** Gets the value from an internal field. */ | |
|
| inline Local<Value> GetInternalField(int index); | | V8_INLINE(Local<Value> GetInternalField(int index)); | |
| | | | |
| /** Sets the value in an internal field. */ | | /** Sets the value in an internal field. */ | |
| V8EXPORT void SetInternalField(int index, Handle<Value> value); | | V8EXPORT void SetInternalField(int index, Handle<Value> value); | |
| | | | |
| /** | | /** | |
| * Gets a native pointer from an internal field. Deprecated. If the point
er is | | * Gets a native pointer from an internal field. Deprecated. If the point
er is | |
| * always 2-byte-aligned, use GetAlignedPointerFromInternalField instead, | | * always 2-byte-aligned, use GetAlignedPointerFromInternalField instead, | |
| * otherwise use a combination of GetInternalField, External::Cast and | | * otherwise use a combination of GetInternalField, External::Cast and | |
| * External::Value. | | * External::Value. | |
| */ | | */ | |
| V8EXPORT V8_DEPRECATED(void* GetPointerFromInternalField(int index)); | | V8EXPORT V8_DEPRECATED(void* GetPointerFromInternalField(int index)); | |
| | | | |
| /** | | /** | |
| * Sets a native pointer in an internal field. Deprecated. If the pointer
is | | * Sets a native pointer in an internal field. Deprecated. If the pointer
is | |
| * always 2-byte aligned, use SetAlignedPointerInInternalField instead, | | * always 2-byte aligned, use SetAlignedPointerInInternalField instead, | |
| * otherwise use a combination of External::New and SetInternalField. | | * otherwise use a combination of External::New and SetInternalField. | |
| */ | | */ | |
|
| inline V8_DEPRECATED(void SetPointerInInternalField(int index, void* valu | | V8_DEPRECATED(V8_INLINE(void SetPointerInInternalField(int index, | |
| e)); | | void* value))); | |
| | | | |
| /** | | /** | |
| * Gets a 2-byte-aligned native pointer from an internal field. This fiel
d | | * Gets a 2-byte-aligned native pointer from an internal field. This fiel
d | |
| * must have been set by SetAlignedPointerInInternalField, everything els
e | | * must have been set by SetAlignedPointerInInternalField, everything els
e | |
| * leads to undefined behavior. | | * leads to undefined behavior. | |
| */ | | */ | |
|
| inline void* GetAlignedPointerFromInternalField(int index); | | V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); | |
| | | | |
| /** | | /** | |
| * Sets a 2-byte-aligned native pointer in an internal field. To retrieve
such | | * Sets a 2-byte-aligned native pointer in an internal field. To retrieve
such | |
| * a field, GetAlignedPointerFromInternalField must be used, everything e
lse | | * a field, GetAlignedPointerFromInternalField must be used, everything e
lse | |
| * leads to undefined behavior. | | * leads to undefined behavior. | |
| */ | | */ | |
| V8EXPORT void SetAlignedPointerInInternalField(int index, void* value); | | V8EXPORT void SetAlignedPointerInInternalField(int index, void* value); | |
| | | | |
| // Testers for local properties. | | // Testers for local properties. | |
| V8EXPORT bool HasOwnProperty(Handle<String> key); | | V8EXPORT bool HasOwnProperty(Handle<String> key); | |
| | | | |
| skipping to change at line 1745 | | skipping to change at line 1762 | |
| | | | |
| /** | | /** | |
| * Call an Object as a constructor if a callback is set by the | | * Call an Object as a constructor if a callback is set by the | |
| * ObjectTemplate::SetCallAsFunctionHandler method. | | * ObjectTemplate::SetCallAsFunctionHandler method. | |
| * Note: This method behaves like the Function::NewInstance method. | | * Note: This method behaves like the Function::NewInstance method. | |
| */ | | */ | |
| V8EXPORT Local<Value> CallAsConstructor(int argc, | | V8EXPORT Local<Value> CallAsConstructor(int argc, | |
| Handle<Value> argv[]); | | Handle<Value> argv[]); | |
| | | | |
| V8EXPORT static Local<Object> New(); | | V8EXPORT static Local<Object> New(); | |
|
| static inline Object* Cast(Value* obj); | | V8_INLINE(static Object* Cast(Value* obj)); | |
| | | | |
| private: | | private: | |
| V8EXPORT Object(); | | V8EXPORT Object(); | |
| V8EXPORT static void CheckCast(Value* obj); | | V8EXPORT static void CheckCast(Value* obj); | |
| V8EXPORT Local<Value> SlowGetInternalField(int index); | | V8EXPORT Local<Value> SlowGetInternalField(int index); | |
| V8EXPORT void* SlowGetAlignedPointerFromInternalField(int index); | | V8EXPORT void* SlowGetAlignedPointerFromInternalField(int index); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * An instance of the built-in array constructor (ECMA-262, 15.4.2). | | * An instance of the built-in array constructor (ECMA-262, 15.4.2). | |
| | | | |
| skipping to change at line 1773 | | skipping to change at line 1790 | |
| * handle if cloning fails (for any reason). | | * handle if cloning fails (for any reason). | |
| */ | | */ | |
| V8EXPORT Local<Object> CloneElementAt(uint32_t index); | | V8EXPORT Local<Object> CloneElementAt(uint32_t index); | |
| | | | |
| /** | | /** | |
| * Creates a JavaScript array with the given length. If the length | | * Creates a JavaScript array with the given length. If the length | |
| * is negative the returned array will have length 0. | | * is negative the returned array will have length 0. | |
| */ | | */ | |
| V8EXPORT static Local<Array> New(int length = 0); | | V8EXPORT static Local<Array> New(int length = 0); | |
| | | | |
|
| static inline Array* Cast(Value* obj); | | V8_INLINE(static Array* Cast(Value* obj)); | |
| private: | | private: | |
| V8EXPORT Array(); | | V8EXPORT Array(); | |
| V8EXPORT static void CheckCast(Value* obj); | | V8EXPORT static void CheckCast(Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A JavaScript function object (ECMA-262, 15.3). | | * A JavaScript function object (ECMA-262, 15.3). | |
| */ | | */ | |
| class Function : public Object { | | class Function : public Object { | |
| public: | | public: | |
| | | | |
| skipping to change at line 1812 | | skipping to change at line 1829 | |
| * kLineOffsetNotFound if no information available. | | * kLineOffsetNotFound if no information available. | |
| */ | | */ | |
| V8EXPORT int GetScriptLineNumber() const; | | V8EXPORT int GetScriptLineNumber() const; | |
| /** | | /** | |
| * Returns zero based column number of function body and | | * Returns zero based column number of function body and | |
| * kLineOffsetNotFound if no information available. | | * kLineOffsetNotFound if no information available. | |
| */ | | */ | |
| V8EXPORT int GetScriptColumnNumber() const; | | V8EXPORT int GetScriptColumnNumber() const; | |
| V8EXPORT Handle<Value> GetScriptId() const; | | V8EXPORT Handle<Value> GetScriptId() const; | |
| V8EXPORT ScriptOrigin GetScriptOrigin() const; | | V8EXPORT ScriptOrigin GetScriptOrigin() const; | |
|
| static inline Function* Cast(Value* obj); | | V8_INLINE(static Function* Cast(Value* obj)); | |
| V8EXPORT static const int kLineOffsetNotFound; | | V8EXPORT static const int kLineOffsetNotFound; | |
| | | | |
| private: | | private: | |
| V8EXPORT Function(); | | V8EXPORT Function(); | |
| V8EXPORT static void CheckCast(Value* obj); | | V8EXPORT static void CheckCast(Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * An instance of the built-in Date constructor (ECMA-262, 15.9). | | * An instance of the built-in Date constructor (ECMA-262, 15.9). | |
| */ | | */ | |
| class Date : public Object { | | class Date : public Object { | |
| public: | | public: | |
| V8EXPORT static Local<Value> New(double time); | | V8EXPORT static Local<Value> New(double time); | |
| | | | |
| /** | | /** | |
| * A specialization of Value::NumberValue that is more efficient | | * A specialization of Value::NumberValue that is more efficient | |
| * because we know the structure of this object. | | * because we know the structure of this object. | |
| */ | | */ | |
| V8EXPORT double NumberValue() const; | | V8EXPORT double NumberValue() const; | |
| | | | |
|
| static inline Date* Cast(v8::Value* obj); | | V8_INLINE(static Date* Cast(v8::Value* obj)); | |
| | | | |
| /** | | /** | |
| * Notification that the embedder has changed the time zone, | | * Notification that the embedder has changed the time zone, | |
| * daylight savings time, or other date / time configuration | | * daylight savings time, or other date / time configuration | |
| * parameters. V8 keeps a cache of various values used for | | * parameters. V8 keeps a cache of various values used for | |
| * date / time computation. This notification will reset | | * date / time computation. This notification will reset | |
| * those cached values for the current context so that date / | | * those cached values for the current context so that date / | |
| * time configuration changes would be reflected in the Date | | * time configuration changes would be reflected in the Date | |
| * object. | | * object. | |
| * | | * | |
| | | | |
| skipping to change at line 1865 | | skipping to change at line 1882 | |
| */ | | */ | |
| class NumberObject : public Object { | | class NumberObject : public Object { | |
| public: | | public: | |
| V8EXPORT static Local<Value> New(double value); | | V8EXPORT static Local<Value> New(double value); | |
| | | | |
| /** | | /** | |
| * Returns the Number held by the object. | | * Returns the Number held by the object. | |
| */ | | */ | |
| V8EXPORT double NumberValue() const; | | V8EXPORT double NumberValue() const; | |
| | | | |
|
| static inline NumberObject* Cast(v8::Value* obj); | | V8_INLINE(static NumberObject* Cast(v8::Value* obj)); | |
| | | | |
| private: | | private: | |
| V8EXPORT static void CheckCast(v8::Value* obj); | | V8EXPORT static void CheckCast(v8::Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A Boolean object (ECMA-262, 4.3.15). | | * A Boolean object (ECMA-262, 4.3.15). | |
| */ | | */ | |
| class BooleanObject : public Object { | | class BooleanObject : public Object { | |
| public: | | public: | |
| V8EXPORT static Local<Value> New(bool value); | | V8EXPORT static Local<Value> New(bool value); | |
| | | | |
| /** | | /** | |
| * Returns the Boolean held by the object. | | * Returns the Boolean held by the object. | |
| */ | | */ | |
| V8EXPORT bool BooleanValue() const; | | V8EXPORT bool BooleanValue() const; | |
| | | | |
|
| static inline BooleanObject* Cast(v8::Value* obj); | | V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); | |
| | | | |
| private: | | private: | |
| V8EXPORT static void CheckCast(v8::Value* obj); | | V8EXPORT static void CheckCast(v8::Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A String object (ECMA-262, 4.3.18). | | * A String object (ECMA-262, 4.3.18). | |
| */ | | */ | |
| class StringObject : public Object { | | class StringObject : public Object { | |
| public: | | public: | |
| V8EXPORT static Local<Value> New(Handle<String> value); | | V8EXPORT static Local<Value> New(Handle<String> value); | |
| | | | |
| /** | | /** | |
| * Returns the String held by the object. | | * Returns the String held by the object. | |
| */ | | */ | |
| V8EXPORT Local<String> StringValue() const; | | V8EXPORT Local<String> StringValue() const; | |
| | | | |
|
| static inline StringObject* Cast(v8::Value* obj); | | V8_INLINE(static StringObject* Cast(v8::Value* obj)); | |
| | | | |
| private: | | private: | |
| V8EXPORT static void CheckCast(v8::Value* obj); | | V8EXPORT static void CheckCast(v8::Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * An instance of the built-in RegExp constructor (ECMA-262, 15.10). | | * An instance of the built-in RegExp constructor (ECMA-262, 15.10). | |
| */ | | */ | |
| class RegExp : public Object { | | class RegExp : public Object { | |
| public: | | public: | |
| | | | |
| skipping to change at line 1947 | | skipping to change at line 1964 | |
| * Returns the value of the source property: a string representing | | * Returns the value of the source property: a string representing | |
| * the regular expression. | | * the regular expression. | |
| */ | | */ | |
| V8EXPORT Local<String> GetSource() const; | | V8EXPORT Local<String> GetSource() const; | |
| | | | |
| /** | | /** | |
| * Returns the flags bit field. | | * Returns the flags bit field. | |
| */ | | */ | |
| V8EXPORT Flags GetFlags() const; | | V8EXPORT Flags GetFlags() const; | |
| | | | |
|
| static inline RegExp* Cast(v8::Value* obj); | | V8_INLINE(static RegExp* Cast(v8::Value* obj)); | |
| | | | |
| private: | | private: | |
| V8EXPORT static void CheckCast(v8::Value* obj); | | V8EXPORT static void CheckCast(v8::Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A JavaScript value that wraps a C++ void*. This type of value is mainly
used | | * A JavaScript value that wraps a C++ void*. This type of value is mainly
used | |
| * to associate C++ data structures with JavaScript objects. | | * to associate C++ data structures with JavaScript objects. | |
| */ | | */ | |
| class External : public Value { | | class External : public Value { | |
| public: | | public: | |
| /** Deprecated, use New instead. */ | | /** Deprecated, use New instead. */ | |
|
| V8_DEPRECATED(static inline Local<Value> Wrap(void* value)); | | V8_DEPRECATED(V8_INLINE(static Local<Value> Wrap(void* value))); | |
| | | | |
| /** Deprecated, use a combination of Cast and Value instead. */ | | /** Deprecated, use a combination of Cast and Value instead. */ | |
|
| V8_DEPRECATED(static inline void* Unwrap(Handle<Value> obj)); | | V8_DEPRECATED(V8_INLINE(static void* Unwrap(Handle<Value> obj))); | |
| | | | |
| V8EXPORT static Local<External> New(void* value); | | V8EXPORT static Local<External> New(void* value); | |
|
| static inline External* Cast(Value* obj); | | V8_INLINE(static External* Cast(Value* obj)); | |
| V8EXPORT void* Value() const; | | V8EXPORT void* Value() const; | |
| private: | | private: | |
| V8EXPORT static void CheckCast(v8::Value* obj); | | V8EXPORT static void CheckCast(v8::Value* obj); | |
| }; | | }; | |
| | | | |
| // --- Templates --- | | // --- Templates --- | |
| | | | |
| /** | | /** | |
| * The superclass of object and function templates. | | * The superclass of object and function templates. | |
| */ | | */ | |
| class V8EXPORT Template : public Data { | | class V8EXPORT Template : public Data { | |
| public: | | public: | |
| /** Adds a property to each instance created by this template.*/ | | /** Adds a property to each instance created by this template.*/ | |
| void Set(Handle<String> name, Handle<Data> value, | | void Set(Handle<String> name, Handle<Data> value, | |
| PropertyAttribute attributes = None); | | PropertyAttribute attributes = None); | |
|
| inline void Set(const char* name, Handle<Data> value); | | V8_INLINE(void Set(const char* name, Handle<Data> value)); | |
| private: | | private: | |
| Template(); | | Template(); | |
| | | | |
| friend class ObjectTemplate; | | friend class ObjectTemplate; | |
| friend class FunctionTemplate; | | friend class FunctionTemplate; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * The argument information given to function call callbacks. This | | * The argument information given to function call callbacks. This | |
| * class provides access to information about the context of the call, | | * class provides access to information about the context of the call, | |
| * including the receiver, the number and values of arguments, and | | * including the receiver, the number and values of arguments, and | |
| * the holder of the function. | | * the holder of the function. | |
| */ | | */ | |
| class Arguments { | | class Arguments { | |
| public: | | public: | |
|
| inline int Length() const; | | V8_INLINE(int Length() const); | |
| inline Local<Value> operator[](int i) const; | | V8_INLINE(Local<Value> operator[](int i) const); | |
| inline Local<Function> Callee() const; | | V8_INLINE(Local<Function> Callee() const); | |
| inline Local<Object> This() const; | | V8_INLINE(Local<Object> This() const); | |
| inline Local<Object> Holder() const; | | V8_INLINE(Local<Object> Holder() const); | |
| inline bool IsConstructCall() const; | | V8_INLINE(bool IsConstructCall() const); | |
| inline Local<Value> Data() const; | | V8_INLINE(Local<Value> Data() const); | |
| inline Isolate* GetIsolate() const; | | V8_INLINE(Isolate* GetIsolate() const); | |
| | | | |
| private: | | private: | |
| static const int kIsolateIndex = 0; | | static const int kIsolateIndex = 0; | |
| static const int kDataIndex = -1; | | static const int kDataIndex = -1; | |
| static const int kCalleeIndex = -2; | | static const int kCalleeIndex = -2; | |
| static const int kHolderIndex = -3; | | static const int kHolderIndex = -3; | |
| | | | |
| friend class ImplementationUtilities; | | friend class ImplementationUtilities; | |
|
| inline Arguments(internal::Object** implicit_args, | | V8_INLINE(Arguments(internal::Object** implicit_args, | |
| internal::Object** values, | | internal::Object** values, | |
| int length, | | int length, | |
|
| bool is_construct_call); | | bool is_construct_call)); | |
| internal::Object** implicit_args_; | | internal::Object** implicit_args_; | |
| internal::Object** values_; | | internal::Object** values_; | |
| int length_; | | int length_; | |
| bool is_construct_call_; | | bool is_construct_call_; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * The information passed to an accessor callback about the context | | * The information passed to an accessor callback about the context | |
| * of the property access. | | * of the property access. | |
| */ | | */ | |
| class V8EXPORT AccessorInfo { | | class V8EXPORT AccessorInfo { | |
| public: | | public: | |
|
| inline AccessorInfo(internal::Object** args) | | V8_INLINE(AccessorInfo(internal::Object** args)) | |
| : args_(args) { } | | : args_(args) { } | |
|
| inline Isolate* GetIsolate() const; | | V8_INLINE(Isolate* GetIsolate() const); | |
| inline Local<Value> Data() const; | | V8_INLINE(Local<Value> Data() const); | |
| inline Local<Object> This() const; | | V8_INLINE(Local<Object> This() const); | |
| inline Local<Object> Holder() const; | | V8_INLINE(Local<Object> Holder() const); | |
| | | | |
| private: | | private: | |
| internal::Object** args_; | | internal::Object** args_; | |
| }; | | }; | |
| | | | |
| typedef Handle<Value> (*InvocationCallback)(const Arguments& args); | | typedef Handle<Value> (*InvocationCallback)(const Arguments& args); | |
| | | | |
| /** | | /** | |
| * NamedProperty[Getter|Setter] are used as interceptors on object. | | * NamedProperty[Getter|Setter] are used as interceptors on object. | |
| * See ObjectTemplate::SetNamedPropertyHandler. | | * See ObjectTemplate::SetNamedPropertyHandler. | |
| | | | |
| skipping to change at line 2582 | | skipping to change at line 2599 | |
| void operator=(const Extension&); | | void operator=(const Extension&); | |
| }; | | }; | |
| | | | |
| void V8EXPORT RegisterExtension(Extension* extension); | | void V8EXPORT RegisterExtension(Extension* extension); | |
| | | | |
| /** | | /** | |
| * Ignore | | * Ignore | |
| */ | | */ | |
| class V8EXPORT DeclareExtension { | | class V8EXPORT DeclareExtension { | |
| public: | | public: | |
|
| inline DeclareExtension(Extension* extension) { | | V8_INLINE(DeclareExtension(Extension* extension)) { | |
| RegisterExtension(extension); | | RegisterExtension(extension); | |
| } | | } | |
| }; | | }; | |
| | | | |
| // --- Statics --- | | // --- Statics --- | |
| | | | |
| Handle<Primitive> V8EXPORT Undefined(); | | Handle<Primitive> V8EXPORT Undefined(); | |
| Handle<Primitive> V8EXPORT Null(); | | Handle<Primitive> V8EXPORT Null(); | |
| Handle<Boolean> V8EXPORT True(); | | Handle<Boolean> V8EXPORT True(); | |
| Handle<Boolean> V8EXPORT False(); | | Handle<Boolean> V8EXPORT False(); | |
| | | | |
|
| inline Handle<Primitive> Undefined(Isolate* isolate); | | V8_INLINE(Handle<Primitive> Undefined(Isolate* isolate)); | |
| inline Handle<Primitive> Null(Isolate* isolate); | | V8_INLINE(Handle<Primitive> Null(Isolate* isolate)); | |
| inline Handle<Boolean> True(Isolate* isolate); | | V8_INLINE(Handle<Boolean> True(Isolate* isolate)); | |
| inline Handle<Boolean> False(Isolate* isolate); | | V8_INLINE(Handle<Boolean> False(Isolate* isolate)); | |
| | | | |
| /** | | /** | |
| * A set of constraints that specifies the limits of the runtime's memory u
se. | | * A set of constraints that specifies the limits of the runtime's memory u
se. | |
| * You must set the heap size before initializing the VM - the size cannot
be | | * You must set the heap size before initializing the VM - the size cannot
be | |
| * adjusted after the VM is initialized. | | * adjusted after the VM is initialized. | |
| * | | * | |
| * If you are using threads then you should hold the V8::Locker lock while | | * If you are using threads then you should hold the V8::Locker lock while | |
| * setting the stack limit and you must set a non-default stack limit separ
ately | | * setting the stack limit and you must set a non-default stack limit separ
ately | |
| * for each thread. | | * for each thread. | |
| */ | | */ | |
| | | | |
| skipping to change at line 2845 | | skipping to change at line 2862 | |
| | | | |
| /** | | /** | |
| * Disposes the isolate. The isolate must not be entered by any | | * Disposes the isolate. The isolate must not be entered by any | |
| * thread to be disposable. | | * thread to be disposable. | |
| */ | | */ | |
| void Dispose(); | | void Dispose(); | |
| | | | |
| /** | | /** | |
| * Associate embedder-specific data with the isolate | | * Associate embedder-specific data with the isolate | |
| */ | | */ | |
|
| inline void SetData(void* data); | | V8_INLINE(void SetData(void* data)); | |
| | | | |
| /** | | /** | |
| * Retrieve embedder-specific data from the isolate. | | * Retrieve embedder-specific data from the isolate. | |
| * Returns NULL if SetData has never been called. | | * Returns NULL if SetData has never been called. | |
| */ | | */ | |
|
| inline void* GetData(); | | V8_INLINE(void* GetData()); | |
| | | | |
| private: | | private: | |
| Isolate(); | | Isolate(); | |
| Isolate(const Isolate&); | | Isolate(const Isolate&); | |
| ~Isolate(); | | ~Isolate(); | |
| Isolate& operator=(const Isolate&); | | Isolate& operator=(const Isolate&); | |
| void* operator new(size_t size); | | void* operator new(size_t size); | |
| void operator delete(void*, size_t); | | void operator delete(void*, size_t); | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 3222 | | skipping to change at line 3239 | |
| * function, for instance to simulate DOM tree connections among JS | | * function, for instance to simulate DOM tree connections among JS | |
| * wrapper objects. Object groups for all dependent handles need to | | * wrapper objects. Object groups for all dependent handles need to | |
| * be provided for kGCTypeMarkSweepCompact collections, for all other | | * be provided for kGCTypeMarkSweepCompact collections, for all other | |
| * garbage collection types it is sufficient to provide object groups | | * garbage collection types it is sufficient to provide object groups | |
| * for partially dependent handles only. | | * for partially dependent handles only. | |
| * See v8-profiler.h for RetainedObjectInfo interface description. | | * See v8-profiler.h for RetainedObjectInfo interface description. | |
| */ | | */ | |
| static void AddObjectGroup(Persistent<Value>* objects, | | static void AddObjectGroup(Persistent<Value>* objects, | |
| size_t length, | | size_t length, | |
| RetainedObjectInfo* info = NULL); | | RetainedObjectInfo* info = NULL); | |
|
| | | static void AddObjectGroup(Isolate* isolate, | |
| | | Persistent<Value>* objects, | |
| | | size_t length, | |
| | | RetainedObjectInfo* info = NULL); | |
| | | | |
| /** | | /** | |
| * Allows the host application to declare implicit references between | | * Allows the host application to declare implicit references between | |
| * the objects: if |parent| is alive, all |children| are alive too. | | * the objects: if |parent| is alive, all |children| are alive too. | |
| * After each garbage collection, all implicit references | | * After each garbage collection, all implicit references | |
| * are removed. It is intended to be used in the before-garbage-collecti
on | | * are removed. It is intended to be used in the before-garbage-collecti
on | |
| * callback function. | | * callback function. | |
| */ | | */ | |
| static void AddImplicitReferences(Persistent<Object> parent, | | static void AddImplicitReferences(Persistent<Object> parent, | |
| Persistent<Value>* children, | | Persistent<Value>* children, | |
| | | | |
| skipping to change at line 3455 | | skipping to change at line 3476 | |
| private: | | private: | |
| V8(); | | V8(); | |
| | | | |
| static internal::Object** GlobalizeReference(internal::Object** handle); | | static internal::Object** GlobalizeReference(internal::Object** handle); | |
| static void DisposeGlobal(internal::Object** global_handle); | | static void DisposeGlobal(internal::Object** global_handle); | |
| static void DisposeGlobal(internal::Isolate* isolate, | | static void DisposeGlobal(internal::Isolate* isolate, | |
| internal::Object** global_handle); | | internal::Object** global_handle); | |
| static void MakeWeak(internal::Object** global_handle, | | static void MakeWeak(internal::Object** global_handle, | |
| void* data, | | void* data, | |
| WeakReferenceCallback); | | WeakReferenceCallback); | |
|
| | | static void MakeWeak(internal::Isolate* isolate, | |
| | | internal::Object** global_handle, | |
| | | void* data, | |
| | | WeakReferenceCallback); | |
| static void ClearWeak(internal::Object** global_handle); | | static void ClearWeak(internal::Object** global_handle); | |
| static void MarkIndependent(internal::Object** global_handle); | | static void MarkIndependent(internal::Object** global_handle); | |
| static void MarkIndependent(internal::Isolate* isolate, | | static void MarkIndependent(internal::Isolate* isolate, | |
| internal::Object** global_handle); | | internal::Object** global_handle); | |
| static void MarkPartiallyDependent(internal::Object** global_handle); | | static void MarkPartiallyDependent(internal::Object** global_handle); | |
| static void MarkPartiallyDependent(internal::Isolate* isolate, | | static void MarkPartiallyDependent(internal::Isolate* isolate, | |
| internal::Object** global_handle); | | internal::Object** global_handle); | |
| static bool IsGlobalIndependent(internal::Object** global_handle); | | static bool IsGlobalIndependent(internal::Object** global_handle); | |
| static bool IsGlobalIndependent(internal::Isolate* isolate, | | static bool IsGlobalIndependent(internal::Isolate* isolate, | |
| internal::Object** global_handle); | | internal::Object** global_handle); | |
| static bool IsGlobalNearDeath(internal::Object** global_handle); | | static bool IsGlobalNearDeath(internal::Object** global_handle); | |
| static bool IsGlobalWeak(internal::Object** global_handle); | | static bool IsGlobalWeak(internal::Object** global_handle); | |
|
| | | static bool IsGlobalWeak(internal::Isolate* isolate, | |
| | | internal::Object** global_handle); | |
| static void SetWrapperClassId(internal::Object** global_handle, | | static void SetWrapperClassId(internal::Object** global_handle, | |
| uint16_t class_id); | | uint16_t class_id); | |
| static uint16_t GetWrapperClassId(internal::Object** global_handle); | | static uint16_t GetWrapperClassId(internal::Object** global_handle); | |
| | | | |
| template <class T> friend class Handle; | | template <class T> friend class Handle; | |
| template <class T> friend class Local; | | template <class T> friend class Local; | |
| template <class T> friend class Persistent; | | template <class T> friend class Persistent; | |
| friend class Context; | | friend class Context; | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 3722 | | skipping to change at line 3749 | |
| /** Returns true if the context has experienced an out of memory situatio
n. */ | | /** Returns true if the context has experienced an out of memory situatio
n. */ | |
| bool HasOutOfMemoryException(); | | bool HasOutOfMemoryException(); | |
| | | | |
| /** Returns true if V8 has a current context. */ | | /** Returns true if V8 has a current context. */ | |
| static bool InContext(); | | static bool InContext(); | |
| | | | |
| /** | | /** | |
| * Gets embedder data with index 0. Deprecated, use GetEmbedderData with
index | | * Gets embedder data with index 0. Deprecated, use GetEmbedderData with
index | |
| * 0 instead. | | * 0 instead. | |
| */ | | */ | |
|
| V8_DEPRECATED(inline Local<Value> GetData()); | | V8_DEPRECATED(V8_INLINE(Local<Value> GetData())); | |
| | | | |
| /** | | /** | |
| * Sets embedder data with index 0. Deprecated, use SetEmbedderData with
index | | * Sets embedder data with index 0. Deprecated, use SetEmbedderData with
index | |
| * 0 instead. | | * 0 instead. | |
| */ | | */ | |
|
| V8_DEPRECATED(inline void SetData(Handle<Value> value)); | | V8_DEPRECATED(V8_INLINE(void SetData(Handle<Value> value))); | |
| | | | |
| /** | | /** | |
| * Gets the embedder data with the given index, which must have been set
by a | | * Gets the embedder data with the given index, which must have been set
by a | |
| * previous call to SetEmbedderData with the same index. Note that index
0 | | * previous call to SetEmbedderData with the same index. Note that index
0 | |
| * currently has a special meaning for Chrome's debugger. | | * currently has a special meaning for Chrome's debugger. | |
| */ | | */ | |
|
| inline Local<Value> GetEmbedderData(int index); | | V8_INLINE(Local<Value> GetEmbedderData(int index)); | |
| | | | |
| /** | | /** | |
| * Sets the embedder data with the given index, growing the data as | | * Sets the embedder data with the given index, growing the data as | |
| * needed. Note that index 0 currently has a special meaning for Chrome's | | * needed. Note that index 0 currently has a special meaning for Chrome's | |
| * debugger. | | * debugger. | |
| */ | | */ | |
| void SetEmbedderData(int index, Handle<Value> value); | | void SetEmbedderData(int index, Handle<Value> value); | |
| | | | |
| /** | | /** | |
| * Gets a 2-byte-aligned native pointer from the embedder data with the g
iven | | * Gets a 2-byte-aligned native pointer from the embedder data with the g
iven | |
| * index, which must have bees set by a previous call to | | * index, which must have bees set by a previous call to | |
| * SetAlignedPointerInEmbedderData with the same index. Note that index 0 | | * SetAlignedPointerInEmbedderData with the same index. Note that index 0 | |
| * currently has a special meaning for Chrome's debugger. | | * currently has a special meaning for Chrome's debugger. | |
| */ | | */ | |
|
| inline void* GetAlignedPointerFromEmbedderData(int index); | | V8_INLINE(void* GetAlignedPointerFromEmbedderData(int index)); | |
| | | | |
| /** | | /** | |
| * Sets a 2-byte-aligned native pointer in the embedder data with the giv
en | | * Sets a 2-byte-aligned native pointer in the embedder data with the giv
en | |
| * index, growing the data as needed. Note that index 0 currently has a | | * index, growing the data as needed. Note that index 0 currently has a | |
| * special meaning for Chrome's debugger. | | * special meaning for Chrome's debugger. | |
| */ | | */ | |
| void SetAlignedPointerInEmbedderData(int index, void* value); | | void SetAlignedPointerInEmbedderData(int index, void* value); | |
| | | | |
| /** | | /** | |
| * Control whether code generation from strings is allowed. Calling | | * Control whether code generation from strings is allowed. Calling | |
| | | | |
| skipping to change at line 3793 | | skipping to change at line 3820 | |
| * constructor are called. | | * constructor are called. | |
| */ | | */ | |
| void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message); | | void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message); | |
| | | | |
| /** | | /** | |
| * Stack-allocated class which sets the execution context for all | | * Stack-allocated class which sets the execution context for all | |
| * operations executed within a local scope. | | * operations executed within a local scope. | |
| */ | | */ | |
| class Scope { | | class Scope { | |
| public: | | public: | |
|
| explicit inline Scope(Handle<Context> context) : context_(context) { | | explicit V8_INLINE(Scope(Handle<Context> context)) : context_(context)
{ | |
| context_->Enter(); | | context_->Enter(); | |
| } | | } | |
|
| inline ~Scope() { context_->Exit(); } | | V8_INLINE(~Scope()) { context_->Exit(); } | |
| private: | | private: | |
| Handle<Context> context_; | | Handle<Context> context_; | |
| }; | | }; | |
| | | | |
| private: | | private: | |
| friend class Value; | | friend class Value; | |
| friend class Script; | | friend class Script; | |
| friend class Object; | | friend class Object; | |
| friend class Function; | | friend class Function; | |
| | | | |
| | | | |
| skipping to change at line 4030 | | skipping to change at line 4057 | |
| const int kSmiTag = 0; | | const int kSmiTag = 0; | |
| const int kSmiTagSize = 1; | | const int kSmiTagSize = 1; | |
| const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; | | const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; | |
| | | | |
| template <size_t ptr_size> struct SmiTagging; | | template <size_t ptr_size> struct SmiTagging; | |
| | | | |
| // Smi constants for 32-bit systems. | | // Smi constants for 32-bit systems. | |
| template <> struct SmiTagging<4> { | | template <> struct SmiTagging<4> { | |
| static const int kSmiShiftSize = 0; | | static const int kSmiShiftSize = 0; | |
| static const int kSmiValueSize = 31; | | static const int kSmiValueSize = 31; | |
|
| static inline int SmiToInt(internal::Object* value) { | | V8_INLINE(static int SmiToInt(internal::Object* value)) { | |
| int shift_bits = kSmiTagSize + kSmiShiftSize; | | int shift_bits = kSmiTagSize + kSmiShiftSize; | |
| // Throw away top 32 bits and shift down (requires >> to be sign extend
ing). | | // Throw away top 32 bits and shift down (requires >> to be sign extend
ing). | |
| return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bit
s; | | return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bit
s; | |
| } | | } | |
| }; | | }; | |
| | | | |
| // Smi constants for 64-bit systems. | | // Smi constants for 64-bit systems. | |
| template <> struct SmiTagging<8> { | | template <> struct SmiTagging<8> { | |
| static const int kSmiShiftSize = 31; | | static const int kSmiShiftSize = 31; | |
| static const int kSmiValueSize = 32; | | static const int kSmiValueSize = 32; | |
|
| static inline int SmiToInt(internal::Object* value) { | | V8_INLINE(static int SmiToInt(internal::Object* value)) { | |
| int shift_bits = kSmiTagSize + kSmiShiftSize; | | int shift_bits = kSmiTagSize + kSmiShiftSize; | |
| // Shift down and throw away top 32 bits. | | // Shift down and throw away top 32 bits. | |
| return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits
); | | return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits
); | |
| } | | } | |
| }; | | }; | |
| | | | |
| typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; | | typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; | |
| const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; | | const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; | |
| const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; | | const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; | |
| | | | |
| | | | |
| skipping to change at line 4093 | | skipping to change at line 4120 | |
| static const int kEmptySymbolRootIndex = 119; | | static const int kEmptySymbolRootIndex = 119; | |
| | | | |
| static const int kJSObjectType = 0xaa; | | static const int kJSObjectType = 0xaa; | |
| static const int kFirstNonstringType = 0x80; | | static const int kFirstNonstringType = 0x80; | |
| static const int kOddballType = 0x82; | | static const int kOddballType = 0x82; | |
| static const int kForeignType = 0x85; | | static const int kForeignType = 0x85; | |
| | | | |
| static const int kUndefinedOddballKind = 5; | | static const int kUndefinedOddballKind = 5; | |
| static const int kNullOddballKind = 3; | | static const int kNullOddballKind = 3; | |
| | | | |
|
| static inline bool HasHeapObjectTag(internal::Object* value) { | | V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { | |
| return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | | return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | |
| kHeapObjectTag); | | kHeapObjectTag); | |
| } | | } | |
| | | | |
|
| static inline int SmiValue(internal::Object* value) { | | V8_INLINE(static int SmiValue(internal::Object* value)) { | |
| return PlatformSmiTagging::SmiToInt(value); | | return PlatformSmiTagging::SmiToInt(value); | |
| } | | } | |
| | | | |
|
| static inline int GetInstanceType(internal::Object* obj) { | | V8_INLINE(static int GetInstanceType(internal::Object* obj)) { | |
| typedef internal::Object O; | | typedef internal::Object O; | |
| O* map = ReadField<O*>(obj, kHeapObjectMapOffset); | | O* map = ReadField<O*>(obj, kHeapObjectMapOffset); | |
| return ReadField<uint8_t>(map, kMapInstanceTypeOffset); | | return ReadField<uint8_t>(map, kMapInstanceTypeOffset); | |
| } | | } | |
| | | | |
|
| static inline int GetOddballKind(internal::Object* obj) { | | V8_INLINE(static int GetOddballKind(internal::Object* obj)) { | |
| typedef internal::Object O; | | typedef internal::Object O; | |
| return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); | | return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); | |
| } | | } | |
| | | | |
|
| static inline bool IsExternalTwoByteString(int instance_type) { | | V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { | |
| int representation = (instance_type & kFullStringRepresentationMask); | | int representation = (instance_type & kFullStringRepresentationMask); | |
| return representation == kExternalTwoByteRepresentationTag; | | return representation == kExternalTwoByteRepresentationTag; | |
| } | | } | |
| | | | |
|
| static inline bool IsInitialized(v8::Isolate* isolate) { | | V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) { | |
| uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffs
et; | | uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffs
et; | |
| return *reinterpret_cast<int*>(addr) == 1; | | return *reinterpret_cast<int*>(addr) == 1; | |
| } | | } | |
| | | | |
|
| static inline void SetEmbedderData(v8::Isolate* isolate, void* data) { | | V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data))
{ | |
| uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | | uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | |
| kIsolateEmbedderDataOffset; | | kIsolateEmbedderDataOffset; | |
| *reinterpret_cast<void**>(addr) = data; | | *reinterpret_cast<void**>(addr) = data; | |
| } | | } | |
| | | | |
|
| static inline void* GetEmbedderData(v8::Isolate* isolate) { | | V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { | |
| uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | | uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | |
| kIsolateEmbedderDataOffset; | | kIsolateEmbedderDataOffset; | |
| return *reinterpret_cast<void**>(addr); | | return *reinterpret_cast<void**>(addr); | |
| } | | } | |
| | | | |
|
| static inline internal::Object** GetRoot(v8::Isolate* isolate, int index) | | V8_INLINE(static internal::Object** GetRoot(v8::Isolate* isolate, | |
| { | | int index)) { | |
| uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffs
et; | | uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffs
et; | |
| return reinterpret_cast<internal::Object**>(addr + index * kApiPointerS
ize); | | return reinterpret_cast<internal::Object**>(addr + index * kApiPointerS
ize); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| static inline T ReadField(Object* ptr, int offset) { | | V8_INLINE(static T ReadField(Object* ptr, int offset)) { | |
| uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectT
ag; | | uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectT
ag; | |
| return *reinterpret_cast<T*>(addr); | | return *reinterpret_cast<T*>(addr); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| static inline T ReadEmbedderData(Context* context, int index) { | | V8_INLINE(static T ReadEmbedderData(Context* context, int index)) { | |
| typedef internal::Object O; | | typedef internal::Object O; | |
| typedef internal::Internals I; | | typedef internal::Internals I; | |
| O* ctx = *reinterpret_cast<O**>(context); | | O* ctx = *reinterpret_cast<O**>(context); | |
| int embedder_data_offset = I::kContextHeaderSize + | | int embedder_data_offset = I::kContextHeaderSize + | |
| (internal::kApiPointerSize * I::kContextEmbedderDataIndex); | | (internal::kApiPointerSize * I::kContextEmbedderDataIndex); | |
| O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); | | O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); | |
| int value_offset = | | int value_offset = | |
| I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); | | I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); | |
| return I::ReadField<T>(embedder_data, value_offset); | | return I::ReadField<T>(embedder_data, value_offset); | |
| } | | } | |
| | | | |
|
| static inline bool CanCastToHeapObject(void* o) { return false; } | | V8_INLINE(static bool CanCastToHeapObject(void* o)) { return false; } | |
| static inline bool CanCastToHeapObject(Context* o) { return true; } | | V8_INLINE(static bool CanCastToHeapObject(Context* o)) { return true; } | |
| static inline bool CanCastToHeapObject(String* o) { return true; } | | V8_INLINE(static bool CanCastToHeapObject(String* o)) { return true; } | |
| static inline bool CanCastToHeapObject(Object* o) { return true; } | | V8_INLINE(static bool CanCastToHeapObject(Object* o)) { return true; } | |
| static inline bool CanCastToHeapObject(Message* o) { return true; } | | V8_INLINE(static bool CanCastToHeapObject(Message* o)) { return true; } | |
| static inline bool CanCastToHeapObject(StackTrace* o) { return true; } | | V8_INLINE(static bool CanCastToHeapObject(StackTrace* o)) { return true; | |
| static inline bool CanCastToHeapObject(StackFrame* o) { return true; } | | } | |
| | | V8_INLINE(static bool CanCastToHeapObject(StackFrame* o)) { return true; | |
| | | } | |
| }; | | }; | |
| | | | |
| } // namespace internal | | } // namespace internal | |
| | | | |
| template <class T> | | template <class T> | |
| Local<T>::Local() : Handle<T>() { } | | Local<T>::Local() : Handle<T>() { } | |
| | | | |
| template <class T> | | template <class T> | |
| Local<T> Local<T>::New(Handle<T> that) { | | Local<T> Local<T>::New(Handle<T> that) { | |
| if (that.IsEmpty()) return Local<T>(); | | if (that.IsEmpty()) return Local<T>(); | |
| T* that_ptr = *that; | | T* that_ptr = *that; | |
| internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | | internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | |
| if (internal::Internals::CanCastToHeapObject(that_ptr)) { | | if (internal::Internals::CanCastToHeapObject(that_ptr)) { | |
| return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( | | return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( | |
| reinterpret_cast<internal::HeapObject*>(*p)))); | | reinterpret_cast<internal::HeapObject*>(*p)))); | |
| } | | } | |
| return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); | | return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
|
| | | Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { | |
| | | if (that.IsEmpty()) return Local<T>(); | |
| | | T* that_ptr = *that; | |
| | | internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | |
| | | return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( | |
| | | reinterpret_cast<internal::Isolate*>(isolate), *p))); | |
| | | } | |
| | | | |
| | | template <class T> | |
| Persistent<T> Persistent<T>::New(Handle<T> that) { | | Persistent<T> Persistent<T>::New(Handle<T> that) { | |
| if (that.IsEmpty()) return Persistent<T>(); | | if (that.IsEmpty()) return Persistent<T>(); | |
| internal::Object** p = reinterpret_cast<internal::Object**>(*that); | | internal::Object** p = reinterpret_cast<internal::Object**>(*that); | |
| return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); | | return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| bool Persistent<T>::IsIndependent() const { | | bool Persistent<T>::IsIndependent() const { | |
| if (this->IsEmpty()) return false; | | if (this->IsEmpty()) return false; | |
| return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**thi
s)); | | return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**thi
s)); | |
| | | | |
| skipping to change at line 4218 | | skipping to change at line 4255 | |
| return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this)
); | | return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this)
); | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| bool Persistent<T>::IsWeak() const { | | bool Persistent<T>::IsWeak() const { | |
| if (this->IsEmpty()) return false; | | if (this->IsEmpty()) return false; | |
| return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this)); | | return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this)); | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
|
| | | bool Persistent<T>::IsWeak(Isolate* isolate) const { | |
| | | if (this->IsEmpty()) return false; | |
| | | return V8::IsGlobalWeak(reinterpret_cast<internal::Isolate*>(isolate), | |
| | | reinterpret_cast<internal::Object**>(**this)); | |
| | | } | |
| | | | |
| | | template <class T> | |
| void Persistent<T>::Dispose() { | | void Persistent<T>::Dispose() { | |
| if (this->IsEmpty()) return; | | if (this->IsEmpty()) return; | |
| V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this)); | | V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this)); | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| void Persistent<T>::Dispose(Isolate* isolate) { | | void Persistent<T>::Dispose(Isolate* isolate) { | |
| if (this->IsEmpty()) return; | | if (this->IsEmpty()) return; | |
| V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate), | | V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate), | |
| reinterpret_cast<internal::Object**>(**this)); | | reinterpret_cast<internal::Object**>(**this)); | |
| | | | |
| skipping to change at line 4241 | | skipping to change at line 4285 | |
| Persistent<T>::Persistent() : Handle<T>() { } | | Persistent<T>::Persistent() : Handle<T>() { } | |
| | | | |
| template <class T> | | template <class T> | |
| void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callba
ck) { | | void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callba
ck) { | |
| V8::MakeWeak(reinterpret_cast<internal::Object**>(**this), | | V8::MakeWeak(reinterpret_cast<internal::Object**>(**this), | |
| parameters, | | parameters, | |
| callback); | | callback); | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
|
| | | void Persistent<T>::MakeWeak(Isolate* isolate, void* parameters, | |
| | | WeakReferenceCallback callback) { | |
| | | V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), | |
| | | reinterpret_cast<internal::Object**>(**this), | |
| | | parameters, | |
| | | callback); | |
| | | } | |
| | | | |
| | | template <class T> | |
| void Persistent<T>::ClearWeak() { | | void Persistent<T>::ClearWeak() { | |
| V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); | | V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| void Persistent<T>::MarkIndependent() { | | void Persistent<T>::MarkIndependent() { | |
| V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); | | V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| | | | |
End of changes. 103 change blocks. |
| 129 lines changed or deleted | | 184 lines changed or added | |
|