| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 282 |
| 283 static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | 283 static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 284 { | 284 { |
| 285 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 285 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 286 TestTypedefsV8Internal::funcMethod(info); | 286 TestTypedefsV8Internal::funcMethod(info); |
| 287 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 287 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 288 } | 288 } |
| 289 | 289 |
| 290 static void setShadowMethod(const v8::FunctionCallbackInfo<v8::Value>& info) | 290 static void setShadowMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 291 { | 291 { |
| 292 if (UNLIKELY(info.Length() < 3)) { | 292 if (info.Length() < 3) { |
| 293 throwTypeError(ExceptionMessages::failedToExecute("setShadow", "TestType
defs", ExceptionMessages::notEnoughArguments(3, info.Length())), info.GetIsolate
()); | 293 throwTypeError(ExceptionMessages::failedToExecute("setShadow", "TestType
defs", ExceptionMessages::notEnoughArguments(3, info.Length())), info.GetIsolate
()); |
| 294 return; | 294 return; |
| 295 } | 295 } |
| 296 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); | 296 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); |
| 297 V8TRYCATCH_VOID(float, width, static_cast<float>(info[0]->NumberValue())); | 297 V8TRYCATCH_VOID(float, width, static_cast<float>(info[0]->NumberValue())); |
| 298 V8TRYCATCH_VOID(float, height, static_cast<float>(info[1]->NumberValue())); | 298 V8TRYCATCH_VOID(float, height, static_cast<float>(info[1]->NumberValue())); |
| 299 V8TRYCATCH_VOID(float, blur, static_cast<float>(info[2]->NumberValue())); | 299 V8TRYCATCH_VOID(float, blur, static_cast<float>(info[2]->NumberValue())); |
| 300 if (UNLIKELY(info.Length() <= 3)) { | 300 if (UNLIKELY(info.Length() <= 3)) { |
| 301 imp->setShadow(width, height, blur); | 301 imp->setShadow(width, height, blur); |
| 302 return; | 302 return; |
| 303 } | 303 } |
| 304 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, color, info[3]); | 304 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, color, info[3]); |
| 305 if (UNLIKELY(info.Length() <= 4)) { | 305 if (UNLIKELY(info.Length() <= 4)) { |
| 306 imp->setShadow(width, height, blur, color); | 306 imp->setShadow(width, height, blur, color); |
| 307 return; | 307 return; |
| 308 } | 308 } |
| 309 V8TRYCATCH_VOID(float, alpha, static_cast<float>(info[4]->NumberValue())); | 309 V8TRYCATCH_VOID(float, alpha, static_cast<float>(info[4]->NumberValue())); |
| 310 imp->setShadow(width, height, blur, color, alpha); | 310 imp->setShadow(width, height, blur, color, alpha); |
| 311 } | 311 } |
| 312 | 312 |
| 313 static void setShadowMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) | 313 static void setShadowMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) |
| 314 { | 314 { |
| 315 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 315 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 316 TestTypedefsV8Internal::setShadowMethod(info); | 316 TestTypedefsV8Internal::setShadowMethod(info); |
| 317 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 317 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 318 } | 318 } |
| 319 | 319 |
| 320 static void methodWithSequenceArgMethod(const v8::FunctionCallbackInfo<v8::Value
>& info) | 320 static void methodWithSequenceArgMethod(const v8::FunctionCallbackInfo<v8::Value
>& info) |
| 321 { | 321 { |
| 322 if (UNLIKELY(info.Length() < 1)) { | 322 if (info.Length() < 1) { |
| 323 throwTypeError(ExceptionMessages::failedToExecute("methodWithSequenceArg
", "TestTypedefs", ExceptionMessages::notEnoughArguments(1, info.Length())), inf
o.GetIsolate()); | 323 throwTypeError(ExceptionMessages::failedToExecute("methodWithSequenceArg
", "TestTypedefs", ExceptionMessages::notEnoughArguments(1, info.Length())), inf
o.GetIsolate()); |
| 324 return; | 324 return; |
| 325 } | 325 } |
| 326 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); | 326 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); |
| 327 V8TRYCATCH_VOID(Vector<RefPtr<SerializedScriptValue> >, sequenceArg, (toRefP
trNativeArray<SerializedScriptValue, V8SerializedScriptValue>(info[0], 1, info.G
etIsolate()))); | 327 V8TRYCATCH_VOID(Vector<RefPtr<SerializedScriptValue> >, sequenceArg, (toRefP
trNativeArray<SerializedScriptValue, V8SerializedScriptValue>(info[0], 1, info.G
etIsolate()))); |
| 328 v8SetReturnValue(info, static_cast<double>(imp->methodWithSequenceArg(sequen
ceArg))); | 328 v8SetReturnValue(info, static_cast<double>(imp->methodWithSequenceArg(sequen
ceArg))); |
| 329 } | 329 } |
| 330 | 330 |
| 331 static void methodWithSequenceArgMethodCallback(const v8::FunctionCallbackInfo<v
8::Value>& info) | 331 static void methodWithSequenceArgMethodCallback(const v8::FunctionCallbackInfo<v
8::Value>& info) |
| 332 { | 332 { |
| 333 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 333 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 334 TestTypedefsV8Internal::methodWithSequenceArgMethod(info); | 334 TestTypedefsV8Internal::methodWithSequenceArgMethod(info); |
| 335 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 335 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 336 } | 336 } |
| 337 | 337 |
| 338 static void nullableArrayArgMethod(const v8::FunctionCallbackInfo<v8::Value>& in
fo) | 338 static void nullableArrayArgMethod(const v8::FunctionCallbackInfo<v8::Value>& in
fo) |
| 339 { | 339 { |
| 340 if (UNLIKELY(info.Length() < 1)) { | 340 if (info.Length() < 1) { |
| 341 throwTypeError(ExceptionMessages::failedToExecute("nullableArrayArg", "T
estTypedefs", ExceptionMessages::notEnoughArguments(1, info.Length())), info.Get
Isolate()); | 341 throwTypeError(ExceptionMessages::failedToExecute("nullableArrayArg", "T
estTypedefs", ExceptionMessages::notEnoughArguments(1, info.Length())), info.Get
Isolate()); |
| 342 return; | 342 return; |
| 343 } | 343 } |
| 344 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); | 344 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); |
| 345 bool arrayArgIsNull = info[0]->IsNull(); | 345 bool arrayArgIsNull = info[0]->IsNull(); |
| 346 V8TRYCATCH_VOID(Vector<String>, arrayArg, toNativeArray<String>(info[0], 1,
info.GetIsolate())); | 346 V8TRYCATCH_VOID(Vector<String>, arrayArg, toNativeArray<String>(info[0], 1,
info.GetIsolate())); |
| 347 imp->nullableArrayArg(arrayArgIsNull ? 0 : &arrayArg); | 347 imp->nullableArrayArg(arrayArgIsNull ? 0 : &arrayArg); |
| 348 } | 348 } |
| 349 | 349 |
| 350 static void nullableArrayArgMethodCallback(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 350 static void nullableArrayArgMethodCallback(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 363 static void immutablePointFunctionMethodCallback(const v8::FunctionCallbackInfo<
v8::Value>& info) | 363 static void immutablePointFunctionMethodCallback(const v8::FunctionCallbackInfo<
v8::Value>& info) |
| 364 { | 364 { |
| 365 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 365 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 366 TestTypedefsV8Internal::immutablePointFunctionMethod(info); | 366 TestTypedefsV8Internal::immutablePointFunctionMethod(info); |
| 367 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 367 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 368 } | 368 } |
| 369 | 369 |
| 370 static void stringArrayFunctionMethod(const v8::FunctionCallbackInfo<v8::Value>&
info) | 370 static void stringArrayFunctionMethod(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 371 { | 371 { |
| 372 ExceptionState exceptionState(ExceptionState::ExecutionContext, "stringArray
Function", "TestTypedefs", info.Holder(), info.GetIsolate()); | 372 ExceptionState exceptionState(ExceptionState::ExecutionContext, "stringArray
Function", "TestTypedefs", info.Holder(), info.GetIsolate()); |
| 373 if (UNLIKELY(info.Length() < 1)) { | 373 if (info.Length() < 1) { |
| 374 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | 374 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
| 375 exceptionState.throwIfNeeded(); | 375 exceptionState.throwIfNeeded(); |
| 376 return; | 376 return; |
| 377 } | 377 } |
| 378 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); | 378 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); |
| 379 V8TRYCATCH_VOID(Vector<String>, values, toNativeArray<String>(info[0], 1, in
fo.GetIsolate())); | 379 V8TRYCATCH_VOID(Vector<String>, values, toNativeArray<String>(info[0], 1, in
fo.GetIsolate())); |
| 380 Vector<String> result = imp->stringArrayFunction(values, exceptionState); | 380 Vector<String> result = imp->stringArrayFunction(values, exceptionState); |
| 381 if (exceptionState.throwIfNeeded()) | 381 if (exceptionState.throwIfNeeded()) |
| 382 return; | 382 return; |
| 383 v8SetReturnValue(info, v8Array(result, info.GetIsolate())); | 383 v8SetReturnValue(info, v8Array(result, info.GetIsolate())); |
| 384 } | 384 } |
| 385 | 385 |
| 386 static void stringArrayFunctionMethodCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) | 386 static void stringArrayFunctionMethodCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) |
| 387 { | 387 { |
| 388 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 388 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 389 TestTypedefsV8Internal::stringArrayFunctionMethod(info); | 389 TestTypedefsV8Internal::stringArrayFunctionMethod(info); |
| 390 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 390 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 391 } | 391 } |
| 392 | 392 |
| 393 static void stringArrayFunction2Method(const v8::FunctionCallbackInfo<v8::Value>
& info) | 393 static void stringArrayFunction2Method(const v8::FunctionCallbackInfo<v8::Value>
& info) |
| 394 { | 394 { |
| 395 ExceptionState exceptionState(ExceptionState::ExecutionContext, "stringArray
Function2", "TestTypedefs", info.Holder(), info.GetIsolate()); | 395 ExceptionState exceptionState(ExceptionState::ExecutionContext, "stringArray
Function2", "TestTypedefs", info.Holder(), info.GetIsolate()); |
| 396 if (UNLIKELY(info.Length() < 1)) { | 396 if (info.Length() < 1) { |
| 397 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | 397 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
| 398 exceptionState.throwIfNeeded(); | 398 exceptionState.throwIfNeeded(); |
| 399 return; | 399 return; |
| 400 } | 400 } |
| 401 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); | 401 TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); |
| 402 V8TRYCATCH_VOID(Vector<String>, values, toNativeArray<String>(info[0], 1, in
fo.GetIsolate())); | 402 V8TRYCATCH_VOID(Vector<String>, values, toNativeArray<String>(info[0], 1, in
fo.GetIsolate())); |
| 403 Vector<String> result = imp->stringArrayFunction2(values, exceptionState); | 403 Vector<String> result = imp->stringArrayFunction2(values, exceptionState); |
| 404 if (exceptionState.throwIfNeeded()) | 404 if (exceptionState.throwIfNeeded()) |
| 405 return; | 405 return; |
| 406 v8SetReturnValue(info, v8Array(result, info.GetIsolate())); | 406 v8SetReturnValue(info, v8Array(result, info.GetIsolate())); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 424 | 424 |
| 425 static void methodWithExceptionMethodCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) | 425 static void methodWithExceptionMethodCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) |
| 426 { | 426 { |
| 427 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 427 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 428 TestTypedefsV8Internal::methodWithExceptionMethod(info); | 428 TestTypedefsV8Internal::methodWithExceptionMethod(info); |
| 429 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 429 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 430 } | 430 } |
| 431 | 431 |
| 432 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | 432 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 433 { | 433 { |
| 434 if (UNLIKELY(info.Length() < 2)) { | 434 if (info.Length() < 2) { |
| 435 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestTy
pedefs", ExceptionMessages::notEnoughArguments(2, info.Length())), info.GetIsola
te()); | 435 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestTy
pedefs", ExceptionMessages::notEnoughArguments(2, info.Length())), info.GetIsola
te()); |
| 436 return; | 436 return; |
| 437 } | 437 } |
| 438 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, hello, info[0]); | 438 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, hello, info[0]); |
| 439 if (info.Length() <= 1 || !info[1]->IsFunction()) { | 439 if (info.Length() <= 1 || !info[1]->IsFunction()) { |
| 440 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestTy
pedefs", "The callback provided as parameter 2 is not a function."), info.GetIso
late()); | 440 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestTy
pedefs", "The callback provided as parameter 2 is not a function."), info.GetIso
late()); |
| 441 return; | 441 return; |
| 442 } | 442 } |
| 443 OwnPtr<TestCallbackInterface> testCallbackInterface = V8TestCallbackInterfac
e::create(v8::Handle<v8::Function>::Cast(info[1]), getExecutionContext()); | 443 OwnPtr<TestCallbackInterface> testCallbackInterface = V8TestCallbackInterfac
e::create(v8::Handle<v8::Function>::Cast(info[1]), getExecutionContext()); |
| 444 RefPtr<TestTypedefs> impl = TestTypedefs::create(hello, testCallbackInterfac
e); | 444 RefPtr<TestTypedefs> impl = TestTypedefs::create(hello, testCallbackInterfac
e); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 fromInternalPointer(object)->deref(); | 559 fromInternalPointer(object)->deref(); |
| 560 } | 560 } |
| 561 | 561 |
| 562 template<> | 562 template<> |
| 563 v8::Handle<v8::Value> toV8NoInline(TestTypedefs* impl, v8::Handle<v8::Object> cr
eationContext, v8::Isolate* isolate) | 563 v8::Handle<v8::Value> toV8NoInline(TestTypedefs* impl, v8::Handle<v8::Object> cr
eationContext, v8::Isolate* isolate) |
| 564 { | 564 { |
| 565 return toV8(impl, creationContext, isolate); | 565 return toV8(impl, creationContext, isolate); |
| 566 } | 566 } |
| 567 | 567 |
| 568 } // namespace WebCore | 568 } // namespace WebCore |
| OLD | NEW |