Commit 24222a9f authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[api] Use shorter 8::Local::As<*> casts in more places

Bug: v8:11195
Change-Id: I19211af9e440940f85351fb38920eb620c222213
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2555010Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71465}
parent 29ab5697
...@@ -219,7 +219,7 @@ bool JsHttpRequestProcessor::Initialize(map<string, string>* opts, ...@@ -219,7 +219,7 @@ bool JsHttpRequestProcessor::Initialize(map<string, string>* opts,
} }
// It is a function; cast it to a Function // It is a function; cast it to a Function
Local<Function> process_fun = Local<Function>::Cast(process_val); Local<Function> process_fun = process_val.As<Function>();
// Store the function in a Global handle, since we also want // Store the function in a Global handle, since we also want
// that to remain after this call returns // that to remain after this call returns
...@@ -375,7 +375,7 @@ Local<Object> JsHttpRequestProcessor::WrapMap(map<string, string>* obj) { ...@@ -375,7 +375,7 @@ Local<Object> JsHttpRequestProcessor::WrapMap(map<string, string>* obj) {
// Utility function that extracts the C++ map pointer from a wrapper // Utility function that extracts the C++ map pointer from a wrapper
// object. // object.
map<string, string>* JsHttpRequestProcessor::UnwrapMap(Local<Object> obj) { map<string, string>* JsHttpRequestProcessor::UnwrapMap(Local<Object> obj) {
Local<External> field = Local<External>::Cast(obj->GetInternalField(0)); Local<External> field = obj->GetInternalField(0).As<External>();
void* ptr = field->Value(); void* ptr = field->Value();
return static_cast<map<string, string>*>(ptr); return static_cast<map<string, string>*>(ptr);
} }
...@@ -397,7 +397,7 @@ void JsHttpRequestProcessor::MapGet(Local<Name> name, ...@@ -397,7 +397,7 @@ void JsHttpRequestProcessor::MapGet(Local<Name> name,
map<string, string>* obj = UnwrapMap(info.Holder()); map<string, string>* obj = UnwrapMap(info.Holder());
// Convert the JavaScript string to a std::string. // Convert the JavaScript string to a std::string.
string key = ObjectToString(info.GetIsolate(), Local<String>::Cast(name)); string key = ObjectToString(info.GetIsolate(), name.As<String>());
// Look up the value if it exists using the standard STL ideom. // Look up the value if it exists using the standard STL ideom.
map<string, string>::iterator iter = obj->find(key); map<string, string>::iterator iter = obj->find(key);
...@@ -422,7 +422,7 @@ void JsHttpRequestProcessor::MapSet(Local<Name> name, Local<Value> value_obj, ...@@ -422,7 +422,7 @@ void JsHttpRequestProcessor::MapSet(Local<Name> name, Local<Value> value_obj,
map<string, string>* obj = UnwrapMap(info.Holder()); map<string, string>* obj = UnwrapMap(info.Holder());
// Convert the key and value to std::strings. // Convert the key and value to std::strings.
string key = ObjectToString(info.GetIsolate(), Local<String>::Cast(name)); string key = ObjectToString(info.GetIsolate(), name.As<String>());
string value = ObjectToString(info.GetIsolate(), value_obj); string value = ObjectToString(info.GetIsolate(), value_obj);
// Update the map. // Update the map.
...@@ -491,7 +491,7 @@ Local<Object> JsHttpRequestProcessor::WrapRequest(HttpRequest* request) { ...@@ -491,7 +491,7 @@ Local<Object> JsHttpRequestProcessor::WrapRequest(HttpRequest* request) {
* wrapper object. * wrapper object.
*/ */
HttpRequest* JsHttpRequestProcessor::UnwrapRequest(Local<Object> obj) { HttpRequest* JsHttpRequestProcessor::UnwrapRequest(Local<Object> obj) {
Local<External> field = Local<External>::Cast(obj->GetInternalField(0)); Local<External> field = obj->GetInternalField(0).As<External>();
void* ptr = field->Value(); void* ptr = field->Value();
return static_cast<HttpRequest*>(ptr); return static_cast<HttpRequest*>(ptr);
} }
......
...@@ -380,7 +380,7 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) { ...@@ -380,7 +380,7 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) {
v8::Local<v8::Value> stack_trace_string; v8::Local<v8::Value> stack_trace_string;
if (try_catch->StackTrace(context).ToLocal(&stack_trace_string) && if (try_catch->StackTrace(context).ToLocal(&stack_trace_string) &&
stack_trace_string->IsString() && stack_trace_string->IsString() &&
v8::Local<v8::String>::Cast(stack_trace_string)->Length() > 0) { stack_trace_string.As<v8::String>()->Length() > 0) {
v8::String::Utf8Value stack_trace(isolate, stack_trace_string); v8::String::Utf8Value stack_trace(isolate, stack_trace_string);
const char* stack_trace_string = ToCString(stack_trace); const char* stack_trace_string = ToCString(stack_trace);
fprintf(stderr, "%s\n", stack_trace_string); fprintf(stderr, "%s\n", stack_trace_string);
......
...@@ -52,7 +52,7 @@ static AsyncHooksWrap* UnwrapHook( ...@@ -52,7 +52,7 @@ static AsyncHooksWrap* UnwrapHook(
return nullptr; return nullptr;
} }
Local<External> wrap = Local<External>::Cast(hook->GetInternalField(0)); Local<External> wrap = hook->GetInternalField(0).As<External>();
void* ptr = wrap->Value(); void* ptr = wrap->Value();
return static_cast<AsyncHooksWrap*>(ptr); return static_cast<AsyncHooksWrap*>(ptr);
} }
......
...@@ -423,7 +423,7 @@ void Shell::System(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -423,7 +423,7 @@ void Shell::System(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetIsolate(), "system: Argument 2 must be an array")); args.GetIsolate(), "system: Argument 2 must be an array"));
return; return;
} }
command_args = Local<Array>::Cast(args[1]); command_args = args[1].As<Array>();
} else { } else {
command_args = Array::New(args.GetIsolate(), 0); command_args = Array::New(args.GetIsolate(), 0);
} }
......
...@@ -397,7 +397,7 @@ class TraceConfigParser { ...@@ -397,7 +397,7 @@ class TraceConfigParser {
Local<String> source = Local<String> source =
String::NewFromUtf8(isolate, json_str).ToLocalChecked(); String::NewFromUtf8(isolate, json_str).ToLocalChecked();
Local<Value> result = JSON::Parse(context, source).ToLocalChecked(); Local<Value> result = JSON::Parse(context, source).ToLocalChecked();
Local<v8::Object> trace_config_object = Local<v8::Object>::Cast(result); Local<v8::Object> trace_config_object = result.As<v8::Object>();
UpdateIncludedCategoriesList(isolate, context, trace_config_object, UpdateIncludedCategoriesList(isolate, context, trace_config_object,
trace_config); trace_config);
...@@ -410,7 +410,7 @@ class TraceConfigParser { ...@@ -410,7 +410,7 @@ class TraceConfigParser {
Local<Value> value = Local<Value> value =
GetValue(isolate, context, object, kIncludedCategoriesParam); GetValue(isolate, context, object, kIncludedCategoriesParam);
if (value->IsArray()) { if (value->IsArray()) {
Local<Array> v8_array = Local<Array>::Cast(value); Local<Array> v8_array = value.As<Array>();
for (int i = 0, length = v8_array->Length(); i < length; ++i) { for (int i = 0, length = v8_array->Length(); i < length; ++i) {
Local<Value> v = v8_array->Get(context, i) Local<Value> v = v8_array->Get(context, i)
.ToLocalChecked() .ToLocalChecked()
...@@ -1029,8 +1029,7 @@ MaybeLocal<Promise> Shell::HostImportModuleDynamically( ...@@ -1029,8 +1029,7 @@ MaybeLocal<Promise> Shell::HostImportModuleDynamically(
Local<Promise::Resolver> resolver; Local<Promise::Resolver> resolver;
if (maybe_resolver.ToLocal(&resolver)) { if (maybe_resolver.ToLocal(&resolver)) {
DynamicImportData* data = new DynamicImportData( DynamicImportData* data = new DynamicImportData(
isolate, Local<String>::Cast(referrer->GetResourceName()), specifier, isolate, referrer->GetResourceName().As<String>(), specifier, resolver);
resolver);
isolate->EnqueueMicrotask(Shell::DoHostImportModuleDynamically, data); isolate->EnqueueMicrotask(Shell::DoHostImportModuleDynamically, data);
return resolver->GetPromise(); return resolver->GetPromise();
} }
...@@ -1108,7 +1107,7 @@ void Shell::DoHostImportModuleDynamically(void* import_data) { ...@@ -1108,7 +1107,7 @@ void Shell::DoHostImportModuleDynamically(void* import_data) {
Local<Value> module_namespace = root_module->GetModuleNamespace(); Local<Value> module_namespace = root_module->GetModuleNamespace();
if (i::FLAG_harmony_top_level_await) { if (i::FLAG_harmony_top_level_await) {
Local<Promise> result_promise(Local<Promise>::Cast(result)); Local<Promise> result_promise(result.As<Promise>());
if (result_promise->State() == Promise::kRejected) { if (result_promise->State() == Promise::kRejected) {
resolver->Reject(realm, result_promise->Result()).ToChecked(); resolver->Reject(realm, result_promise->Result()).ToChecked();
return; return;
...@@ -1176,7 +1175,7 @@ bool Shell::ExecuteModule(Isolate* isolate, const char* file_name) { ...@@ -1176,7 +1175,7 @@ bool Shell::ExecuteModule(Isolate* isolate, const char* file_name) {
// Loop until module execution finishes // Loop until module execution finishes
// TODO(cbruni): This is a bit wonky. "Real" engines would not be // TODO(cbruni): This is a bit wonky. "Real" engines would not be
// able to just busy loop waiting for execution to finish. // able to just busy loop waiting for execution to finish.
Local<Promise> result_promise(Local<Promise>::Cast(result)); Local<Promise> result_promise(result.As<Promise>());
while (result_promise->State() == Promise::kPending) { while (result_promise->State() == Promise::kPending) {
isolate->PerformMicrotaskCheckpoint(); isolate->PerformMicrotaskCheckpoint();
} }
...@@ -1653,7 +1652,7 @@ void WriteToFile(FILE* file, const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1653,7 +1652,7 @@ void WriteToFile(FILE* file, const v8::FunctionCallbackInfo<v8::Value>& args) {
Local<String> str_obj; Local<String> str_obj;
if (arg->IsSymbol()) { if (arg->IsSymbol()) {
arg = Local<Symbol>::Cast(arg)->Description(); arg = arg.As<Symbol>()->Description();
} }
if (!arg->ToString(args.GetIsolate()->GetCurrentContext()) if (!arg->ToString(args.GetIsolate()->GetCurrentContext())
.ToLocal(&str_obj)) { .ToLocal(&str_obj)) {
...@@ -1776,7 +1775,7 @@ void Shell::SetTimeout(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1776,7 +1775,7 @@ void Shell::SetTimeout(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate(); Isolate* isolate = args.GetIsolate();
args.GetReturnValue().Set(v8::Number::New(isolate, 0)); args.GetReturnValue().Set(v8::Number::New(isolate, 0));
if (args.Length() == 0 || !args[0]->IsFunction()) return; if (args.Length() == 0 || !args[0]->IsFunction()) return;
Local<Function> callback = Local<Function>::Cast(args[0]); Local<Function> callback = args[0].As<Function>();
Local<Context> context = isolate->GetCurrentContext(); Local<Context> context = isolate->GetCurrentContext();
PerIsolateData::Get(isolate)->SetTimeout(callback, context); PerIsolateData::Get(isolate)->SetTimeout(callback, context);
} }
...@@ -1879,7 +1878,7 @@ void Shell::WorkerPostMessage(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1879,7 +1878,7 @@ void Shell::WorkerPostMessage(const v8::FunctionCallbackInfo<v8::Value>& args) {
Local<Value> message = args[0]; Local<Value> message = args[0];
Local<Value> transfer = Local<Value> transfer =
args.Length() >= 2 ? args[1] : Local<Value>::Cast(Undefined(isolate)); args.Length() >= 2 ? args[1] : Undefined(isolate).As<Value>();
std::unique_ptr<SerializationData> data = std::unique_ptr<SerializationData> data =
Shell::SerializeValue(isolate, message, transfer); Shell::SerializeValue(isolate, message, transfer);
if (data) { if (data) {
...@@ -2065,8 +2064,7 @@ void Shell::ReportException(Isolate* isolate, Local<v8::Message> message, ...@@ -2065,8 +2064,7 @@ void Shell::ReportException(Isolate* isolate, Local<v8::Message> message,
if (v8::TryCatch::StackTrace(context, exception_obj) if (v8::TryCatch::StackTrace(context, exception_obj)
.ToLocal(&stack_trace_string) && .ToLocal(&stack_trace_string) &&
stack_trace_string->IsString()) { stack_trace_string->IsString()) {
v8::String::Utf8Value stack_trace(isolate, v8::String::Utf8Value stack_trace(isolate, stack_trace_string.As<String>());
Local<String>::Cast(stack_trace_string));
printf("%s\n", ToCString(stack_trace)); printf("%s\n", ToCString(stack_trace));
} }
printf("\n"); printf("\n");
...@@ -2858,11 +2856,10 @@ class InspectorFrontend final : public v8_inspector::V8Inspector::Channel { ...@@ -2858,11 +2856,10 @@ class InspectorFrontend final : public v8_inspector::V8Inspector::Channel {
if (callback->IsFunction()) { if (callback->IsFunction()) {
v8::TryCatch try_catch(isolate_); v8::TryCatch try_catch(isolate_);
Local<Value> args[] = {message}; Local<Value> args[] = {message};
USE(Local<Function>::Cast(callback)->Call(context, Undefined(isolate_), 1, USE(callback.As<Function>()->Call(context, Undefined(isolate_), 1, args));
args));
#ifdef DEBUG #ifdef DEBUG
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
Local<Object> exception = Local<Object>::Cast(try_catch.Exception()); Local<Object> exception = try_catch.Exception().As<Object>();
Local<String> key = v8::String::NewFromUtf8Literal( Local<String> key = v8::String::NewFromUtf8Literal(
isolate_, "message", NewStringType::kInternalized); isolate_, "message", NewStringType::kInternalized);
Local<String> expected = v8::String::NewFromUtf8Literal( Local<String> expected = v8::String::NewFromUtf8Literal(
...@@ -2917,8 +2914,7 @@ class InspectorClient : public v8_inspector::V8InspectorClient { ...@@ -2917,8 +2914,7 @@ class InspectorClient : public v8_inspector::V8InspectorClient {
is_paused = true; is_paused = true;
while (is_paused) { while (is_paused) {
USE(Local<Function>::Cast(callback)->Call(context, Undefined(isolate_), 0, USE(callback.As<Function>()->Call(context, Undefined(isolate_), 0, {}));
{}));
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
is_paused = false; is_paused = false;
} }
...@@ -3293,7 +3289,7 @@ void Worker::ProcessMessage(std::unique_ptr<SerializationData> data) { ...@@ -3293,7 +3289,7 @@ void Worker::ProcessMessage(std::unique_ptr<SerializationData> data) {
if (!onmessage->IsFunction()) { if (!onmessage->IsFunction()) {
return; return;
} }
Local<Function> onmessage_fun = Local<Function>::Cast(onmessage); Local<Function> onmessage_fun = onmessage.As<Function>();
v8::TryCatch try_catch(isolate_); v8::TryCatch try_catch(isolate_);
try_catch.SetVerbose(true); try_catch.SetVerbose(true);
...@@ -3419,7 +3415,7 @@ void Worker::PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -3419,7 +3415,7 @@ void Worker::PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args) {
Shell::SerializeValue(isolate, message, transfer); Shell::SerializeValue(isolate, message, transfer);
if (data) { if (data) {
DCHECK(args.Data()->IsExternal()); DCHECK(args.Data()->IsExternal());
Local<External> this_value = Local<External>::Cast(args.Data()); Local<External> this_value = args.Data().As<External>();
Worker* worker = static_cast<Worker*>(this_value->Value()); Worker* worker = static_cast<Worker*>(this_value->Value());
worker->out_queue_.Enqueue(std::move(data)); worker->out_queue_.Enqueue(std::move(data));
worker->out_semaphore_.Signal(); worker->out_semaphore_.Signal();
...@@ -3954,7 +3950,7 @@ class Serializer : public ValueSerializer::Delegate { ...@@ -3954,7 +3950,7 @@ class Serializer : public ValueSerializer::Delegate {
private: private:
Maybe<bool> PrepareTransfer(Local<Context> context, Local<Value> transfer) { Maybe<bool> PrepareTransfer(Local<Context> context, Local<Value> transfer) {
if (transfer->IsArray()) { if (transfer->IsArray()) {
Local<Array> transfer_array = Local<Array>::Cast(transfer); Local<Array> transfer_array = transfer.As<Array>();
uint32_t length = transfer_array->Length(); uint32_t length = transfer_array->Length();
for (uint32_t i = 0; i < length; ++i) { for (uint32_t i = 0; i < length; ++i) {
Local<Value> element; Local<Value> element;
...@@ -3964,7 +3960,7 @@ class Serializer : public ValueSerializer::Delegate { ...@@ -3964,7 +3960,7 @@ class Serializer : public ValueSerializer::Delegate {
return Nothing<bool>(); return Nothing<bool>();
} }
Local<ArrayBuffer> array_buffer = Local<ArrayBuffer>::Cast(element); Local<ArrayBuffer> array_buffer = element.As<ArrayBuffer>();
if (std::find(array_buffers_.begin(), array_buffers_.end(), if (std::find(array_buffers_.begin(), array_buffers_.end(),
array_buffer) != array_buffers_.end()) { array_buffer) != array_buffers_.end()) {
......
...@@ -82,7 +82,7 @@ class InjectedScript::ProtocolPromiseHandler { ...@@ -82,7 +82,7 @@ class InjectedScript::ProtocolPromiseHandler {
} }
v8::MaybeLocal<v8::Promise> originalPromise = v8::MaybeLocal<v8::Promise> originalPromise =
value->IsPromise() ? v8::Local<v8::Promise>::Cast(value) value->IsPromise() ? value.As<v8::Promise>()
: v8::MaybeLocal<v8::Promise>(); : v8::MaybeLocal<v8::Promise>();
V8InspectorImpl* inspector = session->inspector(); V8InspectorImpl* inspector = session->inspector();
ProtocolPromiseHandler* handler = new ProtocolPromiseHandler( ProtocolPromiseHandler* handler = new ProtocolPromiseHandler(
...@@ -119,9 +119,8 @@ class InjectedScript::ProtocolPromiseHandler { ...@@ -119,9 +119,8 @@ class InjectedScript::ProtocolPromiseHandler {
info.Data().As<v8::External>()->Value()); info.Data().As<v8::External>()->Value());
DCHECK(handler); DCHECK(handler);
v8::Local<v8::Value> value = v8::Local<v8::Value> value =
info.Length() > 0 info.Length() > 0 ? info[0]
? info[0] : v8::Undefined(info.GetIsolate()).As<v8::Value>();
: v8::Local<v8::Value>::Cast(v8::Undefined(info.GetIsolate()));
handler->thenCallback(value); handler->thenCallback(value);
delete handler; delete handler;
} }
...@@ -131,9 +130,8 @@ class InjectedScript::ProtocolPromiseHandler { ...@@ -131,9 +130,8 @@ class InjectedScript::ProtocolPromiseHandler {
info.Data().As<v8::External>()->Value()); info.Data().As<v8::External>()->Value());
DCHECK(handler); DCHECK(handler);
v8::Local<v8::Value> value = v8::Local<v8::Value> value =
info.Length() > 0 info.Length() > 0 ? info[0]
? info[0] : v8::Undefined(info.GetIsolate()).As<v8::Value>();
: v8::Local<v8::Value>::Cast(v8::Undefined(info.GetIsolate()));
handler->catchCallback(value); handler->catchCallback(value);
delete handler; delete handler;
} }
...@@ -268,8 +266,8 @@ class InjectedScript::ProtocolPromiseHandler { ...@@ -268,8 +266,8 @@ class InjectedScript::ProtocolPromiseHandler {
toProtocolString(isolate, toProtocolString(isolate,
result->ToDetailString(isolate->GetCurrentContext()) result->ToDetailString(isolate->GetCurrentContext())
.ToLocalChecked()); .ToLocalChecked());
v8::Local<v8::StackTrace> stackTrace = v8::debug::GetDetailedStackTrace( v8::Local<v8::StackTrace> stackTrace =
isolate, v8::Local<v8::Object>::Cast(result)); v8::debug::GetDetailedStackTrace(isolate, result.As<v8::Object>());
if (!stackTrace.IsEmpty()) { if (!stackTrace.IsEmpty()) {
stack = m_inspector->debugger()->createStackTrace(stackTrace); stack = m_inspector->debugger()->createStackTrace(stackTrace);
} }
......
...@@ -70,8 +70,8 @@ InspectedContext::InspectedContext(V8InspectorImpl* inspector, ...@@ -70,8 +70,8 @@ InspectedContext::InspectedContext(V8InspectorImpl* inspector,
if (global->Get(info.context, toV8String(m_inspector->isolate(), "console")) if (global->Get(info.context, toV8String(m_inspector->isolate(), "console"))
.ToLocal(&console) && .ToLocal(&console) &&
console->IsObject()) { console->IsObject()) {
m_inspector->console()->installMemoryGetter( m_inspector->console()->installMemoryGetter(info.context,
info.context, v8::Local<v8::Object>::Cast(console)); console.As<v8::Object>());
} }
} }
......
...@@ -90,34 +90,33 @@ class V8ValueStringBuilder { ...@@ -90,34 +90,33 @@ class V8ValueStringBuilder {
if (value.IsEmpty()) return true; if (value.IsEmpty()) return true;
if ((ignoreOptions & IgnoreNull) && value->IsNull()) return true; if ((ignoreOptions & IgnoreNull) && value->IsNull()) return true;
if ((ignoreOptions & IgnoreUndefined) && value->IsUndefined()) return true; if ((ignoreOptions & IgnoreUndefined) && value->IsUndefined()) return true;
if (value->IsString()) return append(v8::Local<v8::String>::Cast(value)); if (value->IsString()) return append(value.As<v8::String>());
if (value->IsStringObject()) if (value->IsStringObject())
return append(v8::Local<v8::StringObject>::Cast(value)->ValueOf()); return append(value.As<v8::StringObject>()->ValueOf());
if (value->IsBigInt()) return append(v8::Local<v8::BigInt>::Cast(value)); if (value->IsBigInt()) return append(value.As<v8::BigInt>());
if (value->IsBigIntObject()) if (value->IsBigIntObject())
return append(v8::Local<v8::BigIntObject>::Cast(value)->ValueOf()); return append(value.As<v8::BigIntObject>()->ValueOf());
if (value->IsSymbol()) return append(v8::Local<v8::Symbol>::Cast(value)); if (value->IsSymbol()) return append(value.As<v8::Symbol>());
if (value->IsSymbolObject()) if (value->IsSymbolObject())
return append(v8::Local<v8::SymbolObject>::Cast(value)->ValueOf()); return append(value.As<v8::SymbolObject>()->ValueOf());
if (value->IsNumberObject()) { if (value->IsNumberObject()) {
m_builder.append(String16::fromDouble( m_builder.append(
v8::Local<v8::NumberObject>::Cast(value)->ValueOf(), 6)); String16::fromDouble(value.As<v8::NumberObject>()->ValueOf(), 6));
return true; return true;
} }
if (value->IsBooleanObject()) { if (value->IsBooleanObject()) {
m_builder.append(v8::Local<v8::BooleanObject>::Cast(value)->ValueOf() m_builder.append(value.As<v8::BooleanObject>()->ValueOf() ? "true"
? "true" : "false");
: "false");
return true; return true;
} }
if (value->IsArray()) return append(v8::Local<v8::Array>::Cast(value)); if (value->IsArray()) return append(value.As<v8::Array>());
if (value->IsProxy()) { if (value->IsProxy()) {
m_builder.append("[object Proxy]"); m_builder.append("[object Proxy]");
return true; return true;
} }
if (value->IsObject() && !value->IsDate() && !value->IsFunction() && if (value->IsObject() && !value->IsDate() && !value->IsFunction() &&
!value->IsNativeError() && !value->IsRegExp()) { !value->IsNativeError() && !value->IsRegExp()) {
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); v8::Local<v8::Object> object = value.As<v8::Object>();
v8::Local<v8::String> stringValue; v8::Local<v8::String> stringValue;
if (object->ObjectProtoToString(m_context).ToLocal(&stringValue)) if (object->ObjectProtoToString(m_context).ToLocal(&stringValue))
return append(stringValue); return append(stringValue);
...@@ -267,7 +266,7 @@ V8ConsoleMessage::wrapArguments(V8InspectorSessionImpl* session, ...@@ -267,7 +266,7 @@ V8ConsoleMessage::wrapArguments(V8InspectorSessionImpl* session,
if (m_arguments.size() > 1) { if (m_arguments.size() > 1) {
v8::Local<v8::Value> secondArgument = m_arguments[1]->Get(isolate); v8::Local<v8::Value> secondArgument = m_arguments[1]->Get(isolate);
if (secondArgument->IsArray()) { if (secondArgument->IsArray()) {
columns = v8::Local<v8::Array>::Cast(secondArgument); columns = secondArgument.As<v8::Array>();
} else if (secondArgument->IsString()) { } else if (secondArgument->IsString()) {
v8::TryCatch tryCatch(isolate); v8::TryCatch tryCatch(isolate);
v8::Local<v8::Array> array = v8::Array::New(isolate); v8::Local<v8::Array> array = v8::Array::New(isolate);
...@@ -277,8 +276,7 @@ V8ConsoleMessage::wrapArguments(V8InspectorSessionImpl* session, ...@@ -277,8 +276,7 @@ V8ConsoleMessage::wrapArguments(V8InspectorSessionImpl* session,
} }
} }
std::unique_ptr<protocol::Runtime::RemoteObject> wrapped = std::unique_ptr<protocol::Runtime::RemoteObject> wrapped =
session->wrapTable(context, v8::Local<v8::Object>::Cast(value), session->wrapTable(context, value.As<v8::Object>(), columns);
columns);
inspectedContext = inspector->getContext(contextGroupId, contextId); inspectedContext = inspector->getContext(contextGroupId, contextId);
if (!inspectedContext) return nullptr; if (!inspectedContext) return nullptr;
if (wrapped) { if (wrapped) {
......
...@@ -545,7 +545,7 @@ void V8Console::monitorFunctionCallback( ...@@ -545,7 +545,7 @@ void V8Console::monitorFunctionCallback(
v8::Local<v8::Function> function; v8::Local<v8::Function> function;
if (!helper.firstArgAsFunction().ToLocal(&function)) return; if (!helper.firstArgAsFunction().ToLocal(&function)) return;
v8::Local<v8::Value> name = function->GetName(); v8::Local<v8::Value> name = function->GetName();
if (!name->IsString() || !v8::Local<v8::String>::Cast(name)->Length()) if (!name->IsString() || !name.As<v8::String>()->Length())
name = function->GetInferredName(); name = function->GetInferredName();
String16 functionName = String16 functionName =
toProtocolStringWithTypeCheck(info.GetIsolate(), name); toProtocolStringWithTypeCheck(info.GetIsolate(), name);
...@@ -844,7 +844,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope( ...@@ -844,7 +844,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope(
if (!m_installedMethods->Add(context, name).ToLocal(&m_installedMethods)) if (!m_installedMethods->Add(context, name).ToLocal(&m_installedMethods))
continue; continue;
if (!m_global if (!m_global
->SetAccessor(context, v8::Local<v8::Name>::Cast(name), ->SetAccessor(context, name.As<v8::Name>(),
CommandLineAPIScope::accessorGetterCallback, CommandLineAPIScope::accessorGetterCallback,
CommandLineAPIScope::accessorSetterCallback, CommandLineAPIScope::accessorSetterCallback,
m_thisReference, v8::DEFAULT, v8::DontEnum, m_thisReference, v8::DEFAULT, v8::DontEnum,
...@@ -869,10 +869,9 @@ V8Console::CommandLineAPIScope::~CommandLineAPIScope() { ...@@ -869,10 +869,9 @@ V8Console::CommandLineAPIScope::~CommandLineAPIScope() {
if (!names->Get(m_context, i).ToLocal(&name) || !name->IsName()) continue; if (!names->Get(m_context, i).ToLocal(&name) || !name->IsName()) continue;
if (name->IsString()) { if (name->IsString()) {
v8::Local<v8::Value> descriptor; v8::Local<v8::Value> descriptor;
bool success = m_global bool success =
->GetOwnPropertyDescriptor( m_global->GetOwnPropertyDescriptor(m_context, name.As<v8::String>())
m_context, v8::Local<v8::String>::Cast(name)) .ToLocal(&descriptor);
.ToLocal(&descriptor);
USE(success); USE(success);
} }
} }
......
...@@ -657,7 +657,7 @@ v8::MaybeLocal<v8::Value> V8Debugger::getTargetScopes( ...@@ -657,7 +657,7 @@ v8::MaybeLocal<v8::Value> V8Debugger::getTargetScopes(
switch (kind) { switch (kind) {
case FUNCTION: case FUNCTION:
iterator = v8::debug::ScopeIterator::CreateForFunction( iterator = v8::debug::ScopeIterator::CreateForFunction(
m_isolate, v8::Local<v8::Function>::Cast(value)); m_isolate, value.As<v8::Function>());
break; break;
case GENERATOR: case GENERATOR:
v8::Local<v8::debug::GeneratorObject> generatorObject = v8::Local<v8::debug::GeneratorObject> generatorObject =
...@@ -665,7 +665,7 @@ v8::MaybeLocal<v8::Value> V8Debugger::getTargetScopes( ...@@ -665,7 +665,7 @@ v8::MaybeLocal<v8::Value> V8Debugger::getTargetScopes(
if (!generatorObject->IsSuspended()) return v8::MaybeLocal<v8::Value>(); if (!generatorObject->IsSuspended()) return v8::MaybeLocal<v8::Value>();
iterator = v8::debug::ScopeIterator::CreateForGeneratorObject( iterator = v8::debug::ScopeIterator::CreateForGeneratorObject(
m_isolate, v8::Local<v8::Object>::Cast(value)); m_isolate, value.As<v8::Object>());
break; break;
} }
if (!iterator) return v8::MaybeLocal<v8::Value>(); if (!iterator) return v8::MaybeLocal<v8::Value>();
......
...@@ -615,7 +615,7 @@ Response V8RuntimeAgentImpl::queryObjects( ...@@ -615,7 +615,7 @@ Response V8RuntimeAgentImpl::queryObjects(
return Response::ServerError("Prototype should be instance of Object"); return Response::ServerError("Prototype should be instance of Object");
} }
v8::Local<v8::Array> resultArray = m_inspector->debugger()->queryObjects( v8::Local<v8::Array> resultArray = m_inspector->debugger()->queryObjects(
scope.context(), v8::Local<v8::Object>::Cast(scope.object())); scope.context(), scope.object().As<v8::Object>());
return scope.injectedScript()->wrapObject( return scope.injectedScript()->wrapObject(
resultArray, objectGroup.fromMaybe(scope.objectGroupName()), resultArray, objectGroup.fromMaybe(scope.objectGroupName()),
WrapMode::kNoPreview, objects); WrapMode::kNoPreview, objects);
...@@ -735,10 +735,8 @@ void V8RuntimeAgentImpl::bindingCallback( ...@@ -735,10 +735,8 @@ void V8RuntimeAgentImpl::bindingCallback(
int contextId = InspectedContext::contextId(isolate->GetCurrentContext()); int contextId = InspectedContext::contextId(isolate->GetCurrentContext());
int contextGroupId = inspector->contextGroupId(contextId); int contextGroupId = inspector->contextGroupId(contextId);
String16 name = String16 name = toProtocolString(isolate, info.Data().As<v8::String>());
toProtocolString(isolate, v8::Local<v8::String>::Cast(info.Data())); String16 payload = toProtocolString(isolate, info[0].As<v8::String>());
String16 payload =
toProtocolString(isolate, v8::Local<v8::String>::Cast(info[0]));
inspector->forEachSession( inspector->forEachSession(
contextGroupId, contextGroupId,
......
...@@ -123,7 +123,7 @@ Response toProtocolValue(v8::Local<v8::Context> context, ...@@ -123,7 +123,7 @@ Response toProtocolValue(v8::Local<v8::Context> context,
if (value->IsObject()) { if (value->IsObject()) {
std::unique_ptr<protocol::DictionaryValue> jsonObject = std::unique_ptr<protocol::DictionaryValue> jsonObject =
protocol::DictionaryValue::create(); protocol::DictionaryValue::create();
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); v8::Local<v8::Object> object = value.As<v8::Object>();
v8::Local<v8::Array> propertyNames; v8::Local<v8::Array> propertyNames;
if (!object->GetPropertyNames(context).ToLocal(&propertyNames)) if (!object->GetPropertyNames(context).ToLocal(&propertyNames))
return Response::InternalError(); return Response::InternalError();
...@@ -134,8 +134,8 @@ Response toProtocolValue(v8::Local<v8::Context> context, ...@@ -134,8 +134,8 @@ Response toProtocolValue(v8::Local<v8::Context> context,
return Response::InternalError(); return Response::InternalError();
// FIXME(yurys): v8::Object should support GetOwnPropertyNames // FIXME(yurys): v8::Object should support GetOwnPropertyNames
if (name->IsString()) { if (name->IsString()) {
v8::Maybe<bool> hasRealNamedProperty = object->HasRealNamedProperty( v8::Maybe<bool> hasRealNamedProperty =
context, v8::Local<v8::String>::Cast(name)); object->HasRealNamedProperty(context, name.As<v8::String>());
if (hasRealNamedProperty.IsNothing() || if (hasRealNamedProperty.IsNothing() ||
!hasRealNamedProperty.FromJust()) !hasRealNamedProperty.FromJust())
continue; continue;
...@@ -883,7 +883,7 @@ bool isArrayLike(v8::Local<v8::Context> context, v8::Local<v8::Value> value, ...@@ -883,7 +883,7 @@ bool isArrayLike(v8::Local<v8::Context> context, v8::Local<v8::Value> value,
!lengthValue->IsUint32()) { !lengthValue->IsUint32()) {
return false; return false;
} }
*length = v8::Local<v8::Uint32>::Cast(lengthValue)->Value(); *length = lengthValue.As<v8::Uint32>()->Value();
return true; return true;
} }
...@@ -1904,7 +1904,7 @@ std::unique_ptr<ValueMirror> ValueMirror::create(v8::Local<v8::Context> context, ...@@ -1904,7 +1904,7 @@ std::unique_ptr<ValueMirror> ValueMirror::create(v8::Local<v8::Context> context,
descriptionForCollection(isolate, view, view->ByteLength())); descriptionForCollection(isolate, view, view->ByteLength()));
} }
V8InternalValueType internalType = V8InternalValueType internalType =
v8InternalValueTypeFrom(context, v8::Local<v8::Object>::Cast(value)); v8InternalValueTypeFrom(context, value.As<v8::Object>());
if (value->IsArray() && internalType == V8InternalValueType::kScopeList) { if (value->IsArray() && internalType == V8InternalValueType::kScopeList) {
return std::make_unique<ObjectMirror>( return std::make_unique<ObjectMirror>(
value, "internal#scopeList", value, "internal#scopeList",
......
...@@ -63,11 +63,10 @@ bool IsWasmCompileAllowed(v8::Isolate* isolate, v8::Local<v8::Value> value, ...@@ -63,11 +63,10 @@ bool IsWasmCompileAllowed(v8::Isolate* isolate, v8::Local<v8::Value> value,
DCHECK_GT(GetPerIsolateWasmControls()->count(isolate), 0); DCHECK_GT(GetPerIsolateWasmControls()->count(isolate), 0);
const WasmCompileControls& ctrls = GetPerIsolateWasmControls()->at(isolate); const WasmCompileControls& ctrls = GetPerIsolateWasmControls()->at(isolate);
return (is_async && ctrls.AllowAnySizeForAsync) || return (is_async && ctrls.AllowAnySizeForAsync) ||
(value->IsArrayBuffer() && (value->IsArrayBuffer() && value.As<v8::ArrayBuffer>()->ByteLength() <=
v8::Local<v8::ArrayBuffer>::Cast(value)->ByteLength() <= ctrls.MaxWasmBufferSize) ||
ctrls.MaxWasmBufferSize) ||
(value->IsArrayBufferView() && (value->IsArrayBufferView() &&
v8::Local<v8::ArrayBufferView>::Cast(value)->ByteLength() <= value.As<v8::ArrayBufferView>()->ByteLength() <=
ctrls.MaxWasmBufferSize); ctrls.MaxWasmBufferSize);
} }
......
...@@ -194,8 +194,7 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) { ...@@ -194,8 +194,7 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) {
if (*script != NULL) { if (*script != NULL) {
// Get the source file name and set it to jmethod.source_file_name // Get the source file name and set it to jmethod.source_file_name
if ((*script->GetScriptName())->IsString()) { if ((*script->GetScriptName())->IsString()) {
Local<String> script_name = Local<String> script_name = script->GetScriptName().As<String>();
Local<String>::Cast(script->GetScriptName());
temp_file_name.reset( temp_file_name.reset(
new char[script_name->Utf8Length(event->isolate) + 1]); new char[script_name->Utf8Length(event->isolate) + 1]);
script_name->WriteUtf8(event->isolate, temp_file_name.get()); script_name->WriteUtf8(event->isolate, temp_file_name.get());
......
...@@ -166,10 +166,11 @@ Handle<BytecodeArray> OptimizedBytecodeSourcePositionTester::MakeBytecode( ...@@ -166,10 +166,11 @@ Handle<BytecodeArray> OptimizedBytecodeSourcePositionTester::MakeBytecode(
SetOptimizationFlags(optimization_bitmap); SetOptimizationFlags(optimization_bitmap);
CompileRun(script.c_str()); CompileRun(script.c_str());
Local<Function> api_function = Local<Function>::Cast( Local<Function> api_function =
CcTest::global() CcTest::global()
->Get(CcTest::isolate()->GetCurrentContext(), v8_str("test_function")) ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("test_function"))
.ToLocalChecked()); .ToLocalChecked()
.As<Function>();
Handle<JSFunction> function = Handle<JSFunction> function =
Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function)); Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function));
return handle(function->shared().GetBytecodeArray(), isolate_); return handle(function->shared().GetBytecodeArray(), isolate_);
......
...@@ -97,8 +97,10 @@ static const char* sampler_test_source = "function start(count) {\n" ...@@ -97,8 +97,10 @@ static const char* sampler_test_source = "function start(count) {\n"
static v8::Local<v8::Function> GetFunction(v8::Local<v8::Context> env, static v8::Local<v8::Function> GetFunction(v8::Local<v8::Context> env,
const char* name) { const char* name) {
return v8::Local<v8::Function>::Cast( return env->Global()
env->Global()->Get(env, v8_str(name)).ToLocalChecked()); ->Get(env, v8_str(name))
.ToLocalChecked()
.As<v8::Function>();
} }
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "src/init/v8.h"
#include "src/api/api-inl.h" #include "src/api/api-inl.h"
#include "src/execution/frames-inl.h" #include "src/execution/frames-inl.h"
#include "src/strings/string-stream.h" #include "src/strings/string-stream.h"
...@@ -149,8 +147,7 @@ THREADED_TEST(PropertyHandler) { ...@@ -149,8 +147,7 @@ THREADED_TEST(PropertyHandler) {
static void GetIntValue(Local<String> property, static void GetIntValue(Local<String> property,
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz(); ApiTestFuzzer::Fuzz();
int* value = int* value = static_cast<int*>(info.Data().As<v8::External>()->Value());
static_cast<int*>(v8::Local<v8::External>::Cast(info.Data())->Value());
info.GetReturnValue().Set(v8_num(*value)); info.GetReturnValue().Set(v8_num(*value));
} }
...@@ -158,8 +155,7 @@ static void GetIntValue(Local<String> property, ...@@ -158,8 +155,7 @@ static void GetIntValue(Local<String> property,
static void SetIntValue(Local<String> property, static void SetIntValue(Local<String> property,
Local<Value> value, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) { const v8::PropertyCallbackInfo<void>& info) {
int* field = int* field = static_cast<int*>(info.Data().As<v8::External>()->Value());
static_cast<int*>(v8::Local<v8::External>::Cast(info.Data())->Value());
*field = value->Int32Value(info.GetIsolate()->GetCurrentContext()).FromJust(); *field = value->Int32Value(info.GetIsolate()->GetCurrentContext()).FromJust();
} }
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "test/cctest/test-api.h"
#include "src/api/api-inl.h" #include "src/api/api-inl.h"
#include "test/cctest/test-api.h"
using ::v8::Array; using ::v8::Array;
using ::v8::Context; using ::v8::Context;
...@@ -30,8 +29,7 @@ void CheckIsTypedArrayVarDetached(const char* name) { ...@@ -30,8 +29,7 @@ void CheckIsTypedArrayVarDetached(const char* name) {
"%s.byteLength == 0 && %s.byteOffset == 0 && %s.length == 0", "%s.byteLength == 0 && %s.byteOffset == 0 && %s.length == 0",
name, name, name); name, name, name);
CHECK(CompileRun(source.begin())->IsTrue()); CHECK(CompileRun(source.begin())->IsTrue());
v8::Local<v8::TypedArray> ta = v8::Local<v8::TypedArray> ta = CompileRun(name).As<v8::TypedArray>();
v8::Local<v8::TypedArray>::Cast(CompileRun(name));
CheckIsDetached(ta); CheckIsDetached(ta);
} }
...@@ -122,7 +120,7 @@ THREADED_TEST(ArrayBuffer_JSInternalToExternal) { ...@@ -122,7 +120,7 @@ THREADED_TEST(ArrayBuffer_JSInternalToExternal) {
"var u8_a = new Uint8Array(ab1);" "var u8_a = new Uint8Array(ab1);"
"u8_a[0] = 0xAA;" "u8_a[0] = 0xAA;"
"u8_a[1] = 0xFF; u8_a.buffer"); "u8_a[1] = 0xFF; u8_a.buffer");
Local<v8::ArrayBuffer> ab1 = Local<v8::ArrayBuffer>::Cast(result); Local<v8::ArrayBuffer> ab1 = result.As<v8::ArrayBuffer>();
CheckInternalFieldsAreZero(ab1); CheckInternalFieldsAreZero(ab1);
CHECK_EQ(2, ab1->ByteLength()); CHECK_EQ(2, ab1->ByteLength());
std::shared_ptr<v8::BackingStore> backing_store = Externalize(ab1); std::shared_ptr<v8::BackingStore> backing_store = Externalize(ab1);
...@@ -272,10 +270,8 @@ THREADED_TEST(ArrayBuffer_DetachingScript) { ...@@ -272,10 +270,8 @@ THREADED_TEST(ArrayBuffer_DetachingScript) {
"var f64a = new Float64Array(ab, 8, 127);" "var f64a = new Float64Array(ab, 8, 127);"
"var dv = new DataView(ab, 1, 1023);"); "var dv = new DataView(ab, 1, 1023);");
v8::Local<v8::ArrayBuffer> ab = v8::Local<v8::ArrayBuffer> ab = CompileRun("ab").As<v8::ArrayBuffer>();
Local<v8::ArrayBuffer>::Cast(CompileRun("ab")); v8::Local<v8::DataView> dv = CompileRun("dv").As<v8::DataView>();
v8::Local<v8::DataView> dv = v8::Local<v8::DataView>::Cast(CompileRun("dv"));
Externalize(ab); Externalize(ab);
ab->Detach(); ab->Detach();
...@@ -424,7 +420,7 @@ THREADED_TEST(SharedArrayBuffer_JSInternalToExternal) { ...@@ -424,7 +420,7 @@ THREADED_TEST(SharedArrayBuffer_JSInternalToExternal) {
"var u8_a = new Uint8Array(ab1);" "var u8_a = new Uint8Array(ab1);"
"u8_a[0] = 0xAA;" "u8_a[0] = 0xAA;"
"u8_a[1] = 0xFF; u8_a.buffer"); "u8_a[1] = 0xFF; u8_a.buffer");
Local<v8::SharedArrayBuffer> ab1 = Local<v8::SharedArrayBuffer>::Cast(result); Local<v8::SharedArrayBuffer> ab1 = result.As<v8::SharedArrayBuffer>();
CheckInternalFieldsAreZero(ab1); CheckInternalFieldsAreZero(ab1);
CHECK_EQ(2, ab1->ByteLength()); CHECK_EQ(2, ab1->ByteLength());
CHECK(!ab1->IsExternal()); CHECK(!ab1->IsExternal());
......
This diff is collapsed.
...@@ -2276,6 +2276,7 @@ THREADED_TEST(TestDataTypeChecks) { ...@@ -2276,6 +2276,7 @@ THREADED_TEST(TestDataTypeChecks) {
CHECK(!x->IsObjectTemplate()); CHECK(!x->IsObjectTemplate());
CHECK(!x->IsFunctionTemplate()); CHECK(!x->IsFunctionTemplate());
v8::Local<v8::Value>::Cast(x); v8::Local<v8::Value>::Cast(x);
x.As<v8::Value>();
} }
v8::ScriptOrigin origin(v8_str(""), 0, 0, false, -1, Local<v8::Value>(), v8::ScriptOrigin origin(v8_str(""), 0, 0, false, -1, Local<v8::Value>(),
...@@ -2290,6 +2291,7 @@ THREADED_TEST(TestDataTypeChecks) { ...@@ -2290,6 +2291,7 @@ THREADED_TEST(TestDataTypeChecks) {
CHECK(!module->IsObjectTemplate()); CHECK(!module->IsObjectTemplate());
CHECK(!module->IsFunctionTemplate()); CHECK(!module->IsFunctionTemplate());
v8::Local<v8::Module>::Cast(module); v8::Local<v8::Module>::Cast(module);
module.As<v8::Module>();
v8::Local<v8::Data> p = v8::Private::New(isolate); v8::Local<v8::Data> p = v8::Private::New(isolate);
CHECK(!p->IsModule()); CHECK(!p->IsModule());
...@@ -2604,7 +2606,7 @@ THREADED_TEST(DescriptorInheritance2) { ...@@ -2604,7 +2606,7 @@ THREADED_TEST(DescriptorInheritance2) {
void SimpleAccessorGetter(Local<String> name, void SimpleAccessorGetter(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
Local<Object> self = Local<Object>::Cast(info.This()); Local<Object> self = info.This().As<Object>();
info.GetReturnValue().Set( info.GetReturnValue().Set(
self->Get(info.GetIsolate()->GetCurrentContext(), self->Get(info.GetIsolate()->GetCurrentContext(),
String::Concat(info.GetIsolate(), v8_str("accessor_"), name)) String::Concat(info.GetIsolate(), v8_str("accessor_"), name))
...@@ -2613,7 +2615,7 @@ void SimpleAccessorGetter(Local<String> name, ...@@ -2613,7 +2615,7 @@ void SimpleAccessorGetter(Local<String> name,
void SimpleAccessorSetter(Local<String> name, Local<Value> value, void SimpleAccessorSetter(Local<String> name, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) { const v8::PropertyCallbackInfo<void>& info) {
Local<Object> self = Local<Object>::Cast(info.This()); Local<Object> self = info.This().As<Object>();
CHECK(self->Set(info.GetIsolate()->GetCurrentContext(), CHECK(self->Set(info.GetIsolate()->GetCurrentContext(),
String::Concat(info.GetIsolate(), v8_str("accessor_"), name), String::Concat(info.GetIsolate(), v8_str("accessor_"), name),
value) value)
...@@ -2623,7 +2625,7 @@ void SimpleAccessorSetter(Local<String> name, Local<Value> value, ...@@ -2623,7 +2625,7 @@ void SimpleAccessorSetter(Local<String> name, Local<Value> value,
void SymbolAccessorGetter(Local<Name> name, void SymbolAccessorGetter(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(name->IsSymbol()); CHECK(name->IsSymbol());
Local<Symbol> sym = Local<Symbol>::Cast(name); Local<Symbol> sym = name.As<Symbol>();
if (sym->Description()->IsUndefined()) return; if (sym->Description()->IsUndefined()) return;
SimpleAccessorGetter(Local<String>::Cast(sym->Description()), info); SimpleAccessorGetter(Local<String>::Cast(sym->Description()), info);
} }
...@@ -2631,7 +2633,7 @@ void SymbolAccessorGetter(Local<Name> name, ...@@ -2631,7 +2633,7 @@ void SymbolAccessorGetter(Local<Name> name,
void SymbolAccessorSetter(Local<Name> name, Local<Value> value, void SymbolAccessorSetter(Local<Name> name, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) { const v8::PropertyCallbackInfo<void>& info) {
CHECK(name->IsSymbol()); CHECK(name->IsSymbol());
Local<Symbol> sym = Local<Symbol>::Cast(name); Local<Symbol> sym = name.As<Symbol>();
if (sym->Description()->IsUndefined()) return; if (sym->Description()->IsUndefined()) return;
SimpleAccessorSetter(Local<String>::Cast(sym->Description()), value, info); SimpleAccessorSetter(Local<String>::Cast(sym->Description()), value, info);
} }
...@@ -2639,7 +2641,7 @@ void SymbolAccessorSetter(Local<Name> name, Local<Value> value, ...@@ -2639,7 +2641,7 @@ void SymbolAccessorSetter(Local<Name> name, Local<Value> value,
void SymbolAccessorGetterReturnsDefault( void SymbolAccessorGetterReturnsDefault(
Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(name->IsSymbol()); CHECK(name->IsSymbol());
Local<Symbol> sym = Local<Symbol>::Cast(name); Local<Symbol> sym = name.As<Symbol>();
if (sym->Description()->IsUndefined()) return; if (sym->Description()->IsUndefined()) return;
info.GetReturnValue().Set(info.Data()); info.GetReturnValue().Set(info.Data());
} }
...@@ -8828,7 +8830,7 @@ static void YGetter(Local<String> name, ...@@ -8828,7 +8830,7 @@ static void YGetter(Local<String> name,
static void YSetter(Local<String> name, static void YSetter(Local<String> name,
Local<Value> value, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) { const v8::PropertyCallbackInfo<void>& info) {
Local<Object> this_obj = Local<Object>::Cast(info.This()); Local<Object> this_obj = info.This().As<Object>();
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
if (this_obj->Has(context, name).FromJust()) if (this_obj->Has(context, name).FromJust())
this_obj->Delete(context, name).FromJust(); this_obj->Delete(context, name).FromJust();
...@@ -17588,7 +17590,8 @@ static void SetterWhichSetsYOnThisTo23( ...@@ -17588,7 +17590,8 @@ static void SetterWhichSetsYOnThisTo23(
const v8::PropertyCallbackInfo<void>& info) { const v8::PropertyCallbackInfo<void>& info) {
CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject());
CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject());
Local<Object>::Cast(info.This()) info.This()
.As<Object>()
->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(23)) ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(23))
.FromJust(); .FromJust();
} }
...@@ -17614,7 +17617,8 @@ void FooSetInterceptor(Local<Name> name, Local<Value> value, ...@@ -17614,7 +17617,8 @@ void FooSetInterceptor(Local<Name> name, Local<Value> value,
.FromJust()) { .FromJust()) {
return; return;
} }
Local<Object>::Cast(info.This()) info.This()
.As<Object>()
->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(23)) ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(23))
.FromJust(); .FromJust();
info.GetReturnValue().Set(v8_num(23)); info.GetReturnValue().Set(v8_num(23));
...@@ -17678,7 +17682,8 @@ static void NamedPropertySetterWhichSetsYOnThisTo23( ...@@ -17678,7 +17682,8 @@ static void NamedPropertySetterWhichSetsYOnThisTo23(
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
if (name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("x")) if (name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("x"))
.FromJust()) { .FromJust()) {
Local<Object>::Cast(info.This()) info.This()
.As<Object>()
->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(23)) ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(23))
.FromJust(); .FromJust();
} }
...@@ -330,7 +330,7 @@ TEST(ModuleEvaluation) { ...@@ -330,7 +330,7 @@ TEST(ModuleEvaluation) {
MaybeLocal<Value> result = module->Evaluate(env.local()); MaybeLocal<Value> result = module->Evaluate(env.local());
CHECK_EQ(Module::kEvaluated, module->GetStatus()); CHECK_EQ(Module::kEvaluated, module->GetStatus());
if (i::FLAG_harmony_top_level_await) { if (i::FLAG_harmony_top_level_await) {
Local<Promise> promise = Local<Promise>::Cast(result.ToLocalChecked()); Local<Promise> promise = result.ToLocalChecked().As<Promise>();
CHECK_EQ(promise->State(), v8::Promise::kFulfilled); CHECK_EQ(promise->State(), v8::Promise::kFulfilled);
CHECK(promise->Result()->IsUndefined()); CHECK(promise->Result()->IsUndefined());
} else { } else {
...@@ -377,7 +377,7 @@ TEST(ModuleEvaluationError1) { ...@@ -377,7 +377,7 @@ TEST(ModuleEvaluationError1) {
// With top level await, we do not throw and errored evaluation returns // With top level await, we do not throw and errored evaluation returns
// a rejected promise with the exception. // a rejected promise with the exception.
CHECK(!inner_try_catch.HasCaught()); CHECK(!inner_try_catch.HasCaught());
Local<Promise> promise = Local<Promise>::Cast(result.ToLocalChecked()); Local<Promise> promise = result.ToLocalChecked().As<Promise>();
CHECK_EQ(promise->State(), v8::Promise::kRejected); CHECK_EQ(promise->State(), v8::Promise::kRejected);
CHECK_EQ(promise->Result(), module->GetException()); CHECK_EQ(promise->Result(), module->GetException());
} else { } else {
...@@ -399,7 +399,7 @@ TEST(ModuleEvaluationError1) { ...@@ -399,7 +399,7 @@ TEST(ModuleEvaluationError1) {
// With top level await, we do not throw and errored evaluation returns // With top level await, we do not throw and errored evaluation returns
// a rejected promise with the exception. // a rejected promise with the exception.
CHECK(!inner_try_catch.HasCaught()); CHECK(!inner_try_catch.HasCaught());
Local<Promise> promise = Local<Promise>::Cast(result.ToLocalChecked()); Local<Promise> promise = result.ToLocalChecked().As<Promise>();
CHECK_EQ(promise->State(), v8::Promise::kRejected); CHECK_EQ(promise->State(), v8::Promise::kRejected);
CHECK_EQ(promise->Result(), module->GetException()); CHECK_EQ(promise->Result(), module->GetException());
} else { } else {
...@@ -460,7 +460,7 @@ TEST(ModuleEvaluationError2) { ...@@ -460,7 +460,7 @@ TEST(ModuleEvaluationError2) {
// With top level await, we do not throw and errored evaluation returns // With top level await, we do not throw and errored evaluation returns
// a rejected promise with the exception. // a rejected promise with the exception.
CHECK(!inner_try_catch.HasCaught()); CHECK(!inner_try_catch.HasCaught());
Local<Promise> promise = Local<Promise>::Cast(result.ToLocalChecked()); Local<Promise> promise = result.ToLocalChecked().As<Promise>();
CHECK_EQ(promise->State(), v8::Promise::kRejected); CHECK_EQ(promise->State(), v8::Promise::kRejected);
CHECK_EQ(promise->Result(), failure_module->GetException()); CHECK_EQ(promise->Result(), failure_module->GetException());
} else { } else {
...@@ -496,7 +496,7 @@ TEST(ModuleEvaluationError2) { ...@@ -496,7 +496,7 @@ TEST(ModuleEvaluationError2) {
// With top level await, we do not throw and errored evaluation returns // With top level await, we do not throw and errored evaluation returns
// a rejected promise with the exception. // a rejected promise with the exception.
CHECK(!inner_try_catch.HasCaught()); CHECK(!inner_try_catch.HasCaught());
Local<Promise> promise = Local<Promise>::Cast(result.ToLocalChecked()); Local<Promise> promise = result.ToLocalChecked().As<Promise>();
CHECK_EQ(promise->State(), v8::Promise::kRejected); CHECK_EQ(promise->State(), v8::Promise::kRejected);
CHECK_EQ(promise->Result(), failure_module->GetException()); CHECK_EQ(promise->Result(), failure_module->GetException());
} else { } else {
...@@ -561,12 +561,12 @@ TEST(ModuleEvaluationCompletion1) { ...@@ -561,12 +561,12 @@ TEST(ModuleEvaluationCompletion1) {
CHECK_EQ(Module::kEvaluated, module->GetStatus()); CHECK_EQ(Module::kEvaluated, module->GetStatus());
if (i::FLAG_harmony_top_level_await) { if (i::FLAG_harmony_top_level_await) {
Local<Promise> promise = Local<Promise>::Cast(result_1); Local<Promise> promise = result_1.As<Promise>();
CHECK_EQ(promise->State(), v8::Promise::kFulfilled); CHECK_EQ(promise->State(), v8::Promise::kFulfilled);
CHECK(promise->Result()->IsUndefined()); CHECK(promise->Result()->IsUndefined());
// Second evaluation should return the same promise. // Second evaluation should return the same promise.
Local<Promise> promise_too = Local<Promise>::Cast(result_2); Local<Promise> promise_too = result_2.As<Promise>();
CHECK_EQ(promise, promise_too); CHECK_EQ(promise, promise_too);
CHECK_EQ(promise_too->State(), v8::Promise::kFulfilled); CHECK_EQ(promise_too->State(), v8::Promise::kFulfilled);
CHECK(promise_too->Result()->IsUndefined()); CHECK(promise_too->Result()->IsUndefined());
...@@ -628,12 +628,12 @@ TEST(ModuleEvaluationCompletion2) { ...@@ -628,12 +628,12 @@ TEST(ModuleEvaluationCompletion2) {
Local<Value> result_2 = module->Evaluate(env.local()).ToLocalChecked(); Local<Value> result_2 = module->Evaluate(env.local()).ToLocalChecked();
CHECK_EQ(Module::kEvaluated, module->GetStatus()); CHECK_EQ(Module::kEvaluated, module->GetStatus());
if (i::FLAG_harmony_top_level_await) { if (i::FLAG_harmony_top_level_await) {
Local<Promise> promise = Local<Promise>::Cast(result_1); Local<Promise> promise = result_1.As<Promise>();
CHECK_EQ(promise->State(), v8::Promise::kFulfilled); CHECK_EQ(promise->State(), v8::Promise::kFulfilled);
CHECK(promise->Result()->IsUndefined()); CHECK(promise->Result()->IsUndefined());
// Second Evaluation should return the same promise. // Second Evaluation should return the same promise.
Local<Promise> promise_too = Local<Promise>::Cast(result_2); Local<Promise> promise_too = result_2.As<Promise>();
CHECK_EQ(promise, promise_too); CHECK_EQ(promise, promise_too);
CHECK_EQ(promise_too->State(), v8::Promise::kFulfilled); CHECK_EQ(promise_too->State(), v8::Promise::kFulfilled);
CHECK(promise_too->Result()->IsUndefined()); CHECK(promise_too->Result()->IsUndefined());
......
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