blob: 0a979db995659ec69a8ca3c492722c4ebe4a5df0 [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 by code_generator_v8.py. DO NOT MODIFY!
#include "V8TestSpecialOperations.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/GeneratedCodeHelper.h"
#include "bindings/core/v8/NodeOrNodeList.h"
#include "bindings/core/v8/V8DOMConfiguration.h"
#include "bindings/core/v8/V8Node.h"
#include "bindings/core/v8/V8NodeList.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
#include "core/dom/Document.h"
#include "core/dom/NameNodeList.h"
#include "core/dom/NodeList.h"
#include "core/dom/StaticNodeList.h"
#include "core/html/LabelsNodeList.h"
#include "wtf/GetPtr.h"
#include "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) && COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
#endif
const WrapperTypeInfo V8TestSpecialOperations::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperations::domTemplate, V8TestSpecialOperations::trace, V8TestSpecialOperations::traceWrappers, 0, nullptr, "TestSpecialOperations", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::NotInheritFromActiveScriptWrappable, WrapperTypeInfo::NotInheritFromEventTarget, WrapperTypeInfo::Independent };
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestSpecialOperations.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
// bindings/core/v8/ScriptWrappable.h.
const WrapperTypeInfo& TestSpecialOperations::s_wrapperTypeInfo = V8TestSpecialOperations::wrapperTypeInfo;
// not [ActiveScriptWrappable]
static_assert(
!std::is_base_of<ActiveScriptWrappable, TestSpecialOperations>::value,
"TestSpecialOperations inherits from ActiveScriptWrappable, but is not specifying "
"[ActiveScriptWrappable] extended attribute in the IDL file. "
"Be consistent.");
static_assert(
std::is_same<decltype(&TestSpecialOperations::hasPendingActivity),
decltype(&ScriptWrappable::hasPendingActivity)>::value,
"TestSpecialOperations is overriding hasPendingActivity(), but is not specifying "
"[ActiveScriptWrappable] extended attribute in the IDL file. "
"Be consistent.");
namespace TestSpecialOperationsV8Internal {
static void namedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("namedItem", "TestSpecialOperations", ExceptionMessages::notEnoughArguments(1, info.Length())));
return;
}
V8StringResource<> name;
name = info[0];
if (!name.prepare())
return;
NodeOrNodeList result;
impl->getItem(name, result);
v8SetReturnValue(info, result);
}
static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TestSpecialOperationsV8Internal::namedItemMethod(info);
}
static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
NodeOrNodeList result;
impl->getItem(name, result);
if (result.isNull())
return;
v8SetReturnValue(info, result);
}
void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
if (!name->IsString())
return;
const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>());
TestSpecialOperationsV8Internal::namedPropertyGetter(propertyName, info);
}
static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
Node* propertyValue = V8Node::toImplWithTypeCheck(info.GetIsolate(), v8Value);
if (!propertyValue && !isUndefinedOrNull(v8Value)) {
exceptionState.throwTypeError("The provided value is not of type 'Node'.");
return;
}
bool result = impl->anonymousNamedSetter(name, propertyValue);
if (!result)
return;
v8SetReturnValue(info, v8Value);
}
void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
if (!name->IsString())
return;
const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>());
TestSpecialOperationsV8Internal::namedPropertySetter(propertyName, v8Value, info);
}
static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Integer>& info)
{
const CString& nameInUtf8 = name.utf8();
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext, "TestSpecialOperations", nameInUtf8.data());
TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
bool result = impl->namedPropertyQuery(name, exceptionState);
if (!result)
return;
v8SetReturnValueInt(info, v8::None);
}
void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
{
if (!name->IsString())
return;
const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>());
TestSpecialOperationsV8Internal::namedPropertyQuery(propertyName, info);
}
static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
{
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::EnumerationContext, "TestSpecialOperations");
TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
Vector<String> names;
impl->namedPropertyEnumerator(names, exceptionState);
if (exceptionState.hadException())
return;
v8SetReturnValue(info, toV8(names, info.Holder(), info.GetIsolate()).As<v8::Array>());
}
void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
{
TestSpecialOperationsV8Internal::namedPropertyEnumerator(info);
}
void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
{
const AtomicString& propertyName = AtomicString::number(index);
TestSpecialOperationsV8Internal::namedPropertyGetter(propertyName, info);
}
void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
const AtomicString& propertyName = AtomicString::number(index);
TestSpecialOperationsV8Internal::namedPropertySetter(propertyName, v8Value, info);
}
} // namespace TestSpecialOperationsV8Internal
const V8DOMConfiguration::MethodConfiguration V8TestSpecialOperationsMethods[] = {
{"namedItem", TestSpecialOperationsV8Internal::namedItemMethodCallback, 0, 1, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype},
};
static void installV8TestSpecialOperationsTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate)
{
// Initialize the interface object's template.
V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, V8TestSpecialOperations::wrapperTypeInfo.interfaceName, v8::Local<v8::FunctionTemplate>(), V8TestSpecialOperations::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 DOM constants, attributes and operations.
V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototypeTemplate, interfaceTemplate, signature, V8TestSpecialOperationsMethods, WTF_ARRAY_LENGTH(V8TestSpecialOperationsMethods));
// Indexed properties
v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(TestSpecialOperationsV8Internal::indexedPropertyGetterCallback, TestSpecialOperationsV8Internal::indexedPropertySetterCallback, 0, 0, 0, v8::Local<v8::Value>(), v8::PropertyHandlerFlags::kNone);
instanceTemplate->SetHandler(indexedPropertyHandlerConfig);
// Named properties
v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig(TestSpecialOperationsV8Internal::namedPropertyGetterCallback, TestSpecialOperationsV8Internal::namedPropertySetterCallback, TestSpecialOperationsV8Internal::namedPropertyQueryCallback, 0, TestSpecialOperationsV8Internal::namedPropertyEnumeratorCallback, v8::Local<v8::Value>(), static_cast<v8::PropertyHandlerFlags>(int(v8::PropertyHandlerFlags::kOnlyInterceptStrings)));
instanceTemplate->SetHandler(namedPropertyHandlerConfig);
}
v8::Local<v8::FunctionTemplate> V8TestSpecialOperations::domTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world)
{
return V8DOMConfiguration::domClassTemplate(isolate, world, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestSpecialOperationsTemplate);
}
bool V8TestSpecialOperations::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
}
v8::Local<v8::Object> V8TestSpecialOperations::findInstanceInPrototypeChain(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
}
TestSpecialOperations* V8TestSpecialOperations::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local<v8::Value> value)
{
return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)) : nullptr;
}
} // namespace blink