Commit 4e92e124 authored by daniel.bevenius's avatar daniel.bevenius Committed by Commit bot

Adding V8_WARN_UNUSED_RESULT for specified TODOs

Currently there are a number of comment in src/v8.h which look like
this: TODO(dcarney): mark V8_WARN_UNUSED_RESULT.

This commit attempts to remove these comments and add the
V8_WARN_UNUSED_RESULT macro to the methods in question.

BUG=

Review-Url: https://codereview.chromium.org/2135973002
Cr-Commit-Position: refs/heads/master@{#44010}
parent 71fe3dd8
......@@ -3004,15 +3004,16 @@ class V8_EXPORT Object : public Value {
Local<Value> key);
V8_DEPRECATE_SOON("Use maybe version", bool Delete(Local<Value> key));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Delete(Local<Context> context, Local<Value> key);
V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context,
Local<Value> key);
V8_DEPRECATED("Use maybe version", bool Has(uint32_t index));
V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index);
V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
uint32_t index);
V8_DEPRECATED("Use maybe version", bool Delete(uint32_t index));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Delete(Local<Context> context, uint32_t index);
V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context,
uint32_t index);
V8_DEPRECATED("Use maybe version",
bool SetAccessor(Local<String> name,
......@@ -3028,8 +3029,8 @@ class V8_EXPORT Object : public Value {
Local<Value> data = Local<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name,
V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(Local<Context> context,
Local<Name> name,
AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter = 0,
MaybeLocal<Value> data = MaybeLocal<Value>(),
......@@ -3761,12 +3762,12 @@ class V8_EXPORT Promise : public Object {
* Ignored if the promise is no longer pending.
*/
V8_DEPRECATE_SOON("Use maybe version", void Resolve(Local<Value> value));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Resolve(Local<Context> context, Local<Value> value);
V8_WARN_UNUSED_RESULT Maybe<bool> Resolve(Local<Context> context,
Local<Value> value);
V8_DEPRECATE_SOON("Use maybe version", void Reject(Local<Value> value));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Reject(Local<Context> context, Local<Value> value);
V8_WARN_UNUSED_RESULT Maybe<bool> Reject(Local<Context> context,
Local<Value> value);
V8_INLINE static Resolver* Cast(Value* obj);
......
......@@ -189,7 +189,8 @@ void WebAssemblyCompile(const v8::FunctionCallbackInfo<v8::Value>& args) {
auto bytes = GetFirstArgumentAsBytes(args, &thrower);
if (!IsCompilationAllowed(i_isolate, &thrower, args[0], true)) {
resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
auto maybe = resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
CHECK(!maybe.IsNothing());
return;
}
DCHECK(!thrower.error());
......@@ -337,7 +338,8 @@ void WebAssemblyInstantiate(const v8::FunctionCallbackInfo<v8::Value>& args) {
thrower.TypeError(
"Argument 0 must be provided and must be either a buffer source or a "
"WebAssembly.Module object");
resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
auto maybe = resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
CHECK(!maybe.IsNothing());
return;
}
......@@ -345,18 +347,21 @@ void WebAssemblyInstantiate(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (!first_arg->IsJSObject()) {
thrower.TypeError(
"Argument 0 must be a buffer source or a WebAssembly.Module object");
resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
auto maybe = resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
CHECK(!maybe.IsNothing());
return;
}
auto maybe_imports = GetSecondArgumentAsImports(args, &thrower);
if (thrower.error()) {
resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
auto maybe = resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
CHECK(!maybe.IsNothing());
return;
}
if (!IsInstantiationAllowed(i_isolate, &thrower, args[0], maybe_imports,
true)) {
resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
auto maybe = resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
CHECK(!maybe.IsNothing());
return;
}
i::Handle<i::JSPromise> promise = Utils::OpenHandle(*resolver->GetPromise());
......@@ -369,7 +374,8 @@ void WebAssemblyInstantiate(const v8::FunctionCallbackInfo<v8::Value>& args) {
// WebAssembly.instantiate(bytes, imports) -> {module, instance}
auto bytes = GetFirstArgumentAsBytes(args, &thrower);
if (thrower.error()) {
resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
auto maybe = resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
CHECK(!maybe.IsNothing());
return;
}
i::wasm::AsyncCompileAndInstantiate(i_isolate, promise, bytes,
......
......@@ -2863,8 +2863,9 @@ void RejectPromise(Isolate* isolate, ErrorThrower* thrower,
v8::Local<v8::Promise::Resolver> resolver =
v8::Utils::PromiseToLocal(promise).As<v8::Promise::Resolver>();
Handle<Context> context(isolate->context(), isolate);
resolver->Reject(v8::Utils::ToLocal(context),
auto maybe = resolver->Reject(v8::Utils::ToLocal(context),
v8::Utils::ToLocal(thrower->Reify()));
CHECK(!maybe.IsNothing());
}
void ResolvePromise(Isolate* isolate, Handle<JSPromise> promise,
......@@ -2872,7 +2873,9 @@ void ResolvePromise(Isolate* isolate, Handle<JSPromise> promise,
v8::Local<v8::Promise::Resolver> resolver =
v8::Utils::PromiseToLocal(promise).As<v8::Promise::Resolver>();
Handle<Context> context(isolate->context(), isolate);
resolver->Resolve(v8::Utils::ToLocal(context), v8::Utils::ToLocal(result));
auto maybe = resolver->Resolve(v8::Utils::ToLocal(context),
v8::Utils::ToLocal(result));
CHECK(!maybe.IsNothing());
}
} // namespace
......
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