| // 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 "V8TestInterface2.h" |
| |
| #include "bindings/core/v8/ExceptionState.h" |
| #include "bindings/core/v8/GeneratedCodeHelper.h" |
| #include "bindings/core/v8/ScriptState.h" |
| #include "bindings/core/v8/ScriptValue.h" |
| #include "bindings/core/v8/V8DOMConfiguration.h" |
| #include "bindings/core/v8/V8GCController.h" |
| #include "bindings/core/v8/V8Iterator.h" |
| #include "bindings/core/v8/V8ObjectConstructor.h" |
| #include "bindings/core/v8/V8TestInterfaceEmpty.h" |
| #include "core/dom/Document.h" |
| #include "core/dom/Element.h" |
| #include "core/frame/LocalDOMWindow.h" |
| #include "platform/RuntimeEnabledFeatures.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 |
| WrapperTypeInfo V8TestInterface2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface2::domTemplate, V8TestInterface2::trace, V8TestInterface2::traceWrappers, V8TestInterface2::visitDOMWrapper, nullptr, "TestInterface2", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::InheritFromActiveScriptWrappable, WrapperTypeInfo::NotInheritFromEventTarget, WrapperTypeInfo::Dependent }; |
| #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
| #pragma clang diagnostic pop |
| #endif |
| |
| // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterface2.h. |
| // For details, see the comment of DEFINE_WRAPPERTYPEINFO in |
| // bindings/core/v8/ScriptWrappable.h. |
| const WrapperTypeInfo& TestInterface2::s_wrapperTypeInfo = V8TestInterface2::wrapperTypeInfo; |
| |
| // [ActiveScriptWrappable] |
| static_assert( |
| std::is_base_of<ActiveScriptWrappable, TestInterface2>::value, |
| "TestInterface2 does not inherit from ActiveScriptWrappable, but specifying " |
| "[ActiveScriptWrappable] extended attribute in the IDL file. " |
| "Be consistent."); |
| static_assert( |
| !std::is_same<decltype(&TestInterface2::hasPendingActivity), |
| decltype(&ScriptWrappable::hasPendingActivity)>::value, |
| "TestInterface2 is not overriding hasPendingActivity(), but is specifying " |
| "[ActiveScriptWrappable] extended attribute in the IDL file. " |
| "Be consistent."); |
| |
| namespace TestInterface2V8Internal { |
| |
| static void itemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "item"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| if (UNLIKELY(info.Length() < 1)) { |
| exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); |
| return; |
| } |
| |
| unsigned index; |
| index = toUInt32(info.GetIsolate(), info[0], NormalConversion, exceptionState); |
| if (exceptionState.hadException()) |
| return; |
| |
| TestInterfaceEmpty* result = impl->item(index, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValue(info, result); |
| } |
| |
| static void itemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::itemMethod(info); |
| } |
| |
| static void setItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "setItem"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| if (UNLIKELY(info.Length() < 2)) { |
| exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length())); |
| return; |
| } |
| |
| unsigned index; |
| TestInterfaceEmpty* value; |
| index = toUInt32(info.GetIsolate(), info[0], NormalConversion, exceptionState); |
| if (exceptionState.hadException()) |
| return; |
| |
| value = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[1]); |
| if (!value) { |
| exceptionState.throwTypeError("parameter 2 is not of type 'TestInterfaceEmpty'."); |
| |
| return; |
| } |
| |
| TestInterfaceEmpty* result = impl->setItem(index, value, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValue(info, result); |
| } |
| |
| static void setItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::setItemMethod(info); |
| } |
| |
| static void deleteItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "deleteItem"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| if (UNLIKELY(info.Length() < 1)) { |
| exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); |
| return; |
| } |
| |
| unsigned index; |
| index = toUInt32(info.GetIsolate(), info[0], NormalConversion, exceptionState); |
| if (exceptionState.hadException()) |
| return; |
| |
| bool result = impl->deleteItem(index, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValueBool(info, result); |
| } |
| |
| static void deleteItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::deleteItemMethod(info); |
| } |
| |
| static void namedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "namedItem"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| if (UNLIKELY(info.Length() < 1)) { |
| exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); |
| return; |
| } |
| |
| V8StringResource<> name; |
| name = info[0]; |
| if (!name.prepare()) |
| return; |
| |
| TestInterfaceEmpty* result = impl->namedItem(name, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValue(info, result); |
| } |
| |
| static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::namedItemMethod(info); |
| } |
| |
| static void setNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "setNamedItem"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| if (UNLIKELY(info.Length() < 2)) { |
| exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length())); |
| return; |
| } |
| |
| V8StringResource<> name; |
| TestInterfaceEmpty* value; |
| name = info[0]; |
| if (!name.prepare()) |
| return; |
| |
| value = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[1]); |
| if (!value && !isUndefinedOrNull(info[1])) { |
| exceptionState.throwTypeError("parameter 2 is not of type 'TestInterfaceEmpty'."); |
| |
| return; |
| } |
| |
| TestInterfaceEmpty* result = impl->setNamedItem(name, value, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValue(info, result); |
| } |
| |
| static void setNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::setNamedItemMethod(info); |
| } |
| |
| static void deleteNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "deleteNamedItem"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| if (UNLIKELY(info.Length() < 1)) { |
| exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); |
| return; |
| } |
| |
| V8StringResource<> name; |
| name = info[0]; |
| if (!name.prepare()) |
| return; |
| |
| bool result = impl->deleteNamedItem(name, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValueBool(info, result); |
| } |
| |
| static void deleteNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::deleteNamedItemMethod(info); |
| } |
| |
| static void stringifierMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| v8SetReturnValueString(info, impl->stringifierMethod(), info.GetIsolate()); |
| } |
| |
| static void stringifierMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::stringifierMethodMethod(info); |
| } |
| |
| static void keysMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "keys"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| |
| Iterator* result = impl->keysForBinding(scriptState, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValue(info, result); |
| } |
| |
| static void keysMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::keysMethod(info); |
| } |
| |
| static void valuesMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "values"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| |
| Iterator* result = impl->valuesForBinding(scriptState, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValue(info, result); |
| } |
| |
| static void valuesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::valuesMethod(info); |
| } |
| |
| static void entriesMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "entries"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| |
| Iterator* result = impl->entriesForBinding(scriptState, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValue(info, result); |
| } |
| |
| static void entriesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::entriesMethod(info); |
| } |
| |
| static void forEachMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "forEach"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| |
| if (UNLIKELY(info.Length() < 1)) { |
| exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); |
| return; |
| } |
| |
| ScriptValue callback; |
| ScriptValue thisArg; |
| if (!info[0]->IsFunction()) { |
| exceptionState.throwTypeError("The callback provided as parameter 1 is not a function."); |
| |
| return; |
| } |
| callback = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]); |
| |
| thisArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[1]); |
| |
| impl->forEachForBinding(scriptState, ScriptValue(scriptState, info.Holder()), callback, thisArg, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| } |
| |
| static void forEachMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::forEachMethod(info); |
| } |
| |
| static void hasMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "has"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| |
| if (UNLIKELY(info.Length() < 1)) { |
| exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); |
| return; |
| } |
| |
| TestInterfaceEmpty* value; |
| value = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[0]); |
| if (!value) { |
| exceptionState.throwTypeError("parameter 1 is not of type 'TestInterfaceEmpty'."); |
| |
| return; |
| } |
| |
| bool result = impl->hasForBinding(scriptState, value, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValueBool(info, result); |
| } |
| |
| static void hasMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::hasMethod(info); |
| } |
| |
| static void toStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| v8SetReturnValueString(info, impl->stringifierMethod(), info.GetIsolate()); |
| } |
| |
| static void toStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::toStringMethod(info); |
| } |
| |
| static void iteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "iterator"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| |
| Iterator* result = impl->iterator(scriptState, exceptionState); |
| if (exceptionState.hadException()) { |
| return; |
| } |
| v8SetReturnValue(info, result); |
| } |
| |
| static void iteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::iteratorMethod(info); |
| } |
| |
| static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2* impl = TestInterface2::create(); |
| v8::Local<v8::Object> wrapper = info.Holder(); |
| wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterface2::wrapperTypeInfo, wrapper); |
| v8SetReturnValue(info, wrapper); |
| } |
| |
| static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| { |
| const CString& nameInUtf8 = name.utf8(); |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext, "TestInterface2", nameInUtf8.data()); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| TestInterfaceEmpty* result = impl->namedItem(name, exceptionState); |
| if (!result) |
| return; |
| v8SetReturnValueFast(info, result, impl); |
| } |
| |
| 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>()); |
| |
| TestInterface2V8Internal::namedPropertyGetter(propertyName, info); |
| } |
| |
| static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) |
| { |
| const CString& nameInUtf8 = name.utf8(); |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface2", nameInUtf8.data()); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), v8Value); |
| if (!propertyValue && !isUndefinedOrNull(v8Value)) { |
| exceptionState.throwTypeError("The provided value is not of type 'TestInterfaceEmpty'."); |
| return; |
| } |
| |
| bool result = impl->setNamedItem(name, propertyValue, exceptionState); |
| if (exceptionState.hadException()) |
| return; |
| 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>()); |
| |
| TestInterface2V8Internal::namedPropertySetter(propertyName, v8Value, info); |
| } |
| |
| static void namedPropertyDeleter(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Boolean>& info) |
| { |
| const CString& nameInUtf8 = name.utf8(); |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::DeletionContext, "TestInterface2", nameInUtf8.data()); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| DeleteResult result = impl->deleteNamedItem(name, exceptionState); |
| if (exceptionState.hadException()) |
| return; |
| if (result == DeleteUnknownProperty) |
| return; |
| v8SetReturnValue(info, result == DeleteSuccess); |
| } |
| |
| void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) |
| { |
| if (!name->IsString()) |
| return; |
| const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); |
| |
| TestInterface2V8Internal::namedPropertyDeleter(propertyName, info); |
| } |
| |
| static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Integer>& info) |
| { |
| const CString& nameInUtf8 = name.utf8(); |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext, "TestInterface2", nameInUtf8.data()); |
| |
| TestInterface2* impl = V8TestInterface2::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>()); |
| |
| TestInterface2V8Internal::namedPropertyQuery(propertyName, info); |
| } |
| |
| static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::EnumerationContext, "TestInterface2"); |
| |
| TestInterface2* impl = V8TestInterface2::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) |
| { |
| TestInterface2V8Internal::namedPropertyEnumerator(info); |
| } |
| |
| static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetterContext, "TestInterface2"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| TestInterfaceEmpty* result = impl->item(index, exceptionState); |
| if (!result) |
| return; |
| v8SetReturnValueFast(info, result, impl); |
| } |
| |
| void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::indexedPropertyGetter(index, info); |
| } |
| |
| static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedSetterContext, "TestInterface2"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), v8Value); |
| if (!propertyValue) { |
| exceptionState.throwTypeError("The provided value is not of type 'TestInterfaceEmpty'."); |
| return; |
| } |
| |
| bool result = impl->setItem(index, propertyValue, exceptionState); |
| if (exceptionState.hadException()) |
| return; |
| if (!result) |
| return; |
| v8SetReturnValue(info, v8Value); |
| } |
| |
| void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) |
| { |
| TestInterface2V8Internal::indexedPropertySetter(index, v8Value, info); |
| } |
| |
| static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) |
| { |
| ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedDeletionContext, "TestInterface2"); |
| |
| TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); |
| |
| DeleteResult result = impl->deleteItem(index, exceptionState); |
| if (exceptionState.hadException()) |
| return; |
| if (result == DeleteUnknownProperty) |
| return; |
| v8SetReturnValue(info, result == DeleteSuccess); |
| } |
| |
| void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) |
| { |
| TestInterface2V8Internal::indexedPropertyDeleter(index, info); |
| } |
| |
| } // namespace TestInterface2V8Internal |
| |
| void V8TestInterface2::visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* scriptWrappable, const v8::Persistent<v8::Object>& wrapper) |
| { |
| TestInterface2* impl = scriptWrappable->toImpl<TestInterface2>(); |
| // The ownerNode() method may return a reference or a pointer. |
| if (Node* owner = WTF::getPtr(impl->ownerNode())) { |
| Node* root = V8GCController::opaqueRootForGC(isolate, owner); |
| isolate->SetReferenceFromGroup(v8::UniqueId(reinterpret_cast<intptr_t>(root)), wrapper); |
| return; |
| } |
| } |
| |
| const V8DOMConfiguration::MethodConfiguration V8TestInterface2Methods[] = { |
| {"item", TestInterface2V8Internal::itemMethodCallback, 0, 1, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"setItem", TestInterface2V8Internal::setItemMethodCallback, 0, 2, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"deleteItem", TestInterface2V8Internal::deleteItemMethodCallback, 0, 1, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"namedItem", TestInterface2V8Internal::namedItemMethodCallback, 0, 1, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"setNamedItem", TestInterface2V8Internal::setNamedItemMethodCallback, 0, 2, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"deleteNamedItem", TestInterface2V8Internal::deleteNamedItemMethodCallback, 0, 1, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"stringifierMethod", TestInterface2V8Internal::stringifierMethodMethodCallback, 0, 0, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"keys", TestInterface2V8Internal::keysMethodCallback, 0, 0, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"values", TestInterface2V8Internal::valuesMethodCallback, 0, 0, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"entries", TestInterface2V8Internal::entriesMethodCallback, 0, 0, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"forEach", TestInterface2V8Internal::forEachMethodCallback, 0, 1, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"has", TestInterface2V8Internal::hasMethodCallback, 0, 1, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"toString", TestInterface2V8Internal::toStringMethodCallback, 0, 0, v8::None, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| }; |
| |
| void V8TestInterface2::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| if (!info.IsConstructCall()) { |
| V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("TestInterface2")); |
| return; |
| } |
| |
| if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) { |
| v8SetReturnValue(info, info.Holder()); |
| return; |
| } |
| |
| TestInterface2V8Internal::constructor(info); |
| } |
| |
| void V8TestInterface2::installV8TestInterface2Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) |
| { |
| // Initialize the interface object's template. |
| V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, V8TestInterface2::wrapperTypeInfo.interfaceName, v8::Local<v8::FunctionTemplate>(), V8TestInterface2::internalFieldCount); |
| interfaceTemplate->SetCallHandler(V8TestInterface2::constructorCallback); |
| interfaceTemplate->SetLength(0); |
| 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. |
| if (RuntimeEnabledFeatures::featureNameEnabled()) { |
| const V8DOMConfiguration::ConstantConfiguration constantConstValue1Configuration = {"CONST_VALUE_1", 1, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}; |
| V8DOMConfiguration::installConstant(isolate, interfaceTemplate, prototypeTemplate, constantConstValue1Configuration); |
| } |
| static_assert(1 == TestInterface2::kConstValue1, "the value of TestInterface2_kConstValue1 does not match with implementation"); |
| V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototypeTemplate, interfaceTemplate, signature, V8TestInterface2Methods, WTF_ARRAY_LENGTH(V8TestInterface2Methods)); |
| |
| // Indexed properties |
| v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(TestInterface2V8Internal::indexedPropertyGetterCallback, TestInterface2V8Internal::indexedPropertySetterCallback, 0, TestInterface2V8Internal::indexedPropertyDeleterCallback, indexedPropertyEnumerator<TestInterface2>, v8::Local<v8::Value>(), v8::PropertyHandlerFlags::kNone); |
| instanceTemplate->SetHandler(indexedPropertyHandlerConfig); |
| // Named properties |
| v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig(TestInterface2V8Internal::namedPropertyGetterCallback, TestInterface2V8Internal::namedPropertySetterCallback, TestInterface2V8Internal::namedPropertyQueryCallback, TestInterface2V8Internal::namedPropertyDeleterCallback, TestInterface2V8Internal::namedPropertyEnumeratorCallback, v8::Local<v8::Value>(), static_cast<v8::PropertyHandlerFlags>(int(v8::PropertyHandlerFlags::kOnlyInterceptStrings) | int(v8::PropertyHandlerFlags::kNonMasking))); |
| instanceTemplate->SetHandler(namedPropertyHandlerConfig); |
| |
| // Iterator (@@iterator) |
| const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, TestInterface2V8Internal::iteratorMethodCallback, 0, v8::DontDelete, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype }; |
| V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signature, symbolKeyedIteratorConfiguration); |
| } |
| |
| v8::Local<v8::FunctionTemplate> V8TestInterface2::domTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world) |
| { |
| return V8DOMConfiguration::domClassTemplate(isolate, world, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), V8TestInterface2::installV8TestInterface2TemplateFunction); |
| } |
| |
| bool V8TestInterface2::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolate) |
| { |
| return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); |
| } |
| |
| v8::Local<v8::Object> V8TestInterface2::findInstanceInPrototypeChain(v8::Local<v8::Value> v8Value, v8::Isolate* isolate) |
| { |
| return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); |
| } |
| |
| TestInterface2* V8TestInterface2::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local<v8::Value> value) |
| { |
| return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)) : nullptr; |
| } |
| |
| InstallTemplateFunction V8TestInterface2::installV8TestInterface2TemplateFunction = (InstallTemplateFunction)&V8TestInterface2::installV8TestInterface2Template; |
| |
| void V8TestInterface2::updateWrapperTypeInfo(InstallTemplateFunction installTemplateFunction, PreparePrototypeAndInterfaceObjectFunction preparePrototypeAndInterfaceObjectFunction) |
| { |
| V8TestInterface2::installV8TestInterface2TemplateFunction = installTemplateFunction; |
| if (preparePrototypeAndInterfaceObjectFunction) |
| V8TestInterface2::wrapperTypeInfo.preparePrototypeAndInterfaceObjectFunction = preparePrototypeAndInterfaceObjectFunction; |
| } |
| |
| } // namespace blink |