Commit cf8a4164 authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

bindings: Expose an indexed property descriptor handler for named properties.

Follow-up to https://chromium-review.googlesource.com/576183 ("bindings:
Return the right property descriptors for legacy platform objects"), which
introduced the indexed descriptor callbacks for bindings.

Even if a given IDL (such as Storage.idl) only supports named properties,
our bindings layer installs a handler for indexed properties that, in this
case, mostly just ends up falling back to the named property handlers.

However, we were not defining a descriptor callback for indexed properties
when the IDL only supports named properties. Consequently, we were not
setting the right property descriptor values for a given numeric property,
leading to bizarre cases where, e.g. if Storage only had numeric keys,
Object.values() and Object.keys() would return arrays of diffferent
lengths (the latter would be an empty one, actually).

This change is a bit complicated because we install our indexed and named
property handlers differently: the former is created with descriptor and
definer callbacks, whereas the latter uses the query callback signature
instead. This means the indexed property descriptor callback for named
properties needs to call the query callback and translate its return value
into a format suitable for descriptor callbacks, which is not very
efficient. Ideally, both named and indexed properties should converge in
terms of how their handlers are declared.

Despite the fact that this is a follow-up commit, the original CL did not
introduce a regression; interfaces that only support named properties were
just behaving like they did in the past, with an indexed descriptor callback
not being set.

