blob: ed85c0178e8c01958ec5822b58dc89eb728df112 [file] [log] [blame]
// 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 from the Jinja2 template
// third_party/blink/renderer/bindings/templates/interface.cc.tmpl
// by the script code_generator_v8.py.
// DO NOT MODIFY!
// clang-format off
#include "third_party/blink/renderer/bindings/tests/results/modules/v8_test_interface_5.h"
#include <algorithm>
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_configuration.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_test_interface_empty.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_test_interface_5.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_void_callback_function_modules.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/bindings/exception_messages.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/runtime_call_stats.h"
#include "third_party/blink/renderer/platform/bindings/v8_object_constructor.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/cooperative_scheduling_manager.h"
#include "third_party/blink/renderer/platform/wtf/get_ptr.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 v8_test_interface_5_wrapper_type_info = {
gin::kEmbedderBlink,
V8TestInterface5::DomTemplate,
V8TestInterface5::InstallConditionalFeatures,
"TestInterface5",
V8TestInterfaceEmpty::GetWrapperTypeInfo(),
WrapperTypeInfo::kWrapperTypeObjectPrototype,
WrapperTypeInfo::kObjectClassId,
WrapperTypeInfo::kInheritFromActiveScriptWrappable,
};
#if defined(COMPONENT_BUILD) && defined(WIN32) && defined(__clang__)
#pragma clang diagnostic pop
#endif
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterface5Implementation.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
// platform/bindings/ScriptWrappable.h.
const WrapperTypeInfo& TestInterface5Implementation::wrapper_type_info_ = v8_test_interface_5_wrapper_type_info;
// [ActiveScriptWrappable]
static_assert(
std::is_base_of<ActiveScriptWrappableBase, TestInterface5Implementation>::value,
"TestInterface5Implementation does not inherit from ActiveScriptWrappable<>, but specifying "
"[ActiveScriptWrappable] extended attribute in the IDL file. "
"Be consistent.");
static_assert(
!std::is_same<decltype(&TestInterface5Implementation::HasPendingActivity),
decltype(&ScriptWrappable::HasPendingActivity)>::value,
"TestInterface5Implementation is not overriding hasPendingActivity(), but is specifying "
"[ActiveScriptWrappable] extended attribute in the IDL file. "
"Be consistent.");
namespace test_interface_5_implementation_v8_internal {
static void TestInterfaceAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
V8SetReturnValueFast(info, WTF::GetPtr(impl->testInterfaceAttribute()), impl);
}
static void TestInterfaceAttributeAttributeSetter(
v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
ALLOW_UNUSED_LOCAL(isolate);
v8::Local<v8::Object> holder = info.Holder();
ALLOW_UNUSED_LOCAL(holder);
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface5", "testInterfaceAttribute");
// Prepare the value to be set.
TestInterface5Implementation* cpp_value{ V8TestInterface5::ToImplWithTypeCheck(info.GetIsolate(), v8_value) };
// Type check per: http://heycam.github.io/webidl/#es-interface
if (!cpp_value) {
exception_state.ThrowTypeError("The provided value is not of type 'TestInterface5'.");
return;
}
impl->setTestInterfaceAttribute(cpp_value);
}
static void DoubleAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
V8SetReturnValue(info, impl->doubleAttribute());
}
static void DoubleAttributeAttributeSetter(
v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
ALLOW_UNUSED_LOCAL(isolate);
v8::Local<v8::Object> holder = info.Holder();
ALLOW_UNUSED_LOCAL(holder);
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface5", "doubleAttribute");
// Prepare the value to be set.
double cpp_value{ NativeValueTraits<IDLDouble>::NativeValue(info.GetIsolate(), v8_value, exception_state) };
if (exception_state.HadException())
return;
impl->setDoubleAttribute(cpp_value);
}
static void FloatAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
V8SetReturnValue(info, impl->floatAttribute());
}
static void FloatAttributeAttributeSetter(
v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
ALLOW_UNUSED_LOCAL(isolate);
v8::Local<v8::Object> holder = info.Holder();
ALLOW_UNUSED_LOCAL(holder);
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface5", "floatAttribute");
// Prepare the value to be set.
float cpp_value{ NativeValueTraits<IDLFloat>::NativeValue(info.GetIsolate(), v8_value, exception_state) };
if (exception_state.HadException())
return;
impl->setFloatAttribute(cpp_value);
}
static void UnrestrictedDoubleAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
V8SetReturnValue(info, impl->unrestrictedDoubleAttribute());
}
static void UnrestrictedDoubleAttributeAttributeSetter(
v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
ALLOW_UNUSED_LOCAL(isolate);
v8::Local<v8::Object> holder = info.Holder();
ALLOW_UNUSED_LOCAL(holder);
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface5", "unrestrictedDoubleAttribute");
// Prepare the value to be set.
double cpp_value{ NativeValueTraits<IDLUnrestrictedDouble>::NativeValue(info.GetIsolate(), v8_value, exception_state) };
if (exception_state.HadException())
return;
impl->setUnrestrictedDoubleAttribute(cpp_value);
}
static void UnrestrictedFloatAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
V8SetReturnValue(info, impl->unrestrictedFloatAttribute());
}
static void UnrestrictedFloatAttributeAttributeSetter(
v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
ALLOW_UNUSED_LOCAL(isolate);
v8::Local<v8::Object> holder = info.Holder();
ALLOW_UNUSED_LOCAL(holder);
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface5", "unrestrictedFloatAttribute");
// Prepare the value to be set.
float cpp_value{ NativeValueTraits<IDLUnrestrictedFloat>::NativeValue(info.GetIsolate(), v8_value, exception_state) };
if (exception_state.HadException())
return;
impl->setUnrestrictedFloatAttribute(cpp_value);
}
static void StaticStringAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
V8SetReturnValueString(info, TestInterface5Implementation::staticStringAttribute(), info.GetIsolate());
}
static void StaticStringAttributeAttributeSetter(
v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
ALLOW_UNUSED_LOCAL(isolate);
v8::Local<v8::Object> holder = info.Holder();
ALLOW_UNUSED_LOCAL(holder);
// Prepare the value to be set.
V8StringResource<> cpp_value{ v8_value };
if (!cpp_value.Prepare())
return;
TestInterface5Implementation::setStaticStringAttribute(cpp_value);
}
static void LengthAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
V8SetReturnValueUnsigned(info, impl->length());
}
static void AlwaysExposedAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
V8SetReturnValueInt(info, impl->alwaysExposedAttribute());
}
static void AlwaysExposedAttributeAttributeSetter(
v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
ALLOW_UNUSED_LOCAL(isolate);
v8::Local<v8::Object> holder = info.Holder();
ALLOW_UNUSED_LOCAL(holder);
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface5", "alwaysExposedAttribute");
// Prepare the value to be set.
int32_t cpp_value{ NativeValueTraits<IDLLong>::NativeValue(info.GetIsolate(), v8_value, exception_state) };
if (exception_state.HadException())
return;
impl->setAlwaysExposedAttribute(cpp_value);
}
static void WorkerExposedAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
V8SetReturnValueInt(info, impl->workerExposedAttribute());
}
static void WorkerExposedAttributeAttributeSetter(
v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
ALLOW_UNUSED_LOCAL(isolate);
v8::Local<v8::Object> holder = info.Holder();
ALLOW_UNUSED_LOCAL(holder);
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface5", "workerExposedAttribute");
// Prepare the value to be set.
int32_t cpp_value{ NativeValueTraits<IDLLong>::NativeValue(info.GetIsolate(), v8_value, exception_state) };
if (exception_state.HadException())
return;
impl->setWorkerExposedAttribute(cpp_value);
}
static void WindowExposedAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
V8SetReturnValueInt(info, impl->windowExposedAttribute());
}
static void WindowExposedAttributeAttributeSetter(
v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
ALLOW_UNUSED_LOCAL(isolate);
v8::Local<v8::Object> holder = info.Holder();
ALLOW_UNUSED_LOCAL(holder);
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(holder);
ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface5", "windowExposedAttribute");
// Prepare the value to be set.
int32_t cpp_value{ NativeValueTraits<IDLLong>::NativeValue(info.GetIsolate(), v8_value, exception_state) };
if (exception_state.HadException())
return;
impl->setWindowExposedAttribute(cpp_value);
}
static void VoidMethodTestInterfaceEmptyArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodTestInterfaceEmptyArg", "TestInterface5", ExceptionMessages::NotEnoughArguments(1, info.Length())));
return;
}
TestInterfaceEmpty* test_interface_empty_arg;
test_interface_empty_arg = V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), info[0]);
if (!test_interface_empty_arg) {
V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodTestInterfaceEmptyArg", "TestInterface5", ExceptionMessages::ArgumentNotOfType(0, "TestInterfaceEmpty")));
return;
}
impl->voidMethodTestInterfaceEmptyArg(test_interface_empty_arg);
}
static void VoidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface5", "voidMethodDoubleArgFloatArg");
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
if (UNLIKELY(info.Length() < 2)) {
exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(2, info.Length()));
return;
}
double double_arg;
float float_arg;
double_arg = NativeValueTraits<IDLDouble>::NativeValue(info.GetIsolate(), info[0], exception_state);
if (exception_state.HadException())
return;
float_arg = NativeValueTraits<IDLFloat>::NativeValue(info.GetIsolate(), info[1], exception_state);
if (exception_state.HadException())
return;
impl->voidMethodDoubleArgFloatArg(double_arg, float_arg);
}
static void VoidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface5", "voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg");
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
if (UNLIKELY(info.Length() < 2)) {
exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(2, info.Length()));
return;
}
double unrestricted_double_arg;
float unrestricted_float_arg;
unrestricted_double_arg = NativeValueTraits<IDLUnrestrictedDouble>::NativeValue(info.GetIsolate(), info[0], exception_state);
if (exception_state.HadException())
return;
unrestricted_float_arg = NativeValueTraits<IDLUnrestrictedFloat>::NativeValue(info.GetIsolate(), info[1], exception_state);
if (exception_state.HadException())
return;
impl->voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg(unrestricted_double_arg, unrestricted_float_arg);
}
static void VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
impl->voidMethod();
}
static void VoidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
impl->voidMethod();
}
static void AlwaysExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
impl->alwaysExposedMethod();
}
static void WorkerExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
impl->workerExposedMethod();
}
static void WindowExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
impl->windowExposedMethod();
}
static void AlwaysExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation::alwaysExposedStaticMethod();
}
static void WorkerExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation::workerExposedStaticMethod();
}
static void WindowExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation::windowExposedStaticMethod();
}
static void WindowAndServiceWorkerExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
impl->windowAndServiceWorkerExposedMethod();
}
static void VoidMethodBooleanOrDOMStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface5", "voidMethodBooleanOrDOMStringArg");
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}
BooleanOrString arg;
V8BooleanOrString::ToImpl(info.GetIsolate(), info[0], arg, UnionTypeConversionMode::kNotNullable, exception_state);
if (exception_state.HadException())
return;
impl->voidMethodBooleanOrDOMStringArg(arg);
}
static void VoidMethodDoubleOrDOMStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface5", "voidMethodDoubleOrDOMStringArg");
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}
DoubleOrString arg;
V8DoubleOrString::ToImpl(info.GetIsolate(), info[0], arg, UnionTypeConversionMode::kNotNullable, exception_state);
if (exception_state.HadException())
return;
impl->voidMethodDoubleOrDOMStringArg(arg);
}
static void VoidMethodVoidExperimentalCallbackFunctionMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodVoidExperimentalCallbackFunction", "TestInterface5", ExceptionMessages::NotEnoughArguments(1, info.Length())));
return;
}
VoidExperimentalCallbackFunction* arg;
arg = V8VoidExperimentalCallbackFunction::ToImplWithTypeCheck(info.GetIsolate(), info[0]);
if (!arg) {
V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodVoidExperimentalCallbackFunction", "TestInterface5", ExceptionMessages::ArgumentNotOfType(0, "VoidExperimentalCallbackFunction")));
return;
}
impl->voidMethodVoidExperimentalCallbackFunction(arg);
}
static void VoidMethodVoidCallbackFunctionModulesArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodVoidCallbackFunctionModulesArg", "TestInterface5", ExceptionMessages::NotEnoughArguments(1, info.Length())));
return;
}
V8VoidCallbackFunctionModules* arg;
if (info[0]->IsFunction()) {
arg = V8VoidCallbackFunctionModules::Create(info[0].As<v8::Function>());
} else {
V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodVoidCallbackFunctionModulesArg", "TestInterface5", "The callback provided as parameter 1 is not a function."));
return;
}
impl->voidMethodVoidCallbackFunctionModulesArg(arg);
}
static void ToStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
V8SetReturnValueString(info, impl->toString(), info.GetIsolate());
}
static void NamedPropertyGetter(const AtomicString& name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
String result = impl->AnonymousNamedGetter(name);
if (result.IsNull())
return;
V8SetReturnValueString(info, result, info.GetIsolate());
}
static void NamedPropertyQuery(
const AtomicString& name, const v8::PropertyCallbackInfo<v8::Integer>& info) {
const std::string& name_in_utf8 = name.Utf8();
ExceptionState exception_state(
info.GetIsolate(),
ExceptionState::kGetterContext,
"TestInterface5",
name_in_utf8.c_str());
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
bool result = impl->NamedPropertyQuery(name, exception_state);
if (!result)
return;
// https://heycam.github.io/webidl/#LegacyPlatformObjectGetOwnProperty
// 2.7. If |O| implements an interface with a named property setter, then set
// desc.[[Writable]] to true, otherwise set it to false.
// 2.8. If |O| implements an interface with the
// [LegacyUnenumerableNamedProperties] extended attribute, then set
// desc.[[Enumerable]] to false, otherwise set it to true.
V8SetReturnValueInt(info, v8::ReadOnly);
}
static void NamedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) {
ExceptionState exception_state(
info.GetIsolate(),
ExceptionState::kEnumerationContext,
"TestInterface5");
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
Vector<String> names;
impl->NamedPropertyEnumerator(names, exception_state);
if (exception_state.HadException())
return;
V8SetReturnValue(info, ToV8(names, info.Holder(), info.GetIsolate()).As<v8::Array>());
}
static void IndexedPropertyGetter(
uint32_t index,
const v8::PropertyCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
// We assume that all the implementations support length() method, although
// the spec doesn't require that length() must exist. It's okay that
// the interface does not have length attribute as long as the
// implementation supports length() member function.
if (index >= impl->length())
return; // Returns undefined due to out-of-range.
String result = impl->AnonymousIndexedGetter(index);
V8SetReturnValueString(info, result, info.GetIsolate());
}
static void IndexedPropertyDescriptor(
uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
// https://heycam.github.io/webidl/#LegacyPlatformObjectGetOwnProperty
// Steps 1.1 to 1.2.4 are covered here: we rely on indexedPropertyGetter() to
// call the getter function and check that |index| is a valid property index,
// in which case it will have set info.GetReturnValue() to something other
// than undefined.
V8TestInterface5::IndexedPropertyGetterCallback(index, info);
v8::Local<v8::Value> getter_value = info.GetReturnValue().Get();
if (!getter_value->IsUndefined()) {
// 1.2.5. Let |desc| be a newly created Property Descriptor with no fields.
// 1.2.6. Set desc.[[Value]] to the result of converting value to an
// ECMAScript value.
// 1.2.7. If O implements an interface with an indexed property setter,
// then set desc.[[Writable]] to true, otherwise set it to false.
v8::PropertyDescriptor desc(getter_value, true);
// 1.2.8. Set desc.[[Enumerable]] and desc.[[Configurable]] to true.
desc.set_enumerable(true);
desc.set_configurable(true);
// 1.2.9. Return |desc|.
V8SetReturnValue(info, desc);
}
}
static void IndexedPropertySetter(
uint32_t index,
v8::Local<v8::Value> v8_value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
V8StringResource<> property_value{ v8_value };
if (!property_value.Prepare())
return;
IndexedPropertySetterResult result = impl->AnonymousIndexedSetter(index, property_value);
if (result == IndexedPropertySetterResult::kDidNotIntercept)
return;
V8SetReturnValue(info, v8_value);
}
static void IndexedPropertyDeleter(
uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) {
TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder());
NamedPropertyDeleterResult result = impl->AnonymousIndexedDeleter(index);
if (result == NamedPropertyDeleterResult::kDidNotIntercept)
return;
V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted);
}
} // namespace test_interface_5_implementation_v8_internal
void V8TestInterface5::TestInterfaceAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_testInterfaceAttribute_Getter");
test_interface_5_implementation_v8_internal::TestInterfaceAttributeAttributeGetter(info);
}
void V8TestInterface5::TestInterfaceAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_testInterfaceAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
test_interface_5_implementation_v8_internal::TestInterfaceAttributeAttributeSetter(v8_value, info);
}
void V8TestInterface5::TestInterfaceConstructorAttributeConstructorGetterCallback(
v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_testInterfaceConstructorAttribute_ConstructorGetterCallback");
V8ConstructorAttributeGetter(property, info, V8TestInterface5::GetWrapperTypeInfo());
}
void V8TestInterface5::DoubleAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_doubleAttribute_Getter");
test_interface_5_implementation_v8_internal::DoubleAttributeAttributeGetter(info);
}
void V8TestInterface5::DoubleAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_doubleAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
test_interface_5_implementation_v8_internal::DoubleAttributeAttributeSetter(v8_value, info);
}
void V8TestInterface5::FloatAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_floatAttribute_Getter");
test_interface_5_implementation_v8_internal::FloatAttributeAttributeGetter(info);
}
void V8TestInterface5::FloatAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_floatAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
test_interface_5_implementation_v8_internal::FloatAttributeAttributeSetter(v8_value, info);
}
void V8TestInterface5::UnrestrictedDoubleAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_unrestrictedDoubleAttribute_Getter");
test_interface_5_implementation_v8_internal::UnrestrictedDoubleAttributeAttributeGetter(info);
}
void V8TestInterface5::UnrestrictedDoubleAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_unrestrictedDoubleAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
test_interface_5_implementation_v8_internal::UnrestrictedDoubleAttributeAttributeSetter(v8_value, info);
}
void V8TestInterface5::UnrestrictedFloatAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_unrestrictedFloatAttribute_Getter");
test_interface_5_implementation_v8_internal::UnrestrictedFloatAttributeAttributeGetter(info);
}
void V8TestInterface5::UnrestrictedFloatAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_unrestrictedFloatAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
test_interface_5_implementation_v8_internal::UnrestrictedFloatAttributeAttributeSetter(v8_value, info);
}
void V8TestInterface5::StaticStringAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_staticStringAttribute_Getter");
test_interface_5_implementation_v8_internal::StaticStringAttributeAttributeGetter(info);
}
void V8TestInterface5::StaticStringAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_staticStringAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
test_interface_5_implementation_v8_internal::StaticStringAttributeAttributeSetter(v8_value, info);
}
void V8TestInterface5::LengthAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_length_Getter");
test_interface_5_implementation_v8_internal::LengthAttributeGetter(info);
}
void V8TestInterface5::AlwaysExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_alwaysExposedAttribute_Getter");
test_interface_5_implementation_v8_internal::AlwaysExposedAttributeAttributeGetter(info);
}
void V8TestInterface5::AlwaysExposedAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_alwaysExposedAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
test_interface_5_implementation_v8_internal::AlwaysExposedAttributeAttributeSetter(v8_value, info);
}
void V8TestInterface5::WorkerExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_workerExposedAttribute_Getter");
test_interface_5_implementation_v8_internal::WorkerExposedAttributeAttributeGetter(info);
}
void V8TestInterface5::WorkerExposedAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_workerExposedAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
test_interface_5_implementation_v8_internal::WorkerExposedAttributeAttributeSetter(v8_value, info);
}
void V8TestInterface5::WindowExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_windowExposedAttribute_Getter");
test_interface_5_implementation_v8_internal::WindowExposedAttributeAttributeGetter(info);
}
void V8TestInterface5::WindowExposedAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_windowExposedAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
test_interface_5_implementation_v8_internal::WindowExposedAttributeAttributeSetter(v8_value, info);
}
void V8TestInterface5::VoidMethodTestInterfaceEmptyArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.voidMethodTestInterfaceEmptyArg");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_voidMethodTestInterfaceEmptyArg");
test_interface_5_implementation_v8_internal::VoidMethodTestInterfaceEmptyArgMethod(info);
}
void V8TestInterface5::VoidMethodDoubleArgFloatArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.voidMethodDoubleArgFloatArg");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_voidMethodDoubleArgFloatArg");
test_interface_5_implementation_v8_internal::VoidMethodDoubleArgFloatArgMethod(info);
}
void V8TestInterface5::VoidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg");
test_interface_5_implementation_v8_internal::VoidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(info);
}
void V8TestInterface5::VoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.voidMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_voidMethod");
test_interface_5_implementation_v8_internal::VoidMethodMethod(info);
}
void V8TestInterface5::VoidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.voidMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_voidMethod");
test_interface_5_implementation_v8_internal::VoidMethodMethodForMainWorld(info);
}
void V8TestInterface5::AlwaysExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.alwaysExposedMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_alwaysExposedMethod");
test_interface_5_implementation_v8_internal::AlwaysExposedMethodMethod(info);
}
void V8TestInterface5::WorkerExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.workerExposedMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_workerExposedMethod");
test_interface_5_implementation_v8_internal::WorkerExposedMethodMethod(info);
}
void V8TestInterface5::WindowExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.windowExposedMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_windowExposedMethod");
test_interface_5_implementation_v8_internal::WindowExposedMethodMethod(info);
}
void V8TestInterface5::AlwaysExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.alwaysExposedStaticMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_alwaysExposedStaticMethod");
test_interface_5_implementation_v8_internal::AlwaysExposedStaticMethodMethod(info);
}
void V8TestInterface5::WorkerExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.workerExposedStaticMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_workerExposedStaticMethod");
test_interface_5_implementation_v8_internal::WorkerExposedStaticMethodMethod(info);
}
void V8TestInterface5::WindowExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.windowExposedStaticMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_windowExposedStaticMethod");
test_interface_5_implementation_v8_internal::WindowExposedStaticMethodMethod(info);
}
void V8TestInterface5::WindowAndServiceWorkerExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.windowAndServiceWorkerExposedMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_windowAndServiceWorkerExposedMethod");
test_interface_5_implementation_v8_internal::WindowAndServiceWorkerExposedMethodMethod(info);
}
void V8TestInterface5::VoidMethodBooleanOrDOMStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.voidMethodBooleanOrDOMStringArg");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_voidMethodBooleanOrDOMStringArg");
test_interface_5_implementation_v8_internal::VoidMethodBooleanOrDOMStringArgMethod(info);
}
void V8TestInterface5::VoidMethodDoubleOrDOMStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.voidMethodDoubleOrDOMStringArg");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_voidMethodDoubleOrDOMStringArg");
test_interface_5_implementation_v8_internal::VoidMethodDoubleOrDOMStringArgMethod(info);
}
void V8TestInterface5::VoidMethodVoidExperimentalCallbackFunctionMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.voidMethodVoidExperimentalCallbackFunction");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_voidMethodVoidExperimentalCallbackFunction");
test_interface_5_implementation_v8_internal::VoidMethodVoidExperimentalCallbackFunctionMethod(info);
}
void V8TestInterface5::VoidMethodVoidCallbackFunctionModulesArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.voidMethodVoidCallbackFunctionModulesArg");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_voidMethodVoidCallbackFunctionModulesArg");
test_interface_5_implementation_v8_internal::VoidMethodVoidCallbackFunctionModulesArgMethod(info);
}
void V8TestInterface5::ToStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestInterface5.toString");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_toString");
test_interface_5_implementation_v8_internal::ToStringMethod(info);
}
void V8TestInterface5::NamedPropertyGetterCallback(
v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_NamedPropertyGetter");
if (!name->IsString())
return;
const AtomicString& property_name = ToCoreAtomicString(name.As<v8::String>());
test_interface_5_implementation_v8_internal::NamedPropertyGetter(property_name, info);
}
void V8TestInterface5::NamedPropertyQueryCallback(
v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_NamedPropertyQuery");
if (!name->IsString())
return;
const AtomicString& property_name = ToCoreAtomicString(name.As<v8::String>());
test_interface_5_implementation_v8_internal::NamedPropertyQuery(property_name, info);
}
void V8TestInterface5::NamedPropertyEnumeratorCallback(
const v8::PropertyCallbackInfo<v8::Array>& info) {
test_interface_5_implementation_v8_internal::NamedPropertyEnumerator(info);
}
void V8TestInterface5::IndexedPropertyGetterCallback(
uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface5Implementation_IndexedPropertyGetter");
test_interface_5_implementation_v8_internal::IndexedPropertyGetter(index, info);
}
void V8TestInterface5::IndexedPropertyDescriptorCallback(
uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
test_interface_5_implementation_v8_internal::IndexedPropertyDescriptor(index, info);
}
void V8TestInterface5::IndexedPropertySetterCallback(
uint32_t index,
v8::Local<v8::Value> v8_value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
test_interface_5_implementation_v8_internal::IndexedPropertySetter(index, v8_value, info);
}
void V8TestInterface5::IndexedPropertyDeleterCallback(
uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) {
test_interface_5_implementation_v8_internal::IndexedPropertyDeleter(index, info);
}
void V8TestInterface5::IndexedPropertyDefinerCallback(
uint32_t index,
const v8::PropertyDescriptor& desc,
const v8::PropertyCallbackInfo<v8::Value>& info) {
// https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty
// 3.9.3. [[DefineOwnProperty]]
// step 1.1. If the result of calling IsDataDescriptor(Desc) is false, then
// return false.
if (desc.has_get() || desc.has_set()) {
V8SetReturnValue(info, v8::Null(info.GetIsolate()));
if (info.ShouldThrowOnError()) {
ExceptionState exception_state(info.GetIsolate(),
ExceptionState::kIndexedSetterContext,
"TestInterface5");
exception_state.ThrowTypeError("Accessor properties are not allowed.");
}
return;
}
// Return nothing and fall back to indexedPropertySetterCallback.
}
static constexpr V8DOMConfiguration::MethodConfiguration kV8TestInterface5Methods[] = {
{"voidMethodTestInterfaceEmptyArg", V8TestInterface5::VoidMethodTestInterfaceEmptyArgMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"voidMethodDoubleArgFloatArg", V8TestInterface5::VoidMethodDoubleArgFloatArgMethodCallback, 2, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", V8TestInterface5::VoidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback, 2, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"voidMethod", V8TestInterface5::VoidMethodMethodCallbackForMainWorld, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kMainWorld},
{"voidMethod", V8TestInterface5::VoidMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kNonMainWorlds},
{"alwaysExposedMethod", V8TestInterface5::AlwaysExposedMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"alwaysExposedStaticMethod", V8TestInterface5::AlwaysExposedStaticMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnInterface, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"voidMethodBooleanOrDOMStringArg", V8TestInterface5::VoidMethodBooleanOrDOMStringArgMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"voidMethodDoubleOrDOMStringArg", V8TestInterface5::VoidMethodDoubleOrDOMStringArgMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"voidMethodVoidExperimentalCallbackFunction", V8TestInterface5::VoidMethodVoidExperimentalCallbackFunctionMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"voidMethodVoidCallbackFunctionModulesArg", V8TestInterface5::VoidMethodVoidCallbackFunctionModulesArgMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"toString", V8TestInterface5::ToStringMethodCallback, 0, static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
};
static void InstallV8TestInterface5Template(
v8::Isolate* isolate,
const DOMWrapperWorld& world,
v8::Local<v8::FunctionTemplate> interface_template) {
// Initialize the interface object's template.
V8DOMConfiguration::InitializeDOMInterfaceTemplate(isolate, interface_template, V8TestInterface5::GetWrapperTypeInfo()->interface_name, V8TestInterfaceEmpty::DomTemplate(isolate, world), V8TestInterface5::kInternalFieldCount);
if (!RuntimeEnabledFeatures::RuntimeFeatureEnabled()) {
return;
}
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.
{
static constexpr V8DOMConfiguration::ConstantConfiguration kConstants[] = {
{"UNSIGNED_LONG", V8DOMConfiguration::kConstantTypeUnsignedLong, static_cast<int>(0)},
{"CONST_JAVASCRIPT", V8DOMConfiguration::kConstantTypeShort, static_cast<int>(1)},
};
V8DOMConfiguration::InstallConstants(
isolate, interface_template, prototype_template,
kConstants, base::size(kConstants));
}
static constexpr V8DOMConfiguration::AttributeConfiguration
kAttributeConfigurations[] = {
{ "testInterfaceConstructorAttribute", V8TestInterface5::TestInterfaceConstructorAttributeConstructorGetterCallback, nullptr, static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::kOnInstance, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kReplaceWithDataProperty, V8DOMConfiguration::kAllWorlds },
};
V8DOMConfiguration::InstallAttributes(
isolate, world, instance_template, prototype_template,
kAttributeConfigurations, base::size(kAttributeConfigurations));
static constexpr V8DOMConfiguration::AccessorConfiguration
kAccessorConfigurations[] = {
{ "testInterfaceAttribute", V8TestInterface5::TestInterfaceAttributeAttributeGetterCallback, V8TestInterface5::TestInterfaceAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "doubleAttribute", V8TestInterface5::DoubleAttributeAttributeGetterCallback, V8TestInterface5::DoubleAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "floatAttribute", V8TestInterface5::FloatAttributeAttributeGetterCallback, V8TestInterface5::FloatAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "unrestrictedDoubleAttribute", V8TestInterface5::UnrestrictedDoubleAttributeAttributeGetterCallback, V8TestInterface5::UnrestrictedDoubleAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "unrestrictedFloatAttribute", V8TestInterface5::UnrestrictedFloatAttributeAttributeGetterCallback, V8TestInterface5::UnrestrictedFloatAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "staticStringAttribute", V8TestInterface5::StaticStringAttributeAttributeGetterCallback, V8TestInterface5::StaticStringAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnInterface, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "length", V8TestInterface5::LengthAttributeGetterCallback, nullptr, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "alwaysExposedAttribute", V8TestInterface5::AlwaysExposedAttributeAttributeGetterCallback, V8TestInterface5::AlwaysExposedAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
};
V8DOMConfiguration::InstallAccessors(
isolate, world, instance_template, prototype_template, interface_template,
signature, kAccessorConfigurations,
base::size(kAccessorConfigurations));
V8DOMConfiguration::InstallMethods(
isolate, world, instance_template, prototype_template, interface_template,
signature, kV8TestInterface5Methods, base::size(kV8TestInterface5Methods));
// Indexed properties
v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(
V8TestInterface5::IndexedPropertyGetterCallback,
V8TestInterface5::IndexedPropertySetterCallback,
V8TestInterface5::IndexedPropertyDescriptorCallback,
V8TestInterface5::IndexedPropertyDeleterCallback,
IndexedPropertyEnumerator<TestInterface5Implementation>,
V8TestInterface5::IndexedPropertyDefinerCallback,
v8::Local<v8::Value>(),
v8::PropertyHandlerFlags::kNone);
instance_template->SetHandler(indexedPropertyHandlerConfig);
// Named properties
v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig(V8TestInterface5::NamedPropertyGetterCallback, nullptr, V8TestInterface5::NamedPropertyQueryCallback, nullptr, V8TestInterface5::NamedPropertyEnumeratorCallback, v8::Local<v8::Value>(), static_cast<v8::PropertyHandlerFlags>(int(v8::PropertyHandlerFlags::kOnlyInterceptStrings) | int(v8::PropertyHandlerFlags::kNonMasking)));
instance_template->SetHandler(namedPropertyHandlerConfig);
// Array iterator (@@iterator)
prototype_template->SetIntrinsicDataProperty(v8::Symbol::GetIterator(isolate), v8::kArrayProto_values, v8::DontEnum);
// For value iterators, the properties below must originally be set to the corresponding ones in %ArrayPrototype%.
// See https://heycam.github.io/webidl/#es-iterators.
prototype_template->SetIntrinsicDataProperty(V8AtomicString(isolate, "entries"), v8::kArrayProto_entries);
prototype_template->SetIntrinsicDataProperty(V8AtomicString(isolate, "forEach"), v8::kArrayProto_forEach);
prototype_template->SetIntrinsicDataProperty(V8AtomicString(isolate, "keys"), v8::kArrayProto_keys);
prototype_template->SetIntrinsicDataProperty(V8AtomicString(isolate, "values"), v8::kArrayProto_values);
instance_template->SetCallAsFunctionHandler(V8TestInterface5::LegacyCallCustom);
// Custom signature
V8TestInterface5::InstallRuntimeEnabledFeaturesOnTemplate(
isolate, world, interface_template);
}
void V8TestInterface5::InstallRuntimeEnabledFeaturesOnTemplate(
v8::Isolate* isolate,
const DOMWrapperWorld& world,
v8::Local<v8::FunctionTemplate> interface_template) {
if (!RuntimeEnabledFeatures::RuntimeFeatureEnabled()) {
return;
}
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> V8TestInterface5::DomTemplate(
v8::Isolate* isolate, const DOMWrapperWorld& world) {
return V8DOMConfiguration::DomClassTemplate(
isolate, world, const_cast<WrapperTypeInfo*>(V8TestInterface5::GetWrapperTypeInfo()),
InstallV8TestInterface5Template);
}
bool V8TestInterface5::HasInstance(v8::Local<v8::Value> v8_value, v8::Isolate* isolate) {
return V8PerIsolateData::From(isolate)->HasInstance(V8TestInterface5::GetWrapperTypeInfo(), v8_value);
}
v8::Local<v8::Object> V8TestInterface5::FindInstanceInPrototypeChain(
v8::Local<v8::Value> v8_value, v8::Isolate* isolate) {
return V8PerIsolateData::From(isolate)->FindInstanceInPrototypeChain(
V8TestInterface5::GetWrapperTypeInfo(), v8_value);
}
TestInterface5Implementation* V8TestInterface5::ToImplWithTypeCheck(
v8::Isolate* isolate, v8::Local<v8::Value> value) {
return HasInstance(value, isolate) ? ToImpl(v8::Local<v8::Object>::Cast(value)) : nullptr;
}
void V8TestInterface5::InstallConditionalFeatures(
v8::Local<v8::Context> context,
const DOMWrapperWorld& world,
v8::Local<v8::Object> instance_object,
v8::Local<v8::Object> prototype_object,
v8::Local<v8::Function> interface_object,
v8::Local<v8::FunctionTemplate> interface_template) {
CHECK(!interface_template.IsEmpty());
DCHECK((!prototype_object.IsEmpty() && !interface_object.IsEmpty()) ||
!instance_object.IsEmpty());
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_template);
ExecutionContext* execution_context = ToExecutionContext(context);
DCHECK(execution_context);
if (!prototype_object.IsEmpty() || !interface_object.IsEmpty()) {
if (execution_context && (execution_context->IsWindow())) {
static constexpr V8DOMConfiguration::AccessorConfiguration
kAccessorConfigurations[] = {
{ "windowExposedAttribute", V8TestInterface5::WindowExposedAttributeAttributeGetterCallback, V8TestInterface5::WindowExposedAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
};
V8DOMConfiguration::InstallAccessors(
isolate, world, instance_object, prototype_object, interface_object,
signature, kAccessorConfigurations,
base::size(kAccessorConfigurations));
}
if (execution_context && (execution_context->IsWorkerGlobalScope())) {
static constexpr V8DOMConfiguration::AccessorConfiguration
kAccessorConfigurations[] = {
{ "workerExposedAttribute", V8TestInterface5::WorkerExposedAttributeAttributeGetterCallback, V8TestInterface5::WorkerExposedAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
};
V8DOMConfiguration::InstallAccessors(
isolate, world, instance_object, prototype_object, interface_object,
signature, kAccessorConfigurations,
base::size(kAccessorConfigurations));
}
if (execution_context && (execution_context->IsWorkerGlobalScope())) {
{
// Install workerExposedMethod configuration
const V8DOMConfiguration::MethodConfiguration kConfigurations[] = {
{"workerExposedMethod", V8TestInterface5::WorkerExposedMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds}
};
for (const auto& config : kConfigurations) {
V8DOMConfiguration::InstallMethod(
isolate, world, instance_object, prototype_object,
interface_object, signature, config);
}
}
}
if (execution_context && (execution_context->IsWindow())) {
{
// Install windowExposedMethod configuration
const V8DOMConfiguration::MethodConfiguration kConfigurations[] = {
{"windowExposedMethod", V8TestInterface5::WindowExposedMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds}
};
for (const auto& config : kConfigurations) {
V8DOMConfiguration::InstallMethod(
isolate, world, instance_object, prototype_object,
interface_object, signature, config);
}
}
}
if (execution_context && (execution_context->IsServiceWorkerGlobalScope() || execution_context->IsWindow())) {
{
// Install windowAndServiceWorkerExposedMethod configuration
const V8DOMConfiguration::MethodConfiguration kConfigurations[] = {
{"windowAndServiceWorkerExposedMethod", V8TestInterface5::WindowAndServiceWorkerExposedMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds}
};
for (const auto& config : kConfigurations) {
V8DOMConfiguration::InstallMethod(
isolate, world, instance_object, prototype_object,
interface_object, signature, config);
}
}
}
if (execution_context && (execution_context->IsWorkerGlobalScope())) {
{
// Install workerExposedStaticMethod configuration
const V8DOMConfiguration::MethodConfiguration kConfigurations[] = {
{"workerExposedStaticMethod", V8TestInterface5::WorkerExposedStaticMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnInterface, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds}
};
for (const auto& config : kConfigurations) {
V8DOMConfiguration::InstallMethod(
isolate, world, instance_object, prototype_object,
interface_object, signature, config);
}
}
}
if (execution_context && (execution_context->IsWindow())) {
{
// Install windowExposedStaticMethod configuration
const V8DOMConfiguration::MethodConfiguration kConfigurations[] = {
{"windowExposedStaticMethod", V8TestInterface5::WindowExposedStaticMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnInterface, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds}
};
for (const auto& config : kConfigurations) {
V8DOMConfiguration::InstallMethod(
isolate, world, instance_object, prototype_object,
interface_object, signature, config);
}
}
}
}
}
} // namespace blink