diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 63edc67edfd95f..4a104e57d873b9 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -1123,6 +1123,10 @@ class V8_EXPORT PrimitiveArray { public: static Local New(Isolate* isolate, int length); int Length() const; + V8_DEPRECATED("Use Isolate* version", + void Set(int index, Local item)); + V8_DEPRECATED("Use Isolate* version", + Local Get(int index)); void Set(Isolate* isolate, int index, Local item); Local Get(Isolate* isolate, int index); }; @@ -1829,6 +1833,8 @@ class V8_EXPORT StackTrace { /** * Returns a StackFrame at a particular index. */ + V8_DEPRECATED("Use Isolate version", + Local GetFrame(uint32_t index) const); Local GetFrame(Isolate* isolate, uint32_t index) const; /** @@ -2524,18 +2530,25 @@ class V8_EXPORT Value : public Data { Local context) const; V8_WARN_UNUSED_RESULT MaybeLocal ToInt32(Local context) const; - V8_DEPRECATE_SOON("Use maybe version", - Local ToBoolean(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local ToNumber(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local ToString(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local ToObject(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local ToInteger(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local ToInt32(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToBoolean(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToNumber(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToString(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToObject(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToInteger(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToInt32(Isolate* isolate) const); + + inline V8_DEPRECATED("Use maybe version", + Local ToBoolean() const); + inline V8_DEPRECATED("Use maybe version", Local ToString() const); + inline V8_DEPRECATED("Use maybe version", Local ToObject() const); + inline V8_DEPRECATED("Use maybe version", + Local ToInteger() const); /** * Attempts to convert a string to an array index. @@ -2552,7 +2565,14 @@ class V8_EXPORT Value : public Data { Local context) const; V8_WARN_UNUSED_RESULT Maybe Int32Value(Local context) const; + V8_DEPRECATED("Use maybe version", bool BooleanValue() const); + V8_DEPRECATED("Use maybe version", double NumberValue() const); + V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const); + V8_DEPRECATED("Use maybe version", uint32_t Uint32Value() const); + V8_DEPRECATED("Use maybe version", int32_t Int32Value() const); + /** JS == */ + V8_DEPRECATED("Use maybe version", bool Equals(Local that) const); V8_WARN_UNUSED_RESULT Maybe Equals(Local context, Local that) const; bool StrictEquals(Local that) const; @@ -2659,6 +2679,8 @@ class V8_EXPORT String : public Name { * Returns the number of bytes in the UTF-8 encoded * representation of this string. */ + V8_DEPRECATED("Use Isolate version instead", int Utf8Length() const); + int Utf8Length(Isolate* isolate) const; /** @@ -2715,12 +2737,23 @@ class V8_EXPORT String : public Name { // 16-bit character codes. int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1, int options = NO_OPTIONS) const; + V8_DEPRECATED("Use Isolate* version", + int Write(uint16_t* buffer, int start = 0, int length = -1, + int options = NO_OPTIONS) const); // One byte characters. int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0, int length = -1, int options = NO_OPTIONS) const; + V8_DEPRECATED("Use Isolate* version", + int WriteOneByte(uint8_t* buffer, int start = 0, + int length = -1, int options = NO_OPTIONS) + const); // UTF-8 encoded characters. int WriteUtf8(Isolate* isolate, char* buffer, int length = -1, int* nchars_ref = NULL, int options = NO_OPTIONS) const; + V8_DEPRECATED("Use Isolate* version", + int WriteUtf8(char* buffer, int length = -1, + int* nchars_ref = NULL, + int options = NO_OPTIONS) const); /** * A zero length string. @@ -2884,6 +2917,9 @@ class V8_EXPORT String : public Name { */ static Local Concat(Isolate* isolate, Local left, Local right); + static V8_DEPRECATED("Use Isolate* version", + Local Concat(Local left, + Local right)); /** * Creates a new external string using the data defined in the given @@ -2952,6 +2988,8 @@ class V8_EXPORT String : public Name { */ class V8_EXPORT Utf8Value { public: + V8_DEPRECATED("Use Isolate version", + explicit Utf8Value(Local obj)); Utf8Value(Isolate* isolate, Local obj); ~Utf8Value(); char* operator*() { return str_; } @@ -2975,6 +3013,7 @@ class V8_EXPORT String : public Name { */ class V8_EXPORT Value { public: + V8_DEPRECATED("Use Isolate version", explicit Value(Local obj)); Value(Isolate* isolate, Local obj); ~Value(); uint16_t* operator*() { return str_; } @@ -5217,6 +5256,8 @@ class V8_EXPORT BooleanObject : public Object { class V8_EXPORT StringObject : public Object { public: static Local New(Isolate* isolate, Local value); + V8_DEPRECATED("Use Isolate* version", + static Local New(Local value)); Local ValueOf() const; @@ -10216,6 +10257,30 @@ template Value* Value::Cast(T* value) { } +Local Value::ToBoolean() const { + return ToBoolean(Isolate::GetCurrent()->GetCurrentContext()) + .FromMaybe(Local()); +} + + +Local Value::ToString() const { + return ToString(Isolate::GetCurrent()->GetCurrentContext()) + .FromMaybe(Local()); +} + + +Local Value::ToObject() const { + return ToObject(Isolate::GetCurrent()->GetCurrentContext()) + .FromMaybe(Local()); +} + + +Local Value::ToInteger() const { + return ToInteger(Isolate::GetCurrent()->GetCurrentContext()) + .FromMaybe(Local()); +} + + Boolean* Boolean::Cast(v8::Value* value) { #ifdef V8_ENABLE_CHECKS CheckCast(value); diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index d141496c5749cc..5f1737b2a42b2d 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -2157,6 +2157,10 @@ int PrimitiveArray::Length() const { return array->length(); } +void PrimitiveArray::Set(int index, Local item) { + return Set(Isolate::GetCurrent(), index, item); +} + void PrimitiveArray::Set(Isolate* v8_isolate, int index, Local item) { i::Isolate* isolate = reinterpret_cast(v8_isolate); @@ -2170,6 +2174,10 @@ void PrimitiveArray::Set(Isolate* v8_isolate, int index, array->set(index, *i_item); } +Local PrimitiveArray::Get(int index) { + return Get(Isolate::GetCurrent(), index); +} + Local PrimitiveArray::Get(Isolate* v8_isolate, int index) { i::Isolate* isolate = reinterpret_cast(v8_isolate); i::Handle array = Utils::OpenHandle(this); @@ -2900,6 +2908,10 @@ void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { // --- S t a c k T r a c e --- +Local StackTrace::GetFrame(uint32_t index) const { + return GetFrame(Isolate::GetCurrent(), index); +} + Local StackTrace::GetFrame(Isolate* v8_isolate, uint32_t index) const { i::Isolate* isolate = reinterpret_cast(v8_isolate); @@ -3876,6 +3888,36 @@ void v8::RegExp::CheckCast(v8::Value* that) { } +bool Value::BooleanValue() const { + return BooleanValue(Isolate::GetCurrent()->GetCurrentContext()) + .FromJust(); +} + + +double Value::NumberValue() const { + return NumberValue(Isolate::GetCurrent()->GetCurrentContext()) + .FromMaybe(std::numeric_limits::quiet_NaN()); +} + + +int64_t Value::IntegerValue() const { + return NumberValue(Isolate::GetCurrent()->GetCurrentContext()) + .FromMaybe(0); +} + + +uint32_t Value::Uint32Value() const { + return Uint32Value(Isolate::GetCurrent()->GetCurrentContext()) + .FromMaybe(0); +} + + +int32_t Value::Int32Value() const { + return Int32Value(Isolate::GetCurrent()->GetCurrentContext()) + .FromMaybe(0); +} + + Maybe Value::BooleanValue(Local context) const { i::Isolate* isolate = reinterpret_cast(context->GetIsolate()); return Just(Utils::OpenHandle(this)->BooleanValue(isolate)); @@ -3964,6 +4006,12 @@ MaybeLocal Value::ToArrayIndex(Local context) const { } +bool Value::Equals(Local that) const { + return Equals(Isolate::GetCurrent()->GetCurrentContext(), that) + .FromMaybe(false); +} + + Maybe Value::Equals(Local context, Local that) const { i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); auto self = Utils::OpenHandle(this); @@ -5295,6 +5343,10 @@ bool String::ContainsOnlyOneByte() const { return helper.Check(*str); } +int String::Utf8Length() const { + return Utf8Length(Isolate::GetCurrent()); +} + int String::Utf8Length(Isolate* isolate) const { i::Handle str = Utils::OpenHandle(this); str = i::String::Flatten(reinterpret_cast(isolate), str); @@ -5518,6 +5570,14 @@ static bool RecursivelySerializeToUtf8(i::String* current, return true; } + +int String::WriteUtf8(char* buffer, int capacity, + int* nchars_ref, int options) const { + return WriteUtf8(Isolate::GetCurrent(), + buffer, capacity, nchars_ref, options); +} + + int String::WriteUtf8(Isolate* v8_isolate, char* buffer, int capacity, int* nchars_ref, int options) const { i::Handle str = Utils::OpenHandle(this); @@ -5585,6 +5645,18 @@ static inline int WriteHelper(i::Isolate* isolate, const String* string, } +int String::WriteOneByte(uint8_t* buffer, int start, + int length, int options) const { + return WriteOneByte(Isolate::GetCurrent(), buffer, start, length, options); +} + + +int String::Write(uint16_t* buffer, int start, int length, + int options) const { + return Write(Isolate::GetCurrent(), buffer, start, length, options); +} + + int String::WriteOneByte(Isolate* isolate, uint8_t* buffer, int start, int length, int options) const { return WriteHelper(reinterpret_cast(isolate), this, buffer, @@ -6532,6 +6604,11 @@ MaybeLocal String::NewFromTwoByte(Isolate* isolate, return result; } +Local v8::String::Concat(Local left, + Local right) { + return Concat(Isolate::GetCurrent(), left, right); +} + Local v8::String::Concat(Isolate* v8_isolate, Local left, Local right) { i::Isolate* isolate = reinterpret_cast(v8_isolate); @@ -6758,6 +6835,11 @@ bool v8::BooleanObject::ValueOf() const { } +Local v8::StringObject::New(Local value) { + return New(Isolate::GetCurrent(), value); +} + + Local v8::StringObject::New(Isolate* v8_isolate, Local value) { i::Handle string = Utils::OpenHandle(*value); @@ -8893,6 +8975,9 @@ bool MicrotasksScope::IsRunningMicrotasks(Isolate* v8Isolate) { return isolate->IsRunningMicrotasks(); } +String::Utf8Value::Utf8Value(v8::Local obj) + : Utf8Value(Isolate::GetCurrent(), obj) {} + String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local obj) : str_(nullptr), length_(0) { if (obj.IsEmpty()) return; @@ -8912,6 +8997,9 @@ String::Utf8Value::~Utf8Value() { i::DeleteArray(str_); } +String::Value::Value(v8::Local obj) + : Value(Isolate::GetCurrent(), obj) {} + String::Value::Value(v8::Isolate* isolate, v8::Local obj) : str_(nullptr), length_(0) { if (obj.IsEmpty()) return;