Bug: 719703, 764633
Change-Id: I1ebaabe61f5f8b6cadb0cfa8b41664a64e49e51b
Reviewed-on: https://chromium-review.googlesource.com/660497
Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501591}
parent de8d63e5
......@@ -34,6 +34,33 @@
assert_array_equals(enumeratedArray, expectArray);
}, name + ": enumerate a Storage object and get only the keys as a result and the built-in properties of the Storage object should be ignored");
test(function() {
const storage = window[name];
storage.clear();
storage.setItem("foo", "bar");
storage.baz = "quux";
storage.setItem(0, "alpha");
storage[42] = "beta";
for (let prop in storage) {
if (!storage.hasOwnProperty(prop))
continue;
const desc = Object.getOwnPropertyDescriptor(storage, prop);
assert_true(desc.configurable);
assert_true(desc.enumerable);
assert_true(desc.writable);
}
const keys = Object.keys(storage);
keys.sort(); // Storage order is implementation-defined.
assert_array_equals(keys, ["0", "42", "baz", "foo"]);
const values = Object.values(storage);
values.sort(); // Storage order is implementation-defined.
assert_array_equals(values, ["alpha", "bar", "beta", "quux"]);
}, name + ": test enumeration of numeric and non-numeric keys");
});
</script>
</body>
......
......@@ -188,11 +188,71 @@ static void indexedPropertyDescriptor(uint32_t index, const v8::PropertyCallback
{% endblock %}
{##############################################################################}
{% block named_property_descriptor %}
{% if not indexed_property_getter and named_property_getter %}
static void namedPropertyDescriptor(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
// This function is called when an IDL interface supports named properties
// but not indexed properties. When a numeric property is queried, V8 calls
// indexedPropertyDescriptorCallback(), which calls this function.
{% if named_property_getter.is_enumerable %}
// Since we initialize our indexed and named property handlers differently
// (the former use descriptors and definers, the latter uses a query
// callback), we need to inefficiently call the query callback and convert
// the v8::PropertyAttribute integer it returns into a v8::PropertyDescriptor
// expected by a descriptor callback.
// TODO(rakuco): remove this hack once we switch named property handlers to
// using descriptor and definer callbacks (bug 764633).
const AtomicString& indexAsName = AtomicString::Number(index);
{% if named_property_getter.is_custom_property_query %}
{{v8_class}}::namedPropertyQueryCustom(indexAsName, info);
{% else %}
{{cpp_class}}V8Internal::namedPropertyQuery(indexAsName, info);
{% endif %}
v8::Local<v8::Value> getterValue = info.GetReturnValue().Get();
if (!getterValue->IsUndefined()) {
DCHECK(getterValue->IsInt32());
const int32_t props =
getterValue->ToInt32(info.GetIsolate()->GetCurrentContext())
.ToLocalChecked()
->Value();
v8::PropertyDescriptor desc(V8String(info.GetIsolate(), indexAsName),
!(props & v8::ReadOnly));
desc.set_enumerable(!(props & v8::DontEnum));
desc.set_configurable(!(props & v8::DontDelete));
V8SetReturnValue(info, desc);
}
{% else %}{# TODO(rakuco): drop this once we remove [NotEnumerable] getters #}
// This IDL interface defines a [NotEnumerable] getter. We need to do
// something similar to indexedPropertyDescriptor(): call
// indexedPropertyGetterCallback, let it end up calling the named property
// getter and, if all goes well, we create a v8::PropertyDescriptor with the
// right values.
{{v8_class_or_partial}}::indexedPropertyGetterCallback(index, info);
v8::Local<v8::Value> getterValue = info.GetReturnValue().Get();
if (!getterValue->IsUndefined()) {
v8::PropertyDescriptor desc(getterValue, {% if named_property_setter %}true{% else %}false{% endif %});
desc.set_enumerable(false);
desc.set_configurable(true);
V8SetReturnValue(info, desc);
}
{% endif %}
}
{% endif %}
{% endblock %}
{##############################################################################}
{% block indexed_property_descriptor_callback %}
{% if indexed_property_getter %}
{% if indexed_property_getter or named_property_getter %}
void {{v8_class_or_partial}}::indexedPropertyDescriptorCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
{% if indexed_property_getter %}
{{cpp_class}}V8Internal::indexedPropertyDescriptor(index, info);
{% else %}{# The interface only supports named properties. #}
{{cpp_class}}V8Internal::namedPropertyDescriptor(index, info);
{% endif %}{# indexed_property_getter #}
}
{% endif %}
......@@ -504,7 +564,18 @@ void {{v8_class_or_partial}}::namedPropertyDeleterCallback(v8::Local<v8::Name> n
{% set getter = named_property_getter %}
{# If there is an enumerator, there MUST be a query method to properly
communicate property attributes. #}
{% if indexed_property_getter %}
static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Integer>& info) {
{% else %}
{# If we do not have an indexed property getter, this function is called #}
{# from namedPropertyDescriptor(), whose v8::PropertyCallbackInfo has a #}
{# v8::Value instead of a v8::Integer. We use this template trick to make #}
{# the compiler accept the call. #}
{# TODO(rakuco): remove this hack once we switch named property handlers to #}
{# using descriptor and definer callbacks (bug 764633). #}
template <typename T>
static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<T>& info) {
{% endif %}
const CString& nameInUtf8 = name.Utf8();
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kGetterContext, "{{interface_name}}", nameInUtf8.data());
{% if getter.is_call_with_script_state %}
......@@ -831,7 +902,7 @@ for (const auto& attributeConfig : {{method.name}}OriginSafeAttributeConfigurati
if indexed_property_getter or named_property_setter else 'nullptr' %}
{% set indexed_property_descriptor_callback =
'%s::indexedPropertyDescriptorCallback' % v8_class_or_partial
if indexed_property_getter else 'nullptr' %}
if indexed_property_getter or named_property_getter else 'nullptr' %}
{% set indexed_property_deleter_callback =
'%s::indexedPropertyDeleterCallback' % v8_class_or_partial
if indexed_property_deleter or named_property_deleter else 'nullptr' %}
......
......@@ -245,7 +245,7 @@ class {{v8_class}} {
{% if indexed_property_getter or named_property_setter %}
{{exported}}static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if indexed_property_getter %}
{% if indexed_property_getter or named_property_getter %}
{{exported}}static void indexedPropertyDescriptorCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if indexed_property_deleter or named_property_deleter %}
......
......@@ -143,6 +143,7 @@ static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallba
{% block named_property_setter %}{% endblock %}
{% block named_property_deleter %}{% endblock %}
{% block named_property_query %}{% endblock %}
{% block named_property_descriptor %}{% endblock %}
{% block named_property_enumerator %}{% endblock %}
{% block indexed_property_getter %}{% endblock %}
{% block indexed_property_descriptor %}{% endblock %}
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Tests whether an interface that only supports named properties and has its
// getter annotated with [NotEnumerable] works as expected.
interface TestNotEnumerableNamedGetter {
[NotEnumerable] getter long (DOMString name);
};
......@@ -113,7 +113,8 @@ static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v
V8SetReturnValue(info, v8Value);
}
static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Integer>& info) {
template <typename T>
static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<T>& info) {
const CString& nameInUtf8 = name.Utf8();
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kGetterContext, "TestSpecialOperations", nameInUtf8.data());
......@@ -131,6 +132,35 @@ static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallb
V8SetReturnValueInt(info, v8::None);
}
static void namedPropertyDescriptor(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
// This function is called when an IDL interface supports named properties
// but not indexed properties. When a numeric property is queried, V8 calls
// indexedPropertyDescriptorCallback(), which calls this function.
// Since we initialize our indexed and named property handlers differently
// (the former use descriptors and definers, the latter uses a query
// callback), we need to inefficiently call the query callback and convert
// the v8::PropertyAttribute integer it returns into a v8::PropertyDescriptor
// expected by a descriptor callback.
// TODO(rakuco): remove this hack once we switch named property handlers to
// using descriptor and definer callbacks (bug 764633).
const AtomicString& indexAsName = AtomicString::Number(index);
TestSpecialOperationsV8Internal::namedPropertyQuery(indexAsName, info);
v8::Local<v8::Value> getterValue = info.GetReturnValue().Get();
if (!getterValue->IsUndefined()) {
DCHECK(getterValue->IsInt32());
const int32_t props =
getterValue->ToInt32(info.GetIsolate()->GetCurrentContext())
.ToLocalChecked()
->Value();
v8::PropertyDescriptor desc(V8String(info.GetIsolate(), indexAsName),
!(props & v8::ReadOnly));
desc.set_enumerable(!(props & v8::DontEnum));
desc.set_configurable(!(props & v8::DontDelete));
V8SetReturnValue(info, desc);
}
}
static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) {
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kEnumerationContext, "TestSpecialOperations");
......@@ -193,6 +223,10 @@ void V8TestSpecialOperations::indexedPropertyGetterCallback(uint32_t index, cons
TestSpecialOperationsV8Internal::namedPropertyGetter(propertyName, info);
}
void V8TestSpecialOperations::indexedPropertyDescriptorCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
TestSpecialOperationsV8Internal::namedPropertyDescriptor(index, info);
}
void V8TestSpecialOperations::indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) {
const AtomicString& propertyName = AtomicString::Number(index);
......@@ -226,7 +260,7 @@ static void installV8TestSpecialOperationsTemplate(
v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(
V8TestSpecialOperations::indexedPropertyGetterCallback,
V8TestSpecialOperations::indexedPropertySetterCallback,
nullptr,
V8TestSpecialOperations::indexedPropertyDescriptorCallback,
nullptr,
nullptr,
nullptr,
......
......@@ -55,6 +55,7 @@ class V8TestSpecialOperations {
CORE_EXPORT static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>&);
CORE_EXPORT static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
CORE_EXPORT static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
CORE_EXPORT static void indexedPropertyDescriptorCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
static void InstallRuntimeEnabledFeaturesOnTemplate(
v8::Isolate*,
......
......@@ -82,7 +82,8 @@ static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCall
V8SetReturnValueInt(info, result);
}
static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Integer>& info) {
template <typename T>
static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<T>& info) {
const CString& nameInUtf8 = name.Utf8();
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kGetterContext, "TestInheritedLegacyUnenumerableNamedProperties", nameInUtf8.data());
......@@ -100,6 +101,35 @@ static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallb
V8SetReturnValueInt(info, v8::DontEnum | v8::ReadOnly);
}
static void namedPropertyDescriptor(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
// This function is called when an IDL interface supports named properties
// but not indexed properties. When a numeric property is queried, V8 calls
// indexedPropertyDescriptorCallback(), which calls this function.
// Since we initialize our indexed and named property handlers differently
// (the former use descriptors and definers, the latter uses a query
// callback), we need to inefficiently call the query callback and convert
// the v8::PropertyAttribute integer it returns into a v8::PropertyDescriptor
// expected by a descriptor callback.
// TODO(rakuco): remove this hack once we switch named property handlers to
// using descriptor and definer callbacks (bug 764633).
const AtomicString& indexAsName = AtomicString::Number(index);
TestInheritedLegacyUnenumerableNamedPropertiesV8Internal::namedPropertyQuery(indexAsName, info);
v8::Local<v8::Value> getterValue = info.GetReturnValue().Get();
if (!getterValue->IsUndefined()) {
DCHECK(getterValue->IsInt32());
const int32_t props =
getterValue->ToInt32(info.GetIsolate()->GetCurrentContext())
.ToLocalChecked()
->Value();
v8::PropertyDescriptor desc(V8String(info.GetIsolate(), indexAsName),
!(props & v8::ReadOnly));
desc.set_enumerable(!(props & v8::DontEnum));
desc.set_configurable(!(props & v8::DontDelete));
V8SetReturnValue(info, desc);
}
}
static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) {
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kEnumerationContext, "TestInheritedLegacyUnenumerableNamedProperties");
......@@ -152,6 +182,10 @@ void V8TestInheritedLegacyUnenumerableNamedProperties::indexedPropertyGetterCall
TestInheritedLegacyUnenumerableNamedPropertiesV8Internal::namedPropertyGetter(propertyName, info);
}
void V8TestInheritedLegacyUnenumerableNamedProperties::indexedPropertyDescriptorCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
TestInheritedLegacyUnenumerableNamedPropertiesV8Internal::namedPropertyDescriptor(index, info);
}
static const V8DOMConfiguration::AccessorConfiguration V8TestInheritedLegacyUnenumerableNamedPropertiesAccessors[] = {
{ "longAttribute", V8TestInheritedLegacyUnenumerableNamedProperties::longAttributeAttributeGetterCallback, nullptr, V8PrivateProperty::kNoCachedAccessor, static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds },
};
......@@ -179,7 +213,7 @@ static void installV8TestInheritedLegacyUnenumerableNamedPropertiesTemplate(
v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(
V8TestInheritedLegacyUnenumerableNamedProperties::indexedPropertyGetterCallback,
nullptr,
nullptr,
V8TestInheritedLegacyUnenumerableNamedProperties::indexedPropertyDescriptorCallback,
nullptr,
nullptr,
nullptr,
......
......@@ -53,6 +53,7 @@ class V8TestInheritedLegacyUnenumerableNamedProperties {
MODULES_EXPORT static void namedPropertyQueryCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Integer>&);
MODULES_EXPORT static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>&);
MODULES_EXPORT static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
MODULES_EXPORT static void indexedPropertyDescriptorCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
static void InstallRuntimeEnabledFeaturesOnTemplate(
v8::Isolate*,
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py.
// DO NOT MODIFY!
// This file has been generated from the Jinja2 template in
// third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl
// clang-format off
#include "V8TestNotEnumerableNamedGetter.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/IDLTypes.h"
#include "bindings/core/v8/NativeValueTraitsImpl.h"
#include "bindings/core/v8/V8DOMConfiguration.h"
#include "core/dom/ExecutionContext.h"
#include "platform/bindings/V8ObjectConstructor.h"
#include "platform/wtf/GetPtr.h"
#include "platform/wtf/RefPtr.h"
namespace blink {
// Suppress warning: global constructors, because struct WrapperTypeInfo is trivial
// and does not depend on another global objects.
#if defined(COMPONENT_BUILD) && defined(WIN32) && defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
#endif
const WrapperTypeInfo V8TestNotEnumerableNamedGetter::wrapperTypeInfo = {
gin::kEmbedderBlink,
V8TestNotEnumerableNamedGetter::domTemplate,
V8TestNotEnumerableNamedGetter::Trace,
V8TestNotEnumerableNamedGetter::TraceWrappers,
nullptr,
"TestNotEnumerableNamedGetter",
nullptr,
WrapperTypeInfo::kWrapperTypeObjectPrototype,
WrapperTypeInfo::kObjectClassId,
WrapperTypeInfo::kNotInheritFromActiveScriptWrappable,
WrapperTypeInfo::kIndependent,
};
#if defined(COMPONENT_BUILD) && defined(WIN32) && defined(__clang__)
#pragma clang diagnostic pop
#endif
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestNotEnumerableNamedGetter.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
// platform/bindings/ScriptWrappable.h.
const WrapperTypeInfo& TestNotEnumerableNamedGetter::wrapper_type_info_ = V8TestNotEnumerableNamedGetter::wrapperTypeInfo;
// not [ActiveScriptWrappable]
static_assert(
!std::is_base_of<ActiveScriptWrappableBase, TestNotEnumerableNamedGetter>::value,
"TestNotEnumerableNamedGetter inherits from ActiveScriptWrappable<>, but is not specifying "
"[ActiveScriptWrappable] extended attribute in the IDL file. "
"Be consistent.");
static_assert(
std::is_same<decltype(&TestNotEnumerableNamedGetter::HasPendingActivity),
decltype(&ScriptWrappable::HasPendingActivity)>::value,
"TestNotEnumerableNamedGetter is overriding hasPendingActivity(), but is not specifying "
"[ActiveScriptWrappable] extended attribute in the IDL file. "
"Be consistent.");
namespace TestNotEnumerableNamedGetterV8Internal {
static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Value>& info) {
TestNotEnumerableNamedGetter* impl = V8TestNotEnumerableNamedGetter::ToImpl(info.Holder());
int32_t result = impl->AnonymousNamedGetter(name);
if ()
return;
V8SetReturnValueInt(info, result);
}
static void namedPropertyDescriptor(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
// This function is called when an IDL interface supports named properties
// but not indexed properties. When a numeric property is queried, V8 calls
// indexedPropertyDescriptorCallback(), which calls this function.
// This IDL interface defines a [NotEnumerable] getter. We need to do
// something similar to indexedPropertyDescriptor(): call
// indexedPropertyGetterCallback, let it end up calling the named property
// getter and, if all goes well, we create a v8::PropertyDescriptor with the
// right values.
V8TestNotEnumerableNamedGetter::indexedPropertyGetterCallback(index, info);
v8::Local<v8::Value> getterValue = info.GetReturnValue().Get();
if (!getterValue->IsUndefined()) {
v8::PropertyDescriptor desc(getterValue, false);
desc.set_enumerable(false);
desc.set_configurable(true);
V8SetReturnValue(info, desc);
}
}
} // namespace TestNotEnumerableNamedGetterV8Internal
void V8TestNotEnumerableNamedGetter::namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestNotEnumerableNamedGetter_NamedPropertyGetter");
if (!name->IsString())
return;
const AtomicString& propertyName = ToCoreAtomicString(name.As<v8::String>());
TestNotEnumerableNamedGetterV8Internal::namedPropertyGetter(propertyName, info);
}
void V8TestNotEnumerableNamedGetter::indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestNotEnumerableNamedGetter_IndexedPropertyGetter");
const AtomicString& propertyName = AtomicString::Number(index);
TestNotEnumerableNamedGetterV8Internal::namedPropertyGetter(propertyName, info);
}
void V8TestNotEnumerableNamedGetter::indexedPropertyDescriptorCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
TestNotEnumerableNamedGetterV8Internal::namedPropertyDescriptor(index, info);
}
static void installV8TestNotEnumerableNamedGetterTemplate(
v8::Isolate* isolate,
const DOMWrapperWorld& world,
v8::Local<v8::FunctionTemplate> interfaceTemplate) {
// Initialize the interface object's template.
V8DOMConfiguration::InitializeDOMInterfaceTemplate(isolate, interfaceTemplate, V8TestNotEnumerableNamedGetter::wrapperTypeInfo.interface_name, v8::Local<v8::FunctionTemplate>(), V8TestNotEnumerableNamedGetter::internalFieldCount);
v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemplate);
ALLOW_UNUSED_LOCAL(signature);
v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTemplate();
ALLOW_UNUSED_LOCAL(instanceTemplate);
v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->PrototypeTemplate();
ALLOW_UNUSED_LOCAL(prototypeTemplate);
// Register IDL constants, attributes and operations.
// Indexed properties
v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(
V8TestNotEnumerableNamedGetter::indexedPropertyGetterCallback,
nullptr,
V8TestNotEnumerableNamedGetter::indexedPropertyDescriptorCallback,
nullptr,
nullptr,
nullptr,
v8::Local<v8::Value>(),
v8::PropertyHandlerFlags::kNone);
instanceTemplate->SetHandler(indexedPropertyHandlerConfig);
// Named properties
v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig(V8TestNotEnumerableNamedGetter::namedPropertyGetterCallback, nullptr, nullptr, nullptr, nullptr, v8::Local<v8::Value>(), static_cast<v8::PropertyHandlerFlags>(int(v8::PropertyHandlerFlags::kOnlyInterceptStrings) | int(v8::PropertyHandlerFlags::kNonMasking)));
instanceTemplate->SetHandler(namedPropertyHandlerConfig);
// Custom signature
V8TestNotEnumerableNamedGetter::InstallRuntimeEnabledFeaturesOnTemplate(
isolate, world, interfaceTemplate);
}
void V8TestNotEnumerableNamedGetter::InstallRuntimeEnabledFeaturesOnTemplate(
v8::Isolate* isolate,
const DOMWrapperWorld& world,
v8::Local<v8::FunctionTemplate> interface_template) {
v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_template);
ALLOW_UNUSED_LOCAL(signature);
v8::Local<v8::ObjectTemplate> instance_template = interface_template->InstanceTemplate();
ALLOW_UNUSED_LOCAL(instance_template);
v8::Local<v8::ObjectTemplate> prototype_template = interface_template->PrototypeTemplate();
ALLOW_UNUSED_LOCAL(prototype_template);
// Register IDL constants, attributes and operations.
// Custom signature
}
v8::Local<v8::FunctionTemplate> V8TestNotEnumerableNamedGetter::domTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world) {
return V8DOMConfiguration::DomClassTemplate(isolate, world, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestNotEnumerableNamedGetterTemplate);
}
bool V8TestNotEnumerableNamedGetter::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolate) {
return V8PerIsolateData::From(isolate)->HasInstance(&wrapperTypeInfo, v8Value);
}
v8::Local<v8::Object> V8TestNotEnumerableNamedGetter::findInstanceInPrototypeChain(v8::Local<v8::Value> v8Value, v8::Isolate* isolate) {
return V8PerIsolateData::From(isolate)->FindInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
}
TestNotEnumerableNamedGetter* V8TestNotEnumerableNamedGetter::ToImplWithTypeCheck(v8::Isolate* isolate, v8::Local<v8::Value> value) {
return hasInstance(value, isolate) ? ToImpl(v8::Local<v8::Object>::Cast(value)) : nullptr;
}
TestNotEnumerableNamedGetter* NativeValueTraits<TestNotEnumerableNamedGetter>::NativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
TestNotEnumerableNamedGetter* nativeValue = V8TestNotEnumerableNamedGetter::ToImplWithTypeCheck(isolate, value);
if (!nativeValue) {
exceptionState.ThrowTypeError(ExceptionMessages::FailedToConvertJSValue(
"TestNotEnumerableNamedGetter"));
}
return nativeValue;
}
} // namespace blink
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py.
// DO NOT MODIFY!
// This file has been generated from the Jinja2 template in
// third_party/WebKit/Source/bindings/templates/interface.h.tmpl
// clang-format off
#ifndef V8TestNotEnumerableNamedGetter_h
#define V8TestNotEnumerableNamedGetter_h
#include "bindings/core/v8/GeneratedCodeHelper.h"
#include "bindings/core/v8/NativeValueTraits.h"
#include "bindings/core/v8/ToV8ForCore.h"
#include "bindings/core/v8/V8BindingForCore.h"
#include "bindings/tests/idls/modules/TestNotEnumerableNamedGetter.h"
#include "modules/ModulesExport.h"
#include "platform/bindings/ScriptWrappable.h"
#include "platform/bindings/V8DOMWrapper.h"
#include "platform/bindings/WrapperTypeInfo.h"
#include "platform/heap/Handle.h"
namespace blink {
class V8TestNotEnumerableNamedGetter {
STATIC_ONLY(V8TestNotEnumerableNamedGetter);
public:
MODULES_EXPORT static bool hasInstance(v8::Local<v8::Value>, v8::Isolate*);
static v8::Local<v8::Object> findInstanceInPrototypeChain(v8::Local<v8::Value>, v8::Isolate*);
MODULES_EXPORT static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWrapperWorld&);
static TestNotEnumerableNamedGetter* ToImpl(v8::Local<v8::Object> object) {
return ToScriptWrappable(object)->ToImpl<TestNotEnumerableNamedGetter>();
}
MODULES_EXPORT static TestNotEnumerableNamedGetter* ToImplWithTypeCheck(v8::Isolate*, v8::Local<v8::Value>);
MODULES_EXPORT static const WrapperTypeInfo wrapperTypeInfo;
static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) {
visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl<TestNotEnumerableNamedGetter>());
}
static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) {
visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl<TestNotEnumerableNamedGetter>());
}
static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount;
// Callback functions
MODULES_EXPORT static void namedPropertyGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
MODULES_EXPORT static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
MODULES_EXPORT static void indexedPropertyDescriptorCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
static void InstallRuntimeEnabledFeaturesOnTemplate(
v8::Isolate*,
const DOMWrapperWorld&,
v8::Local<v8::FunctionTemplate> interface_template);
};
template <>
struct NativeValueTraits<TestNotEnumerableNamedGetter> : public NativeValueTraitsBase<TestNotEnumerableNamedGetter> {
MODULES_EXPORT static TestNotEnumerableNamedGetter* NativeValue(v8::Isolate*, v8::Local<v8::Value>, ExceptionState&);
};
template <>
struct V8TypeOf<TestNotEnumerableNamedGetter> {
typedef V8TestNotEnumerableNamedGetter Type;
};
} // namespace blink
#endif // V8TestNotEnumerableNamedGetter_h
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