| Index: include/v8.h
|
| diff --git a/include/v8.h b/include/v8.h
|
| index c0bec79b01f1123d7926fe14a7fb0dec8dbf5810..0f949a8b89f3ca6bcf815447ff45a4ccbe7c2a17 100644
|
| --- a/include/v8.h
|
| +++ b/include/v8.h
|
| @@ -123,7 +123,6 @@ class ImplementationUtilities;
|
| class Int32;
|
| class Integer;
|
| class Isolate;
|
| -class LocalContext;
|
| class Number;
|
| class NumberObject;
|
| class Object;
|
| @@ -162,8 +161,7 @@ class Heap;
|
| class HeapObject;
|
| class Isolate;
|
| class Object;
|
| -template<typename T>
|
| -class CustomArguments;
|
| +template<typename T> class CustomArguments;
|
| class PropertyCallbackArguments;
|
| class FunctionCallbackArguments;
|
| }
|
| @@ -222,8 +220,6 @@ class WeakReferenceCallbacks {
|
| }
|
|
|
|
|
| -#define V8_USE_UNSAFE_HANDLES
|
| -
|
| /**
|
| * An object reference managed by the v8 garbage collector.
|
| *
|
| @@ -365,21 +361,19 @@ template <class T> class Handle {
|
| #endif
|
|
|
| private:
|
| + friend class Utils;
|
| template<class F> friend class Persistent;
|
| template<class F> friend class Local;
|
| friend class Arguments;
|
| template<class F> friend class FunctionCallbackInfo;
|
| template<class F> friend class PropertyCallbackInfo;
|
| - friend class String;
|
| - friend class Object;
|
| + template<class F> friend class internal::CustomArguments;
|
| friend class AccessorInfo;
|
| friend Handle<Primitive> Undefined(Isolate* isolate);
|
| friend Handle<Primitive> Null(Isolate* isolate);
|
| friend Handle<Boolean> True(Isolate* isolate);
|
| friend Handle<Boolean> False(Isolate* isolate);
|
| friend class Context;
|
| - friend class InternalHandleHelper;
|
| - friend class LocalContext;
|
| friend class HandleScope;
|
|
|
| #ifndef V8_USE_UNSAFE_HANDLES
|
| @@ -454,6 +448,7 @@ template <class T> class Local : public Handle<T> {
|
| #endif
|
|
|
| private:
|
| + friend class Utils;
|
| template<class F> friend class Persistent;
|
| template<class F> friend class Handle;
|
| friend class Arguments;
|
| @@ -463,8 +458,7 @@ template <class T> class Local : public Handle<T> {
|
| friend class Object;
|
| friend class AccessorInfo;
|
| friend class Context;
|
| - friend class InternalHandleHelper;
|
| - friend class LocalContext;
|
| + template<class F> friend class internal::CustomArguments;
|
| friend class HandleScope;
|
|
|
| V8_INLINE(static Local<T> New(Isolate* isolate, T* that));
|
| @@ -496,10 +490,10 @@ template <class T> class Persistent // NOLINT
|
| public:
|
| #ifndef V8_USE_UNSAFE_HANDLES
|
| V8_INLINE(Persistent()) : val_(0) { }
|
| - V8_INLINE(~Persistent()) {
|
| - // TODO(dcarney): add this back before cutover.
|
| - // Dispose();
|
| - }
|
| + // TODO(dcarney): add this back before cutover.
|
| +// V8_INLINE(~Persistent()) {
|
| +// Dispose();
|
| +// }
|
| V8_INLINE(bool IsEmpty() const) { return val_ == 0; }
|
| // TODO(dcarney): remove somehow before cutover
|
| // The handle should either be 0, or a pointer to a live cell.
|
| @@ -511,11 +505,11 @@ template <class T> class Persistent // NOLINT
|
| * to be separately disposed.
|
| */
|
| template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that))
|
| - : val_(*New(isolate, that)) { }
|
| + : val_(New(isolate, *that)) { }
|
|
|
| template <class S> V8_INLINE(Persistent(Isolate* isolate,
|
| Persistent<S>& that)) // NOLINT
|
| - : val_(*New(isolate, that)) { }
|
| + : val_(New(isolate, *that)) { }
|
|
|
| #else
|
| /**
|
| @@ -594,15 +588,9 @@ template <class T> class Persistent // NOLINT
|
| }
|
| #endif
|
|
|
| +#ifdef V8_USE_UNSAFE_HANDLES
|
| V8_DEPRECATED(static Persistent<T> New(Handle<T> that));
|
| -
|
| - /**
|
| - * Creates a new persistent handle for an existing local or persistent handle.
|
| - */
|
| - // TODO(dcarney): remove before cutover
|
| V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that));
|
| -#ifndef V8_USE_UNSAFE_HANDLES
|
| - // TODO(dcarney): remove before cutover
|
| V8_INLINE(static Persistent<T> New(Isolate* isolate, Persistent<T> that));
|
| #endif
|
|
|
| @@ -652,23 +640,17 @@ template <class T> class Persistent // NOLINT
|
| P* parameters,
|
| typename WeakReferenceCallbacks<T, P>::Revivable callback));
|
|
|
| - // TODO(dcarney): deprecate
|
| template<typename S, typename P>
|
| - V8_INLINE(void MakeWeak(
|
| + V8_DEPRECATED(void MakeWeak(
|
| Isolate* isolate,
|
| P* parameters,
|
| - typename WeakReferenceCallbacks<S, P>::Revivable callback)) {
|
| - MakeWeak<S, P>(parameters, callback);
|
| - }
|
| + typename WeakReferenceCallbacks<S, P>::Revivable callback));
|
|
|
| - // TODO(dcarney): deprecate
|
| template<typename P>
|
| - V8_INLINE(void MakeWeak(
|
| + V8_DEPRECATED(void MakeWeak(
|
| Isolate* isolate,
|
| P* parameters,
|
| - typename WeakReferenceCallbacks<T, P>::Revivable callback)) {
|
| - MakeWeak<P>(parameters, callback);
|
| - }
|
| + typename WeakReferenceCallbacks<T, P>::Revivable callback));
|
|
|
| V8_INLINE(void ClearWeak());
|
|
|
| @@ -779,11 +761,7 @@ template <class T> class Persistent // NOLINT
|
| #endif
|
| // TODO(dcarney): remove before cutover
|
| template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { }
|
| - // TODO(dcarney): remove before cutover
|
| - template <class S> V8_INLINE(Persistent(Persistent<S> that))
|
| - : val_(*that) {
|
| - TYPE_CHECK(T, S);
|
| - }
|
| +
|
| // TODO(dcarney): remove before cutover
|
| V8_INLINE(T* operator*() const) { return val_; }
|
|
|
| @@ -794,16 +772,13 @@ template <class T> class Persistent // NOLINT
|
| #endif
|
|
|
| private:
|
| + friend class Utils;
|
| template<class F> friend class Handle;
|
| template<class F> friend class Local;
|
| + template<class F> friend class Persistent;
|
| template<class F> friend class ReturnValue;
|
| - friend class ImplementationUtilities;
|
| - friend class ObjectTemplate;
|
| - friend class Context;
|
| - friend class InternalHandleHelper;
|
| - friend class LocalContext;
|
|
|
| - V8_INLINE(static Persistent<T> New(Isolate* isolate, T* that));
|
| + V8_INLINE(static T* New(Isolate* isolate, T* that));
|
|
|
| #ifndef V8_USE_UNSAFE_HANDLES
|
| T* val_;
|
| @@ -5333,7 +5308,7 @@ class Internals {
|
| static const int kNullValueRootIndex = 7;
|
| static const int kTrueValueRootIndex = 8;
|
| static const int kFalseValueRootIndex = 9;
|
| - static const int kEmptyStringRootIndex = 130;
|
| + static const int kEmptyStringRootIndex = 131;
|
|
|
| static const int kNodeClassIdOffset = 1 * kApiPointerSize;
|
| static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
|
| @@ -5343,10 +5318,10 @@ class Internals {
|
| static const int kNodeIsIndependentShift = 4;
|
| static const int kNodeIsPartiallyDependentShift = 5;
|
|
|
| - static const int kJSObjectType = 0xaf;
|
| + static const int kJSObjectType = 0xb0;
|
| static const int kFirstNonstringType = 0x80;
|
| static const int kOddballType = 0x83;
|
| - static const int kForeignType = 0x87;
|
| + static const int kForeignType = 0x88;
|
|
|
| static const int kUndefinedOddballKind = 5;
|
| static const int kNullOddballKind = 3;
|
| @@ -5510,6 +5485,7 @@ Local<T> Local<T>::New(Isolate* isolate, T* that) {
|
| }
|
|
|
|
|
| +#ifdef V8_USE_UNSAFE_HANDLES
|
| template <class T>
|
| Persistent<T> Persistent<T>::New(Handle<T> that) {
|
| return New(Isolate::GetCurrent(), that.val_);
|
| @@ -5521,20 +5497,20 @@ Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) {
|
| return New(Isolate::GetCurrent(), that.val_);
|
| }
|
|
|
| -#ifndef V8_USE_UNSAFE_HANDLES
|
| template <class T>
|
| Persistent<T> Persistent<T>::New(Isolate* isolate, Persistent<T> that) {
|
| return New(Isolate::GetCurrent(), that.val_);
|
| }
|
| #endif
|
|
|
| +
|
| template <class T>
|
| -Persistent<T> Persistent<T>::New(Isolate* isolate, T* that) {
|
| - if (that == NULL) return Persistent<T>();
|
| +T* Persistent<T>::New(Isolate* isolate, T* that) {
|
| + if (that == NULL) return NULL;
|
| internal::Object** p = reinterpret_cast<internal::Object**>(that);
|
| - return Persistent<T>(reinterpret_cast<T*>(
|
| + return reinterpret_cast<T*>(
|
| V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
|
| - p)));
|
| + p));
|
| }
|
|
|
|
|
| @@ -5598,6 +5574,26 @@ void Persistent<T>::MakeWeak(
|
|
|
|
|
| template <class T>
|
| +template <typename S, typename P>
|
| +void Persistent<T>::MakeWeak(
|
| + Isolate* isolate,
|
| + P* parameters,
|
| + typename WeakReferenceCallbacks<S, P>::Revivable callback) {
|
| + MakeWeak<S, P>(parameters, callback);
|
| +}
|
| +
|
| +
|
| +template <class T>
|
| +template<typename P>
|
| +void Persistent<T>::MakeWeak(
|
| + Isolate* isolate,
|
| + P* parameters,
|
| + typename WeakReferenceCallbacks<T, P>::Revivable callback) {
|
| + MakeWeak<P>(parameters, callback);
|
| +}
|
| +
|
| +
|
| +template <class T>
|
| void Persistent<T>::ClearWeak() {
|
| V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_));
|
| }
|
| @@ -5716,11 +5712,13 @@ void ReturnValue<T>::Set(const Handle<S> handle) {
|
|
|
| template<typename T>
|
| void ReturnValue<T>::Set(double i) {
|
| + TYPE_CHECK(T, Number);
|
| Set(Number::New(GetIsolate(), i));
|
| }
|
|
|
| template<typename T>
|
| void ReturnValue<T>::Set(int32_t i) {
|
| + TYPE_CHECK(T, Integer);
|
| typedef internal::Internals I;
|
| if (V8_LIKELY(I::IsValidSmi(i))) {
|
| *value_ = I::IntToSmi(i);
|
| @@ -5731,6 +5729,7 @@ void ReturnValue<T>::Set(int32_t i) {
|
|
|
| template<typename T>
|
| void ReturnValue<T>::Set(uint32_t i) {
|
| + TYPE_CHECK(T, Integer);
|
| typedef internal::Internals I;
|
| // Can't simply use INT32_MAX here for whatever reason.
|
| bool fits_into_int32_t = (i & (1 << 31)) == 0;
|
| @@ -5743,6 +5742,7 @@ void ReturnValue<T>::Set(uint32_t i) {
|
|
|
| template<typename T>
|
| void ReturnValue<T>::Set(bool value) {
|
| + TYPE_CHECK(T, Boolean);
|
| typedef internal::Internals I;
|
| int root_index;
|
| if (value) {
|
| @@ -5755,18 +5755,21 @@ void ReturnValue<T>::Set(bool value) {
|
|
|
| template<typename T>
|
| void ReturnValue<T>::SetNull() {
|
| + TYPE_CHECK(T, Primitive);
|
| typedef internal::Internals I;
|
| *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
|
| }
|
|
|
| template<typename T>
|
| void ReturnValue<T>::SetUndefined() {
|
| + TYPE_CHECK(T, Primitive);
|
| typedef internal::Internals I;
|
| *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
|
| }
|
|
|
| template<typename T>
|
| void ReturnValue<T>::SetEmptyString() {
|
| + TYPE_CHECK(T, String);
|
| typedef internal::Internals I;
|
| *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
|
| }
|
|
|