2 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
34 #include "V8TestSpecialOperationsOverrideBuiltins.h"
36 #include "RuntimeEnabledFeatures.h"
37 #include "bindings/v8/ExceptionState.h"
38 #include "bindings/v8/V8DOMConfiguration.h"
39 #include "bindings/v8/V8ObjectConstructor.h"
40 #include "core/dom/ContextFeatures.h"
41 #include "core/dom/Document.h"
42 #include "platform/TraceEvent.h"
43 #include "wtf/GetPtr.h"
44 #include "wtf/RefPtr.h"
48 static void initializeScriptWrappableForInterface(TestSpecialOperationsOverrideBuiltins* object)
50 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
51 ScriptWrappable::setTypeInfoInObject(object, &V8TestSpecialOperationsOverrideBuiltins::wrapperTypeInfo);
56 } // namespace WebCore
58 // In ScriptWrappable::init, the use of a local function declaration has an issue on Windows:
59 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
60 // in the global namespace.
61 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c)
62 void webCoreInitializeScriptWrappableForInterface(WebCore::TestSpecialOperationsOverrideBuiltins* object)
64 WebCore::initializeScriptWrappableForInterface(object);
68 const WrapperTypeInfo V8TestSpecialOperationsOverrideBuiltins::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperationsOverrideBuiltins::domTemplate, V8TestSpecialOperationsOverrideBuiltins::derefObject, 0, 0, 0, V8TestSpecialOperationsOverrideBuiltins::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false };
70 namespace TestSpecialOperationsOverrideBuiltinsV8Internal {
72 template <typename T> void V8_USE(T) { }
74 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
76 TestSpecialOperationsOverrideBuiltins* imp = V8TestSpecialOperationsOverrideBuiltins::toNative(info.Holder());
77 AtomicString propertyName = toCoreAtomicString(name);
78 String result = imp->anonymousNamedGetter(propertyName);
81 v8SetReturnValueString(info, result, info.GetIsolate());
84 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
86 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
87 TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertyGetter(name, info);
88 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
91 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)
93 TestSpecialOperationsOverrideBuiltins* imp = V8TestSpecialOperationsOverrideBuiltins::toNative(info.Holder());
94 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name);
95 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, jsValue);
96 bool result = imp->anonymousNamedSetter(propertyName, propertyValue);
99 v8SetReturnValue(info, jsValue);
102 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)
104 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
105 TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertySetter(name, jsValue, info);
106 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
109 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
111 TestSpecialOperationsOverrideBuiltins* imp = V8TestSpecialOperationsOverrideBuiltins::toNative(info.Holder());
112 AtomicString propertyName = toCoreAtomicString(name);
113 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
114 bool result = imp->namedPropertyQuery(propertyName, exceptionState);
115 if (exceptionState.throwIfNeeded())
119 v8SetReturnValueInt(info, v8::None);
122 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
124 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
125 TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertyQuery(name, info);
126 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
129 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
131 TestSpecialOperationsOverrideBuiltins* imp = V8TestSpecialOperationsOverrideBuiltins::toNative(info.Holder());
132 Vector<String> names;
133 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
134 imp->namedPropertyEnumerator(names, exceptionState);
135 if (exceptionState.throwIfNeeded())
137 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size());
138 for (size_t i = 0; i < names.size(); ++i)
139 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIsolate(), names[i]));
140 v8SetReturnValue(info, v8names);
143 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
145 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
146 TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertyEnumerator(info);
147 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
150 } // namespace TestSpecialOperationsOverrideBuiltinsV8Internal
152 static void configureV8TestSpecialOperationsOverrideBuiltinsTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType)
154 functionTemplate->ReadOnlyPrototype();
156 v8::Local<v8::Signature> defaultSignature;
157 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestSpecialOperationsOverrideBuiltins", v8::Local<v8::FunctionTemplate>(), V8TestSpecialOperationsOverrideBuiltins::internalFieldCount,
161 isolate, currentWorldType);
162 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
163 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
164 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertyGetterCallback, TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertySetterCallback, TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertyQueryCallback, 0, TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertyEnumeratorCallback);
166 // Custom toString template
167 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
170 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperationsOverrideBuiltins::domTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType)
172 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
173 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&wrapperTypeInfo);
174 if (result != data->templateMap(currentWorldType).end())
175 return result->value.newLocal(isolate);
177 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
178 v8::EscapableHandleScope handleScope(isolate);
179 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
180 configureV8TestSpecialOperationsOverrideBuiltinsTemplate(templ, isolate, currentWorldType);
181 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTemplate>(isolate, templ));
182 return handleScope.Escape(templ);
185 bool V8TestSpecialOperationsOverrideBuiltins::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate)
187 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeInfo, jsValue)
188 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTypeInfo, jsValue);
191 v8::Handle<v8::Object> V8TestSpecialOperationsOverrideBuiltins::createWrapper(PassRefPtr<TestSpecialOperationsOverrideBuiltins> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
194 ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperationsOverrideBuiltins>(impl.get(), isolate));
195 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
196 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
197 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
198 // the same object de-ref functions, though, so use that as the basis of the check.
199 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
202 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
203 if (UNLIKELY(wrapper.IsEmpty()))
206 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
207 V8DOMWrapper::associateObjectWithWrapper<V8TestSpecialOperationsOverrideBuiltins>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
211 void V8TestSpecialOperationsOverrideBuiltins::derefObject(void* object)
213 fromInternalPointer(object)->deref();
217 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperationsOverrideBuiltins* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
219 return toV8(impl, creationContext, isolate);
222 } // namespace WebCore