Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-08-26 10:41:26 +0300
committerMichaël Zasso <targos@protonmail.com>2018-08-29 13:28:13 +0300
commit7c84489b8828797e77236da26594bd642d0120f9 (patch)
treeb78ed6dd6458f937f49f8b390328529df7839c5e /deps
parent30c79467771c9f63d0519480b393a7084d48a7fb (diff)
deps: backport String::Write{OneByte,Utf8} with isolate
These overloads were added in V8 6.9 and the ones without the isolate parameter were removed in V8 7.0. Refs: https://github.com/v8/v8/commit/8a011b57d8b26e9cfe1c20a2ef26adb14be6ecc2 PR-URL: https://github.com/nodejs/node/pull/22531 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps')
-rw-r--r--deps/v8/include/v8.h27
-rw-r--r--deps/v8/src/api.cc42
2 files changed, 45 insertions, 24 deletions
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h
index 0f1f74e6a12..67c1e1065fe 100644
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -2728,20 +2728,25 @@ class V8_EXPORT String : public Name {
};
// 16-bit character codes.
- int Write(uint16_t* buffer,
- int start = 0,
- int length = -1,
+ int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1,
int options = NO_OPTIONS) const;
+ V8_DEPRECATE_SOON("Use Isolate* version",
+ int Write(uint16_t* buffer, int start = 0, int length = -1,
+ int options = NO_OPTIONS) const);
// One byte characters.
- int WriteOneByte(uint8_t* buffer,
- int start = 0,
- int length = -1,
- int options = NO_OPTIONS) const;
+ int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0,
+ int length = -1, int options = NO_OPTIONS) const;
+ V8_DEPRECATE_SOON("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(char* buffer,
- int length = -1,
- int* nchars_ref = NULL,
- int options = NO_OPTIONS) const;
+ int WriteUtf8(Isolate* isolate, char* buffer, int length = -1,
+ int* nchars_ref = NULL, int options = NO_OPTIONS) const;
+ V8_DEPRECATE_SOON("Use Isolate* version",
+ int WriteUtf8(char* buffer, int length = -1,
+ int* nchars_ref = NULL,
+ int options = NO_OPTIONS) const);
/**
* A zero length string.
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc
index 3fec027b01d..ffb68532066 100644
--- a/deps/v8/src/api.cc
+++ b/deps/v8/src/api.cc
@@ -5710,12 +5710,10 @@ static bool RecursivelySerializeToUtf8(i::String* current,
}
-int String::WriteUtf8(char* buffer,
- int capacity,
- int* nchars_ref,
- int options) const {
+int String::WriteUtf8(Isolate* v8_isolate, char* buffer, int capacity,
+ int* nchars_ref, int options) const {
i::Handle<i::String> str = Utils::OpenHandle(this);
- i::Isolate* isolate = str->GetIsolate();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, String, WriteUtf8);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
str = i::String::Flatten(str); // Flatten the string for efficiency.
@@ -5756,14 +5754,18 @@ int String::WriteUtf8(char* buffer,
return writer.CompleteWrite(write_null, nchars_ref);
}
+int String::WriteUtf8(char* buffer, int capacity, int* nchars_ref,
+ int options) const {
+ i::Handle<i::String> str = Utils::OpenHandle(this);
+ i::Isolate* isolate = str->GetIsolate();
+ return WriteUtf8(reinterpret_cast<Isolate*>(isolate), buffer, capacity,
+ nchars_ref, options);
+}
-template<typename CharType>
-static inline int WriteHelper(const String* string,
- CharType* buffer,
- int start,
- int length,
+template <typename CharType>
+static inline int WriteHelper(i::Isolate* isolate, const String* string,
+ CharType* buffer, int start, int length,
int options) {
- i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate();
LOG_API(isolate, String, Write);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
DCHECK(start >= 0 && length >= -1);
@@ -5786,7 +5788,14 @@ int String::WriteOneByte(uint8_t* buffer,
int start,
int length,
int options) const {
- return WriteHelper(this, buffer, start, length, options);
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+ return WriteHelper(isolate, this, 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,
+ start, length, options);
}
@@ -5794,7 +5803,14 @@ int String::Write(uint16_t* buffer,
int start,
int length,
int options) const {
- return WriteHelper(this, buffer, start, length, options);
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+ return WriteHelper(isolate, this, buffer, start, length, options);
+}
+
+int String::Write(Isolate* isolate, uint16_t* buffer, int start, int length,
+ int options) const {
+ return WriteHelper(reinterpret_cast<i::Isolate*>(isolate), this, buffer,
+ start, length, options);
}