1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! 6 7 #include "config.h" 8 #if ENABLE(CONDITION) 9 #include "V8TestInterface.h" 10 11 #include "bindings/tests/idls/TestImplements2.h" 12 #include "bindings/tests/idls/TestImplements3Implementation.h" 13 #include "bindings/tests/idls/TestPartialInterface.h" 14 #include "bindings/tests/idls/TestPartialInterfaceImplementation.h" 15 #include "bindings/tests/v8/V8Node.h" 16 #include "bindings/tests/v8/V8TestInterface.h" 17 #include "bindings/tests/v8/V8TestInterfaceEmpty.h" 18 #include "bindings/v8/ExceptionState.h" 19 #include "bindings/v8/ScriptValue.h" 20 #include "bindings/v8/V8AbstractEventListener.h" 21 #include "bindings/v8/V8DOMConfiguration.h" 22 #include "bindings/v8/V8EventListenerList.h" 23 #include "bindings/v8/V8HiddenValue.h" 24 #include "bindings/v8/V8ObjectConstructor.h" 25 #include "core/dom/ContextFeatures.h" 26 #include "core/dom/Document.h" 27 #include "platform/RuntimeEnabledFeatures.h" 28 #include "platform/TraceEvent.h" 29 #include "wtf/GetPtr.h" 30 #include "wtf/RefPtr.h" 31 32 namespace WebCore { 33 34 static void initializeScriptWrappableForInterface(TestInterfaceImplementation* object) 35 { 36 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 37 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterface::wrapperTypeInfo); 38 else 39 ASSERT_NOT_REACHED(); 40 } 41 42 } // namespace WebCore 43 44 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceImplementation* object) 45 { 46 WebCore::initializeScriptWrappableForInterface(object); 47 } 48 49 namespace WebCore { 50 const WrapperTypeInfo V8TestInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface::domTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0, V8TestInterface::visitDOMWrapper, V8TestInterface::installPerContextEnabledMethods, &V8TestInterfaceEmpty::wrapperTypeInfo, WrapperTypeObjectPrototype, RefCountedObject }; 51 52 namespace TestInterfaceImplementationV8Internal { 53 54 template <typename T> void V8_USE(T) { } 55 56 static void testInterfaceAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 57 { 58 v8::Handle<v8::Object> holder = info.Holder(); 59 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 60 v8SetReturnValueFast(info, WTF::getPtr(impl->testInterfaceAttribute()), impl); 61 } 62 63 static void testInterfaceAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 64 { 65 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 66 TestInterfaceImplementationV8Internal::testInterfaceAttributeAttributeGetter(info); 67 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 68 } 69 70 static void testInterfaceAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 71 { 72 v8::Handle<v8::Object> holder = info.Holder(); 73 ExceptionState exceptionState(ExceptionState::SetterContext, "testInterfaceAttribute", "TestInterface", holder, info.GetIsolate()); 74 if (!V8TestInterface::hasInstance(v8Value, info.GetIsolate())) { 75 exceptionState.throwTypeError("The provided value is not of type 'TestInterface'."); 76 exceptionState.throwIfNeeded(); 77 return; 78 } 79 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 80 TONATIVE_VOID(TestInterfaceImplementation*, cppValue, V8TestInterface::toNativeWithTypeCheck(info.GetIsolate(), v8Value)); 81 impl->setTestInterfaceAttribute(WTF::getPtr(cppValue)); 82 } 83 84 static void testInterfaceAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 85 { 86 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 87 TestInterfaceImplementationV8Internal::testInterfaceAttributeAttributeSetter(v8Value, info); 88 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 89 } 90 91 static void doubleAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 92 { 93 v8::Handle<v8::Object> holder = info.Holder(); 94 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 95 v8SetReturnValue(info, impl->doubleAttribute()); 96 } 97 98 static void doubleAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 99 { 100 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 101 TestInterfaceImplementationV8Internal::doubleAttributeAttributeGetter(info); 102 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 103 } 104 105 static void doubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 106 { 107 v8::Handle<v8::Object> holder = info.Holder(); 108 ExceptionState exceptionState(ExceptionState::SetterContext, "doubleAttribute", "TestInterface", holder, info.GetIsolate()); 109 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 110 TONATIVE_VOID(double, cppValue, static_cast<double>(v8Value->NumberValue())); 111 if (!std::isfinite(cppValue)) { 112 exceptionState.throwTypeError("The provided double value is non-finite."); 113 exceptionState.throwIfNeeded(); 114 return; 115 } 116 impl->setDoubleAttribute(cppValue); 117 } 118 119 static void doubleAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 120 { 121 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 122 TestInterfaceImplementationV8Internal::doubleAttributeAttributeSetter(v8Value, info); 123 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 124 } 125 126 static void floatAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 127 { 128 v8::Handle<v8::Object> holder = info.Holder(); 129 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 130 v8SetReturnValue(info, impl->floatAttribute()); 131 } 132 133 static void floatAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 134 { 135 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 136 TestInterfaceImplementationV8Internal::floatAttributeAttributeGetter(info); 137 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 138 } 139 140 static void floatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 141 { 142 v8::Handle<v8::Object> holder = info.Holder(); 143 ExceptionState exceptionState(ExceptionState::SetterContext, "floatAttribute", "TestInterface", holder, info.GetIsolate()); 144 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 145 TONATIVE_VOID(float, cppValue, static_cast<float>(v8Value->NumberValue())); 146 if (!std::isfinite(cppValue)) { 147 exceptionState.throwTypeError("The provided float value is non-finite."); 148 exceptionState.throwIfNeeded(); 149 return; 150 } 151 impl->setFloatAttribute(cppValue); 152 } 153 154 static void floatAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 155 { 156 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 157 TestInterfaceImplementationV8Internal::floatAttributeAttributeSetter(v8Value, info); 158 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 159 } 160 161 static void unrestrictedDoubleAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 162 { 163 v8::Handle<v8::Object> holder = info.Holder(); 164 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 165 v8SetReturnValue(info, impl->unrestrictedDoubleAttribute()); 166 } 167 168 static void unrestrictedDoubleAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 169 { 170 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 171 TestInterfaceImplementationV8Internal::unrestrictedDoubleAttributeAttributeGetter(info); 172 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 173 } 174 175 static void unrestrictedDoubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 176 { 177 v8::Handle<v8::Object> holder = info.Holder(); 178 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 179 TONATIVE_VOID(double, cppValue, static_cast<double>(v8Value->NumberValue())); 180 impl->setUnrestrictedDoubleAttribute(cppValue); 181 } 182 183 static void unrestrictedDoubleAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 184 { 185 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 186 TestInterfaceImplementationV8Internal::unrestrictedDoubleAttributeAttributeSetter(v8Value, info); 187 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 188 } 189 190 static void unrestrictedFloatAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 191 { 192 v8::Handle<v8::Object> holder = info.Holder(); 193 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 194 v8SetReturnValue(info, impl->unrestrictedFloatAttribute()); 195 } 196 197 static void unrestrictedFloatAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 198 { 199 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 200 TestInterfaceImplementationV8Internal::unrestrictedFloatAttributeAttributeGetter(info); 201 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 202 } 203 204 static void unrestrictedFloatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 205 { 206 v8::Handle<v8::Object> holder = info.Holder(); 207 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 208 TONATIVE_VOID(float, cppValue, static_cast<float>(v8Value->NumberValue())); 209 impl->setUnrestrictedFloatAttribute(cppValue); 210 } 211 212 static void unrestrictedFloatAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 213 { 214 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 215 TestInterfaceImplementationV8Internal::unrestrictedFloatAttributeAttributeSetter(v8Value, info); 216 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 217 } 218 219 static void staticStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 220 { 221 v8SetReturnValueString(info, TestInterfaceImplementation::staticStringAttribute(), info.GetIsolate()); 222 } 223 224 static void staticStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 225 { 226 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 227 TestInterfaceImplementationV8Internal::staticStringAttributeAttributeGetter(info); 228 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 229 } 230 231 static void staticStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 232 { 233 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); 234 TestInterfaceImplementation::setStaticStringAttribute(cppValue); 235 } 236 237 static void staticStringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 238 { 239 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 240 TestInterfaceImplementationV8Internal::staticStringAttributeAttributeSetter(v8Value, info); 241 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 242 } 243 244 static void implementsStaticReadOnlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 245 { 246 v8SetReturnValueInt(info, TestInterfaceImplementation::implementsStaticReadOnlyLongAttribute()); 247 } 248 249 static void implementsStaticReadOnlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 250 { 251 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 252 TestInterfaceImplementationV8Internal::implementsStaticReadOnlyLongAttributeAttributeGetter(info); 253 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 254 } 255 256 static void implementsStaticStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 257 { 258 v8SetReturnValueString(info, TestInterfaceImplementation::implementsStaticStringAttribute(), info.GetIsolate()); 259 } 260 261 static void implementsStaticStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 262 { 263 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 264 TestInterfaceImplementationV8Internal::implementsStaticStringAttributeAttributeGetter(info); 265 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 266 } 267 268 static void implementsStaticStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 269 { 270 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); 271 TestInterfaceImplementation::setImplementsStaticStringAttribute(cppValue); 272 } 273 274 static void implementsStaticStringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 275 { 276 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 277 TestInterfaceImplementationV8Internal::implementsStaticStringAttributeAttributeSetter(v8Value, info); 278 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 279 } 280 281 static void implementsReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 282 { 283 v8::Handle<v8::Object> holder = info.Holder(); 284 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 285 v8SetReturnValueString(info, impl->implementsReadonlyStringAttribute(), info.GetIsolate()); 286 } 287 288 static void implementsReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 289 { 290 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 291 TestInterfaceImplementationV8Internal::implementsReadonlyStringAttributeAttributeGetter(info); 292 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 293 } 294 295 static void implementsStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 296 { 297 v8::Handle<v8::Object> holder = info.Holder(); 298 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 299 v8SetReturnValueString(info, impl->implementsStringAttribute(), info.GetIsolate()); 300 } 301 302 static void implementsStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 303 { 304 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 305 TestInterfaceImplementationV8Internal::implementsStringAttributeAttributeGetter(info); 306 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 307 } 308 309 static void implementsStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 310 { 311 v8::Handle<v8::Object> holder = info.Holder(); 312 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 313 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); 314 impl->setImplementsStringAttribute(cppValue); 315 } 316 317 static void implementsStringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 318 { 319 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 320 TestInterfaceImplementationV8Internal::implementsStringAttributeAttributeSetter(v8Value, info); 321 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 322 } 323 324 static void implementsNodeAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 325 { 326 v8::Handle<v8::Object> holder = info.Holder(); 327 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 328 v8SetReturnValueFast(info, WTF::getPtr(impl->implementsNodeAttribute()), impl); 329 } 330 331 static void implementsNodeAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 332 { 333 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 334 TestInterfaceImplementationV8Internal::implementsNodeAttributeAttributeGetter(info); 335 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 336 } 337 338 static void implementsNodeAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 339 { 340 v8::Handle<v8::Object> holder = info.Holder(); 341 ExceptionState exceptionState(ExceptionState::SetterContext, "implementsNodeAttribute", "TestInterface", holder, info.GetIsolate()); 342 if (!V8Node::hasInstance(v8Value, info.GetIsolate())) { 343 exceptionState.throwTypeError("The provided value is not of type 'Node'."); 344 exceptionState.throwIfNeeded(); 345 return; 346 } 347 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 348 TONATIVE_VOID(Node*, cppValue, V8Node::toNativeWithTypeCheck(info.GetIsolate(), v8Value)); 349 impl->setImplementsNodeAttribute(WTF::getPtr(cppValue)); 350 } 351 352 static void implementsNodeAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 353 { 354 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 355 TestInterfaceImplementationV8Internal::implementsNodeAttributeAttributeSetter(v8Value, info); 356 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 357 } 358 359 static void implementsEventHandlerAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 360 { 361 v8::Handle<v8::Object> holder = info.Holder(); 362 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 363 EventListener* v8Value = impl->implementsEventHandlerAttribute(); 364 v8SetReturnValue(info, v8Value ? v8::Handle<v8::Value>(V8AbstractEventListener::cast(v8Value)->getListenerObject(impl->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate()))); 365 } 366 367 static void implementsEventHandlerAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 368 { 369 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 370 TestInterfaceImplementationV8Internal::implementsEventHandlerAttributeAttributeGetter(info); 371 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 372 } 373 374 static void implementsEventHandlerAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 375 { 376 v8::Handle<v8::Object> holder = info.Holder(); 377 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 378 moveEventListenerToNewWrapper(holder, impl->implementsEventHandlerAttribute(), v8Value, V8TestInterface::eventListenerCacheIndex, info.GetIsolate()); 379 impl->setImplementsEventHandlerAttribute(V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate)); 380 } 381 382 static void implementsEventHandlerAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 383 { 384 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 385 TestInterfaceImplementationV8Internal::implementsEventHandlerAttributeAttributeSetter(v8Value, info); 386 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 387 } 388 389 static void implementsRuntimeEnabledNodeAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 390 { 391 v8::Handle<v8::Object> holder = info.Holder(); 392 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 393 v8SetReturnValueFast(info, WTF::getPtr(impl->implementsRuntimeEnabledNodeAttribute()), impl); 394 } 395 396 static void implementsRuntimeEnabledNodeAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 397 { 398 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 399 TestInterfaceImplementationV8Internal::implementsRuntimeEnabledNodeAttributeAttributeGetter(info); 400 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 401 } 402 403 static void implementsRuntimeEnabledNodeAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 404 { 405 v8::Handle<v8::Object> holder = info.Holder(); 406 ExceptionState exceptionState(ExceptionState::SetterContext, "implementsRuntimeEnabledNodeAttribute", "TestInterface", holder, info.GetIsolate()); 407 if (!V8Node::hasInstance(v8Value, info.GetIsolate())) { 408 exceptionState.throwTypeError("The provided value is not of type 'Node'."); 409 exceptionState.throwIfNeeded(); 410 return; 411 } 412 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 413 TONATIVE_VOID(Node*, cppValue, V8Node::toNativeWithTypeCheck(info.GetIsolate(), v8Value)); 414 impl->setImplementsRuntimeEnabledNodeAttribute(WTF::getPtr(cppValue)); 415 } 416 417 static void implementsRuntimeEnabledNodeAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 418 { 419 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 420 TestInterfaceImplementationV8Internal::implementsRuntimeEnabledNodeAttributeAttributeSetter(v8Value, info); 421 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 422 } 423 424 static void implementsPerContextEnabledNodeAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 425 { 426 v8::Handle<v8::Object> holder = info.Holder(); 427 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 428 v8SetReturnValueFast(info, WTF::getPtr(impl->implementsPerContextEnabledNodeAttribute()), impl); 429 } 430 431 static void implementsPerContextEnabledNodeAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 432 { 433 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 434 TestInterfaceImplementationV8Internal::implementsPerContextEnabledNodeAttributeAttributeGetter(info); 435 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 436 } 437 438 static void implementsPerContextEnabledNodeAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 439 { 440 v8::Handle<v8::Object> holder = info.Holder(); 441 ExceptionState exceptionState(ExceptionState::SetterContext, "implementsPerContextEnabledNodeAttribute", "TestInterface", holder, info.GetIsolate()); 442 if (!V8Node::hasInstance(v8Value, info.GetIsolate())) { 443 exceptionState.throwTypeError("The provided value is not of type 'Node'."); 444 exceptionState.throwIfNeeded(); 445 return; 446 } 447 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 448 TONATIVE_VOID(Node*, cppValue, V8Node::toNativeWithTypeCheck(info.GetIsolate(), v8Value)); 449 impl->setImplementsPerContextEnabledNodeAttribute(WTF::getPtr(cppValue)); 450 } 451 452 static void implementsPerContextEnabledNodeAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 453 { 454 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 455 TestInterfaceImplementationV8Internal::implementsPerContextEnabledNodeAttributeAttributeSetter(v8Value, info); 456 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 457 } 458 459 static void implements2StaticStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 460 { 461 v8SetReturnValueString(info, TestImplements2::implements2StaticStringAttribute(), info.GetIsolate()); 462 } 463 464 static void implements2StaticStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 465 { 466 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 467 TestInterfaceImplementationV8Internal::implements2StaticStringAttributeAttributeGetter(info); 468 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 469 } 470 471 static void implements2StaticStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 472 { 473 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); 474 TestImplements2::setImplements2StaticStringAttribute(cppValue); 475 } 476 477 static void implements2StaticStringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 478 { 479 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 480 TestInterfaceImplementationV8Internal::implements2StaticStringAttributeAttributeSetter(v8Value, info); 481 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 482 } 483 484 static void implements2StringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 485 { 486 v8::Handle<v8::Object> holder = info.Holder(); 487 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 488 v8SetReturnValueString(info, TestImplements2::implements2StringAttribute(*impl), info.GetIsolate()); 489 } 490 491 static void implements2StringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 492 { 493 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 494 TestInterfaceImplementationV8Internal::implements2StringAttributeAttributeGetter(info); 495 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 496 } 497 498 static void implements2StringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 499 { 500 v8::Handle<v8::Object> holder = info.Holder(); 501 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 502 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); 503 TestImplements2::setImplements2StringAttribute(*impl, cppValue); 504 } 505 506 static void implements2StringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 507 { 508 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 509 TestInterfaceImplementationV8Internal::implements2StringAttributeAttributeSetter(v8Value, info); 510 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 511 } 512 513 static void implements3StringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 514 { 515 v8::Handle<v8::Object> holder = info.Holder(); 516 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 517 v8SetReturnValueString(info, TestImplements3Implementation::implements3StringAttribute(*impl), info.GetIsolate()); 518 } 519 520 static void implements3StringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 521 { 522 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 523 TestInterfaceImplementationV8Internal::implements3StringAttributeAttributeGetter(info); 524 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 525 } 526 527 static void implements3StringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 528 { 529 v8::Handle<v8::Object> holder = info.Holder(); 530 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 531 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); 532 TestImplements3Implementation::setImplements3StringAttribute(*impl, cppValue); 533 } 534 535 static void implements3StringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 536 { 537 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 538 TestInterfaceImplementationV8Internal::implements3StringAttributeAttributeSetter(v8Value, info); 539 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 540 } 541 542 static void implements3StaticStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 543 { 544 v8SetReturnValueString(info, TestImplements3Implementation::implements3StaticStringAttribute(), info.GetIsolate()); 545 } 546 547 static void implements3StaticStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 548 { 549 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 550 TestInterfaceImplementationV8Internal::implements3StaticStringAttributeAttributeGetter(info); 551 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 552 } 553 554 static void implements3StaticStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 555 { 556 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); 557 TestImplements3Implementation::setImplements3StaticStringAttribute(cppValue); 558 } 559 560 static void implements3StaticStringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 561 { 562 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 563 TestInterfaceImplementationV8Internal::implements3StaticStringAttributeAttributeSetter(v8Value, info); 564 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 565 } 566 567 #if ENABLE(PARTIAL_CONDITION) 568 static void partialLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 569 { 570 v8::Handle<v8::Object> holder = info.Holder(); 571 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 572 v8SetReturnValueInt(info, TestPartialInterface::partialLongAttribute(*impl)); 573 } 574 #endif // ENABLE(PARTIAL_CONDITION) 575 576 #if ENABLE(PARTIAL_CONDITION) 577 static void partialLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 578 { 579 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 580 TestInterfaceImplementationV8Internal::partialLongAttributeAttributeGetter(info); 581 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 582 } 583 #endif // ENABLE(PARTIAL_CONDITION) 584 585 #if ENABLE(PARTIAL_CONDITION) 586 static void partialLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 587 { 588 v8::Handle<v8::Object> holder = info.Holder(); 589 ExceptionState exceptionState(ExceptionState::SetterContext, "partialLongAttribute", "TestInterface", holder, info.GetIsolate()); 590 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 591 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 592 TestPartialInterface::setPartialLongAttribute(*impl, cppValue); 593 } 594 #endif // ENABLE(PARTIAL_CONDITION) 595 596 #if ENABLE(PARTIAL_CONDITION) 597 static void partialLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 598 { 599 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 600 TestInterfaceImplementationV8Internal::partialLongAttributeAttributeSetter(v8Value, info); 601 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 602 } 603 #endif // ENABLE(PARTIAL_CONDITION) 604 605 #if ENABLE(PARTIAL_CONDITION) 606 static void partialStaticLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 607 { 608 v8SetReturnValueInt(info, TestPartialInterface::partialStaticLongAttribute()); 609 } 610 #endif // ENABLE(PARTIAL_CONDITION) 611 612 #if ENABLE(PARTIAL_CONDITION) 613 static void partialStaticLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 614 { 615 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 616 TestInterfaceImplementationV8Internal::partialStaticLongAttributeAttributeGetter(info); 617 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 618 } 619 #endif // ENABLE(PARTIAL_CONDITION) 620 621 #if ENABLE(PARTIAL_CONDITION) 622 static void partialStaticLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 623 { 624 ExceptionState exceptionState(ExceptionState::SetterContext, "partialStaticLongAttribute", "TestInterface", holder, info.GetIsolate()); 625 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 626 TestPartialInterface::setPartialStaticLongAttribute(cppValue); 627 } 628 #endif // ENABLE(PARTIAL_CONDITION) 629 630 #if ENABLE(PARTIAL_CONDITION) 631 static void partialStaticLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 632 { 633 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 634 TestInterfaceImplementationV8Internal::partialStaticLongAttributeAttributeSetter(v8Value, info); 635 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 636 } 637 #endif // ENABLE(PARTIAL_CONDITION) 638 639 #if ENABLE(PARTIAL_CONDITION) 640 static void partialCallWithExecutionContextLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 641 { 642 v8::Handle<v8::Object> holder = info.Holder(); 643 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 644 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); 645 v8SetReturnValueInt(info, TestPartialInterface::partialCallWithExecutionContextLongAttribute(executionContext, *impl)); 646 } 647 #endif // ENABLE(PARTIAL_CONDITION) 648 649 #if ENABLE(PARTIAL_CONDITION) 650 static void partialCallWithExecutionContextLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 651 { 652 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 653 TestInterfaceImplementationV8Internal::partialCallWithExecutionContextLongAttributeAttributeGetter(info); 654 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 655 } 656 #endif // ENABLE(PARTIAL_CONDITION) 657 658 #if ENABLE(PARTIAL_CONDITION) 659 static void partialCallWithExecutionContextLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 660 { 661 v8::Handle<v8::Object> holder = info.Holder(); 662 ExceptionState exceptionState(ExceptionState::SetterContext, "partialCallWithExecutionContextLongAttribute", "TestInterface", holder, info.GetIsolate()); 663 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 664 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 665 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); 666 TestPartialInterface::setPartialCallWithExecutionContextLongAttribute(executionContext, *impl, cppValue); 667 } 668 #endif // ENABLE(PARTIAL_CONDITION) 669 670 #if ENABLE(PARTIAL_CONDITION) 671 static void partialCallWithExecutionContextLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 672 { 673 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 674 TestInterfaceImplementationV8Internal::partialCallWithExecutionContextLongAttributeAttributeSetter(v8Value, info); 675 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 676 } 677 #endif // ENABLE(PARTIAL_CONDITION) 678 679 #if ENABLE(PARTIAL_CONDITION) 680 static void partialPartialEnumTypeAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 681 { 682 v8::Handle<v8::Object> holder = info.Holder(); 683 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 684 v8SetReturnValueString(info, TestPartialInterface::partialPartialEnumTypeAttribute(*impl), info.GetIsolate()); 685 } 686 #endif // ENABLE(PARTIAL_CONDITION) 687 688 #if ENABLE(PARTIAL_CONDITION) 689 static void partialPartialEnumTypeAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 690 { 691 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 692 TestInterfaceImplementationV8Internal::partialPartialEnumTypeAttributeAttributeGetter(info); 693 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 694 } 695 #endif // ENABLE(PARTIAL_CONDITION) 696 697 #if ENABLE(PARTIAL_CONDITION) 698 static void partialPartialEnumTypeAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 699 { 700 v8::Handle<v8::Object> holder = info.Holder(); 701 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 702 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); 703 String string = cppValue; 704 if (!(string == "foo" || string == "bar")) 705 return; 706 TestPartialInterface::setPartialPartialEnumTypeAttribute(*impl, cppValue); 707 } 708 #endif // ENABLE(PARTIAL_CONDITION) 709 710 #if ENABLE(PARTIAL_CONDITION) 711 static void partialPartialEnumTypeAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 712 { 713 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 714 TestInterfaceImplementationV8Internal::partialPartialEnumTypeAttributeAttributeSetter(v8Value, info); 715 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 716 } 717 #endif // ENABLE(PARTIAL_CONDITION) 718 719 static void partial2LongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 720 { 721 v8::Handle<v8::Object> holder = info.Holder(); 722 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 723 v8SetReturnValueInt(info, TestPartialInterfaceImplementation::partial2LongAttribute(*impl)); 724 } 725 726 static void partial2LongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 727 { 728 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 729 TestInterfaceImplementationV8Internal::partial2LongAttributeAttributeGetter(info); 730 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 731 } 732 733 static void partial2LongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 734 { 735 v8::Handle<v8::Object> holder = info.Holder(); 736 ExceptionState exceptionState(ExceptionState::SetterContext, "partial2LongAttribute", "TestInterface", holder, info.GetIsolate()); 737 TestInterfaceImplementation* impl = V8TestInterface::toNative(holder); 738 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 739 TestPartialInterfaceImplementation::setPartial2LongAttribute(*impl, cppValue); 740 } 741 742 static void partial2LongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 743 { 744 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 745 TestInterfaceImplementationV8Internal::partial2LongAttributeAttributeSetter(v8Value, info); 746 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 747 } 748 749 static void partial2StaticLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 750 { 751 v8SetReturnValueInt(info, TestPartialInterfaceImplementation::partial2StaticLongAttribute()); 752 } 753 754 static void partial2StaticLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 755 { 756 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 757 TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeGetter(info); 758 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 759 } 760 761 static void partial2StaticLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 762 { 763 ExceptionState exceptionState(ExceptionState::SetterContext, "partial2StaticLongAttribute", "TestInterface", holder, info.GetIsolate()); 764 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 765 TestPartialInterfaceImplementation::setPartial2StaticLongAttribute(cppValue); 766 } 767 768 static void partial2StaticLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 769 { 770 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 771 TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeSetter(v8Value, info); 772 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 773 } 774 775 static void TestInterfaceImplementationConstructorGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 776 { 777 v8::Handle<v8::Value> data = info.Data(); 778 ASSERT(data->IsExternal()); 779 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext()); 780 if (!perContextData) 781 return; 782 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::unwrap(data))); 783 } 784 785 static void TestInterfaceImplementationReplaceableAttributeSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 786 { 787 if (info.This()->IsObject()) 788 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); 789 } 790 791 static void TestInterfaceImplementationReplaceableAttributeSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 792 { 793 TestInterfaceImplementationV8Internal::TestInterfaceImplementationReplaceableAttributeSetter(name, v8Value, info); 794 } 795 796 static void voidMethodTestInterfaceEmptyArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 797 { 798 if (UNLIKELY(info.Length() < 1)) { 799 throwMinimumArityTypeErrorForMethod("voidMethodTestInterfaceEmptyArg", "TestInterface", 1, info.Length(), info.GetIsolate()); 800 return; 801 } 802 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 803 TestInterfaceEmpty* testInterfaceEmptyArg; 804 { 805 v8::TryCatch block; 806 V8RethrowTryCatchScope rethrow(block); 807 if (info.Length() > 0 && !V8TestInterfaceEmpty::hasInstance(info[0], info.GetIsolate())) { 808 throwTypeError(ExceptionMessages::failedToExecute("voidMethodTestInterfaceEmptyArg", "TestInterface", "parameter 1 is not of type 'TestInterfaceEmpty'."), info.GetIsolate()); 809 return; 810 } 811 TONATIVE_VOID_INTERNAL(testInterfaceEmptyArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[0])); 812 } 813 impl->voidMethodTestInterfaceEmptyArg(testInterfaceEmptyArg); 814 } 815 816 static void voidMethodTestInterfaceEmptyArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 817 { 818 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 819 TestInterfaceImplementationV8Internal::voidMethodTestInterfaceEmptyArgMethod(info); 820 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 821 } 822 823 static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 824 { 825 if (UNLIKELY(info.Length() < 2)) { 826 throwMinimumArityTypeErrorForMethod("voidMethodDoubleArgFloatArg", "TestInterface", 2, info.Length(), info.GetIsolate()); 827 return; 828 } 829 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 830 double doubleArg; 831 float floatArg; 832 { 833 v8::TryCatch block; 834 V8RethrowTryCatchScope rethrow(block); 835 TONATIVE_VOID_INTERNAL(doubleArg, static_cast<double>(info[0]->NumberValue())); 836 if (!std::isfinite(doubleArg)) { 837 throwTypeError(ExceptionMessages::failedToExecute("voidMethodDoubleArgFloatArg", "TestInterface", "double parameter 1 is non-finite."), info.GetIsolate()); 838 return; 839 } 840 TONATIVE_VOID_INTERNAL(floatArg, static_cast<float>(info[1]->NumberValue())); 841 if (!std::isfinite(floatArg)) { 842 throwTypeError(ExceptionMessages::failedToExecute("voidMethodDoubleArgFloatArg", "TestInterface", "float parameter 2 is non-finite."), info.GetIsolate()); 843 return; 844 } 845 } 846 impl->voidMethodDoubleArgFloatArg(doubleArg, floatArg); 847 } 848 849 static void voidMethodDoubleArgFloatArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 850 { 851 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 852 TestInterfaceImplementationV8Internal::voidMethodDoubleArgFloatArgMethod(info); 853 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 854 } 855 856 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 857 { 858 if (UNLIKELY(info.Length() < 2)) { 859 throwMinimumArityTypeErrorForMethod("voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", "TestInterface", 2, info.Length(), info.GetIsolate()); 860 return; 861 } 862 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 863 double unrestrictedDoubleArg; 864 float unrestrictedFloatArg; 865 { 866 v8::TryCatch block; 867 V8RethrowTryCatchScope rethrow(block); 868 TONATIVE_VOID_INTERNAL(unrestrictedDoubleArg, static_cast<double>(info[0]->NumberValue())); 869 TONATIVE_VOID_INTERNAL(unrestrictedFloatArg, static_cast<float>(info[1]->NumberValue())); 870 } 871 impl->voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg(unrestrictedDoubleArg, unrestrictedFloatArg); 872 } 873 874 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 875 { 876 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 877 TestInterfaceImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(info); 878 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 879 } 880 881 static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 882 { 883 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 884 impl->voidMethod(); 885 } 886 887 static void voidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 888 { 889 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 890 TestInterfaceImplementationV8Internal::voidMethodMethod(info); 891 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 892 } 893 894 static void voidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info) 895 { 896 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 897 impl->voidMethod(); 898 } 899 900 static void voidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info) 901 { 902 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 903 TestInterfaceImplementationV8Internal::voidMethodMethodForMainWorld(info); 904 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 905 } 906 907 static void implementsVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 908 { 909 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 910 impl->implementsVoidMethod(); 911 } 912 913 static void implementsVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 914 { 915 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 916 TestInterfaceImplementationV8Internal::implementsVoidMethodMethod(info); 917 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 918 } 919 920 static void implementsComplexMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 921 { 922 ExceptionState exceptionState(ExceptionState::ExecutionContext, "implementsComplexMethod", "TestInterface", info.Holder(), info.GetIsolate()); 923 if (UNLIKELY(info.Length() < 2)) { 924 throwMinimumArityTypeError(exceptionState, 2, info.Length()); 925 return; 926 } 927 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 928 V8StringResource<> strArg; 929 TestInterfaceEmpty* testInterfaceEmptyArg; 930 { 931 v8::TryCatch block; 932 V8RethrowTryCatchScope rethrow(block); 933 TOSTRING_VOID_INTERNAL(strArg, info[0]); 934 if (info.Length() > 1 && !V8TestInterfaceEmpty::hasInstance(info[1], info.GetIsolate())) { 935 exceptionState.throwTypeError("parameter 2 is not of type 'TestInterfaceEmpty'."); 936 exceptionState.throwIfNeeded(); 937 return; 938 } 939 TONATIVE_VOID_INTERNAL(testInterfaceEmptyArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[1])); 940 } 941 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); 942 RefPtr<TestInterfaceEmpty> result = impl->implementsComplexMethod(executionContext, strArg, testInterfaceEmptyArg, exceptionState); 943 if (exceptionState.hadException()) { 944 exceptionState.throwIfNeeded(); 945 return; 946 } 947 v8SetReturnValue(info, result.release()); 948 } 949 950 static void implementsComplexMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 951 { 952 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 953 TestInterfaceImplementationV8Internal::implementsComplexMethodMethod(info); 954 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 955 } 956 957 static void implementsCustomVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 958 { 959 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 960 V8TestInterface::implementsCustomVoidMethodMethodCustom(info); 961 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 962 } 963 964 static void implementsStaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 965 { 966 TestInterfaceImplementation::implementsStaticVoidMethod(); 967 } 968 969 static void implementsStaticVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 970 { 971 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 972 TestInterfaceImplementationV8Internal::implementsStaticVoidMethodMethod(info); 973 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 974 } 975 976 static void implements2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 977 { 978 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 979 TestImplements2::implements2VoidMethod(*impl); 980 } 981 982 static void implements2VoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 983 { 984 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 985 TestInterfaceImplementationV8Internal::implements2VoidMethodMethod(info); 986 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 987 } 988 989 static void implements3VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 990 { 991 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 992 TestImplements3Implementation::implements3VoidMethod(*impl); 993 } 994 995 static void implements3VoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 996 { 997 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 998 TestInterfaceImplementationV8Internal::implements3VoidMethodMethod(info); 999 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1000 } 1001 1002 static void implements3StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 1003 { 1004 TestImplements3Implementation::implements3StaticVoidMethod(); 1005 } 1006 1007 static void implements3StaticVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 1008 { 1009 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 1010 TestInterfaceImplementationV8Internal::implements3StaticVoidMethodMethod(info); 1011 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1012 } 1013 1014 #if ENABLE(PARTIAL_CONDITION) 1015 static void partialVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 1016 { 1017 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1018 TestPartialInterface::partialVoidMethod(*impl); 1019 } 1020 #endif // ENABLE(PARTIAL_CONDITION) 1021 1022 #if ENABLE(PARTIAL_CONDITION) 1023 static void partialVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 1024 { 1025 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 1026 TestInterfaceImplementationV8Internal::partialVoidMethodMethod(info); 1027 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1028 } 1029 #endif // ENABLE(PARTIAL_CONDITION) 1030 1031 #if ENABLE(PARTIAL_CONDITION) 1032 static void partialStaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 1033 { 1034 TestPartialInterface::partialStaticVoidMethod(); 1035 } 1036 #endif // ENABLE(PARTIAL_CONDITION) 1037 1038 #if ENABLE(PARTIAL_CONDITION) 1039 static void partialStaticVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 1040 { 1041 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 1042 TestInterfaceImplementationV8Internal::partialStaticVoidMethodMethod(info); 1043 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1044 } 1045 #endif // ENABLE(PARTIAL_CONDITION) 1046 1047 #if ENABLE(PARTIAL_CONDITION) 1048 static void partialVoidMethodLongArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 1049 { 1050 ExceptionState exceptionState(ExceptionState::ExecutionContext, "partialVoidMethodLongArg", "TestInterface", info.Holder(), info.GetIsolate()); 1051 if (UNLIKELY(info.Length() < 1)) { 1052 throwMinimumArityTypeError(exceptionState, 1, info.Length()); 1053 return; 1054 } 1055 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1056 int longArg; 1057 { 1058 v8::TryCatch block; 1059 V8RethrowTryCatchScope rethrow(block); 1060 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(longArg, toInt32(info[0], exceptionState), exceptionState); 1061 } 1062 TestPartialInterface::partialVoidMethodLongArg(*impl, longArg); 1063 } 1064 #endif // ENABLE(PARTIAL_CONDITION) 1065 1066 #if ENABLE(PARTIAL_CONDITION) 1067 static void partialVoidMethodLongArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 1068 { 1069 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 1070 TestInterfaceImplementationV8Internal::partialVoidMethodLongArgMethod(info); 1071 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1072 } 1073 #endif // ENABLE(PARTIAL_CONDITION) 1074 1075 #if ENABLE(PARTIAL_CONDITION) 1076 static void partialCallWithExecutionContextRaisesExceptionVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 1077 { 1078 ExceptionState exceptionState(ExceptionState::ExecutionContext, "partialCallWithExecutionContextRaisesExceptionVoidMethod", "TestInterface", info.Holder(), info.GetIsolate()); 1079 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1080 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); 1081 TestPartialInterface::partialCallWithExecutionContextRaisesExceptionVoidMethod(executionContext, *impl, exceptionState); 1082 if (exceptionState.hadException()) { 1083 exceptionState.throwIfNeeded(); 1084 return; 1085 } 1086 } 1087 #endif // ENABLE(PARTIAL_CONDITION) 1088 1089 #if ENABLE(PARTIAL_CONDITION) 1090 static void partialCallWithExecutionContextRaisesExceptionVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 1091 { 1092 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 1093 TestInterfaceImplementationV8Internal::partialCallWithExecutionContextRaisesExceptionVoidMethodMethod(info); 1094 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1095 } 1096 #endif // ENABLE(PARTIAL_CONDITION) 1097 1098 #if ENABLE(PARTIAL_CONDITION) 1099 static void partialVoidMethodPartialCallbackTypeArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 1100 { 1101 if (UNLIKELY(info.Length() < 1)) { 1102 throwMinimumArityTypeErrorForMethod("partialVoidMethodPartialCallbackTypeArg", "TestInterface", 1, info.Length(), info.GetIsolate()); 1103 return; 1104 } 1105 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1106 ScriptValue partialCallbackTypeArg; 1107 { 1108 v8::TryCatch block; 1109 V8RethrowTryCatchScope rethrow(block); 1110 TONATIVE_VOID_INTERNAL(partialCallbackTypeArg, ScriptValue(ScriptState::current(info.GetIsolate()), info[0])); 1111 } 1112 TestPartialInterface::partialVoidMethodPartialCallbackTypeArg(*impl, partialCallbackTypeArg); 1113 } 1114 #endif // ENABLE(PARTIAL_CONDITION) 1115 1116 #if ENABLE(PARTIAL_CONDITION) 1117 static void partialVoidMethodPartialCallbackTypeArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 1118 { 1119 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 1120 TestInterfaceImplementationV8Internal::partialVoidMethodPartialCallbackTypeArgMethod(info); 1121 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1122 } 1123 #endif // ENABLE(PARTIAL_CONDITION) 1124 1125 static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 1126 { 1127 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1128 TestPartialInterfaceImplementation::partial2VoidMethod(*impl); 1129 } 1130 1131 static void partial2VoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 1132 { 1133 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 1134 TestInterfaceImplementationV8Internal::partial2VoidMethodMethod(info); 1135 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1136 } 1137 1138 static void partial2StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 1139 { 1140 TestPartialInterfaceImplementation::partial2StaticVoidMethod(); 1141 } 1142 1143 static void partial2StaticVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 1144 { 1145 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 1146 TestInterfaceImplementationV8Internal::partial2StaticVoidMethodMethod(info); 1147 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1148 } 1149 1150 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) 1151 { 1152 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1153 String result = impl->anonymousIndexedGetter(index); 1154 if (result.isNull()) 1155 return; 1156 v8SetReturnValueString(info, result, info.GetIsolate()); 1157 } 1158 1159 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) 1160 { 1161 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); 1162 TestInterfaceImplementationV8Internal::indexedPropertyGetter(index, info); 1163 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1164 } 1165 1166 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 1167 { 1168 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1169 TOSTRING_VOID(V8StringResource<>, propertyValue, v8Value); 1170 bool result = impl->anonymousIndexedSetter(index, propertyValue); 1171 if (!result) 1172 return; 1173 v8SetReturnValue(info, v8Value); 1174 } 1175 1176 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 1177 { 1178 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); 1179 TestInterfaceImplementationV8Internal::indexedPropertySetter(index, v8Value, info); 1180 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1181 } 1182 1183 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) 1184 { 1185 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1186 DeleteResult result = impl->anonymousIndexedDeleter(index); 1187 if (result != DeleteUnknownProperty) 1188 return v8SetReturnValueBool(info, result == DeleteSuccess); 1189 } 1190 1191 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) 1192 { 1193 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); 1194 TestInterfaceImplementationV8Internal::indexedPropertyDeleter(index, info); 1195 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1196 } 1197 1198 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 1199 { 1200 if (info.Holder()->HasRealNamedProperty(name)) 1201 return; 1202 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) 1203 return; 1204 1205 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1206 AtomicString propertyName = toCoreAtomicString(name); 1207 String result = impl->anonymousNamedGetter(propertyName); 1208 if (result.isNull()) 1209 return; 1210 v8SetReturnValueString(info, result, info.GetIsolate()); 1211 } 1212 1213 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 1214 { 1215 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 1216 TestInterfaceImplementationV8Internal::namedPropertyGetter(name, info); 1217 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1218 } 1219 1220 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 1221 { 1222 if (info.Holder()->HasRealNamedProperty(name)) 1223 return; 1224 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) 1225 return; 1226 1227 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1228 TOSTRING_VOID(V8StringResource<>, propertyName, name); 1229 TOSTRING_VOID(V8StringResource<>, propertyValue, v8Value); 1230 bool result = impl->anonymousNamedSetter(propertyName, propertyValue); 1231 if (!result) 1232 return; 1233 v8SetReturnValue(info, v8Value); 1234 } 1235 1236 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 1237 { 1238 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 1239 TestInterfaceImplementationV8Internal::namedPropertySetter(name, v8Value, info); 1240 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1241 } 1242 1243 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info) 1244 { 1245 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1246 AtomicString propertyName = toCoreAtomicString(name); 1247 v8::String::Utf8Value namedProperty(name); 1248 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestInterface", info.Holder(), info.GetIsolate()); 1249 bool result = impl->namedPropertyQuery(propertyName, exceptionState); 1250 if (exceptionState.throwIfNeeded()) 1251 return; 1252 if (!result) 1253 return; 1254 v8SetReturnValueInt(info, v8::None); 1255 } 1256 1257 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info) 1258 { 1259 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 1260 TestInterfaceImplementationV8Internal::namedPropertyQuery(name, info); 1261 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1262 } 1263 1264 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) 1265 { 1266 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1267 AtomicString propertyName = toCoreAtomicString(name); 1268 DeleteResult result = impl->anonymousNamedDeleter(propertyName); 1269 if (result != DeleteUnknownProperty) 1270 return v8SetReturnValueBool(info, result == DeleteSuccess); 1271 } 1272 1273 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) 1274 { 1275 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 1276 TestInterfaceImplementationV8Internal::namedPropertyDeleter(name, info); 1277 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1278 } 1279 1280 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) 1281 { 1282 TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder()); 1283 v8::Isolate* isolate = info.GetIsolate(); 1284 Vector<String> names; 1285 ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestInterface", info.Holder(), isolate); 1286 impl->namedPropertyEnumerator(names, exceptionState); 1287 if (exceptionState.throwIfNeeded()) 1288 return; 1289 v8::Handle<v8::Array> v8names = v8::Array::New(isolate, names.size()); 1290 for (size_t i = 0; i < names.size(); ++i) 1291 v8names->Set(v8::Integer::New(isolate, i), v8String(isolate, names[i])); 1292 v8SetReturnValue(info, v8names); 1293 } 1294 1295 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info) 1296 { 1297 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 1298 TestInterfaceImplementationV8Internal::namedPropertyEnumerator(info); 1299 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 1300 } 1301 1302 } // namespace TestInterfaceImplementationV8Internal 1303 1304 void V8TestInterface::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) 1305 { 1306 TestInterfaceImplementation* impl = fromInternalPointer(object); 1307 v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate, wrapper); 1308 V8WrapperInstantiationScope scope(creationContext, isolate); 1309 TestInterfaceImplementation* referencedName = impl->referencedName(); 1310 if (referencedName) { 1311 if (!DOMDataStore::containsWrapper<V8TestInterface>(referencedName, isolate)) 1312 wrap(referencedName, creationContext, isolate); 1313 DOMDataStore::setWrapperReference<V8TestInterface>(wrapper, referencedName, isolate); 1314 } 1315 setObjectGroup(object, wrapper, isolate); 1316 } 1317 1318 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceAttributes[] = { 1319 {"testInterfaceAttribute", TestInterfaceImplementationV8Internal::testInterfaceAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::testInterfaceAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1320 {"testInterfaceConstructorAttribute", TestInterfaceImplementationV8Internal::TestInterfaceImplementationConstructorGetter, TestInterfaceImplementationV8Internal::TestInterfaceImplementationReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8TestInterface::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */}, 1321 {"doubleAttribute", TestInterfaceImplementationV8Internal::doubleAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::doubleAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1322 {"floatAttribute", TestInterfaceImplementationV8Internal::floatAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::floatAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1323 {"unrestrictedDoubleAttribute", TestInterfaceImplementationV8Internal::unrestrictedDoubleAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::unrestrictedDoubleAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1324 {"unrestrictedFloatAttribute", TestInterfaceImplementationV8Internal::unrestrictedFloatAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::unrestrictedFloatAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1325 {"implementsReadonlyStringAttribute", TestInterfaceImplementationV8Internal::implementsReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1326 {"implementsStringAttribute", TestInterfaceImplementationV8Internal::implementsStringAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implementsStringAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1327 {"implementsNodeAttribute", TestInterfaceImplementationV8Internal::implementsNodeAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implementsNodeAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1328 {"implementsEventHandlerAttribute", TestInterfaceImplementationV8Internal::implementsEventHandlerAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implementsEventHandlerAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1329 {"implements3StringAttribute", TestInterfaceImplementationV8Internal::implements3StringAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implements3StringAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 1330 }; 1331 1332 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceMethods[] = { 1333 {"voidMethodTestInterfaceEmptyArg", TestInterfaceImplementationV8Internal::voidMethodTestInterfaceEmptyArgMethodCallback, 0, 1}, 1334 {"voidMethodDoubleArgFloatArg", TestInterfaceImplementationV8Internal::voidMethodDoubleArgFloatArgMethodCallback, 0, 2}, 1335 {"voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", TestInterfaceImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback, 0, 2}, 1336 {"voidMethod", TestInterfaceImplementationV8Internal::voidMethodMethodCallback, TestInterfaceImplementationV8Internal::voidMethodMethodCallbackForMainWorld, 0}, 1337 {"implementsVoidMethod", TestInterfaceImplementationV8Internal::implementsVoidMethodMethodCallback, 0, 0}, 1338 {"implementsComplexMethod", TestInterfaceImplementationV8Internal::implementsComplexMethodMethodCallback, 0, 2}, 1339 {"implementsCustomVoidMethod", TestInterfaceImplementationV8Internal::implementsCustomVoidMethodMethodCallback, 0, 0}, 1340 {"implements3VoidMethod", TestInterfaceImplementationV8Internal::implements3VoidMethodMethodCallback, 0, 0}, 1341 }; 1342 1343 static void configureV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) 1344 { 1345 functionTemplate->ReadOnlyPrototype(); 1346 1347 v8::Local<v8::Signature> defaultSignature; 1348 if (!RuntimeEnabledFeatures::featureNameEnabled()) 1349 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "", V8TestInterfaceEmpty::domTemplate(isolate), V8TestInterface::internalFieldCount, 0, 0, 0, 0, 0, 0, isolate); 1350 else 1351 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterface", V8TestInterfaceEmpty::domTemplate(isolate), V8TestInterface::internalFieldCount, 1352 V8TestInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceAttributes), 1353 0, 0, 1354 V8TestInterfaceMethods, WTF_ARRAY_LENGTH(V8TestInterfaceMethods), 1355 isolate); 1356 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate(); 1357 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate(); 1358 if (RuntimeEnabledFeatures::implementsFeatureNameEnabled()) { 1359 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 1360 {"implementsRuntimeEnabledNodeAttribute", TestInterfaceImplementationV8Internal::implementsRuntimeEnabledNodeAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implementsRuntimeEnabledNodeAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 1361 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 1362 } 1363 if (RuntimeEnabledFeatures::implements2FeatureNameEnabled()) { 1364 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 1365 {"implements2StringAttribute", TestInterfaceImplementationV8Internal::implements2StringAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implements2StringAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 1366 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 1367 } 1368 #if ENABLE(PARTIAL_CONDITION) 1369 if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) { 1370 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 1371 {"partialLongAttribute", TestInterfaceImplementationV8Internal::partialLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partialLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 1372 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 1373 } 1374 #endif // ENABLE(PARTIAL_CONDITION) 1375 #if ENABLE(PARTIAL_CONDITION) 1376 if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) { 1377 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 1378 {"partialCallWithExecutionContextLongAttribute", TestInterfaceImplementationV8Internal::partialCallWithExecutionContextLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partialCallWithExecutionContextLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 1379 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 1380 } 1381 #endif // ENABLE(PARTIAL_CONDITION) 1382 #if ENABLE(PARTIAL_CONDITION) 1383 if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) { 1384 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 1385 {"partialPartialEnumTypeAttribute", TestInterfaceImplementationV8Internal::partialPartialEnumTypeAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partialPartialEnumTypeAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 1386 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 1387 } 1388 #endif // ENABLE(PARTIAL_CONDITION) 1389 static const V8DOMConfiguration::ConstantConfiguration V8TestInterfaceConstants[] = { 1390 {"UNSIGNED_LONG", 0}, 1391 {"CONST_JAVASCRIPT", 1}, 1392 {"IMPLEMENTS_CONSTANT_1", 1}, 1393 {"IMPLEMENTS_CONSTANT_2", 2}, 1394 {"PARTIAL2_UNSIGNED_SHORT", 0}, 1395 }; 1396 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate); 1397 if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) { 1398 static const V8DOMConfiguration::ConstantConfiguration constantConfiguration = {"PARTIAL_UNSIGNED_SHORT", static_cast<signed int>(0)}; 1399 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, &constantConfiguration, 1, isolate); 1400 } 1401 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestInterfaceImplementationV8Internal::indexedPropertyGetterCallback, TestInterfaceImplementationV8Internal::indexedPropertySetterCallback, 0, TestInterfaceImplementationV8Internal::indexedPropertyDeleterCallback, indexedPropertyEnumerator<TestInterfaceImplementation>); 1402 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestInterfaceImplementationV8Internal::namedPropertyGetterCallback, TestInterfaceImplementationV8Internal::namedPropertySetterCallback, TestInterfaceImplementationV8Internal::namedPropertyQueryCallback, TestInterfaceImplementationV8Internal::namedPropertyDeleterCallback, TestInterfaceImplementationV8Internal::namedPropertyEnumeratorCallback); 1403 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler(V8TestInterface::legacyCallCustom); 1404 functionTemplate->Set(v8AtomicString(isolate, "implementsStaticVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::implementsStaticVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0)); 1405 if (RuntimeEnabledFeatures::implements2FeatureNameEnabled()) { 1406 prototypeTemplate->Set(v8AtomicString(isolate, "implements2VoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::implements2VoidMethodMethodCallback, v8Undefined(), defaultSignature, 0)); 1407 } 1408 functionTemplate->Set(v8AtomicString(isolate, "implements3StaticVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::implements3StaticVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0)); 1409 #if ENABLE(PARTIAL_CONDITION) 1410 if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) { 1411 prototypeTemplate->Set(v8AtomicString(isolate, "partialVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::partialVoidMethodMethodCallback, v8Undefined(), defaultSignature, 0)); 1412 } 1413 #endif // ENABLE(PARTIAL_CONDITION) 1414 #if ENABLE(PARTIAL_CONDITION) 1415 if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) { 1416 functionTemplate->Set(v8AtomicString(isolate, "partialStaticVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::partialStaticVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0)); 1417 } 1418 #endif // ENABLE(PARTIAL_CONDITION) 1419 #if ENABLE(PARTIAL_CONDITION) 1420 if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) { 1421 prototypeTemplate->Set(v8AtomicString(isolate, "partialVoidMethodLongArg"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::partialVoidMethodLongArgMethodCallback, v8Undefined(), defaultSignature, 1)); 1422 } 1423 #endif // ENABLE(PARTIAL_CONDITION) 1424 #if ENABLE(PARTIAL_CONDITION) 1425 if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) { 1426 prototypeTemplate->Set(v8AtomicString(isolate, "partialCallWithExecutionContextRaisesExceptionVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::partialCallWithExecutionContextRaisesExceptionVoidMethodMethodCallback, v8Undefined(), defaultSignature, 0)); 1427 } 1428 #endif // ENABLE(PARTIAL_CONDITION) 1429 #if ENABLE(PARTIAL_CONDITION) 1430 if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) { 1431 prototypeTemplate->Set(v8AtomicString(isolate, "partialVoidMethodPartialCallbackTypeArg"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::partialVoidMethodPartialCallbackTypeArgMethodCallback, v8Undefined(), defaultSignature, 1)); 1432 } 1433 #endif // ENABLE(PARTIAL_CONDITION) 1434 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "staticStringAttribute"), TestInterfaceImplementationV8Internal::staticStringAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::staticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 1435 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implementsStaticReadOnlyLongAttribute"), TestInterfaceImplementationV8Internal::implementsStaticReadOnlyLongAttributeAttributeGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 1436 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implementsStaticStringAttribute"), TestInterfaceImplementationV8Internal::implementsStaticStringAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implementsStaticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 1437 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implements2StaticStringAttribute"), TestInterfaceImplementationV8Internal::implements2StaticStringAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implements2StaticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 1438 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implements3StaticStringAttribute"), TestInterfaceImplementationV8Internal::implements3StaticStringAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implements3StaticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 1439 #if ENABLE(PARTIAL_CONDITION) 1440 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "partialStaticLongAttribute"), TestInterfaceImplementationV8Internal::partialStaticLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partialStaticLongAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 1441 #endif // ENABLE(PARTIAL_CONDITION) 1442 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "partial2StaticLongAttribute"), TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 1443 1444 // Custom toString template 1445 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); 1446 } 1447 1448 v8::Handle<v8::FunctionTemplate> V8TestInterface::domTemplate(v8::Isolate* isolate) 1449 { 1450 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), configureV8TestInterfaceTemplate); 1451 } 1452 1453 bool V8TestInterface::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 1454 { 1455 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); 1456 } 1457 1458 v8::Handle<v8::Object> V8TestInterface::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 1459 { 1460 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); 1461 } 1462 1463 TestInterfaceImplementation* V8TestInterface::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) 1464 { 1465 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0; 1466 } 1467 1468 void V8TestInterface::installPerContextEnabledProperties(v8::Handle<v8::Object> instanceTemplate, TestInterfaceImplementation* impl, v8::Isolate* isolate) 1469 { 1470 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instanceTemplate->GetPrototype()); 1471 if (ContextFeatures::implementsContextNameEnabled(impl->document())) { 1472 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 1473 {"implementsPerContextEnabledNodeAttribute", TestInterfaceImplementationV8Internal::implementsPerContextEnabledNodeAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implementsPerContextEnabledNodeAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 1474 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 1475 } 1476 if (ContextFeatures::partialContextNameEnabled(impl->document())) { 1477 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 1478 {"partial2LongAttribute", TestInterfaceImplementationV8Internal::partial2LongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partial2LongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 1479 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 1480 } 1481 if (ContextFeatures::partialContextNameEnabled(impl->document())) { 1482 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 1483 {"partial2StaticLongAttribute", TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 1484 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 1485 } 1486 } 1487 1488 void V8TestInterface::installPerContextEnabledMethods(v8::Handle<v8::Object> prototypeTemplate, v8::Isolate* isolate) 1489 { 1490 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domTemplate(isolate)); 1491 1492 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationContext()); 1493 if (context && context->isDocument() && ContextFeatures::partialContextNameEnabled(toDocument(context))) 1494 prototypeTemplate->Set(v8AtomicString(isolate, "partial2VoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::partial2VoidMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); 1495 if (context && context->isDocument() && ContextFeatures::partialContextNameEnabled(toDocument(context))) 1496 prototypeTemplate->Set(v8AtomicString(isolate, "partial2StaticVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::partial2StaticVoidMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); 1497 } 1498 1499 ActiveDOMObject* V8TestInterface::toActiveDOMObject(v8::Handle<v8::Object> wrapper) 1500 { 1501 return toNative(wrapper); 1502 } 1503 1504 void V8TestInterface::derefObject(void* object) 1505 { 1506 fromInternalPointer(object)->deref(); 1507 } 1508 1509 template<> 1510 v8::Handle<v8::Value> toV8NoInline(TestInterfaceImplementation* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 1511 { 1512 return toV8(impl, creationContext, isolate); 1513 } 1514 1515 } // namespace WebCore 1516 #endif // ENABLE(CONDITION) 1517