| // 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 "config.h" |
| #if ENABLE(CONDITION) |
| #include "V8TestInterfacePartial.h" |
| |
| #include "bindings/core/v8/ExceptionState.h" |
| #include "bindings/core/v8/PrivateScriptRunner.h" |
| #include "bindings/core/v8/ScriptPromise.h" |
| #include "bindings/core/v8/V8DOMConfiguration.h" |
| #include "bindings/core/v8/V8Document.h" |
| #include "bindings/core/v8/V8Node.h" |
| #include "bindings/core/v8/V8ObjectConstructor.h" |
| #include "bindings/core/v8/V8TestInterface.h" |
| #include "bindings/tests/idls/modules/TestPartialInterfaceImplementation3.h" |
| #include "core/dom/ContextFeatures.h" |
| #include "core/dom/Document.h" |
| #include "core/frame/LocalFrame.h" |
| #include "core/frame/UseCounter.h" |
| #include "platform/RuntimeEnabledFeatures.h" |
| #include "platform/ScriptForbiddenScope.h" |
| #include "platform/TraceEvent.h" |
| #include "wtf/GetPtr.h" |
| #include "wtf/RefPtr.h" |
| |
| namespace blink { |
| |
| namespace TestInterfaceImplementationPartialV8Internal { |
| |
| static void voidMethodPartialOverload3Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); |
| V8StringResource<> value; |
| { |
| value = info[0]; |
| if (!value.prepare()) |
| return; |
| } |
| TestPartialInterfaceImplementation3::voidMethodPartialOverload(*impl, value); |
| } |
| |
| static void voidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodPartialOverload", "TestInterface", info.Holder(), info.GetIsolate()); |
| switch (std::min(1, info.Length())) { |
| case 0: |
| break; |
| case 1: |
| if (true) { |
| voidMethodPartialOverload3Method(info); |
| return; |
| } |
| break; |
| default: |
| break; |
| } |
| exceptionState.throwTypeError("No function was found that matched the signature provided."); |
| exceptionState.throwIfNeeded(); |
| return; |
| } |
| |
| static void staticVoidMethodPartialOverload2Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| V8StringResource<> value; |
| { |
| value = info[0]; |
| if (!value.prepare()) |
| return; |
| } |
| TestPartialInterfaceImplementation3::staticVoidMethodPartialOverload(value); |
| } |
| |
| static void staticVoidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "staticVoidMethodPartialOverload", "TestInterface", info.Holder(), info.GetIsolate()); |
| switch (std::min(1, info.Length())) { |
| case 0: |
| break; |
| case 1: |
| if (true) { |
| staticVoidMethodPartialOverload2Method(info); |
| return; |
| } |
| break; |
| default: |
| break; |
| } |
| exceptionState.throwTypeError("No function was found that matched the signature provided."); |
| exceptionState.throwIfNeeded(); |
| return; |
| } |
| |
| static void promiseMethodPartialOverload3Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); |
| Document* document; |
| { |
| document = V8Document::toImplWithTypeCheck(info.GetIsolate(), info[0]); |
| if (!document) { |
| v8SetReturnValue(info, ScriptPromise::rejectRaw(ScriptState::current(info.GetIsolate()), V8ThrowException::createTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("promiseMethodPartialOverload", "TestInterface", "parameter 1 is not of type 'Document'.")))); |
| return; |
| } |
| } |
| v8SetReturnValue(info, TestPartialInterfaceImplementation3::promiseMethodPartialOverload(*impl, document).v8Value()); |
| } |
| |
| static void promiseMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "promiseMethodPartialOverload", "TestInterface", info.Holder(), info.GetIsolate()); |
| switch (std::min(1, info.Length())) { |
| case 0: |
| break; |
| case 1: |
| if (V8Document::hasInstance(info[0], info.GetIsolate())) { |
| promiseMethodPartialOverload3Method(info); |
| return; |
| } |
| break; |
| default: |
| break; |
| } |
| exceptionState.throwTypeError("No function was found that matched the signature provided."); |
| v8SetReturnValue(info, exceptionState.reject(ScriptState::current(info.GetIsolate())).v8Value()); |
| return; |
| } |
| |
| static void staticPromiseMethodPartialOverload2MethodPromise(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionState) |
| { |
| V8StringResource<> value; |
| { |
| value = info[0]; |
| if (!value.prepare(exceptionState)) |
| return; |
| } |
| v8SetReturnValue(info, TestPartialInterfaceImplementation3::staticPromiseMethodPartialOverload(value).v8Value()); |
| } |
| |
| static void staticPromiseMethodPartialOverload2Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "staticPromiseMethodPartialOverload", "TestInterface", info.Holder(), info.GetIsolate()); |
| staticPromiseMethodPartialOverload2MethodPromise(info, exceptionState); |
| if (exceptionState.hadException()) |
| v8SetReturnValue(info, exceptionState.reject(ScriptState::current(info.GetIsolate())).v8Value()); |
| } |
| |
| static void staticPromiseMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "staticPromiseMethodPartialOverload", "TestInterface", info.Holder(), info.GetIsolate()); |
| switch (std::min(1, info.Length())) { |
| case 0: |
| break; |
| case 1: |
| if (true) { |
| staticPromiseMethodPartialOverload2Method(info); |
| return; |
| } |
| break; |
| default: |
| break; |
| } |
| exceptionState.throwTypeError("No function was found that matched the signature provided."); |
| v8SetReturnValue(info, exceptionState.reject(ScriptState::current(info.GetIsolate())).v8Value()); |
| return; |
| } |
| |
| static void partial2VoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); |
| V8StringResource<> value; |
| { |
| value = info[0]; |
| if (!value.prepare()) |
| return; |
| } |
| TestPartialInterfaceImplementation3::partial2VoidMethod(*impl, value); |
| } |
| |
| static void partial2VoidMethod3Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); |
| Node* node; |
| { |
| node = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[0]); |
| if (!node) { |
| V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("partial2VoidMethod", "TestInterface", "parameter 1 is not of type 'Node'.")); |
| return; |
| } |
| } |
| TestPartialInterfaceImplementation3::partial2VoidMethod(*impl, node); |
| } |
| |
| static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2VoidMethod", "TestInterface", info.Holder(), info.GetIsolate()); |
| switch (std::min(1, info.Length())) { |
| case 0: |
| break; |
| case 1: |
| if (V8Node::hasInstance(info[0], info.GetIsolate())) { |
| partial2VoidMethod3Method(info); |
| return; |
| } |
| if (true) { |
| partial2VoidMethod2Method(info); |
| return; |
| } |
| break; |
| default: |
| break; |
| } |
| exceptionState.throwTypeError("No function was found that matched the signature provided."); |
| exceptionState.throwIfNeeded(); |
| return; |
| } |
| |
| static void partialVoidTestEnumModulesArgMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "partialVoidTestEnumModulesArgMethod", "TestInterface", info.Holder(), info.GetIsolate()); |
| if (UNLIKELY(info.Length() < 1)) { |
| setMinimumArityTypeError(exceptionState, 1, info.Length()); |
| exceptionState.throwIfNeeded(); |
| return; |
| } |
| TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); |
| V8StringResource<> arg; |
| { |
| arg = info[0]; |
| if (!arg.prepare()) |
| return; |
| const char* validValues[] = { |
| "EnumModulesValue1", |
| "EnumModulesValue2", |
| }; |
| if (!isValidEnum(arg, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnumModules", exceptionState)) { |
| exceptionState.throwIfNeeded(); |
| return; |
| } |
| } |
| TestPartialInterfaceImplementation3::partialVoidTestEnumModulesArgMethod(*impl, arg); |
| } |
| |
| static void partialVoidTestEnumModulesArgMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| TestInterfaceImplementationPartialV8Internal::partialVoidTestEnumModulesArgMethodMethod(info); |
| TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| } |
| |
| static void partial2StaticVoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| V8StringResource<> value; |
| { |
| value = info[0]; |
| if (!value.prepare()) |
| return; |
| } |
| TestPartialInterfaceImplementation3::partial2StaticVoidMethod(value); |
| } |
| |
| static void partial2StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2StaticVoidMethod", "TestInterface", info.Holder(), info.GetIsolate()); |
| switch (std::min(1, info.Length())) { |
| case 0: |
| break; |
| case 1: |
| if (true) { |
| partial2StaticVoidMethod2Method(info); |
| return; |
| } |
| break; |
| default: |
| break; |
| } |
| exceptionState.throwTypeError("No function was found that matched the signature provided."); |
| exceptionState.throwIfNeeded(); |
| return; |
| } |
| |
| static void unscopeableVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); |
| TestPartialInterfaceImplementation3::unscopeableVoidMethod(*impl); |
| } |
| |
| static void unscopeableVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| TestInterfaceImplementationPartialV8Internal::unscopeableVoidMethodMethod(info); |
| TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| } |
| |
| } // namespace TestInterfaceImplementationPartialV8Internal |
| |
| const V8DOMConfiguration::MethodConfiguration V8TestInterfaceMethods[] = { |
| {"partialVoidTestEnumModulesArgMethod", TestInterfaceImplementationPartialV8Internal::partialVoidTestEnumModulesArgMethodMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| {"unscopeableVoidMethod", TestInterfaceImplementationPartialV8Internal::unscopeableVoidMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype}, |
| }; |
| |
| void V8TestInterfacePartial::installV8TestInterfaceTemplate(v8::Local<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) |
| { |
| V8TestInterface::installV8TestInterfaceTemplate(functionTemplate, isolate); |
| |
| v8::Local<v8::Signature> defaultSignature; |
| if (!RuntimeEnabledFeatures::featureNameEnabled()) |
| defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "TestInterface", v8::Local<v8::FunctionTemplate>(), V8TestInterface::internalFieldCount, 0, 0, 0, 0, 0, 0); |
| else |
| defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "TestInterface", v8::Local<v8::FunctionTemplate>(), V8TestInterface::internalFieldCount, |
| 0, 0, |
| 0, 0, |
| V8TestInterfaceMethods, WTF_ARRAY_LENGTH(V8TestInterfaceMethods)); |
| v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate(); |
| ALLOW_UNUSED_LOCAL(instanceTemplate); |
| v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate(); |
| ALLOW_UNUSED_LOCAL(prototypeTemplate); |
| const V8DOMConfiguration::ConstantConfiguration V8TestInterfaceConstants[] = { |
| {"PARTIAL3_UNSIGNED_SHORT", 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, |
| }; |
| V8DOMConfiguration::installConstants(isolate, functionTemplate, prototypeTemplate, V8TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants)); |
| functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler(V8TestInterface::legacyCallCustom); |
| } |
| |
| void V8TestInterfacePartial::preparePrototypeObject(v8::Isolate* isolate, v8::Local<v8::Object> prototypeObject, v8::Local<v8::FunctionTemplate> interfaceTemplate) |
| { |
| V8TestInterface::preparePrototypeObject(isolate, prototypeObject, interfaceTemplate); |
| v8::Local<v8::Context> v8Context(prototypeObject->CreationContext()); |
| v8::Local<v8::Name> unscopablesSymbol(v8::Symbol::GetUnscopables(isolate)); |
| v8::Local<v8::Object> unscopeables; |
| if (v8CallBoolean(prototypeObject->HasOwnProperty(v8Context, unscopablesSymbol))) |
| unscopeables = prototypeObject->Get(v8Context, unscopablesSymbol).ToLocalChecked().As<v8::Object>(); |
| else |
| unscopeables = v8::Object::New(isolate); |
| unscopeables->CreateDataProperty(v8Context, v8AtomicString(isolate, "unscopeableVoidMethod"), v8::True(isolate)).FromJust(); |
| prototypeObject->CreateDataProperty(v8Context, unscopablesSymbol, unscopeables).FromJust(); |
| } |
| |
| void V8TestInterfacePartial::initialize() |
| { |
| // Should be invoked from initModules. |
| V8TestInterface::updateWrapperTypeInfo( |
| &V8TestInterfacePartial::installV8TestInterfaceTemplate, |
| &V8TestInterfacePartial::preparePrototypeObject); |
| V8TestInterface::registerVoidMethodPartialOverloadMethodForPartialInterface(&TestInterfaceImplementationPartialV8Internal::voidMethodPartialOverloadMethod); |
| V8TestInterface::registerStaticVoidMethodPartialOverloadMethodForPartialInterface(&TestInterfaceImplementationPartialV8Internal::staticVoidMethodPartialOverloadMethod); |
| V8TestInterface::registerPromiseMethodPartialOverloadMethodForPartialInterface(&TestInterfaceImplementationPartialV8Internal::promiseMethodPartialOverloadMethod); |
| V8TestInterface::registerStaticPromiseMethodPartialOverloadMethodForPartialInterface(&TestInterfaceImplementationPartialV8Internal::staticPromiseMethodPartialOverloadMethod); |
| V8TestInterface::registerPartial2VoidMethodMethodForPartialInterface(&TestInterfaceImplementationPartialV8Internal::partial2VoidMethodMethod); |
| V8TestInterface::registerPartial2StaticVoidMethodMethodForPartialInterface(&TestInterfaceImplementationPartialV8Internal::partial2StaticVoidMethodMethod); |
| } |
| |
| } // namespace blink |
| #endif // ENABLE(CONDITION) |