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 "V8TestInterface5.h" 10 11 #include "bindings/core/v8/ExceptionState.h" 12 #include "bindings/core/v8/ScriptState.h" 13 #include "bindings/core/v8/V8DOMConfiguration.h" 14 #include "bindings/core/v8/V8HiddenValue.h" 15 #include "bindings/core/v8/V8Iterator.h" 16 #include "bindings/core/v8/V8ObjectConstructor.h" 17 #include "bindings/core/v8/V8TestInterfaceEmpty.h" 18 #include "bindings/modules/v8/V8TestInterface5.h" 19 #include "core/dom/ContextFeatures.h" 20 #include "core/dom/Document.h" 21 #include "platform/RuntimeEnabledFeatures.h" 22 #include "platform/TraceEvent.h" 23 #include "wtf/GetPtr.h" 24 #include "wtf/RefPtr.h" 25 26 namespace blink { 27 28 const WrapperTypeInfo V8TestInterface5::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface5::domTemplate, V8TestInterface5::refObject, V8TestInterface5::derefObject, V8TestInterface5::createPersistentHandle, V8TestInterface5::toActiveDOMObject, 0, V8TestInterface5::visitDOMWrapper, V8TestInterface5::installConditionallyEnabledMethods, V8TestInterface5::installConditionallyEnabledProperties, &V8TestInterfaceEmpty::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCountedObject }; 29 30 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterface5Implementation.h. 31 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in 32 // bindings/core/v8/ScriptWrappable.h. 33 const WrapperTypeInfo& TestInterface5Implementation::s_wrapperTypeInfo = V8TestInterface5::wrapperTypeInfo; 34 35 namespace TestInterface5ImplementationV8Internal { 36 37 template <typename T> void V8_USE(T) { } 38 39 static void testInterfaceAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 40 { 41 v8::Handle<v8::Object> holder = info.Holder(); 42 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 43 v8SetReturnValueFast(info, WTF::getPtr(impl->testInterfaceAttribute()), impl); 44 } 45 46 static void testInterfaceAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 47 { 48 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 49 TestInterface5ImplementationV8Internal::testInterfaceAttributeAttributeGetter(info); 50 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 51 } 52 53 static void testInterfaceAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 54 { 55 v8::Handle<v8::Object> holder = info.Holder(); 56 ExceptionState exceptionState(ExceptionState::SetterContext, "testInterfaceAttribute", "TestInterface5", holder, info.GetIsolate()); 57 if (!V8TestInterface5::hasInstance(v8Value, info.GetIsolate())) { 58 exceptionState.throwTypeError("The provided value is not of type 'TestInterface5'."); 59 exceptionState.throwIfNeeded(); 60 return; 61 } 62 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 63 TestInterface5Implementation* cppValue = V8TestInterface5::toImplWithTypeCheck(info.GetIsolate(), v8Value); 64 impl->setTestInterfaceAttribute(WTF::getPtr(cppValue)); 65 } 66 67 static void testInterfaceAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 68 { 69 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 70 TestInterface5ImplementationV8Internal::testInterfaceAttributeAttributeSetter(v8Value, info); 71 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 72 } 73 74 static void doubleAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 75 { 76 v8::Handle<v8::Object> holder = info.Holder(); 77 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 78 v8SetReturnValue(info, impl->doubleAttribute()); 79 } 80 81 static void doubleAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 82 { 83 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 84 TestInterface5ImplementationV8Internal::doubleAttributeAttributeGetter(info); 85 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 86 } 87 88 static void doubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 89 { 90 v8::Handle<v8::Object> holder = info.Holder(); 91 ExceptionState exceptionState(ExceptionState::SetterContext, "doubleAttribute", "TestInterface5", holder, info.GetIsolate()); 92 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 93 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState); 94 if (!std::isfinite(cppValue)) { 95 exceptionState.throwTypeError("The provided double value is non-finite."); 96 exceptionState.throwIfNeeded(); 97 return; 98 } 99 impl->setDoubleAttribute(cppValue); 100 } 101 102 static void doubleAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 103 { 104 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 105 TestInterface5ImplementationV8Internal::doubleAttributeAttributeSetter(v8Value, info); 106 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 107 } 108 109 static void floatAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 110 { 111 v8::Handle<v8::Object> holder = info.Holder(); 112 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 113 v8SetReturnValue(info, impl->floatAttribute()); 114 } 115 116 static void floatAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 117 { 118 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 119 TestInterface5ImplementationV8Internal::floatAttributeAttributeGetter(info); 120 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 121 } 122 123 static void floatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 124 { 125 v8::Handle<v8::Object> holder = info.Holder(); 126 ExceptionState exceptionState(ExceptionState::SetterContext, "floatAttribute", "TestInterface5", holder, info.GetIsolate()); 127 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 128 TONATIVE_VOID_EXCEPTIONSTATE(float, cppValue, toFloat(v8Value, exceptionState), exceptionState); 129 if (!std::isfinite(cppValue)) { 130 exceptionState.throwTypeError("The provided float value is non-finite."); 131 exceptionState.throwIfNeeded(); 132 return; 133 } 134 impl->setFloatAttribute(cppValue); 135 } 136 137 static void floatAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 138 { 139 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 140 TestInterface5ImplementationV8Internal::floatAttributeAttributeSetter(v8Value, info); 141 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 142 } 143 144 static void unrestrictedDoubleAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 145 { 146 v8::Handle<v8::Object> holder = info.Holder(); 147 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 148 v8SetReturnValue(info, impl->unrestrictedDoubleAttribute()); 149 } 150 151 static void unrestrictedDoubleAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 152 { 153 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 154 TestInterface5ImplementationV8Internal::unrestrictedDoubleAttributeAttributeGetter(info); 155 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 156 } 157 158 static void unrestrictedDoubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 159 { 160 v8::Handle<v8::Object> holder = info.Holder(); 161 ExceptionState exceptionState(ExceptionState::SetterContext, "unrestrictedDoubleAttribute", "TestInterface5", holder, info.GetIsolate()); 162 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 163 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState); 164 impl->setUnrestrictedDoubleAttribute(cppValue); 165 } 166 167 static void unrestrictedDoubleAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 168 { 169 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 170 TestInterface5ImplementationV8Internal::unrestrictedDoubleAttributeAttributeSetter(v8Value, info); 171 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 172 } 173 174 static void unrestrictedFloatAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 175 { 176 v8::Handle<v8::Object> holder = info.Holder(); 177 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 178 v8SetReturnValue(info, impl->unrestrictedFloatAttribute()); 179 } 180 181 static void unrestrictedFloatAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 182 { 183 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 184 TestInterface5ImplementationV8Internal::unrestrictedFloatAttributeAttributeGetter(info); 185 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 186 } 187 188 static void unrestrictedFloatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 189 { 190 v8::Handle<v8::Object> holder = info.Holder(); 191 ExceptionState exceptionState(ExceptionState::SetterContext, "unrestrictedFloatAttribute", "TestInterface5", holder, info.GetIsolate()); 192 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 193 TONATIVE_VOID_EXCEPTIONSTATE(float, cppValue, toFloat(v8Value, exceptionState), exceptionState); 194 impl->setUnrestrictedFloatAttribute(cppValue); 195 } 196 197 static void unrestrictedFloatAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 198 { 199 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 200 TestInterface5ImplementationV8Internal::unrestrictedFloatAttributeAttributeSetter(v8Value, info); 201 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 202 } 203 204 static void staticStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 205 { 206 v8SetReturnValueString(info, TestInterface5Implementation::staticStringAttribute(), info.GetIsolate()); 207 } 208 209 static void staticStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 210 { 211 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 212 TestInterface5ImplementationV8Internal::staticStringAttributeAttributeGetter(info); 213 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 214 } 215 216 static void staticStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 217 { 218 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); 219 TestInterface5Implementation::setStaticStringAttribute(cppValue); 220 } 221 222 static void staticStringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 223 { 224 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 225 TestInterface5ImplementationV8Internal::staticStringAttributeAttributeSetter(v8Value, info); 226 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 227 } 228 229 static void alwaysExposedAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 230 { 231 v8::Handle<v8::Object> holder = info.Holder(); 232 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 233 v8SetReturnValueInt(info, impl->alwaysExposedAttribute()); 234 } 235 236 static void alwaysExposedAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 237 { 238 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 239 TestInterface5ImplementationV8Internal::alwaysExposedAttributeAttributeGetter(info); 240 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 241 } 242 243 static void alwaysExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 244 { 245 v8::Handle<v8::Object> holder = info.Holder(); 246 ExceptionState exceptionState(ExceptionState::SetterContext, "alwaysExposedAttribute", "TestInterface5", holder, info.GetIsolate()); 247 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 248 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 249 impl->setAlwaysExposedAttribute(cppValue); 250 } 251 252 static void alwaysExposedAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 253 { 254 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 255 TestInterface5ImplementationV8Internal::alwaysExposedAttributeAttributeSetter(v8Value, info); 256 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 257 } 258 259 static void workerExposedAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 260 { 261 v8::Handle<v8::Object> holder = info.Holder(); 262 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 263 v8SetReturnValueInt(info, impl->workerExposedAttribute()); 264 } 265 266 static void workerExposedAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 267 { 268 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 269 TestInterface5ImplementationV8Internal::workerExposedAttributeAttributeGetter(info); 270 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 271 } 272 273 static void workerExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 274 { 275 v8::Handle<v8::Object> holder = info.Holder(); 276 ExceptionState exceptionState(ExceptionState::SetterContext, "workerExposedAttribute", "TestInterface5", holder, info.GetIsolate()); 277 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 278 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 279 impl->setWorkerExposedAttribute(cppValue); 280 } 281 282 static void workerExposedAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 283 { 284 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 285 TestInterface5ImplementationV8Internal::workerExposedAttributeAttributeSetter(v8Value, info); 286 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 287 } 288 289 static void windowExposedAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 290 { 291 v8::Handle<v8::Object> holder = info.Holder(); 292 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 293 v8SetReturnValueInt(info, impl->windowExposedAttribute()); 294 } 295 296 static void windowExposedAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 297 { 298 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 299 TestInterface5ImplementationV8Internal::windowExposedAttributeAttributeGetter(info); 300 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 301 } 302 303 static void windowExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 304 { 305 v8::Handle<v8::Object> holder = info.Holder(); 306 ExceptionState exceptionState(ExceptionState::SetterContext, "windowExposedAttribute", "TestInterface5", holder, info.GetIsolate()); 307 TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder); 308 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 309 impl->setWindowExposedAttribute(cppValue); 310 } 311 312 static void windowExposedAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 313 { 314 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 315 TestInterface5ImplementationV8Internal::windowExposedAttributeAttributeSetter(v8Value, info); 316 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 317 } 318 319 static void TestInterface5ImplementationConstructorGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 320 { 321 v8::Handle<v8::Value> data = info.Data(); 322 ASSERT(data->IsExternal()); 323 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext()); 324 if (!perContextData) 325 return; 326 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::unwrap(data))); 327 } 328 329 static void TestInterface5ImplementationForceSetAttributeOnThis(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 330 { 331 if (info.This()->IsObject()) 332 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); 333 } 334 335 static void TestInterface5ImplementationForceSetAttributeOnThisCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 336 { 337 TestInterface5ImplementationV8Internal::TestInterface5ImplementationForceSetAttributeOnThis(name, v8Value, info); 338 } 339 340 static void voidMethodTestInterfaceEmptyArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 341 { 342 if (UNLIKELY(info.Length() < 1)) { 343 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("voidMethodTestInterfaceEmptyArg", "TestInterface5", 1, info.Length(), info.GetIsolate()), info.GetIsolate()); 344 return; 345 } 346 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 347 TestInterfaceEmpty* testInterfaceEmptyArg; 348 { 349 if (info.Length() > 0 && !V8TestInterfaceEmpty::hasInstance(info[0], info.GetIsolate())) { 350 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute("voidMethodTestInterfaceEmptyArg", "TestInterface5", "parameter 1 is not of type 'TestInterfaceEmpty'."), info.GetIsolate()); 351 return; 352 } 353 testInterfaceEmptyArg = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[0]); 354 } 355 impl->voidMethodTestInterfaceEmptyArg(testInterfaceEmptyArg); 356 } 357 358 static void voidMethodTestInterfaceEmptyArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 359 { 360 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 361 TestInterface5ImplementationV8Internal::voidMethodTestInterfaceEmptyArgMethod(info); 362 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 363 } 364 365 static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 366 { 367 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodDoubleArgFloatArg", "TestInterface5", info.Holder(), info.GetIsolate()); 368 if (UNLIKELY(info.Length() < 2)) { 369 setMinimumArityTypeError(exceptionState, 2, info.Length()); 370 exceptionState.throwIfNeeded(); 371 return; 372 } 373 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 374 double doubleArg; 375 float floatArg; 376 { 377 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(doubleArg, toDouble(info[0], exceptionState), exceptionState); 378 if (!std::isfinite(doubleArg)) { 379 exceptionState.throwTypeError("double parameter 1 is non-finite."); 380 exceptionState.throwIfNeeded(); 381 return; 382 } 383 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(floatArg, toFloat(info[1], exceptionState), exceptionState); 384 if (!std::isfinite(floatArg)) { 385 exceptionState.throwTypeError("float parameter 2 is non-finite."); 386 exceptionState.throwIfNeeded(); 387 return; 388 } 389 } 390 impl->voidMethodDoubleArgFloatArg(doubleArg, floatArg); 391 } 392 393 static void voidMethodDoubleArgFloatArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 394 { 395 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 396 TestInterface5ImplementationV8Internal::voidMethodDoubleArgFloatArgMethod(info); 397 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 398 } 399 400 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 401 { 402 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", "TestInterface5", info.Holder(), info.GetIsolate()); 403 if (UNLIKELY(info.Length() < 2)) { 404 setMinimumArityTypeError(exceptionState, 2, info.Length()); 405 exceptionState.throwIfNeeded(); 406 return; 407 } 408 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 409 double unrestrictedDoubleArg; 410 float unrestrictedFloatArg; 411 { 412 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(unrestrictedDoubleArg, toDouble(info[0], exceptionState), exceptionState); 413 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(unrestrictedFloatArg, toFloat(info[1], exceptionState), exceptionState); 414 } 415 impl->voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg(unrestrictedDoubleArg, unrestrictedFloatArg); 416 } 417 418 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 419 { 420 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 421 TestInterface5ImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(info); 422 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 423 } 424 425 static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 426 { 427 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 428 impl->voidMethod(); 429 } 430 431 static void voidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 432 { 433 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 434 TestInterface5ImplementationV8Internal::voidMethodMethod(info); 435 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 436 } 437 438 static void voidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info) 439 { 440 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 441 impl->voidMethod(); 442 } 443 444 static void voidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info) 445 { 446 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 447 TestInterface5ImplementationV8Internal::voidMethodMethodForMainWorld(info); 448 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 449 } 450 451 static void alwaysExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 452 { 453 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 454 impl->alwaysExposedMethod(); 455 } 456 457 static void alwaysExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 458 { 459 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 460 TestInterface5ImplementationV8Internal::alwaysExposedMethodMethod(info); 461 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 462 } 463 464 static void workerExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 465 { 466 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 467 impl->workerExposedMethod(); 468 } 469 470 static void workerExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 471 { 472 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 473 TestInterface5ImplementationV8Internal::workerExposedMethodMethod(info); 474 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 475 } 476 477 static void windowExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 478 { 479 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 480 impl->windowExposedMethod(); 481 } 482 483 static void windowExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 484 { 485 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 486 TestInterface5ImplementationV8Internal::windowExposedMethodMethod(info); 487 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 488 } 489 490 static void alwaysExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 491 { 492 TestInterface5Implementation::alwaysExposedStaticMethod(); 493 } 494 495 static void alwaysExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 496 { 497 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 498 TestInterface5ImplementationV8Internal::alwaysExposedStaticMethodMethod(info); 499 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 500 } 501 502 static void workerExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 503 { 504 TestInterface5Implementation::workerExposedStaticMethod(); 505 } 506 507 static void workerExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 508 { 509 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 510 TestInterface5ImplementationV8Internal::workerExposedStaticMethodMethod(info); 511 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 512 } 513 514 static void windowExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 515 { 516 TestInterface5Implementation::windowExposedStaticMethod(); 517 } 518 519 static void windowExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 520 { 521 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 522 TestInterface5ImplementationV8Internal::windowExposedStaticMethodMethod(info); 523 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 524 } 525 526 static void windowAndServiceWorkerExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 527 { 528 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 529 impl->windowAndServiceWorkerExposedMethod(); 530 } 531 532 static void windowAndServiceWorkerExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 533 { 534 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 535 TestInterface5ImplementationV8Internal::windowAndServiceWorkerExposedMethodMethod(info); 536 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 537 } 538 539 static void toStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 540 { 541 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 542 v8SetReturnValueString(info, impl->toString(), info.GetIsolate()); 543 } 544 545 static void toStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 546 { 547 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 548 TestInterface5ImplementationV8Internal::toStringMethod(info); 549 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 550 } 551 552 static void iteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 553 { 554 ExceptionState exceptionState(ExceptionState::ExecutionContext, "iterator", "TestInterface5", info.Holder(), info.GetIsolate()); 555 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 556 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); 557 RawPtr<Iterator> result = impl->iterator(scriptState, exceptionState); 558 if (exceptionState.hadException()) { 559 exceptionState.throwIfNeeded(); 560 return; 561 } 562 v8SetReturnValue(info, result.release()); 563 } 564 565 static void iteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 566 { 567 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 568 TestInterface5ImplementationV8Internal::iteratorMethod(info); 569 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 570 } 571 572 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) 573 { 574 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 575 String result = impl->anonymousIndexedGetter(index); 576 if (result.isNull()) 577 return; 578 v8SetReturnValueString(info, result, info.GetIsolate()); 579 } 580 581 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) 582 { 583 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty"); 584 TestInterface5ImplementationV8Internal::indexedPropertyGetter(index, info); 585 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 586 } 587 588 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 589 { 590 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 591 TOSTRING_VOID(V8StringResource<>, propertyValue, v8Value); 592 bool result = impl->anonymousIndexedSetter(index, propertyValue); 593 if (!result) 594 return; 595 v8SetReturnValue(info, v8Value); 596 } 597 598 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 599 { 600 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty"); 601 TestInterface5ImplementationV8Internal::indexedPropertySetter(index, v8Value, info); 602 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 603 } 604 605 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) 606 { 607 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 608 DeleteResult result = impl->anonymousIndexedDeleter(index); 609 if (result != DeleteUnknownProperty) 610 return v8SetReturnValueBool(info, result == DeleteSuccess); 611 } 612 613 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) 614 { 615 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty"); 616 TestInterface5ImplementationV8Internal::indexedPropertyDeleter(index, info); 617 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 618 } 619 620 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 621 { 622 if (info.Holder()->HasRealNamedProperty(name)) 623 return; 624 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) 625 return; 626 627 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 628 AtomicString propertyName = toCoreAtomicString(name); 629 String result = impl->anonymousNamedGetter(propertyName); 630 if (result.isNull()) 631 return; 632 v8SetReturnValueString(info, result, info.GetIsolate()); 633 } 634 635 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 636 { 637 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 638 TestInterface5ImplementationV8Internal::namedPropertyGetter(name, info); 639 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 640 } 641 642 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 643 { 644 if (info.Holder()->HasRealNamedProperty(name)) 645 return; 646 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) 647 return; 648 649 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 650 TOSTRING_VOID(V8StringResource<>, propertyName, name); 651 TOSTRING_VOID(V8StringResource<>, propertyValue, v8Value); 652 bool result = impl->anonymousNamedSetter(propertyName, propertyValue); 653 if (!result) 654 return; 655 v8SetReturnValue(info, v8Value); 656 } 657 658 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 659 { 660 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 661 TestInterface5ImplementationV8Internal::namedPropertySetter(name, v8Value, info); 662 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 663 } 664 665 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info) 666 { 667 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 668 AtomicString propertyName = toCoreAtomicString(name); 669 v8::String::Utf8Value namedProperty(name); 670 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestInterface5", info.Holder(), info.GetIsolate()); 671 bool result = impl->namedPropertyQuery(propertyName, exceptionState); 672 if (exceptionState.throwIfNeeded()) 673 return; 674 if (!result) 675 return; 676 v8SetReturnValueInt(info, v8::None); 677 } 678 679 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info) 680 { 681 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 682 TestInterface5ImplementationV8Internal::namedPropertyQuery(name, info); 683 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 684 } 685 686 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) 687 { 688 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 689 AtomicString propertyName = toCoreAtomicString(name); 690 DeleteResult result = impl->anonymousNamedDeleter(propertyName); 691 if (result != DeleteUnknownProperty) 692 return v8SetReturnValueBool(info, result == DeleteSuccess); 693 } 694 695 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) 696 { 697 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 698 TestInterface5ImplementationV8Internal::namedPropertyDeleter(name, info); 699 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 700 } 701 702 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) 703 { 704 TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); 705 Vector<String> names; 706 ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestInterface5", info.Holder(), info.GetIsolate()); 707 impl->namedPropertyEnumerator(names, exceptionState); 708 if (exceptionState.throwIfNeeded()) 709 return; 710 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size()); 711 for (size_t i = 0; i < names.size(); ++i) 712 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIsolate(), names[i])); 713 v8SetReturnValue(info, v8names); 714 } 715 716 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info) 717 { 718 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 719 TestInterface5ImplementationV8Internal::namedPropertyEnumerator(info); 720 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 721 } 722 723 } // namespace TestInterface5ImplementationV8Internal 724 725 void V8TestInterface5::visitDOMWrapper(ScriptWrappableBase* internalPointer, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) 726 { 727 TestInterface5Implementation* impl = internalPointer->toImpl<TestInterface5Implementation>(); 728 v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate, wrapper); 729 V8WrapperInstantiationScope scope(creationContext, isolate); 730 TestInterface5Implementation* referencedName = impl->referencedName(); 731 if (referencedName) { 732 if (!DOMDataStore::containsWrapper<V8TestInterface5>(referencedName, isolate)) 733 wrap(referencedName, creationContext, isolate); 734 DOMDataStore::setWrapperReference<V8TestInterface5>(wrapper, referencedName, isolate); 735 } 736 setObjectGroup(internalPointer, wrapper, isolate); 737 } 738 739 static const V8DOMConfiguration::AttributeConfiguration V8TestInterface5Attributes[] = { 740 {"testInterfaceAttribute", TestInterface5ImplementationV8Internal::testInterfaceAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::testInterfaceAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 741 {"testInterfaceConstructorAttribute", TestInterface5ImplementationV8Internal::TestInterface5ImplementationConstructorGetter, TestInterface5ImplementationV8Internal::TestInterface5ImplementationForceSetAttributeOnThisCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8TestInterface5::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 742 {"doubleAttribute", TestInterface5ImplementationV8Internal::doubleAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::doubleAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 743 {"floatAttribute", TestInterface5ImplementationV8Internal::floatAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::floatAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 744 {"unrestrictedDoubleAttribute", TestInterface5ImplementationV8Internal::unrestrictedDoubleAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::unrestrictedDoubleAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 745 {"unrestrictedFloatAttribute", TestInterface5ImplementationV8Internal::unrestrictedFloatAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::unrestrictedFloatAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 746 {"alwaysExposedAttribute", TestInterface5ImplementationV8Internal::alwaysExposedAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::alwaysExposedAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 747 }; 748 749 static const V8DOMConfiguration::MethodConfiguration V8TestInterface5Methods[] = { 750 {"voidMethodTestInterfaceEmptyArg", TestInterface5ImplementationV8Internal::voidMethodTestInterfaceEmptyArgMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, 751 {"voidMethodDoubleArgFloatArg", TestInterface5ImplementationV8Internal::voidMethodDoubleArgFloatArgMethodCallback, 0, 2, V8DOMConfiguration::ExposedToAllScripts}, 752 {"voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", TestInterface5ImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback, 0, 2, V8DOMConfiguration::ExposedToAllScripts}, 753 {"voidMethod", TestInterface5ImplementationV8Internal::voidMethodMethodCallback, TestInterface5ImplementationV8Internal::voidMethodMethodCallbackForMainWorld, 0, V8DOMConfiguration::ExposedToAllScripts}, 754 {"alwaysExposedMethod", TestInterface5ImplementationV8Internal::alwaysExposedMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts}, 755 }; 756 757 static void installV8TestInterface5Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) 758 { 759 functionTemplate->ReadOnlyPrototype(); 760 761 v8::Local<v8::Signature> defaultSignature; 762 if (!RuntimeEnabledFeatures::featureNameEnabled()) 763 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "", V8TestInterfaceEmpty::domTemplate(isolate), V8TestInterface5::internalFieldCount, 0, 0, 0, 0, 0, 0, isolate); 764 else 765 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterface5", V8TestInterfaceEmpty::domTemplate(isolate), V8TestInterface5::internalFieldCount, 766 V8TestInterface5Attributes, WTF_ARRAY_LENGTH(V8TestInterface5Attributes), 767 0, 0, 768 V8TestInterface5Methods, WTF_ARRAY_LENGTH(V8TestInterface5Methods), 769 isolate); 770 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate(); 771 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate(); 772 static const V8DOMConfiguration::ConstantConfiguration V8TestInterface5Constants[] = { 773 {"UNSIGNED_LONG", 0, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedLong}, 774 {"CONST_JAVASCRIPT", 1, 0, 0, V8DOMConfiguration::ConstantTypeShort}, 775 }; 776 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8TestInterface5Constants, WTF_ARRAY_LENGTH(V8TestInterface5Constants), isolate); 777 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestInterface5ImplementationV8Internal::indexedPropertyGetterCallback, TestInterface5ImplementationV8Internal::indexedPropertySetterCallback, 0, TestInterface5ImplementationV8Internal::indexedPropertyDeleterCallback, indexedPropertyEnumerator<TestInterface5Implementation>); 778 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestInterface5ImplementationV8Internal::namedPropertyGetterCallback, TestInterface5ImplementationV8Internal::namedPropertySetterCallback, TestInterface5ImplementationV8Internal::namedPropertyQueryCallback, TestInterface5ImplementationV8Internal::namedPropertyDeleterCallback, TestInterface5ImplementationV8Internal::namedPropertyEnumeratorCallback); 779 static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, TestInterface5ImplementationV8Internal::iteratorMethodCallback, 0, V8DOMConfiguration::ExposedToAllScripts }; 780 V8DOMConfiguration::installMethod(prototypeTemplate, defaultSignature, v8::DontDelete, symbolKeyedIteratorConfiguration, isolate); 781 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler(V8TestInterface5::legacyCallCustom); 782 static const V8DOMConfiguration::MethodConfiguration alwaysExposedStaticMethodMethodConfiguration = { 783 "alwaysExposedStaticMethod", TestInterface5ImplementationV8Internal::alwaysExposedStaticMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts, 784 }; 785 V8DOMConfiguration::installMethod(functionTemplate, v8::Local<v8::Signature>(), v8::None, alwaysExposedStaticMethodMethodConfiguration, isolate); 786 static const V8DOMConfiguration::MethodConfiguration toStringMethodConfiguration = { 787 "toString", TestInterface5ImplementationV8Internal::toStringMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts, 788 }; 789 V8DOMConfiguration::installMethod(prototypeTemplate, defaultSignature, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::DontEnum), toStringMethodConfiguration, isolate); 790 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "staticStringAttribute"), TestInterface5ImplementationV8Internal::staticStringAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::staticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 791 792 // Custom toString template 793 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); 794 } 795 796 v8::Handle<v8::FunctionTemplate> V8TestInterface5::domTemplate(v8::Isolate* isolate) 797 { 798 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterface5Template); 799 } 800 801 bool V8TestInterface5::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 802 { 803 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); 804 } 805 806 v8::Handle<v8::Object> V8TestInterface5::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 807 { 808 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); 809 } 810 811 TestInterface5Implementation* V8TestInterface5::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) 812 { 813 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterface5Implementation>() : 0; 814 } 815 816 void V8TestInterface5::installConditionallyEnabledProperties(v8::Handle<v8::Object> instanceObject, v8::Isolate* isolate) 817 { 818 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instanceObject->GetPrototype()); 819 ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext()); 820 821 if (context && (context->isWorkerGlobalScope())) { 822 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 823 {"workerExposedAttribute", TestInterface5ImplementationV8Internal::workerExposedAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::workerExposedAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}; 824 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attributeConfiguration, isolate); 825 } 826 if (context && (context->isDocument())) { 827 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 828 {"windowExposedAttribute", TestInterface5ImplementationV8Internal::windowExposedAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::windowExposedAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}; 829 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attributeConfiguration, isolate); 830 } 831 } 832 833 void V8TestInterface5::installConditionallyEnabledMethods(v8::Handle<v8::Object> prototypeObject, v8::Isolate* isolate) 834 { 835 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domTemplate(isolate)); 836 ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext()); 837 ASSERT(context); 838 839 if (context && (context->isWorkerGlobalScope())) { 840 prototypeObject->Set(v8AtomicString(isolate, "workerExposedMethod"), v8::FunctionTemplate::New(isolate, TestInterface5ImplementationV8Internal::workerExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); 841 } 842 if (context && (context->isDocument())) { 843 prototypeObject->Set(v8AtomicString(isolate, "windowExposedMethod"), v8::FunctionTemplate::New(isolate, TestInterface5ImplementationV8Internal::windowExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); 844 } 845 if (context && (context->isWorkerGlobalScope())) { 846 prototypeObject->Set(v8AtomicString(isolate, "workerExposedStaticMethod"), v8::FunctionTemplate::New(isolate, TestInterface5ImplementationV8Internal::workerExposedStaticMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); 847 } 848 if (context && (context->isDocument())) { 849 prototypeObject->Set(v8AtomicString(isolate, "windowExposedStaticMethod"), v8::FunctionTemplate::New(isolate, TestInterface5ImplementationV8Internal::windowExposedStaticMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); 850 } 851 if (context && (context->isDocument() || context->isServiceWorkerGlobalScope())) { 852 prototypeObject->Set(v8AtomicString(isolate, "windowAndServiceWorkerExposedMethod"), v8::FunctionTemplate::New(isolate, TestInterface5ImplementationV8Internal::windowAndServiceWorkerExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction()); 853 } 854 } 855 856 ActiveDOMObject* V8TestInterface5::toActiveDOMObject(v8::Handle<v8::Object> wrapper) 857 { 858 return toImpl(wrapper); 859 } 860 861 862 void V8TestInterface5::refObject(ScriptWrappableBase* internalPointer) 863 { 864 internalPointer->toImpl<TestInterface5Implementation>()->ref(); 865 } 866 867 void V8TestInterface5::derefObject(ScriptWrappableBase* internalPointer) 868 { 869 internalPointer->toImpl<TestInterface5Implementation>()->deref(); 870 } 871 872 WrapperPersistentNode* V8TestInterface5::createPersistentHandle(ScriptWrappableBase* internalPointer) 873 { 874 ASSERT_NOT_REACHED(); 875 return 0; 876 } 877 878 template<> 879 v8::Handle<v8::Value> toV8NoInline(TestInterface5Implementation* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 880 { 881 return toV8(impl, creationContext, isolate); 882 } 883 884 } // namespace blink 885 #endif // ENABLE(CONDITION) 886