Index: Source/bindings/tests/results/V8TestExposedInterface.cpp |
diff --git a/Source/bindings/tests/results/V8TestExposedInterface.cpp b/Source/bindings/tests/results/V8TestExposedInterface.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..852686f2f9e6912589ce4ba1051dada898e07a47 |
--- /dev/null |
+++ b/Source/bindings/tests/results/V8TestExposedInterface.cpp |
@@ -0,0 +1,346 @@ |
+// 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" |
+#include "V8TestExposedInterface.h" |
+ |
+#include "bindings/core/v8/ExceptionState.h" |
+#include "bindings/core/v8/V8DOMConfiguration.h" |
+#include "bindings/core/v8/V8HiddenValue.h" |
+#include "bindings/core/v8/V8ObjectConstructor.h" |
+#include "core/dom/ContextFeatures.h" |
+#include "core/dom/Document.h" |
+#include "platform/RuntimeEnabledFeatures.h" |
+#include "platform/TraceEvent.h" |
+#include "wtf/GetPtr.h" |
+#include "wtf/RefPtr.h" |
+ |
+namespace blink { |
+ |
+static void initializeScriptWrappableForInterface(TestExposedInterface* object) |
+{ |
+ if (ScriptWrappable::wrapperCanBeStoredInObject(object)) |
+ ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestExposedInterface::wrapperTypeInfo); |
+ else |
+ ASSERT_NOT_REACHED(); |
+} |
+ |
+} // namespace blink |
+ |
+void webCoreInitializeScriptWrappableForInterface(blink::TestExposedInterface* object) |
+{ |
+ blink::initializeScriptWrappableForInterface(object); |
+} |
+ |
+namespace blink { |
+const WrapperTypeInfo V8TestExposedInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestExposedInterface::domTemplate, V8TestExposedInterface::derefObject, 0, 0, 0, V8TestExposedInterface::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject }; |
+ |
+namespace TestExposedInterfaceV8Internal { |
+ |
+template <typename T> void V8_USE(T) { } |
+ |
+static void alwaysExposedAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) |
+{ |
+ v8::Handle<v8::Object> holder = info.Holder(); |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(holder); |
+ v8SetReturnValueInt(info, impl->alwaysExposedAttribute()); |
+} |
+ |
+static void alwaysExposedAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); |
+ TestExposedInterfaceV8Internal::alwaysExposedAttributeAttributeGetter(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void alwaysExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
+{ |
+ v8::Handle<v8::Object> holder = info.Holder(); |
+ ExceptionState exceptionState(ExceptionState::SetterContext, "alwaysExposedAttribute", "TestExposedInterface", holder, info.GetIsolate()); |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(holder); |
+ TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); |
+ impl->setAlwaysExposedAttribute(cppValue); |
+} |
+ |
+static void alwaysExposedAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); |
+ TestExposedInterfaceV8Internal::alwaysExposedAttributeAttributeSetter(v8Value, info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void workerExposedAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) |
+{ |
+ v8::Handle<v8::Object> holder = info.Holder(); |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(holder); |
+ v8SetReturnValueInt(info, impl->workerExposedAttribute()); |
+} |
+ |
+static void workerExposedAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); |
+ TestExposedInterfaceV8Internal::workerExposedAttributeAttributeGetter(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void workerExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
+{ |
+ v8::Handle<v8::Object> holder = info.Holder(); |
+ ExceptionState exceptionState(ExceptionState::SetterContext, "workerExposedAttribute", "TestExposedInterface", holder, info.GetIsolate()); |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(holder); |
+ TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); |
+ impl->setWorkerExposedAttribute(cppValue); |
+} |
+ |
+static void workerExposedAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); |
+ TestExposedInterfaceV8Internal::workerExposedAttributeAttributeSetter(v8Value, info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void windowExposedAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) |
+{ |
+ v8::Handle<v8::Object> holder = info.Holder(); |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(holder); |
+ v8SetReturnValueInt(info, impl->windowExposedAttribute()); |
+} |
+ |
+static void windowExposedAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); |
+ TestExposedInterfaceV8Internal::windowExposedAttributeAttributeGetter(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void windowExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
+{ |
+ v8::Handle<v8::Object> holder = info.Holder(); |
+ ExceptionState exceptionState(ExceptionState::SetterContext, "windowExposedAttribute", "TestExposedInterface", holder, info.GetIsolate()); |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(holder); |
+ TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); |
+ impl->setWindowExposedAttribute(cppValue); |
+} |
+ |
+static void windowExposedAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); |
+ TestExposedInterfaceV8Internal::windowExposedAttributeAttributeSetter(v8Value, info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void alwaysExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(info.Holder()); |
+ impl->alwaysExposedMethod(); |
+} |
+ |
+static void alwaysExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
+ TestExposedInterfaceV8Internal::alwaysExposedMethodMethod(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void workerExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(info.Holder()); |
+ impl->workerExposedMethod(); |
+} |
+ |
+static void workerExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
+ TestExposedInterfaceV8Internal::workerExposedMethodMethod(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void windowExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(info.Holder()); |
+ impl->windowExposedMethod(); |
+} |
+ |
+static void windowExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
+ TestExposedInterfaceV8Internal::windowExposedMethodMethod(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void alwaysExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TestExposedInterface::alwaysExposedStaticMethod(); |
+} |
+ |
+static void alwaysExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
+ TestExposedInterfaceV8Internal::alwaysExposedStaticMethodMethod(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void workerExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TestExposedInterface::workerExposedStaticMethod(); |
+} |
+ |
+static void workerExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
+ TestExposedInterfaceV8Internal::workerExposedStaticMethodMethod(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void windowExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TestExposedInterface::windowExposedStaticMethod(); |
+} |
+ |
+static void windowExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
+ TestExposedInterfaceV8Internal::windowExposedStaticMethodMethod(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+static void windowAndServiceWorkerExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TestExposedInterface* impl = V8TestExposedInterface::toNative(info.Holder()); |
+ impl->windowAndServiceWorkerExposedMethod(); |
+} |
+ |
+static void windowAndServiceWorkerExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
+ TestExposedInterfaceV8Internal::windowAndServiceWorkerExposedMethodMethod(info); |
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
+} |
+ |
+} // namespace TestExposedInterfaceV8Internal |
+ |
+static const V8DOMConfiguration::AttributeConfiguration V8TestExposedInterfaceAttributes[] = { |
+ {"alwaysExposedAttribute", TestExposedInterfaceV8Internal::alwaysExposedAttributeAttributeGetterCallback, TestExposedInterfaceV8Internal::alwaysExposedAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, |
+}; |
+ |
+static const V8DOMConfiguration::MethodConfiguration V8TestExposedInterfaceMethods[] = { |
+ {"alwaysExposedMethod", TestExposedInterfaceV8Internal::alwaysExposedMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts}, |
+}; |
+ |
+static void installV8TestExposedInterfaceTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) |
+{ |
+ functionTemplate->ReadOnlyPrototype(); |
+ |
+ v8::Local<v8::Signature> defaultSignature; |
+ defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestExposedInterface", v8::Local<v8::FunctionTemplate>(), V8TestExposedInterface::internalFieldCount, |
+ V8TestExposedInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestExposedInterfaceAttributes), |
+ 0, 0, |
+ V8TestExposedInterfaceMethods, WTF_ARRAY_LENGTH(V8TestExposedInterfaceMethods), |
+ isolate); |
+ v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate(); |
+ v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate(); |
+ static const V8DOMConfiguration::MethodConfiguration alwaysExposedStaticMethodMethodConfiguration = { |
+ "alwaysExposedStaticMethod", TestExposedInterfaceV8Internal::alwaysExposedStaticMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts, |
+ }; |
+ V8DOMConfiguration::installMethodCustomSignature(functionTemplate, v8::Local<v8::Signature>(), v8::None, alwaysExposedStaticMethodMethodConfiguration, isolate); |
+ |
+ // Custom toString template |
+ functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); |
+} |
+ |
+v8::Handle<v8::FunctionTemplate> V8TestExposedInterface::domTemplate(v8::Isolate* isolate) |
+{ |
+ return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestExposedInterfaceTemplate); |
+} |
+ |
+bool V8TestExposedInterface::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) |
+{ |
+ return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); |
+} |
+ |
+v8::Handle<v8::Object> V8TestExposedInterface::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) |
+{ |
+ return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); |
+} |
+ |
+TestExposedInterface* V8TestExposedInterface::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) |
+{ |
+ return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0; |
+} |
+ |
+void V8TestExposedInterface::installConditionallyEnabledProperties(v8::Handle<v8::Object> instanceTemplate, TestExposedInterface* impl, v8::Isolate* isolate) |
+{ |
+ v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instanceTemplate->GetPrototype()); |
+ ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationContext()); |
+ |
+ if (context && (context->isWorker())) { |
+ static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ |
+ {"workerExposedAttribute", TestExposedInterfaceV8Internal::workerExposedAttributeAttributeGetterCallback, TestExposedInterfaceV8Internal::workerExposedAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}; |
+ V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); |
+ } |
+ if (context && (context->isWindow())) { |
+ static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ |
+ {"windowExposedAttribute", TestExposedInterfaceV8Internal::windowExposedAttributeAttributeGetterCallback, TestExposedInterfaceV8Internal::windowExposedAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}; |
+ V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); |
+ } |
+} |
+ |
+void V8TestExposedInterface::installConditionallyEnabledMethods(v8::Handle<v8::Object> prototypeTemplate, v8::Isolate* isolate) |
+{ |
+ v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domTemplate(isolate)); |
+ |
+ ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationContext()); |
+ if (context && (context->isWorker())) |
Peter Beverloo
2014/07/29 17:40:26
Note: It'd be good to group methods and attributes
|
+ prototypeTemplate->Set(v8AtomicString(isolate, "workerExposedMethod"), v8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal::workerExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); |
+ if (context && (context->isWindow())) |
+ prototypeTemplate->Set(v8AtomicString(isolate, "windowExposedMethod"), v8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal::windowExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); |
+ if (context && (context->isWorker())) |
+ prototypeTemplate->Set(v8AtomicString(isolate, "workerExposedStaticMethod"), v8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal::workerExposedStaticMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); |
+ if (context && (context->isWindow())) |
+ prototypeTemplate->Set(v8AtomicString(isolate, "windowExposedStaticMethod"), v8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal::windowExposedStaticMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); |
+ if (context && (context->isWindow() || context->isServiceWorker())) |
+ prototypeTemplate->Set(v8AtomicString(isolate, "windowAndServiceWorkerExposedMethod"), v8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal::windowAndServiceWorkerExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); |
+} |
+ |
+v8::Handle<v8::Object> wrap(TestExposedInterface* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
+{ |
+ ASSERT(impl); |
+ ASSERT(!DOMDataStore::containsWrapper<V8TestExposedInterface>(impl, isolate)); |
+ return V8TestExposedInterface::createWrapper(impl, creationContext, isolate); |
+} |
+ |
+v8::Handle<v8::Object> V8TestExposedInterface::createWrapper(PassRefPtr<TestExposedInterface> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
+{ |
+ ASSERT(impl); |
+ ASSERT(!DOMDataStore::containsWrapper<V8TestExposedInterface>(impl.get(), isolate)); |
+ if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
+ const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo(); |
+ // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have |
+ // the same object de-ref functions, though, so use that as the basis of the check. |
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); |
+ } |
+ |
+ v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); |
+ if (UNLIKELY(wrapper.IsEmpty())) |
+ return wrapper; |
+ |
+ installConditionallyEnabledProperties(wrapper, impl.get(), isolate); |
+ V8DOMWrapper::associateObjectWithWrapper<V8TestExposedInterface>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); |
+ return wrapper; |
+} |
+ |
+void V8TestExposedInterface::derefObject(void* object) |
+{ |
+ fromInternalPointer(object)->deref(); |
+} |
+ |
+template<> |
+v8::Handle<v8::Value> toV8NoInline(TestExposedInterface* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
+{ |
+ return toV8(impl, creationContext, isolate); |
+} |
+ |
+} // namespace blink |