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 #if ENABLE(Condition1) || ENABLE(Condition2)
35 #include "V8TestInterface.h"
37 #include "RuntimeEnabledFeatures.h"
39 #include "V8NodeList.h"
40 #include "V8ReferencedType.h"
41 #include "V8TestInterfaceEmpty.h"
42 #include "V8TestObject.h"
43 #include "bindings/tests/idls/TestImplements.h"
44 #include "bindings/tests/idls/TestPartialInterface.h"
45 #include "bindings/v8/ExceptionState.h"
46 #include "bindings/v8/V8AbstractEventListener.h"
47 #include "bindings/v8/V8DOMConfiguration.h"
48 #include "bindings/v8/V8EventListenerList.h"
49 #include "bindings/v8/V8ObjectConstructor.h"
50 #include "core/dom/ContextFeatures.h"
51 #include "core/dom/Document.h"
52 #include "platform/TraceEvent.h"
53 #include "wtf/GetPtr.h"
54 #include "wtf/RefPtr.h"
58 static void initializeScriptWrappableForInterface(TestInterface* object)
60 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
61 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterface::wrapperTypeInfo);
66 } // namespace WebCore
68 // In ScriptWrappable::init, the use of a local function declaration has an issue on Windows:
69 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
70 // in the global namespace.
71 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c)
72 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterface* object)
74 WebCore::initializeScriptWrappableForInterface(object);
78 const WrapperTypeInfo V8TestInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface::domTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0, V8TestInterface::visitDOMWrapper, V8TestInterface::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false };
80 namespace TestInterfaceV8Internal {
82 template <typename T> void V8_USE(T) { }
84 static void implementsStaticReadOnlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
86 v8SetReturnValueInt(info, TestImplements::implementsStaticReadOnlyLongAttribute());
89 static void implementsStaticReadOnlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
91 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
92 TestInterfaceV8Internal::implementsStaticReadOnlyLongAttributeAttributeGetter(info);
93 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
96 static void implementsStaticStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
98 v8SetReturnValueString(info, TestImplements::implementsStaticStringAttribute(), info.GetIsolate());
101 static void implementsStaticStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
103 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
104 TestInterfaceV8Internal::implementsStaticStringAttributeAttributeGetter(info);
105 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
108 static void implementsStaticStringAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
110 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
111 TestImplements::setImplementsStaticStringAttribute(cppValue);
114 static void implementsStaticStringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
116 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
117 TestInterfaceV8Internal::implementsStaticStringAttributeAttributeSetter(jsValue, info);
118 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
121 static void implementsReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
123 TestInterface* imp = V8TestInterface::toNative(info.Holder());
124 v8SetReturnValueString(info, TestImplements::implementsReadonlyStringAttribute(imp), info.GetIsolate());
127 static void implementsReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
129 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
130 TestInterfaceV8Internal::implementsReadonlyStringAttributeAttributeGetter(info);
131 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
134 static void implementsStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
136 TestInterface* imp = V8TestInterface::toNative(info.Holder());
137 v8SetReturnValueString(info, TestImplements::implementsStringAttribute(imp), info.GetIsolate());
140 static void implementsStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
142 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
143 TestInterfaceV8Internal::implementsStringAttributeAttributeGetter(info);
144 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
147 static void implementsStringAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
149 TestInterface* imp = V8TestInterface::toNative(info.Holder());
150 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
151 TestImplements::setImplementsStringAttribute(imp, cppValue);
154 static void implementsStringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
156 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
157 TestInterfaceV8Internal::implementsStringAttributeAttributeSetter(jsValue, info);
158 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
161 static void implementsNodeAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
163 TestInterface* imp = V8TestInterface::toNative(info.Holder());
164 v8SetReturnValueFast(info, TestImplements::implementsNodeAttribute(imp), imp);
167 static void implementsNodeAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
169 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
170 TestInterfaceV8Internal::implementsNodeAttributeAttributeGetter(info);
171 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
174 static void implementsNodeAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
176 TestInterface* imp = V8TestInterface::toNative(info.Holder());
177 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0);
178 TestImplements::setImplementsNodeAttribute(imp, WTF::getPtr(cppValue));
181 static void implementsNodeAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
183 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
184 TestInterfaceV8Internal::implementsNodeAttributeAttributeSetter(jsValue, info);
185 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
188 static void implementsEventHandlerAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
190 TestInterface* imp = V8TestInterface::toNative(info.Holder());
191 EventListener* jsValue = TestImplements::implementsEventHandlerAttribute(imp);
192 v8SetReturnValue(info, jsValue ? v8::Handle<v8::Value>(V8AbstractEventListener::cast(jsValue)->getListenerObject(imp->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));
195 static void implementsEventHandlerAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
197 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
198 TestInterfaceV8Internal::implementsEventHandlerAttributeAttributeGetter(info);
199 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
202 static void implementsEventHandlerAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
204 TestInterface* imp = V8TestInterface::toNative(info.Holder());
205 moveEventListenerToNewWrapper(info.Holder(), TestImplements::implementsEventHandlerAttribute(imp), jsValue, V8TestInterface::eventListenerCacheIndex, info.GetIsolate());
206 TestImplements::setImplementsEventHandlerAttribute(imp, V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate));
209 static void implementsEventHandlerAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
211 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
212 TestInterfaceV8Internal::implementsEventHandlerAttributeAttributeSetter(jsValue, info);
213 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
216 static void implementsRuntimeEnabledNodeAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
218 TestInterface* imp = V8TestInterface::toNative(info.Holder());
219 v8SetReturnValueFast(info, TestImplements::implementsRuntimeEnabledNodeAttribute(imp), imp);
222 static void implementsRuntimeEnabledNodeAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
224 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
225 TestInterfaceV8Internal::implementsRuntimeEnabledNodeAttributeAttributeGetter(info);
226 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
229 static void implementsRuntimeEnabledNodeAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
231 TestInterface* imp = V8TestInterface::toNative(info.Holder());
232 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0);
233 TestImplements::setImplementsRuntimeEnabledNodeAttribute(imp, WTF::getPtr(cppValue));
236 static void implementsRuntimeEnabledNodeAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
238 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
239 TestInterfaceV8Internal::implementsRuntimeEnabledNodeAttributeAttributeSetter(jsValue, info);
240 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
243 static void implementsPerContextEnabledNodeAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
245 TestInterface* imp = V8TestInterface::toNative(info.Holder());
246 v8SetReturnValueFast(info, TestImplements::implementsPerContextEnabledNodeAttribute(imp), imp);
249 static void implementsPerContextEnabledNodeAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
251 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
252 TestInterfaceV8Internal::implementsPerContextEnabledNodeAttributeAttributeGetter(info);
253 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
256 static void implementsPerContextEnabledNodeAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
258 TestInterface* imp = V8TestInterface::toNative(info.Holder());
259 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0);
260 TestImplements::setImplementsPerContextEnabledNodeAttribute(imp, WTF::getPtr(cppValue));
263 static void implementsPerContextEnabledNodeAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
265 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
266 TestInterfaceV8Internal::implementsPerContextEnabledNodeAttributeAttributeSetter(jsValue, info);
267 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
270 #if ENABLE(CONDITION_PARTIAL)
271 static void supplementalStaticReadOnlyAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
273 v8SetReturnValueInt(info, TestPartialInterface::supplementalStaticReadOnlyAttr());
275 #endif // ENABLE(CONDITION_PARTIAL)
277 #if ENABLE(CONDITION_PARTIAL)
278 static void supplementalStaticReadOnlyAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
280 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
281 TestInterfaceV8Internal::supplementalStaticReadOnlyAttrAttributeGetter(info);
282 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
284 #endif // ENABLE(CONDITION_PARTIAL)
286 #if ENABLE(CONDITION_PARTIAL)
287 static void supplementalStaticAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
289 v8SetReturnValueString(info, TestPartialInterface::supplementalStaticAttr(), info.GetIsolate());
291 #endif // ENABLE(CONDITION_PARTIAL)
293 #if ENABLE(CONDITION_PARTIAL)
294 static void supplementalStaticAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
296 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
297 TestInterfaceV8Internal::supplementalStaticAttrAttributeGetter(info);
298 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
300 #endif // ENABLE(CONDITION_PARTIAL)
302 #if ENABLE(CONDITION_PARTIAL)
303 static void supplementalStaticAttrAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
305 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
306 TestPartialInterface::setSupplementalStaticAttr(cppValue);
308 #endif // ENABLE(CONDITION_PARTIAL)
310 #if ENABLE(CONDITION_PARTIAL)
311 static void supplementalStaticAttrAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
313 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
314 TestInterfaceV8Internal::supplementalStaticAttrAttributeSetter(jsValue, info);
315 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
317 #endif // ENABLE(CONDITION_PARTIAL)
319 #if ENABLE(CONDITION_PARTIAL)
320 static void supplementalStr1AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
322 TestInterface* imp = V8TestInterface::toNative(info.Holder());
323 v8SetReturnValueString(info, TestPartialInterface::supplementalStr1(imp), info.GetIsolate());
325 #endif // ENABLE(CONDITION_PARTIAL)
327 #if ENABLE(CONDITION_PARTIAL)
328 static void supplementalStr1AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
330 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
331 TestInterfaceV8Internal::supplementalStr1AttributeGetter(info);
332 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
334 #endif // ENABLE(CONDITION_PARTIAL)
336 #if ENABLE(CONDITION_PARTIAL)
337 static void supplementalStr2AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
339 TestInterface* imp = V8TestInterface::toNative(info.Holder());
340 v8SetReturnValueString(info, TestPartialInterface::supplementalStr2(imp), info.GetIsolate());
342 #endif // ENABLE(CONDITION_PARTIAL)
344 #if ENABLE(CONDITION_PARTIAL)
345 static void supplementalStr2AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
347 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
348 TestInterfaceV8Internal::supplementalStr2AttributeGetter(info);
349 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
351 #endif // ENABLE(CONDITION_PARTIAL)
353 #if ENABLE(CONDITION_PARTIAL)
354 static void supplementalStr2AttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
356 TestInterface* imp = V8TestInterface::toNative(info.Holder());
357 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
358 TestPartialInterface::setSupplementalStr2(imp, cppValue);
360 #endif // ENABLE(CONDITION_PARTIAL)
362 #if ENABLE(CONDITION_PARTIAL)
363 static void supplementalStr2AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
365 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
366 TestInterfaceV8Internal::supplementalStr2AttributeSetter(jsValue, info);
367 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
369 #endif // ENABLE(CONDITION_PARTIAL)
371 #if ENABLE(CONDITION_PARTIAL)
372 static void supplementalNodeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
374 TestInterface* imp = V8TestInterface::toNative(info.Holder());
375 v8SetReturnValueFast(info, TestPartialInterface::supplementalNode(imp), imp);
377 #endif // ENABLE(CONDITION_PARTIAL)
379 #if ENABLE(CONDITION_PARTIAL)
380 static void supplementalNodeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
382 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
383 TestInterfaceV8Internal::supplementalNodeAttributeGetter(info);
384 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
386 #endif // ENABLE(CONDITION_PARTIAL)
388 #if ENABLE(CONDITION_PARTIAL)
389 static void supplementalNodeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
391 TestInterface* imp = V8TestInterface::toNative(info.Holder());
392 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0);
393 TestPartialInterface::setSupplementalNode(imp, WTF::getPtr(cppValue));
395 #endif // ENABLE(CONDITION_PARTIAL)
397 #if ENABLE(CONDITION_PARTIAL)
398 static void supplementalNodeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
400 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
401 TestInterfaceV8Internal::supplementalNodeAttributeSetter(jsValue, info);
402 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
404 #endif // ENABLE(CONDITION_PARTIAL)
406 #if ENABLE(CONDITION_PARTIAL)
407 static void Node13AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
409 TestInterface* imp = V8TestInterface::toNative(info.Holder());
410 v8SetReturnValueFast(info, TestPartialInterface::node13(imp), imp);
412 #endif // ENABLE(CONDITION_PARTIAL)
414 #if ENABLE(CONDITION_PARTIAL)
415 static void Node13AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
417 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
418 TestInterfaceV8Internal::Node13AttributeGetter(info);
419 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
421 #endif // ENABLE(CONDITION_PARTIAL)
423 #if ENABLE(CONDITION_PARTIAL)
424 static void Node13AttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
426 TestInterface* imp = V8TestInterface::toNative(info.Holder());
427 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0);
428 TestPartialInterface::setNode13(imp, WTF::getPtr(cppValue));
430 #endif // ENABLE(CONDITION_PARTIAL)
432 #if ENABLE(CONDITION_PARTIAL)
433 static void Node13AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
435 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
436 TestInterfaceV8Internal::Node13AttributeSetter(jsValue, info);
437 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
439 #endif // ENABLE(CONDITION_PARTIAL)
441 static void namedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
443 if (UNLIKELY(info.Length() < 1)) {
444 throwTypeError(ExceptionMessages::failedToExecute("namedItem", "TestInterface", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());
447 TestInterface* imp = V8TestInterface::toNative(info.Holder());
448 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]);
449 bool result0Enabled = false;
450 RefPtr<Node> result0;
451 bool result1Enabled = false;
452 RefPtr<NodeList> result1;
453 imp->getItem(name, result0Enabled, result0, result1Enabled, result1);
454 if (result0Enabled) {
455 v8SetReturnValue(info, result0.release());
458 if (result1Enabled) {
459 v8SetReturnValue(info, result1.release());
462 v8SetReturnValueNull(info);
465 static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
467 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
468 TestInterfaceV8Internal::namedItemMethod(info);
469 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
472 static void implementsVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
474 TestInterface* imp = V8TestInterface::toNative(info.Holder());
475 TestImplements::implementsVoidMethod(imp);
478 static void implementsVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
480 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
481 TestInterfaceV8Internal::implementsVoidMethodMethod(info);
482 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
485 static void implementsComplexMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
487 ExceptionState exceptionState(ExceptionState::ExecutionContext, "implementsComplexMethod", "TestInterface", info.Holder(), info.GetIsolate());
488 if (UNLIKELY(info.Length() < 2)) {
489 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
490 exceptionState.throwIfNeeded();
493 TestInterface* imp = V8TestInterface::toNative(info.Holder());
494 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]);
495 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceEmpty::hasInstance(info[1], info.GetIsolate()) ? V8TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[1])) : 0);
496 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate());
497 RefPtr<TestInterfaceEmpty> result = TestImplements::implementsComplexMethod(scriptContext, imp, strArg, testInterfaceEmptyArg, exceptionState);
498 if (exceptionState.throwIfNeeded())
500 v8SetReturnValue(info, result.release());
503 static void implementsComplexMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
505 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
506 TestInterfaceV8Internal::implementsComplexMethodMethod(info);
507 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
510 static void implementsCustomVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
512 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
513 V8TestInterface::implementsCustomVoidMethodMethodCustom(info);
514 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
517 static void implementsStaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
519 TestImplements::implementsStaticVoidMethod();
522 static void implementsStaticVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
524 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
525 TestInterfaceV8Internal::implementsStaticVoidMethodMethod(info);
526 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
529 #if ENABLE(CONDITION_PARTIAL)
530 static void supplementalMethod1Method(const v8::FunctionCallbackInfo<v8::Value>& info)
532 TestInterface* imp = V8TestInterface::toNative(info.Holder());
533 TestPartialInterface::supplementalMethod1(imp);
535 #endif // ENABLE(CONDITION_PARTIAL)
537 #if ENABLE(CONDITION_PARTIAL)
538 static void supplementalMethod1MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
540 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
541 TestInterfaceV8Internal::supplementalMethod1Method(info);
542 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
544 #endif // ENABLE(CONDITION_PARTIAL)
546 #if ENABLE(CONDITION_PARTIAL)
547 static void supplementalMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info)
549 ExceptionState exceptionState(ExceptionState::ExecutionContext, "supplementalMethod2", "TestInterface", info.Holder(), info.GetIsolate());
550 if (UNLIKELY(info.Length() < 2)) {
551 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
552 exceptionState.throwIfNeeded();
555 TestInterface* imp = V8TestInterface::toNative(info.Holder());
556 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]);
557 V8TRYCATCH_VOID(TestObj*, objArg, V8TestObject::hasInstance(info[1], info.GetIsolate()) ? V8TestObject::toNative(v8::Handle<v8::Object>::Cast(info[1])) : 0);
558 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate());
559 RefPtr<TestObj> result = TestPartialInterface::supplementalMethod2(scriptContext, imp, strArg, objArg, exceptionState);
560 if (exceptionState.throwIfNeeded())
562 v8SetReturnValue(info, result.release());
564 #endif // ENABLE(CONDITION_PARTIAL)
566 #if ENABLE(CONDITION_PARTIAL)
567 static void supplementalMethod2MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
569 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
570 TestInterfaceV8Internal::supplementalMethod2Method(info);
571 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
573 #endif // ENABLE(CONDITION_PARTIAL)
575 #if ENABLE(CONDITION_PARTIAL)
576 static void supplementalMethod3MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
578 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
579 V8TestInterface::supplementalMethod3MethodCustom(info);
580 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
582 #endif // ENABLE(CONDITION_PARTIAL)
584 #if ENABLE(CONDITION_PARTIAL)
585 static void supplementalMethod4Method(const v8::FunctionCallbackInfo<v8::Value>& info)
587 TestPartialInterface::supplementalMethod4();
589 #endif // ENABLE(CONDITION_PARTIAL)
591 #if ENABLE(CONDITION_PARTIAL)
592 static void supplementalMethod4MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
594 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
595 TestInterfaceV8Internal::supplementalMethod4Method(info);
596 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
598 #endif // ENABLE(CONDITION_PARTIAL)
600 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
602 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterface", info.Holder(), info.GetIsolate());
603 if (UNLIKELY(info.Length() < 1)) {
604 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
605 exceptionState.throwIfNeeded();
608 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, str1, info[0]);
609 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, str2, info[1]);
610 ExecutionContext* context = currentExecutionContext(info.GetIsolate());
611 RefPtr<TestInterface> impl = TestInterface::create(context, str1, str2, exceptionState);
612 v8::Handle<v8::Object> wrapper = info.Holder();
613 if (exceptionState.throwIfNeeded())
616 V8DOMWrapper::associateObjectWithWrapper<V8TestInterface>(impl.release(), &V8TestInterface::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
617 v8SetReturnValue(info, wrapper);
620 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
622 if (info.Holder()->HasRealNamedProperty(name))
624 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
627 TestInterface* imp = V8TestInterface::toNative(info.Holder());
628 AtomicString propertyName = toCoreAtomicString(name);
629 bool result0Enabled = false;
630 RefPtr<Node> result0;
631 bool result1Enabled = false;
632 RefPtr<NodeList> result1;
633 imp->getItem(propertyName, result0Enabled, result0, result1Enabled, result1);
634 if (!result0Enabled && !result1Enabled)
636 if (result0Enabled) {
637 v8SetReturnValueFast(info, result0.release(), imp);
640 if (result1Enabled) {
641 v8SetReturnValueFast(info, result1.release(), imp);
644 v8SetReturnValueNull(info);
647 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
649 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
650 TestInterfaceV8Internal::namedPropertyGetter(name, info);
651 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
654 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)
656 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
657 V8TestInterface::namedPropertySetterCustom(name, jsValue, info);
658 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
661 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
663 TestInterface* imp = V8TestInterface::toNative(info.Holder());
664 AtomicString propertyName = toCoreAtomicString(name);
665 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
666 bool result = imp->namedPropertyQuery(propertyName, exceptionState);
667 if (exceptionState.throwIfNeeded())
671 v8SetReturnValueInt(info, v8::None);
674 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
676 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
677 TestInterfaceV8Internal::namedPropertyQuery(name, info);
678 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
681 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
683 TestInterface* imp = V8TestInterface::toNative(info.Holder());
684 Vector<String> names;
685 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
686 imp->namedPropertyEnumerator(names, exceptionState);
687 if (exceptionState.throwIfNeeded())
689 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size());
690 for (size_t i = 0; i < names.size(); ++i)
691 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIsolate(), names[i]));
692 v8SetReturnValue(info, v8names);
695 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
697 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
698 TestInterfaceV8Internal::namedPropertyEnumerator(info);
699 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
702 } // namespace TestInterfaceV8Internal
704 void V8TestInterface::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate)
706 TestInterface* impl = fromInternalPointer(object);
707 v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate, wrapper);
708 V8WrapperInstantiationScope scope(creationContext, isolate);
709 ReferencedType* referencedName = impl->referencedName();
710 if (referencedName) {
711 if (!DOMDataStore::containsWrapper<V8ReferencedType>(referencedName, isolate))
712 wrap(referencedName, creationContext, isolate);
713 DOMDataStore::setWrapperReference<V8ReferencedType>(wrapper, referencedName, isolate);
715 setObjectGroup(object, wrapper, isolate);
718 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceAttributes[] = {
719 {"implementsReadonlyStringAttribute", TestInterfaceV8Internal::implementsReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
720 {"implementsStringAttribute", TestInterfaceV8Internal::implementsStringAttributeAttributeGetterCallback, TestInterfaceV8Internal::implementsStringAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
721 {"implementsNodeAttribute", TestInterfaceV8Internal::implementsNodeAttributeAttributeGetterCallback, TestInterfaceV8Internal::implementsNodeAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
722 {"implementsEventHandlerAttribute", TestInterfaceV8Internal::implementsEventHandlerAttributeAttributeGetterCallback, TestInterfaceV8Internal::implementsEventHandlerAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
723 #if ENABLE(CONDITION_PARTIAL)
724 {"supplementalStr1", TestInterfaceV8Internal::supplementalStr1AttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
725 #endif // ENABLE(CONDITION_PARTIAL)
726 #if ENABLE(CONDITION_PARTIAL)
727 {"supplementalStr2", TestInterfaceV8Internal::supplementalStr2AttributeGetterCallback, TestInterfaceV8Internal::supplementalStr2AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
728 #endif // ENABLE(CONDITION_PARTIAL)
729 #if ENABLE(CONDITION_PARTIAL)
730 {"supplementalNode", TestInterfaceV8Internal::supplementalNodeAttributeGetterCallback, TestInterfaceV8Internal::supplementalNodeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
731 #endif // ENABLE(CONDITION_PARTIAL)
734 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceMethods[] = {
735 {"namedItem", TestInterfaceV8Internal::namedItemMethodCallback, 0, 1},
736 {"implementsVoidMethod", TestInterfaceV8Internal::implementsVoidMethodMethodCallback, 0, 0},
737 {"implementsComplexMethod", TestInterfaceV8Internal::implementsComplexMethodMethodCallback, 0, 2},
738 {"implementsCustomVoidMethod", TestInterfaceV8Internal::implementsCustomVoidMethodMethodCallback, 0, 0},
739 #if ENABLE(CONDITION_PARTIAL)
740 {"supplementalMethod1", TestInterfaceV8Internal::supplementalMethod1MethodCallback, 0, 0},
741 #endif // ENABLE(CONDITION_PARTIAL)
742 #if ENABLE(CONDITION_PARTIAL)
743 {"supplementalMethod2", TestInterfaceV8Internal::supplementalMethod2MethodCallback, 0, 2},
744 #endif // ENABLE(CONDITION_PARTIAL)
745 #if ENABLE(CONDITION_PARTIAL)
746 {"supplementalMethod3", TestInterfaceV8Internal::supplementalMethod3MethodCallback, 0, 0},
747 #endif // ENABLE(CONDITION_PARTIAL)
750 void V8TestInterface::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
752 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
753 if (!info.IsConstructCall()) {
754 throwTypeError(ExceptionMessages::failedToConstruct("TestInterface", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), info.GetIsolate());
758 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
759 v8SetReturnValue(info, info.Holder());
763 TestInterfaceV8Internal::constructor(info);
766 static void configureV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType)
768 functionTemplate->ReadOnlyPrototype();
770 v8::Local<v8::Signature> defaultSignature;
771 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterface", v8::Local<v8::FunctionTemplate>(), V8TestInterface::internalFieldCount,
772 V8TestInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceAttributes),
774 V8TestInterfaceMethods, WTF_ARRAY_LENGTH(V8TestInterfaceMethods),
775 isolate, currentWorldType);
776 functionTemplate->SetCallHandler(V8TestInterface::constructorCallback);
777 functionTemplate->SetLength(1);
778 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
779 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
780 if (RuntimeEnabledFeatures::implementsFeatureNameEnabled()) {
781 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
782 {"implementsRuntimeEnabledNodeAttribute", TestInterfaceV8Internal::implementsRuntimeEnabledNodeAttributeAttributeGetterCallback, TestInterfaceV8Internal::implementsRuntimeEnabledNodeAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */};
783 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate, currentWorldType);
785 #if ENABLE(CONDITION_PARTIAL)
786 if (RuntimeEnabledFeatures::condition13Enabled()) {
787 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
788 {"Node13", TestInterfaceV8Internal::Node13AttributeGetterCallback, TestInterfaceV8Internal::Node13AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */};
789 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate, currentWorldType);
791 #endif // ENABLE(CONDITION_PARTIAL)
792 static const V8DOMConfiguration::ConstantConfiguration V8TestInterfaceConstants[] = {
793 {"IMPLEMENTS_CONSTANT_1", 1},
794 {"IMPLEMENTS_CONSTANT_2", 2},
795 {"SUPPLEMENTALCONSTANT1", 1},
796 {"SUPPLEMENTALCONSTANT2", 2},
798 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate);
799 COMPILE_ASSERT(1 == TestImplements::IMPLEMENTS_CONSTANT_1, TheValueOfTestInterface_IMPLEMENTS_CONSTANT_1DoesntMatchWithImplementation);
800 COMPILE_ASSERT(2 == TestImplements::IMPLEMENTS_REFLECT_CONSTANT, TheValueOfTestInterface_IMPLEMENTS_REFLECT_CONSTANTDoesntMatchWithImplementation);
801 COMPILE_ASSERT(1 == TestPartialInterface::SUPPLEMENTALCONSTANT1, TheValueOfTestInterface_SUPPLEMENTALCONSTANT1DoesntMatchWithImplementation);
802 COMPILE_ASSERT(2 == TestPartialInterface::CONST_IMPL, TheValueOfTestInterface_CONST_IMPLDoesntMatchWithImplementation);
803 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestInterfaceV8Internal::namedPropertyGetterCallback, TestInterfaceV8Internal::namedPropertySetterCallback, TestInterfaceV8Internal::namedPropertyQueryCallback, 0, TestInterfaceV8Internal::namedPropertyEnumeratorCallback);
804 functionTemplate->Set(v8AtomicString(isolate, "implementsStaticVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceV8Internal::implementsStaticVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0));
805 #if ENABLE(CONDITION_PARTIAL)
806 functionTemplate->Set(v8AtomicString(isolate, "supplementalMethod4"), v8::FunctionTemplate::New(isolate, TestInterfaceV8Internal::supplementalMethod4MethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0));
807 #endif // ENABLE(CONDITION_PARTIAL)
808 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implementsStaticReadOnlyLongAttribute"), TestInterfaceV8Internal::implementsStaticReadOnlyLongAttributeAttributeGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
809 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implementsStaticStringAttribute"), TestInterfaceV8Internal::implementsStaticStringAttributeAttributeGetterCallback, TestInterfaceV8Internal::implementsStaticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
810 #if ENABLE(CONDITION_PARTIAL)
811 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "supplementalStaticReadOnlyAttr"), TestInterfaceV8Internal::supplementalStaticReadOnlyAttrAttributeGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
812 #endif // ENABLE(CONDITION_PARTIAL)
813 #if ENABLE(CONDITION_PARTIAL)
814 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "supplementalStaticAttr"), TestInterfaceV8Internal::supplementalStaticAttrAttributeGetterCallback, TestInterfaceV8Internal::supplementalStaticAttrAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
815 #endif // ENABLE(CONDITION_PARTIAL)
817 // Custom toString template
818 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
821 v8::Handle<v8::FunctionTemplate> V8TestInterface::domTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType)
823 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
824 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&wrapperTypeInfo);
825 if (result != data->templateMap(currentWorldType).end())
826 return result->value.newLocal(isolate);
828 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
829 v8::EscapableHandleScope handleScope(isolate);
830 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
831 configureV8TestInterfaceTemplate(templ, isolate, currentWorldType);
832 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTemplate>(isolate, templ));
833 return handleScope.Escape(templ);
836 bool V8TestInterface::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate)
838 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeInfo, jsValue)
839 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTypeInfo, jsValue);
842 void V8TestInterface::installPerContextEnabledProperties(v8::Handle<v8::Object> instanceTemplate, TestInterface* impl, v8::Isolate* isolate)
844 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instanceTemplate->GetPrototype());
845 if (ContextFeatures::implementsContextNameEnabled(impl->document())) {
846 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
847 {"implementsPerContextEnabledNodeAttribute", TestInterfaceV8Internal::implementsPerContextEnabledNodeAttributeAttributeGetterCallback, TestInterfaceV8Internal::implementsPerContextEnabledNodeAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */};
848 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate);
852 ActiveDOMObject* V8TestInterface::toActiveDOMObject(v8::Handle<v8::Object> wrapper)
854 return toNative(wrapper);
857 v8::Handle<v8::Object> V8TestInterface::createWrapper(PassRefPtr<TestInterface> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
860 ASSERT(!DOMDataStore::containsWrapper<V8TestInterface>(impl.get(), isolate));
861 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
862 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
863 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
864 // the same object de-ref functions, though, so use that as the basis of the check.
865 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
868 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
869 if (UNLIKELY(wrapper.IsEmpty()))
872 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
873 V8DOMWrapper::associateObjectWithWrapper<V8TestInterface>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
877 void V8TestInterface::derefObject(void* object)
879 fromInternalPointer(object)->deref();
883 v8::Handle<v8::Value> toV8NoInline(TestInterface* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
885 return toV8(impl, creationContext, isolate);
888 } // namespace WebCore
889 #endif // ENABLE(Condition1) || ENABLE(Condition2)