v8.h | v8.h | |||
---|---|---|---|---|
skipping to change at line 692 | skipping to change at line 692 | |||
* was previously assigned. | * was previously assigned. | |||
*/ | */ | |||
// TODO(dcarney): remove before cutover | // TODO(dcarney): remove before cutover | |||
V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const); | V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const); | |||
/** | /** | |||
* Disposes the current contents of the handle and replaces it. | * Disposes the current contents of the handle and replaces it. | |||
*/ | */ | |||
V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other)); | V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other)); | |||
/** | ||||
* Returns the underlying raw pointer and clears the handle. The caller i | ||||
s | ||||
* responsible of eventually destroying the underlying object (by creatin | ||||
g a | ||||
* Persistent handle which points to it and Disposing it). In the future, | ||||
* destructing a Persistent will also Dispose it. With this function, the | ||||
* embedder can let the Persistent go out of scope without it getting | ||||
* disposed. | ||||
*/ | ||||
V8_INLINE(T* ClearAndLeak()); | ||||
#ifndef V8_USE_UNSAFE_HANDLES | #ifndef V8_USE_UNSAFE_HANDLES | |||
#ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT | #ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT | |||
private: | private: | |||
#endif | #endif | |||
// TODO(dcarney): make unlinkable before cutover | // TODO(dcarney): make unlinkable before cutover | |||
V8_INLINE(Persistent(const Persistent& that)) : val_(that.val_) {} | V8_INLINE(Persistent(const Persistent& that)) : val_(that.val_) {} | |||
// TODO(dcarney): make unlinkable before cutover | // TODO(dcarney): make unlinkable before cutover | |||
V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT | V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT | |||
skipping to change at line 1761 | skipping to change at line 1771 | |||
/** | /** | |||
* Converts an object to an ASCII string. | * Converts an object to an ASCII string. | |||
* Useful if you want to print the object. | * Useful if you want to print the object. | |||
* If conversion to a string fails (eg. due to an exception in the toStri ng() | * If conversion to a string fails (eg. due to an exception in the toStri ng() | |||
* method of the object) then the length() method returns 0 and the * ope rator | * method of the object) then the length() method returns 0 and the * ope rator | |||
* returns NULL. | * returns NULL. | |||
*/ | */ | |||
class V8EXPORT AsciiValue { | class V8EXPORT AsciiValue { | |||
public: | public: | |||
// TODO(dcarney): deprecate | ||||
explicit AsciiValue(Handle<v8::Value> obj); | explicit AsciiValue(Handle<v8::Value> obj); | |||
~AsciiValue(); | ~AsciiValue(); | |||
char* operator*() { return str_; } | char* operator*() { return str_; } | |||
const char* operator*() const { return str_; } | const char* operator*() const { return str_; } | |||
int length() const { return length_; } | int length() const { return length_; } | |||
private: | private: | |||
char* str_; | char* str_; | |||
int length_; | int length_; | |||
// Disallow copying and assigning. | // Disallow copying and assigning. | |||
skipping to change at line 4512 | skipping to change at line 4523 | |||
* template. The state of the global object will be completely reset | * template. The state of the global object will be completely reset | |||
* and only object identify will remain. | * and only object identify will remain. | |||
*/ | */ | |||
static Local<Context> New( | static Local<Context> New( | |||
Isolate* isolate, | Isolate* isolate, | |||
ExtensionConfiguration* extensions = NULL, | ExtensionConfiguration* extensions = NULL, | |||
Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | |||
Handle<Value> global_object = Handle<Value>()); | Handle<Value> global_object = Handle<Value>()); | |||
/** Deprecated. Use Isolate version instead. */ | /** Deprecated. Use Isolate version instead. */ | |||
// TODO(mstarzinger): Put this behind the V8_DEPRECATED guard. | V8_DEPRECATED(static Persistent<Context> New( | |||
static Persistent<Context> New( | ||||
ExtensionConfiguration* extensions = NULL, | ExtensionConfiguration* extensions = NULL, | |||
Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | |||
Handle<Value> global_object = Handle<Value>()); | Handle<Value> global_object = Handle<Value>())); | |||
/** Returns the last entered context. */ | /** Returns the last entered context. */ | |||
static Local<Context> GetEntered(); | static Local<Context> GetEntered(); | |||
// TODO(svenpanne) Actually deprecate this. | // TODO(svenpanne) Actually deprecate this. | |||
/** Deprecated. Use Isolate::GetCurrentContext instead. */ | /** Deprecated. Use Isolate::GetCurrentContext instead. */ | |||
static Local<Context> GetCurrent(); | static Local<Context> GetCurrent(); | |||
/** | /** | |||
* Returns the context of the calling JavaScript code. That is the | * Returns the context of the calling JavaScript code. That is the | |||
skipping to change at line 4922 | skipping to change at line 4932 | |||
// 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 kFixedArrayHeaderSize = 2 * kApiPointerSize; | |||
static const int kContextHeaderSize = 2 * kApiPointerSize; | static const int kContextHeaderSize = 2 * kApiPointerSize; | |||
static const int kContextEmbedderDataIndex = 65; | static const int kContextEmbedderDataIndex = 64; | |||
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; | |||
skipping to change at line 5280 | skipping to change at line 5290 | |||
this->val_ = NULL; | this->val_ = NULL; | |||
return; | return; | |||
} | } | |||
internal::Object** p = reinterpret_cast<internal::Object**>(other.val_); | internal::Object** p = reinterpret_cast<internal::Object**>(other.val_); | |||
this->val_ = reinterpret_cast<T*>( | this->val_ = reinterpret_cast<T*>( | |||
V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p)); | V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p)); | |||
#endif | #endif | |||
} | } | |||
template <class T> | template <class T> | |||
T* Persistent<T>::ClearAndLeak() { | ||||
T* old; | ||||
#ifdef V8_USE_UNSAFE_HANDLES | ||||
old = **this; | ||||
*this = Persistent<T>(); | ||||
#else | ||||
old = val_; | ||||
val_ = NULL; | ||||
#endif | ||||
return old; | ||||
} | ||||
template <class T> | ||||
void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) { | void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) { | |||
typedef internal::Internals I; | typedef internal::Internals I; | |||
if (this->IsEmpty()) return; | if (this->IsEmpty()) return; | |||
if (!I::IsInitialized(isolate)) return; | if (!I::IsInitialized(isolate)) return; | |||
internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_) ; | internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_) ; | |||
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; | uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; | |||
*reinterpret_cast<uint16_t*>(addr) = class_id; | *reinterpret_cast<uint16_t*>(addr) = class_id; | |||
} | } | |||
template <class T> | template <class T> | |||
End of changes. 6 change blocks. | ||||
4 lines changed or deleted | 29 lines changed or added | |||