Commit ce05578a authored by Adam Klein's avatar Adam Klein Committed by Commit Bot

[api] Mark non-Isolate constructors of String::Utf8Value/Value for deprecation

Also remove last internal callers of the to-be-deprecated APIs.

Bug: v8:2487
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng;master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: Id72cf363eac86e4b4dbf7df83bdb848071260b90
Reviewed-on: https://chromium-review.googlesource.com/639326Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47690}
parent f5dca8a0
......@@ -2767,7 +2767,8 @@ class V8_EXPORT String : public Name {
*/
class V8_EXPORT Utf8Value {
public:
explicit Utf8Value(Local<v8::Value> obj);
V8_DEPRECATE_SOON("Use Isolate version",
explicit Utf8Value(Local<v8::Value> obj));
Utf8Value(Isolate* isolate, Local<v8::Value> obj);
~Utf8Value();
char* operator*() { return str_; }
......@@ -2791,7 +2792,8 @@ class V8_EXPORT String : public Name {
*/
class V8_EXPORT Value {
public:
explicit Value(Local<v8::Value> obj);
V8_DEPRECATE_SOON("Use Isolate version",
explicit Value(Local<v8::Value> obj));
Value(Isolate* isolate, Local<v8::Value> obj);
~Value();
uint16_t* operator*() { return str_; }
......
......@@ -950,7 +950,8 @@ bool PluralRules::InitializePluralRules(Isolate* isolate, Handle<String> locale,
icu::Locale icu_locale;
char locale_name[ULOC_FULLNAME_CAPACITY];
int icu_length = 0;
v8::String::Utf8Value bcp47_locale(v8::Utils::ToLocal(locale));
v8::String::Utf8Value bcp47_locale(reinterpret_cast<v8::Isolate*>(isolate),
v8::Utils::ToLocal(locale));
if (bcp47_locale.length() != 0) {
uloc_forLanguageTag(*bcp47_locale, locale_name, ULOC_FULLNAME_CAPACITY,
&icu_length, &status);
......
......@@ -432,7 +432,9 @@ bool WriteExpectationsFile(const std::vector<std::string>& snippet_list,
}
void PrintMessage(v8::Local<v8::Message> message, v8::Local<v8::Value>) {
std::cerr << "INFO: " << *v8::String::Utf8Value(message->Get()) << '\n';
std::cerr << "INFO: "
<< *v8::String::Utf8Value(v8::Isolate::GetCurrent(), message->Get())
<< '\n';
}
void DiscardMessage(v8::Local<v8::Message>, v8::Local<v8::Value>) {}
......
......@@ -256,8 +256,8 @@ class ValueSerializerTest : public TestWithIsolate {
.ToLocalChecked();
}
static std::string Utf8Value(Local<Value> value) {
String::Utf8Value utf8(value);
std::string Utf8Value(Local<Value> value) {
String::Utf8Value utf8(isolate(), value);
return std::string(*utf8, utf8.length());
}
......@@ -434,21 +434,21 @@ TEST_F(ValueSerializerTest, RoundTripString) {
});
// Inside ASCII.
RoundTripTest([this]() { return StringFromUtf8(kHelloString); },
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(5, String::Cast(*value)->Length());
EXPECT_EQ(kHelloString, Utf8Value(value));
});
// Inside Latin-1 (i.e. one-byte string), but not ASCII.
RoundTripTest([this]() { return StringFromUtf8(kQuebecString); },
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(6, String::Cast(*value)->Length());
EXPECT_EQ(kQuebecString, Utf8Value(value));
});
// An emoji (decodes to two 16-bit chars).
RoundTripTest([this]() { return StringFromUtf8(kEmojiString); },
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(2, String::Cast(*value)->Length());
EXPECT_EQ(kEmojiString, Utf8Value(value));
......@@ -463,19 +463,19 @@ TEST_F(ValueSerializerTest, DecodeString) {
EXPECT_EQ(0, String::Cast(*value)->Length());
});
DecodeTest({0xff, 0x09, 0x53, 0x05, 'H', 'e', 'l', 'l', 'o'},
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(5, String::Cast(*value)->Length());
EXPECT_EQ(kHelloString, Utf8Value(value));
});
DecodeTest({0xff, 0x09, 0x53, 0x07, 'Q', 'u', 0xc3, 0xa9, 'b', 'e', 'c'},
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(6, String::Cast(*value)->Length());
EXPECT_EQ(kQuebecString, Utf8Value(value));
});
DecodeTest({0xff, 0x09, 0x53, 0x04, 0xf0, 0x9f, 0x91, 0x8a},
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(2, String::Cast(*value)->Length());
EXPECT_EQ(kEmojiString, Utf8Value(value));
......@@ -487,13 +487,13 @@ TEST_F(ValueSerializerTest, DecodeString) {
EXPECT_EQ(0, String::Cast(*value)->Length());
});
DecodeTest({0xff, 0x0a, 0x22, 0x05, 'H', 'e', 'l', 'l', 'o'},
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(5, String::Cast(*value)->Length());
EXPECT_EQ(kHelloString, Utf8Value(value));
});
DecodeTest({0xff, 0x0a, 0x22, 0x06, 'Q', 'u', 0xe9, 'b', 'e', 'c'},
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(6, String::Cast(*value)->Length());
EXPECT_EQ(kQuebecString, Utf8Value(value));
......@@ -508,20 +508,20 @@ TEST_F(ValueSerializerTest, DecodeString) {
});
DecodeTest({0xff, 0x09, 0x63, 0x0a, 'H', '\0', 'e', '\0', 'l', '\0', 'l',
'\0', 'o', '\0'},
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(5, String::Cast(*value)->Length());
EXPECT_EQ(kHelloString, Utf8Value(value));
});
DecodeTest({0xff, 0x09, 0x63, 0x0c, 'Q', '\0', 'u', '\0', 0xe9, '\0', 'b',
'\0', 'e', '\0', 'c', '\0'},
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(6, String::Cast(*value)->Length());
EXPECT_EQ(kQuebecString, Utf8Value(value));
});
DecodeTest({0xff, 0x09, 0x63, 0x04, 0x3d, 0xd8, 0x4a, 0xdc},
[](Local<Value> value) {
[this](Local<Value> value) {
ASSERT_TRUE(value->IsString());
EXPECT_EQ(2, String::Cast(*value)->Length());
EXPECT_EQ(kEmojiString, Utf8Value(value));
......@@ -784,7 +784,7 @@ TEST_F(ValueSerializerTest, RoundTripTrickyGetters) {
// If an exception is thrown by script, encoding must fail and the exception
// must be thrown.
InvalidEncodeTest("({ get a() { throw new Error('sentinel'); } })",
[](Local<Message> message) {
[this](Local<Message> message) {
ASSERT_FALSE(message.IsEmpty());
EXPECT_NE(std::string::npos,
Utf8Value(message->Get()).find("sentinel"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment