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
// TODO(svenpanne) Remove this when the Chrome's v8 bindings have been adap
ted.
#define V8_DISABLE_DEPRECATIONS 1
#if defined(__GNUC__) && !defined(V8_DISABLE_DEPRECATIONS)
#define V8_DEPRECATED(func) func __attribute__ ((deprecated))
#elif defined(_MSC_VER) && !defined(V8_DISABLE_DEPRECATIONS)
#define V8_DEPRECATED(func) __declspec(deprecated) func
#else
#define V8_DEPRECATED(func) func
#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;
class Value; class Value;
class Utils; class Utils;
skipping to change at line 1577 skipping to change at line 1588
*/ */
V8EXPORT Local<Value> GetConstructor(); V8EXPORT Local<Value> GetConstructor();
/** /**
* 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 in an internal field. */
/** Gets the value from an internal field. */
inline Local<Value> GetInternalField(int index); 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. */ /**
inline void* GetPointerFromInternalField(int index); * Gets a native pointer from an internal field. Deprecated. If the point
er is
* always 2-byte-aligned, use GetAlignedPointerFromInternalField instead,
* otherwise use a combination of GetInternalField, External::Cast and
* External::Value.
*/
V8EXPORT V8_DEPRECATED(void* GetPointerFromInternalField(int index));
/** Sets a native pointer in an internal field. */ /**
V8EXPORT void SetPointerInInternalField(int index, void* value); * Sets a native pointer in an internal field. Deprecated. If the pointer
is
* always 2-byte aligned, use SetAlignedPointerInInternalField instead,
* otherwise use a combination of External::New and SetInternalField.
*/
inline V8_DEPRECATED(void SetPointerInInternalField(int index, void* valu
e));
/**
* Gets a 2-byte-aligned native pointer from an internal field. This fiel
d
* must have been set by SetAlignedPointerInInternalField, everything els
e
* leads to undefined behavior.
*/
inline void* GetAlignedPointerFromInternalField(int index);
/**
* Sets a 2-byte-aligned native pointer in an internal field. To retrieve
such
* a field, GetAlignedPointerFromInternalField must be used, everything e
lse
* leads to undefined behavior.
*/
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);
V8EXPORT bool HasRealNamedProperty(Handle<String> key); V8EXPORT bool HasRealNamedProperty(Handle<String> key);
V8EXPORT bool HasRealIndexedProperty(uint32_t index); V8EXPORT bool HasRealIndexedProperty(uint32_t index);
V8EXPORT bool HasRealNamedCallbackProperty(Handle<String> key); V8EXPORT bool HasRealNamedCallbackProperty(Handle<String> key);
/** /**
* If result.IsEmpty() no real property was located in the prototype chai n. * If result.IsEmpty() no real property was located in the prototype chai n.
* This means interceptors in the prototype chain are not called. * This means interceptors in the prototype chain are not called.
skipping to change at line 1717 skipping to change at line 1753
*/ */
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); static inline 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> CheckedGetInternalField(int index); V8EXPORT Local<Value> SlowGetInternalField(int index);
V8EXPORT void* SlowGetPointerFromInternalField(int index); V8EXPORT void* SlowGetAlignedPointerFromInternalField(int index);
/**
* If quick access to the internal field is possible this method
* returns the value. Otherwise an empty handle is returned.
*/
inline Local<Value> UncheckedGetInternalField(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).
*/ */
class Array : public Object { class Array : public Object {
public: public:
V8EXPORT uint32_t Length() const; V8EXPORT uint32_t Length() const;
/** /**
skipping to change at line 1927 skipping to change at line 1957
*/ */
V8EXPORT Flags GetFlags() const; V8EXPORT Flags GetFlags() const;
static inline RegExp* Cast(v8::Value* obj); static inline 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 * A JavaScript value that wraps a C++ void*. This type of value is mainly
* mainly used to associate C++ data structures with JavaScript used
* objects. * to associate C++ data structures with JavaScript objects.
*
* The Wrap function V8 will return the most optimal Value object wrapping
the
* C++ void*. The type of the value is not guaranteed to be an External obj
ect
* and no assumptions about its type should be made. To access the wrapped
* value Unwrap should be used, all other operations on that object will le
ad
* to unpredictable results.
*/ */
class External : public Value { class External : public Value {
public: public:
V8EXPORT static Local<Value> Wrap(void* data); /** Deprecated, use New instead. */
static inline void* Unwrap(Handle<Value> obj); V8_DEPRECATED(static inline Local<Value> Wrap(void* value));
/** Deprecated, use a combination of Cast and Value instead. */
V8_DEPRECATED(static inline 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); static inline External* Cast(Value* obj);
V8EXPORT void* Value() const; V8EXPORT void* Value() const;
private: private:
V8EXPORT External();
V8EXPORT static void CheckCast(v8::Value* obj); V8EXPORT static void CheckCast(v8::Value* obj);
static inline void* QuickUnwrap(Handle<v8::Value> obj);
V8EXPORT static void* FullUnwrap(Handle<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.*/
skipping to change at line 3691 skipping to change at line 3714
*/ */
void Exit(); void Exit();
/** 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();
/** /**
* Associate an additional data object with the context. This is mainly u * Gets embedder data with index 0. Deprecated, use GetEmbedderData with
sed index
* with the debugger to provide additional information on the context thr * 0 instead.
ough */
* the debugger API. V8_DEPRECATED(inline Local<Value> GetData());
/**
* Sets embedder data with index 0. Deprecated, use SetEmbedderData with
index
* 0 instead.
*/ */
void SetData(Handle<Value> data); V8_DEPRECATED(inline void SetData(Handle<Value> value));
Local<Value> GetData();
/**
* 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
* currently has a special meaning for Chrome's debugger.
*/
inline Local<Value> GetEmbedderData(int index);
/**
* 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
* debugger.
*/
void SetEmbedderData(int index, Handle<Value> value);
/**
* 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
* SetAlignedPointerInEmbedderData with the same index. Note that index 0
* currently has a special meaning for Chrome's debugger.
*/
inline void* GetAlignedPointerFromEmbedderData(int index);
/**
* 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
* special meaning for Chrome's debugger.
*/
void SetAlignedPointerInEmbedderData(int index, void* value);
/** /**
* Control whether code generation from strings is allowed. Calling * Control whether code generation from strings is allowed. Calling
* this method with false will disable 'eval' and the 'Function' * this method with false will disable 'eval' and the 'Function'
* constructor for code running in this context. If 'eval' or the * constructor for code running in this context. If 'eval' or the
* 'Function' constructor are used an exception will be thrown. * 'Function' constructor are used an exception will be thrown.
* *
* If code generation from strings is not allowed the * If code generation from strings is not allowed the
* V8::AllowCodeGenerationFromStrings callback will be invoked if * V8::AllowCodeGenerationFromStrings callback will be invoked if
* set before blocking the call to 'eval' or the 'Function' * set before blocking the call to 'eval' or the 'Function'
skipping to change at line 3745 skipping to change at line 3801
inline ~Scope() { context_->Exit(); } 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;
Local<Value> SlowGetEmbedderData(int index);
void* SlowGetAlignedPointerFromEmbedderData(int index);
}; };
/** /**
* Multiple threads in V8 are allowed, but only one thread at a time * Multiple threads in V8 are allowed, but only one thread at a time
* is allowed to use any given V8 isolate. See Isolate class * is allowed to use any given V8 isolate. See Isolate class
* comments. The definition of 'using V8 isolate' includes * comments. The definition of 'using V8 isolate' includes
* accessing handles or holding onto object pointers obtained * accessing handles or holding onto object pointers obtained
* from V8 handles while in the particular V8 isolate. It is up * from V8 handles while in the particular V8 isolate. It is up
* to the user of V8 to ensure (perhaps with locking) that this * to the user of V8 to ensure (perhaps with locking) that this
* constraint is not violated. In addition to any other synchronization * constraint is not violated. In addition to any other synchronization
skipping to change at line 3971 skipping to change at line 4030
// 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) { static inline 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;
} }
// For 32-bit systems any 2 bytes aligned pointer can be encoded as smi
// with a plain reinterpret_cast.
static const uintptr_t kEncodablePointerMask = 0x1;
static const int kPointerToSmiShift = 0;
}; };
// 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) { static inline 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 );
} }
// To maximize the range of pointers that can be encoded
// in the available 32 bits, we require them to be 8 bytes aligned.
// This gives 2 ^ (32 + 3) = 32G address space covered.
// It might be not enough to cover stack allocated objects on some platfo
rms.
static const int kPointerAlignment = 3;
static const uintptr_t kEncodablePointerMask =
~(uintptr_t(0xffffffff) << kPointerAlignment);
static const int kPointerToSmiShift =
kSmiTagSize + kSmiShiftSize - kPointerAlignment;
}; };
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;
const uintptr_t kEncodablePointerMask =
PlatformSmiTagging::kEncodablePointerMask;
const int kPointerToSmiShift = PlatformSmiTagging::kPointerToSmiShift;
/** /**
* This class exports constants and functionality from within v8 that * This class exports constants and functionality from within v8 that
* is necessary to implement inline functions in the v8 api. Don't * is necessary to implement inline functions in the v8 api. Don't
* depend on functions and constants defined here. * depend on functions and constants defined here.
*/ */
class Internals { class Internals {
public: public:
// These values match non-compiler-dependent values defined within // These values match non-compiler-dependent values defined within
// the implementation of v8. // the implementation of v8.
static const int kHeapObjectMapOffset = 0; static const int kHeapObjectMapOffset = 0;
static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSi ze; static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSi ze;
static const int kStringResourceOffset = 3 * kApiPointerSize; static const int kStringResourceOffset = 3 * kApiPointerSize;
static const int kOddballKindOffset = 3 * kApiPointerSize; static const int kOddballKindOffset = 3 * kApiPointerSize;
static const int kForeignAddressOffset = kApiPointerSize; static const int kForeignAddressOffset = kApiPointerSize;
static const int kJSObjectHeaderSize = 3 * kApiPointerSize; static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
static const int kContextHeaderSize = 2 * kApiPointerSize;
static const int kContextEmbedderDataIndex = 54;
static const int kFullStringRepresentationMask = 0x07; static const int kFullStringRepresentationMask = 0x07;
static const int kStringEncodingMask = 0x4; static const int kStringEncodingMask = 0x4;
static const int kExternalTwoByteRepresentationTag = 0x02; static const int kExternalTwoByteRepresentationTag = 0x02;
static const int kExternalAsciiRepresentationTag = 0x06; static const int kExternalAsciiRepresentationTag = 0x06;
static const int kIsolateStateOffset = 0; static const int kIsolateStateOffset = 0;
static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
static const int kIsolateRootsOffset = 3 * kApiPointerSize; static const int kIsolateRootsOffset = 3 * kApiPointerSize;
static const int kUndefinedValueRootIndex = 5; static const int kUndefinedValueRootIndex = 5;
static const int kNullValueRootIndex = 7; static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8; static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9; static const int kFalseValueRootIndex = 9;
static const int kEmptySymbolRootIndex = 118; 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) { static inline bool HasHeapObjectTag(internal::Object* value) {
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
kHeapObjectTag); kHeapObjectTag);
} }
static inline bool HasSmiTag(internal::Object* value) {
return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag);
}
static inline int SmiValue(internal::Object* value) { static inline int SmiValue(internal::Object* value) {
return PlatformSmiTagging::SmiToInt(value); return PlatformSmiTagging::SmiToInt(value);
} }
static inline int GetInstanceType(internal::Object* obj) { static inline 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) { static inline 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 void* GetExternalPointerFromSmi(internal::Object* value) {
const uintptr_t address = reinterpret_cast<uintptr_t>(value);
return reinterpret_cast<void*>(address >> kPointerToSmiShift);
}
static inline void* GetExternalPointer(internal::Object* obj) {
if (HasSmiTag(obj)) {
return GetExternalPointerFromSmi(obj);
} else if (GetInstanceType(obj) == kForeignType) {
return ReadField<void*>(obj, kForeignAddressOffset);
} else {
return NULL;
}
}
static inline bool IsExternalTwoByteString(int instance_type) { static inline 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) { static inline 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;
} }
skipping to change at line 4118 skipping to change at line 4141
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) { static inline 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>
static inline T ReadEmbedderData(Context* context, int index) {
typedef internal::Object O;
typedef internal::Internals I;
O* ctx = *reinterpret_cast<O**>(context);
int embedder_data_offset = I::kContextHeaderSize +
(internal::kApiPointerSize * I::kContextEmbedderDataIndex);
O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
int value_offset =
I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
return I::ReadField<T>(embedder_data, value_offset);
}
static inline bool CanCastToHeapObject(void* o) { return false; } static inline bool CanCastToHeapObject(void* o) { return false; }
static inline bool CanCastToHeapObject(Context* o) { return true; } static inline bool CanCastToHeapObject(Context* o) { return true; }
static inline bool CanCastToHeapObject(String* o) { return true; } static inline bool CanCastToHeapObject(String* o) { return true; }
static inline bool CanCastToHeapObject(Object* o) { return true; } static inline bool CanCastToHeapObject(Object* o) { return true; }
static inline bool CanCastToHeapObject(Message* o) { return true; } static inline bool CanCastToHeapObject(Message* o) { return true; }
static inline bool CanCastToHeapObject(StackTrace* o) { return true; } static inline bool CanCastToHeapObject(StackTrace* o) { return true; }
static inline bool CanCastToHeapObject(StackFrame* o) { return true; } static inline bool CanCastToHeapObject(StackFrame* o) { return true; }
}; };
} // namespace internal } // namespace internal
skipping to change at line 4308 skipping to change at line 4344
Handle<Boolean> Boolean::New(bool value) { Handle<Boolean> Boolean::New(bool value) {
return value ? True() : False(); return value ? True() : False();
} }
void Template::Set(const char* name, v8::Handle<Data> value) { void Template::Set(const char* name, v8::Handle<Data> value) {
Set(v8::String::New(name), value); Set(v8::String::New(name), value);
} }
Local<Value> Object::GetInternalField(int index) { Local<Value> Object::GetInternalField(int index) {
#ifndef V8_ENABLE_CHECKS #ifndef V8_ENABLE_CHECKS
Local<Value> quick_result = UncheckedGetInternalField(index);
if (!quick_result.IsEmpty()) return quick_result;
#endif
return CheckedGetInternalField(index);
}
Local<Value> Object::UncheckedGetInternalField(int index) {
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(this); O* obj = *reinterpret_cast<O**>(this);
// Fast path: If the object is a plain JSObject, which is the common case
, we
// know where to find the internal fields and can return the value direct
ly.
if (I::GetInstanceType(obj) == I::kJSObjectType) { if (I::GetInstanceType(obj) == I::kJSObjectType) {
// If the object is a plain JSObject, which is the common case,
// we know where to find the internal fields and can return the
// value directly.
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x); int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x);
O* value = I::ReadField<O*>(obj, offset); O* value = I::ReadField<O*>(obj, offset);
O** result = HandleScope::CreateHandle(value); O** result = HandleScope::CreateHandle(value);
return Local<Value>(reinterpret_cast<Value*>(result)); return Local<Value>(reinterpret_cast<Value*>(result));
} else {
return Local<Value>();
} }
}
void* External::Unwrap(Handle<v8::Value> obj) {
#ifdef V8_ENABLE_CHECKS
return FullUnwrap(obj);
#else
return QuickUnwrap(obj);
#endif #endif
return SlowGetInternalField(index);
} }
void* External::QuickUnwrap(Handle<v8::Value> wrapper) { void Object::SetPointerInInternalField(int index, void* value) {
typedef internal::Object O; SetInternalField(index, External::New(value));
O* obj = *reinterpret_cast<O**>(const_cast<v8::Value*>(*wrapper));
return internal::Internals::GetExternalPointer(obj);
} }
void* Object::GetPointerFromInternalField(int index) { void* Object::GetAlignedPointerFromInternalField(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(this); O* obj = *reinterpret_cast<O**>(this);
// Fast path: If the object is a plain JSObject, which is the common case
, we
// know where to find the internal fields and can return the value direct
ly.
if (I::GetInstanceType(obj) == I::kJSObjectType) { if (I::GetInstanceType(obj) == I::kJSObjectType) {
// If the object is a plain JSObject, which is the common case,
// we know where to find the internal fields and can return the
// value directly.
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x); int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x);
O* value = I::ReadField<O*>(obj, offset); return I::ReadField<void*>(obj, offset);
return I::GetExternalPointer(value);
} }
#endif
return SlowGetPointerFromInternalField(index); return SlowGetAlignedPointerFromInternalField(index);
} }
String* String::Cast(v8::Value* value) { String* String::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
CheckCast(value); CheckCast(value);
#endif #endif
return static_cast<String*>(value); return static_cast<String*>(value);
} }
Local<String> String::Empty(Isolate* isolate) { Local<String> String::Empty(Isolate* isolate) {
skipping to change at line 4534 skipping to change at line 4549
return static_cast<Array*>(value); return static_cast<Array*>(value);
} }
Function* Function::Cast(v8::Value* value) { Function* Function::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
CheckCast(value); CheckCast(value);
#endif #endif
return static_cast<Function*>(value); return static_cast<Function*>(value);
} }
Local<Value> External::Wrap(void* value) {
return External::New(value);
}
void* External::Unwrap(Handle<v8::Value> obj) {
return External::Cast(*obj)->Value();
}
External* External::Cast(v8::Value* value) { External* External::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
CheckCast(value); CheckCast(value);
#endif #endif
return static_cast<External*>(value); return static_cast<External*>(value);
} }
Isolate* AccessorInfo::GetIsolate() const { Isolate* AccessorInfo::GetIsolate() const {
return *reinterpret_cast<Isolate**>(&args_[-3]); return *reinterpret_cast<Isolate**>(&args_[-3]);
} }
skipping to change at line 4599 skipping to change at line 4622
void Isolate::SetData(void* data) { void Isolate::SetData(void* data) {
typedef internal::Internals I; typedef internal::Internals I;
I::SetEmbedderData(this, data); I::SetEmbedderData(this, data);
} }
void* Isolate::GetData() { void* Isolate::GetData() {
typedef internal::Internals I; typedef internal::Internals I;
return I::GetEmbedderData(this); return I::GetEmbedderData(this);
} }
Local<Value> Context::GetData() {
return GetEmbedderData(0);
}
void Context::SetData(Handle<Value> data) {
SetEmbedderData(0, data);
}
Local<Value> Context::GetEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
typedef internal::Internals I;
O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, inde
x));
return Local<Value>(reinterpret_cast<Value*>(result));
#else
return SlowGetEmbedderData(index);
#endif
}
void* Context::GetAlignedPointerFromEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Internals I;
return I::ReadEmbedderData<void*>(this, index);
#else
return SlowGetAlignedPointerFromEmbedderData(index);
#endif
}
/** /**
* \example shell.cc * \example shell.cc
* A simple shell that takes a list of expressions on the * A simple shell that takes a list of expressions on the
* command-line and executes them. * command-line and executes them.
*/ */
/** /**
* \example process.cc * \example process.cc
*/ */
 End of changes. 36 change blocks. 
111 lines changed or deleted 176 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/