summaryrefslogtreecommitdiff
path: root/deps/v8/src
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-09-28 22:43:38 -0400
committerAnna Henningsen <anna@addaleax.net>2018-10-05 16:51:55 -0700
commit48d1335bbc1009717861d8ff9b4a5f10e4d5d79b (patch)
tree5d6af824387ff051f5fa75f0c09a5276dfd05be2 /deps/v8/src
parent01ade5856a08b81443955b52d237b544e79017f2 (diff)
downloadandroid-node-v8-48d1335bbc1009717861d8ff9b4a5f10e4d5d79b.tar.gz
android-node-v8-48d1335bbc1009717861d8ff9b4a5f10e4d5d79b.tar.bz2
android-node-v8-48d1335bbc1009717861d8ff9b4a5f10e4d5d79b.zip
deps: provide more V8 backwards compatibility
Add back a number deprecated APIs, using shims that should work well enough at least for the duration of Node 11 and do not come with significant maintenance overhead. Refs: https://github.com/nodejs/node/issues/23122 PR-URL: https://github.com/nodejs/node/pull/23158 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'deps/v8/src')
-rw-r--r--deps/v8/src/api.cc88
1 files changed, 88 insertions, 0 deletions
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc
index d141496c57..5f1737b2a4 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<Primitive> item) {
+ return Set(Isolate::GetCurrent(), index, item);
+}
+
void PrimitiveArray::Set(Isolate* v8_isolate, int index,
Local<Primitive> item) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
@@ -2170,6 +2174,10 @@ void PrimitiveArray::Set(Isolate* v8_isolate, int index,
array->set(index, *i_item);
}
+Local<Primitive> PrimitiveArray::Get(int index) {
+ return Get(Isolate::GetCurrent(), index);
+}
+
Local<Primitive> PrimitiveArray::Get(Isolate* v8_isolate, int index) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
i::Handle<i::FixedArray> 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<StackFrame> StackTrace::GetFrame(uint32_t index) const {
+ return GetFrame(Isolate::GetCurrent(), index);
+}
+
Local<StackFrame> StackTrace::GetFrame(Isolate* v8_isolate,
uint32_t index) const {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(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<double>::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<bool> Value::BooleanValue(Local<Context> context) const {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
return Just(Utils::OpenHandle(this)->BooleanValue(isolate));
@@ -3964,6 +4006,12 @@ MaybeLocal<Uint32> Value::ToArrayIndex(Local<Context> context) const {
}
+bool Value::Equals(Local<Value> that) const {
+ return Equals(Isolate::GetCurrent()->GetCurrentContext(), that)
+ .FromMaybe(false);
+}
+
+
Maybe<bool> Value::Equals(Local<Context> context, Local<Value> 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<i::String> str = Utils::OpenHandle(this);
str = i::String::Flatten(reinterpret_cast<i::Isolate*>(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<i::String> 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<i::Isolate*>(isolate), this, buffer,
@@ -6532,6 +6604,11 @@ MaybeLocal<String> String::NewFromTwoByte(Isolate* isolate,
return result;
}
+Local<String> v8::String::Concat(Local<String> left,
+ Local<String> right) {
+ return Concat(Isolate::GetCurrent(), left, right);
+}
+
Local<String> v8::String::Concat(Isolate* v8_isolate, Local<String> left,
Local<String> right) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
@@ -6758,6 +6835,11 @@ bool v8::BooleanObject::ValueOf() const {
}
+Local<v8::Value> v8::StringObject::New(Local<String> value) {
+ return New(Isolate::GetCurrent(), value);
+}
+
+
Local<v8::Value> v8::StringObject::New(Isolate* v8_isolate,
Local<String> value) {
i::Handle<i::String> string = Utils::OpenHandle(*value);
@@ -8893,6 +8975,9 @@ bool MicrotasksScope::IsRunningMicrotasks(Isolate* v8Isolate) {
return isolate->IsRunningMicrotasks();
}
+String::Utf8Value::Utf8Value(v8::Local<v8::Value> obj)
+ : Utf8Value(Isolate::GetCurrent(), obj) {}
+
String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> obj)
: str_(nullptr), length_(0) {
if (obj.IsEmpty()) return;
@@ -8912,6 +8997,9 @@ String::Utf8Value::~Utf8Value() {
i::DeleteArray(str_);
}
+String::Value::Value(v8::Local<v8::Value> obj)
+ : Value(Isolate::GetCurrent(), obj) {}
+
String::Value::Value(v8::Isolate* isolate, v8::Local<v8::Value> obj)
: str_(nullptr), length_(0) {
if (obj.IsEmpty()) return;