| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 static void supplementalMethod2Method(const v8::FunctionCallbackInfo<v8::Value>&
info) | 319 static void supplementalMethod2Method(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 320 { | 320 { |
| 321 ExceptionState exceptionState(ExceptionState::ExecutionContext, "supplementa
lMethod2", "SupportTestInterface", info.Holder(), info.GetIsolate()); | 321 ExceptionState exceptionState(ExceptionState::ExecutionContext, "supplementa
lMethod2", "SupportTestInterface", info.Holder(), info.GetIsolate()); |
| 322 if (UNLIKELY(info.Length() < 2)) { | 322 if (UNLIKELY(info.Length() < 2)) { |
| 323 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); | 323 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); |
| 324 exceptionState.throwIfNeeded(); | 324 exceptionState.throwIfNeeded(); |
| 325 return; | 325 return; |
| 326 } | 326 } |
| 327 SupportTestInterface* imp = V8SupportTestInterface::toNative(info.Holder()); | 327 SupportTestInterface* imp = V8SupportTestInterface::toNative(info.Holder()); |
| 328 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); | 328 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); |
| 329 V8TRYCATCH_VOID(TestObj*, objArg, V8TestObject::hasInstance(info[1], info.Ge
tIsolate(), worldType(info.GetIsolate())) ? V8TestObject::toNative(v8::Handle<v8
::Object>::Cast(info[1])) : 0); | 329 if (info.Length() <= 1 || !info[1]->IsFunction()) { |
| 330 throwTypeError(ExceptionMessages::failedToExecute("supplementalMethod2",
"SupportTestInterface", "The callback provided as parameter 2 is not a function
."), info.GetIsolate()); |
| 331 return; |
| 332 } |
| 333 OwnPtr<TestObject> objArg = V8TestObject::create(v8::Handle<v8::Function>::C
ast(info[1]), getExecutionContext()); |
| 330 ExecutionContext* scriptContext = getExecutionContext(); | 334 ExecutionContext* scriptContext = getExecutionContext(); |
| 331 RefPtr<TestObj> result = SupportTestPartialInterface::supplementalMethod2(sc
riptContext, imp, strArg, objArg, exceptionState); | 335 RefPtr<TestObj> result = SupportTestPartialInterface::supplementalMethod2(sc
riptContext, imp, strArg, objArg.release(), exceptionState); |
| 332 if (exceptionState.throwIfNeeded()) | 336 if (exceptionState.throwIfNeeded()) |
| 333 return; | 337 return; |
| 334 v8SetReturnValue(info, result.release()); | 338 v8SetReturnValue(info, result.release()); |
| 335 } | 339 } |
| 336 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 340 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 337 | 341 |
| 338 #if ENABLE(Condition11) || ENABLE(Condition12) | 342 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 339 static void supplementalMethod2MethodCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) | 343 static void supplementalMethod2MethodCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) |
| 340 { | 344 { |
| 341 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 345 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 #if ENABLE(Condition11) || ENABLE(Condition12) | 388 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 385 {"supplementalNode", SupportTestInterfaceV8Internal::supplementalNodeAttribu
teGetterCallback, SupportTestInterfaceV8Internal::supplementalNodeAttributeSette
rCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8:
:PropertyAttribute>(v8::None), 0 /* on instance */}, | 389 {"supplementalNode", SupportTestInterfaceV8Internal::supplementalNodeAttribu
teGetterCallback, SupportTestInterfaceV8Internal::supplementalNodeAttributeSette
rCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8:
:PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 386 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 390 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 387 }; | 391 }; |
| 388 | 392 |
| 389 static const V8DOMConfiguration::MethodConfiguration V8SupportTestInterfaceMetho
ds[] = { | 393 static const V8DOMConfiguration::MethodConfiguration V8SupportTestInterfaceMetho
ds[] = { |
| 390 #if ENABLE(Condition11) || ENABLE(Condition12) | 394 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 391 {"supplementalMethod1", SupportTestInterfaceV8Internal::supplementalMethod1M
ethodCallback, 0, 0}, | 395 {"supplementalMethod1", SupportTestInterfaceV8Internal::supplementalMethod1M
ethodCallback, 0, 0}, |
| 392 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 396 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 393 #if ENABLE(Condition11) || ENABLE(Condition12) | 397 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 398 {"supplementalMethod2", SupportTestInterfaceV8Internal::supplementalMethod2M
ethodCallback, 0, 2}, |
| 399 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 400 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 394 {"supplementalMethod3", SupportTestInterfaceV8Internal::supplementalMethod3M
ethodCallback, 0, 0}, | 401 {"supplementalMethod3", SupportTestInterfaceV8Internal::supplementalMethod3M
ethodCallback, 0, 0}, |
| 395 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 402 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 396 }; | 403 }; |
| 397 | 404 |
| 398 static v8::Handle<v8::FunctionTemplate> ConfigureV8SupportTestInterfaceTemplate(
v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, Wrapper
WorldType currentWorldType) | 405 static v8::Handle<v8::FunctionTemplate> ConfigureV8SupportTestInterfaceTemplate(
v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, Wrapper
WorldType currentWorldType) |
| 399 { | 406 { |
| 400 functionTemplate->ReadOnlyPrototype(); | 407 functionTemplate->ReadOnlyPrototype(); |
| 401 | 408 |
| 402 v8::Local<v8::Signature> defaultSignature; | 409 v8::Local<v8::Signature> defaultSignature; |
| 403 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "SupportTestInterface", v8::Local<v8::FunctionTemplate>(), V8SupportTestInt
erface::internalFieldCount, | 410 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "SupportTestInterface", v8::Local<v8::FunctionTemplate>(), V8SupportTestInt
erface::internalFieldCount, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 415 } | 422 } |
| 416 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 423 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 417 static const V8DOMConfiguration::ConstantConfiguration V8SupportTestInterfac
eConstants[] = { | 424 static const V8DOMConfiguration::ConstantConfiguration V8SupportTestInterfac
eConstants[] = { |
| 418 {"SUPPLEMENTALCONSTANT1", 1}, | 425 {"SUPPLEMENTALCONSTANT1", 1}, |
| 419 {"SUPPLEMENTALCONSTANT2", 2}, | 426 {"SUPPLEMENTALCONSTANT2", 2}, |
| 420 }; | 427 }; |
| 421 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8
SupportTestInterfaceConstants, WTF_ARRAY_LENGTH(V8SupportTestInterfaceConstants)
, isolate); | 428 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8
SupportTestInterfaceConstants, WTF_ARRAY_LENGTH(V8SupportTestInterfaceConstants)
, isolate); |
| 422 COMPILE_ASSERT(1 == SupportTestPartialInterface::SUPPLEMENTALCONSTANT1, TheV
alueOfSupportTestInterface_SUPPLEMENTALCONSTANT1DoesntMatchWithImplementation); | 429 COMPILE_ASSERT(1 == SupportTestPartialInterface::SUPPLEMENTALCONSTANT1, TheV
alueOfSupportTestInterface_SUPPLEMENTALCONSTANT1DoesntMatchWithImplementation); |
| 423 COMPILE_ASSERT(2 == SupportTestPartialInterface::CONST_IMPL, TheValueOfSuppo
rtTestInterface_CONST_IMPLDoesntMatchWithImplementation); | 430 COMPILE_ASSERT(2 == SupportTestPartialInterface::CONST_IMPL, TheValueOfSuppo
rtTestInterface_CONST_IMPLDoesntMatchWithImplementation); |
| 424 #if ENABLE(Condition11) || ENABLE(Condition12) | 431 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 425 | |
| 426 // Custom Signature 'supplementalMethod2' | |
| 427 const int supplementalMethod2Argc = 2; | |
| 428 v8::Handle<v8::FunctionTemplate> supplementalMethod2Argv[supplementalMethod2
Argc] = { v8::Handle<v8::FunctionTemplate>(), V8PerIsolateData::from(isolate)->r
awDOMTemplate(&V8TestObject::wrapperTypeInfo, currentWorldType) }; | |
| 429 v8::Handle<v8::Signature> supplementalMethod2Signature = v8::Signature::New(
isolate, functionTemplate, supplementalMethod2Argc, supplementalMethod2Argv); | |
| 430 prototypeTemplate->Set(v8::String::NewFromUtf8(isolate, "supplementalMethod2
", v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, SupportT
estInterfaceV8Internal::supplementalMethod2MethodCallback, v8Undefined(), supple
mentalMethod2Signature, 2)); | |
| 431 #endif // ENABLE(Condition11) || ENABLE(Condition12) | |
| 432 #if ENABLE(Condition11) || ENABLE(Condition12) | |
| 433 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "supplementalMethod4"
, v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, SupportTe
stInterfaceV8Internal::supplementalMethod4MethodCallback, v8Undefined(), v8::Loc
al<v8::Signature>(), 0)); | 432 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "supplementalMethod4"
, v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, SupportTe
stInterfaceV8Internal::supplementalMethod4MethodCallback, v8Undefined(), v8::Loc
al<v8::Signature>(), 0)); |
| 434 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 433 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 435 #if ENABLE(Condition11) || ENABLE(Condition12) | 434 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 436 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "su
pplementalStaticReadOnlyAttr", v8::String::kInternalizedString), SupportTestInte
rfaceV8Internal::supplementalStaticReadOnlyAttrAttributeGetterCallback, 0, v8::E
xternal::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Hand
le<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); | 435 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "su
pplementalStaticReadOnlyAttr", v8::String::kInternalizedString), SupportTestInte
rfaceV8Internal::supplementalStaticReadOnlyAttrAttributeGetterCallback, 0, v8::E
xternal::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Hand
le<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); |
| 437 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 436 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 438 #if ENABLE(Condition11) || ENABLE(Condition12) | 437 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 439 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "su
pplementalStaticAttr", v8::String::kInternalizedString), SupportTestInterfaceV8I
nternal::supplementalStaticAttrAttributeGetterCallback, SupportTestInterfaceV8In
ternal::supplementalStaticAttrAttributeSetterCallback, v8::External::New(isolate
, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSigna
ture>(), static_cast<v8::AccessControl>(v8::DEFAULT)); | 438 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "su
pplementalStaticAttr", v8::String::kInternalizedString), SupportTestInterfaceV8I
nternal::supplementalStaticAttrAttributeGetterCallback, SupportTestInterfaceV8In
ternal::supplementalStaticAttrAttributeSetterCallback, v8::External::New(isolate
, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSigna
ture>(), static_cast<v8::AccessControl>(v8::DEFAULT)); |
| 440 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 439 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 441 | 440 |
| 442 // Custom toString template | 441 // Custom toString template |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 fromInternalPointer(object)->deref(); | 505 fromInternalPointer(object)->deref(); |
| 507 } | 506 } |
| 508 | 507 |
| 509 template<> | 508 template<> |
| 510 v8::Handle<v8::Value> toV8NoInline(SupportTestInterface* impl, v8::Handle<v8::Ob
ject> creationContext, v8::Isolate* isolate) | 509 v8::Handle<v8::Value> toV8NoInline(SupportTestInterface* impl, v8::Handle<v8::Ob
ject> creationContext, v8::Isolate* isolate) |
| 511 { | 510 { |
| 512 return toV8(impl, creationContext, isolate); | 511 return toV8(impl, creationContext, isolate); |
| 513 } | 512 } |
| 514 | 513 |
| 515 } // namespace WebCore | 514 } // namespace WebCore |
| OLD | NEW |