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 "V8TestSpecialOperationsInt.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(TestSpecialOperationsInt* object)
50 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
51 ScriptWrappable::setTypeInfoInObject(object, &V8TestSpecialOperationsInt::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::TestSpecialOperationsInt* object)
64 WebCore::initializeScriptWrappableForInterface(object);
68 const WrapperTypeInfo V8TestSpecialOperationsInt::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperationsInt::domTemplate, V8TestSpecialOperationsInt::derefObject, 0, 0, 0, V8TestSpecialOperationsInt::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false };
70 namespace TestSpecialOperationsIntV8Internal {
72 template <typename T> void V8_USE(T) { }
74 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
76 TestSpecialOperationsInt* imp = V8TestSpecialOperationsInt::toNative(info.Holder());
77 int result = imp->anonymousIndexedGetter(index);
80 v8SetReturnValueInt(info, result);
83 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
85 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
86 TestSpecialOperationsIntV8Internal::indexedPropertyGetter(index, info);
87 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
90 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)
92 TestSpecialOperationsInt* imp = V8TestSpecialOperationsInt::toNative(info.Holder());
93 V8TRYCATCH_EXCEPTION_VOID(unsigned, propertyValue, toUInt32(jsValue, exceptionState), exceptionState);
94 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
95 bool result = imp->anonymousIndexedSetter(index, propertyValue);
98 v8SetReturnValue(info, jsValue);
101 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)
103 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
104 TestSpecialOperationsIntV8Internal::indexedPropertySetter(index, jsValue, info);
105 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
108 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
110 if (info.Holder()->HasRealNamedProperty(name))
112 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
115 TestSpecialOperationsInt* imp = V8TestSpecialOperationsInt::toNative(info.Holder());
116 AtomicString propertyName = toCoreAtomicString(name);
117 int result = imp->anonymousNamedGetter(propertyName);
120 v8SetReturnValueInt(info, result);
123 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
125 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
126 TestSpecialOperationsIntV8Internal::namedPropertyGetter(name, info);
127 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
130 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)
132 if (info.Holder()->HasRealNamedProperty(name))
134 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
137 TestSpecialOperationsInt* imp = V8TestSpecialOperationsInt::toNative(info.Holder());
138 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name);
139 V8TRYCATCH_EXCEPTION_VOID(unsigned, propertyValue, toUInt32(jsValue, exceptionState), exceptionState);
140 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
141 bool result = imp->anonymousNamedSetter(propertyName, propertyValue);
144 v8SetReturnValue(info, jsValue);
147 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)
149 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
150 TestSpecialOperationsIntV8Internal::namedPropertySetter(name, jsValue, info);
151 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
154 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
156 TestSpecialOperationsInt* imp = V8TestSpecialOperationsInt::toNative(info.Holder());
157 AtomicString propertyName = toCoreAtomicString(name);
158 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
159 bool result = imp->namedPropertyQuery(propertyName, exceptionState);
160 if (exceptionState.throwIfNeeded())
164 v8SetReturnValueInt(info, v8::None);
167 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
169 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
170 TestSpecialOperationsIntV8Internal::namedPropertyQuery(name, info);
171 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
174 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
176 TestSpecialOperationsInt* imp = V8TestSpecialOperationsInt::toNative(info.Holder());
177 Vector<String> names;
178 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
179 imp->namedPropertyEnumerator(names, exceptionState);
180 if (exceptionState.throwIfNeeded())
182 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size());
183 for (size_t i = 0; i < names.size(); ++i)
184 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIsolate(), names[i]));
185 v8SetReturnValue(info, v8names);
188 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
190 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
191 TestSpecialOperationsIntV8Internal::namedPropertyEnumerator(info);
192 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
195 } // namespace TestSpecialOperationsIntV8Internal
197 static void configureV8TestSpecialOperationsIntTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType)
199 functionTemplate->ReadOnlyPrototype();
201 v8::Local<v8::Signature> defaultSignature;
202 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestSpecialOperationsInt", v8::Local<v8::FunctionTemplate>(), V8TestSpecialOperationsInt::internalFieldCount,
206 isolate, currentWorldType);
207 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
208 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
209 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestSpecialOperationsIntV8Internal::indexedPropertyGetterCallback, TestSpecialOperationsIntV8Internal::indexedPropertySetterCallback, 0, 0, indexedPropertyEnumerator<TestSpecialOperationsInt>);
210 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestSpecialOperationsIntV8Internal::namedPropertyGetterCallback, TestSpecialOperationsIntV8Internal::namedPropertySetterCallback, TestSpecialOperationsIntV8Internal::namedPropertyQueryCallback, 0, TestSpecialOperationsIntV8Internal::namedPropertyEnumeratorCallback);
212 // Custom toString template
213 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
216 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperationsInt::domTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType)
218 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
219 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&wrapperTypeInfo);
220 if (result != data->templateMap(currentWorldType).end())
221 return result->value.newLocal(isolate);
223 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
224 v8::EscapableHandleScope handleScope(isolate);
225 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
226 configureV8TestSpecialOperationsIntTemplate(templ, isolate, currentWorldType);
227 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTemplate>(isolate, templ));
228 return handleScope.Escape(templ);
231 bool V8TestSpecialOperationsInt::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate)
233 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeInfo, jsValue)
234 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTypeInfo, jsValue);
237 v8::Handle<v8::Object> V8TestSpecialOperationsInt::createWrapper(PassRefPtr<TestSpecialOperationsInt> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
240 ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperationsInt>(impl.get(), isolate));
241 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
242 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
243 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
244 // the same object de-ref functions, though, so use that as the basis of the check.
245 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
248 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
249 if (UNLIKELY(wrapper.IsEmpty()))
252 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
253 V8DOMWrapper::associateObjectWithWrapper<V8TestSpecialOperationsInt>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
257 void V8TestSpecialOperationsInt::derefObject(void* object)
259 fromInternalPointer(object)->deref();
263 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperationsInt* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
265 return toV8(impl, creationContext, isolate);
268 } // namespace WebCore