Commit 30af507f authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Use info.This/Holder appropriately

Uses info.This() and info.Holder() appropriately according to
v8::FunctionCallbackInfo and v8::PropertyCallbackInfo in
bindings::V8SetReturnValue.

Bug: 839389
Change-Id: I4b43f945fc5ff2952620cfc869e32e91398b3086
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409877Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806993}
parent e2cac317
......@@ -25,6 +25,8 @@ namespace bindings {
// depending on the return value type.
struct V8ReturnValue {
STATIC_ONLY(V8ReturnValue);
// Support compile-time overload resolution by making each value have its own
// type.
......@@ -44,6 +46,16 @@ struct V8ReturnValue {
// Returns the interface object of the given type.
enum InterfaceObject { kInterfaceObject };
// Selects the appropriate creation context.
static v8::Local<v8::Object> CreationContext(
const v8::FunctionCallbackInfo<v8::Value>& info) {
return info.This();
}
static v8::Local<v8::Object> CreationContext(
const v8::PropertyCallbackInfo<v8::Value>& info) {
return info.Holder();
}
};
// V8 handle types
......@@ -72,9 +84,9 @@ PLATFORM_EXPORT v8::Local<v8::Object> CreatePropertyDescriptorObject(
v8::Isolate* isolate,
const v8::PropertyDescriptor& desc);
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
const v8::PropertyDescriptor& value) {
PLATFORM_EXPORT inline void V8SetReturnValue(
const v8::PropertyCallbackInfo<v8::Value>& info,
const v8::PropertyDescriptor& value) {
info.GetReturnValue().Set(
CreatePropertyDescriptorObject(info.GetIsolate(), value));
}
......@@ -120,9 +132,9 @@ PLATFORM_EXPORT inline void V8SetReturnValue(
info.GetReturnValue().SetNull();
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
NamedPropertyDeleterResult value) {
PLATFORM_EXPORT inline void V8SetReturnValue(
const v8::PropertyCallbackInfo<v8::Boolean>& info,
NamedPropertyDeleterResult value) {
if (value == NamedPropertyDeleterResult::kDidNotIntercept) {
// Do not set the return value to indicate that the request was not
// intercepted.
......@@ -273,7 +285,8 @@ void V8SetReturnValue(const CallbackInfo& info,
wrappable))
return;
info.GetReturnValue().Set(wrappable->Wrap(info.GetIsolate(), info.This()));
info.GetReturnValue().Set(
wrappable->Wrap(info.GetIsolate(), V8ReturnValue::CreationContext(info)));
}
template <typename CallbackInfo>
......@@ -286,7 +299,8 @@ void V8SetReturnValue(const CallbackInfo& info,
wrappable))
return;
info.GetReturnValue().Set(wrappable->Wrap(info.GetIsolate(), info.This()));
info.GetReturnValue().Set(
wrappable->Wrap(info.GetIsolate(), V8ReturnValue::CreationContext(info)));
}
template <typename CallbackInfo>
......@@ -298,11 +312,13 @@ void V8SetReturnValue(const CallbackInfo& info,
ScriptWrappable* wrappable = const_cast<ScriptWrappable*>(value);
if (DOMDataStore::SetReturnValueFast(info.GetReturnValue(), wrappable,
info.This(), receiver)) {
V8ReturnValue::CreationContext(info),
receiver)) {
return;
}
info.GetReturnValue().Set(wrappable->Wrap(info.GetIsolate(), info.This()));
info.GetReturnValue().Set(
wrappable->Wrap(info.GetIsolate(), V8ReturnValue::CreationContext(info)));
}
template <typename CallbackInfo>
......@@ -311,11 +327,13 @@ void V8SetReturnValue(const CallbackInfo& info,
const ScriptWrappable* receiver) {
ScriptWrappable* wrappable = const_cast<ScriptWrappable*>(&value);
if (DOMDataStore::SetReturnValueFast(info.GetReturnValue(), wrappable,
info.This(), receiver)) {
V8ReturnValue::CreationContext(info),
receiver)) {
return;
}
info.GetReturnValue().Set(wrappable->Wrap(info.GetIsolate(), info.This()));
info.GetReturnValue().Set(
wrappable->Wrap(info.GetIsolate(), V8ReturnValue::CreationContext(info)));
}
template <typename CallbackInfo>
......
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