| 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 3072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3083 { | 3083 { |
| 3084 ExceptionState exceptionState(ExceptionState::ExecutionContext, "methodThatR
equiresAllArgsAndThrows", "TestObject", info.Holder(), info.GetIsolate()); | 3084 ExceptionState exceptionState(ExceptionState::ExecutionContext, "methodThatR
equiresAllArgsAndThrows", "TestObject", info.Holder(), info.GetIsolate()); |
| 3085 if (UNLIKELY(info.Length() < 2)) { | 3085 if (UNLIKELY(info.Length() < 2)) { |
| 3086 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); | 3086 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); |
| 3087 exceptionState.throwIfNeeded(); | 3087 exceptionState.throwIfNeeded(); |
| 3088 return; | 3088 return; |
| 3089 } | 3089 } |
| 3090 TestObj* imp = V8TestObject::toNative(info.Holder()); | 3090 TestObj* imp = V8TestObject::toNative(info.Holder()); |
| 3091 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); | 3091 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); |
| 3092 if (info.Length() <= 1 || !info[1]->IsFunction()) { | 3092 if (info.Length() <= 1 || !info[1]->IsFunction()) { |
| 3093 throwTypeError(ExceptionMessages::failedToExecute("methodThatRequiresAll
ArgsAndThrows", "TestObject", "The callback provided as parameter 2 is not a fun
ction."), info.GetIsolate()); | 3093 exceptionState.throwTypeError("The callback provided as parameter 2 is n
ot a function."); |
| 3094 exceptionState.throwIfNeeded(); |
| 3094 return; | 3095 return; |
| 3095 } | 3096 } |
| 3096 OwnPtr<TestObject> objArg = V8TestObject::create(v8::Handle<v8::Function>::C
ast(info[1]), getExecutionContext()); | 3097 OwnPtr<TestObject> objArg = V8TestObject::create(v8::Handle<v8::Function>::C
ast(info[1]), getExecutionContext()); |
| 3097 RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, obj
Arg.release(), exceptionState); | 3098 RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, obj
Arg.release(), exceptionState); |
| 3098 if (exceptionState.throwIfNeeded()) | 3099 if (exceptionState.throwIfNeeded()) |
| 3099 return; | 3100 return; |
| 3100 v8SetReturnValue(info, result.release()); | 3101 v8SetReturnValue(info, result.release()); |
| 3101 } | 3102 } |
| 3102 | 3103 |
| 3103 static void methodThatRequiresAllArgsAndThrowsMethodCallback(const v8::FunctionC
allbackInfo<v8::Value>& info) | 3104 static void methodThatRequiresAllArgsAndThrowsMethodCallback(const v8::FunctionC
allbackInfo<v8::Value>& info) |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3639 { | 3640 { |
| 3640 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 3641 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 3641 TestObjV8Internal::methodWithNonCallbackArgAndCallbackInterfaceArgMethod(inf
o); | 3642 TestObjV8Internal::methodWithNonCallbackArgAndCallbackInterfaceArgMethod(inf
o); |
| 3642 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 3643 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 3643 } | 3644 } |
| 3644 | 3645 |
| 3645 static void methodWithCallbackInterfaceAndOptionalArgMethod(const v8::FunctionCa
llbackInfo<v8::Value>& info) | 3646 static void methodWithCallbackInterfaceAndOptionalArgMethod(const v8::FunctionCa
llbackInfo<v8::Value>& info) |
| 3646 { | 3647 { |
| 3647 TestObj* imp = V8TestObject::toNative(info.Holder()); | 3648 TestObj* imp = V8TestObject::toNative(info.Holder()); |
| 3648 OwnPtr<TestCallbackInterface> callbackInterface; | 3649 OwnPtr<TestCallbackInterface> callbackInterface; |
| 3649 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) { | 3650 if (info.Length() > 0 && !isUndefinedOrNull(info[0])) { |
| 3650 if (!info[0]->IsFunction()) { | 3651 if (!info[0]->IsFunction()) { |
| 3651 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbac
kInterfaceAndOptionalArg", "TestObject", "The callback provided as parameter 1 i
s not a function."), info.GetIsolate()); | 3652 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbac
kInterfaceAndOptionalArg", "TestObject", "The callback provided as parameter 1 i
s not a function."), info.GetIsolate()); |
| 3652 return; | 3653 return; |
| 3653 } | 3654 } |
| 3654 callbackInterface = V8TestCallbackInterface::create(v8::Handle<v8::Funct
ion>::Cast(info[0]), getExecutionContext()); | 3655 callbackInterface = V8TestCallbackInterface::create(v8::Handle<v8::Funct
ion>::Cast(info[0]), getExecutionContext()); |
| 3655 } | 3656 } |
| 3656 imp->methodWithCallbackInterfaceAndOptionalArg(callbackInterface.release()); | 3657 imp->methodWithCallbackInterfaceAndOptionalArg(callbackInterface.release()); |
| 3657 } | 3658 } |
| 3658 | 3659 |
| 3659 static void methodWithCallbackInterfaceAndOptionalArgMethodCallback(const v8::Fu
nctionCallbackInfo<v8::Value>& info) | 3660 static void methodWithCallbackInterfaceAndOptionalArgMethodCallback(const v8::Fu
nctionCallbackInfo<v8::Value>& info) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3681 static void methodWithNullableCallbackInterfaceArgMethodCallback(const v8::Funct
ionCallbackInfo<v8::Value>& info) | 3682 static void methodWithNullableCallbackInterfaceArgMethodCallback(const v8::Funct
ionCallbackInfo<v8::Value>& info) |
| 3682 { | 3683 { |
| 3683 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 3684 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 3684 TestObjV8Internal::methodWithNullableCallbackInterfaceArgMethod(info); | 3685 TestObjV8Internal::methodWithNullableCallbackInterfaceArgMethod(info); |
| 3685 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 3686 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 3686 } | 3687 } |
| 3687 | 3688 |
| 3688 static void staticMethodWithCallbackAndOptionalArgMethod(const v8::FunctionCallb
ackInfo<v8::Value>& info) | 3689 static void staticMethodWithCallbackAndOptionalArgMethod(const v8::FunctionCallb
ackInfo<v8::Value>& info) |
| 3689 { | 3690 { |
| 3690 OwnPtr<TestCallbackInterface> callbackInterface; | 3691 OwnPtr<TestCallbackInterface> callbackInterface; |
| 3691 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) { | 3692 if (info.Length() > 0 && !isUndefinedOrNull(info[0])) { |
| 3692 if (!info[0]->IsFunction()) { | 3693 if (!info[0]->IsFunction()) { |
| 3693 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithC
allbackAndOptionalArg", "TestObject", "The callback provided as parameter 1 is n
ot a function."), info.GetIsolate()); | 3694 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithC
allbackAndOptionalArg", "TestObject", "The callback provided as parameter 1 is n
ot a function."), info.GetIsolate()); |
| 3694 return; | 3695 return; |
| 3695 } | 3696 } |
| 3696 callbackInterface = V8TestCallbackInterface::create(v8::Handle<v8::Funct
ion>::Cast(info[0]), getExecutionContext()); | 3697 callbackInterface = V8TestCallbackInterface::create(v8::Handle<v8::Funct
ion>::Cast(info[0]), getExecutionContext()); |
| 3697 } | 3698 } |
| 3698 TestObj::staticMethodWithCallbackAndOptionalArg(callbackInterface.release())
; | 3699 TestObj::staticMethodWithCallbackAndOptionalArg(callbackInterface.release())
; |
| 3699 } | 3700 } |
| 3700 | 3701 |
| 3701 static void staticMethodWithCallbackAndOptionalArgMethodCallback(const v8::Funct
ionCallbackInfo<v8::Value>& info) | 3702 static void staticMethodWithCallbackAndOptionalArgMethodCallback(const v8::Funct
ionCallbackInfo<v8::Value>& info) |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4138 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); | 4139 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); |
| 4139 imp->overloadedMethodB(strArg); | 4140 imp->overloadedMethodB(strArg); |
| 4140 } | 4141 } |
| 4141 | 4142 |
| 4142 static void overloadedMethodBMethod(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) | 4143 static void overloadedMethodBMethod(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) |
| 4143 { | 4144 { |
| 4144 if (((info.Length() == 1))) { | 4145 if (((info.Length() == 1))) { |
| 4145 overloadedMethodB1Method(info); | 4146 overloadedMethodB1Method(info); |
| 4146 return; | 4147 return; |
| 4147 } | 4148 } |
| 4148 if (((info.Length() == 1) && (info[0]->IsNull() || info[0]->IsUndefined() ||
info[0]->IsString() || info[0]->IsObject()))) { | 4149 if (((info.Length() == 1) && (isUndefinedOrNull(info[0]) || info[0]->IsStrin
g() || info[0]->IsObject()))) { |
| 4149 overloadedMethodB2Method(info); | 4150 overloadedMethodB2Method(info); |
| 4150 return; | 4151 return; |
| 4151 } | 4152 } |
| 4152 ExceptionState exceptionState(ExceptionState::ExecutionContext, "overloadedM
ethodB", "TestObject", info.Holder(), info.GetIsolate()); | 4153 ExceptionState exceptionState(ExceptionState::ExecutionContext, "overloadedM
ethodB", "TestObject", info.Holder(), info.GetIsolate()); |
| 4153 if (UNLIKELY(info.Length() < 1)) { | 4154 if (UNLIKELY(info.Length() < 1)) { |
| 4154 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | 4155 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
| 4155 exceptionState.throwIfNeeded(); | 4156 exceptionState.throwIfNeeded(); |
| 4156 return; | 4157 return; |
| 4157 } | 4158 } |
| 4158 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); | 4159 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4437 static void strictSVGPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>
& info) | 4438 static void strictSVGPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>
& info) |
| 4438 { | 4439 { |
| 4439 ExceptionState exceptionState(ExceptionState::ExecutionContext, "strictSVGPo
intMethod", "TestObject", info.Holder(), info.GetIsolate()); | 4440 ExceptionState exceptionState(ExceptionState::ExecutionContext, "strictSVGPo
intMethod", "TestObject", info.Holder(), info.GetIsolate()); |
| 4440 if (UNLIKELY(info.Length() < 2)) { | 4441 if (UNLIKELY(info.Length() < 2)) { |
| 4441 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); | 4442 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); |
| 4442 exceptionState.throwIfNeeded(); | 4443 exceptionState.throwIfNeeded(); |
| 4443 return; | 4444 return; |
| 4444 } | 4445 } |
| 4445 TestObj* imp = V8TestObject::toNative(info.Holder()); | 4446 TestObj* imp = V8TestObject::toNative(info.Holder()); |
| 4446 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8SVGPoint::hasInst
ance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { | 4447 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8SVGPoint::hasInst
ance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { |
| 4447 throwTypeError(ExceptionMessages::failedToExecute("strictSVGPointMethod"
, "TestObject", "parameter 1 is not of type 'SVGPoint'."), info.GetIsolate()); | 4448 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'."); |
| 4449 exceptionState.throwIfNeeded(); |
| 4448 return; | 4450 return; |
| 4449 } | 4451 } |
| 4450 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, item, V8SVGPoint::has
Instance(info[0], info.GetIsolate(), worldType(info.GetIsolate())) ? V8SVGPoint:
:toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0); | 4452 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, item, V8SVGPoint::has
Instance(info[0], info.GetIsolate(), worldType(info.GetIsolate())) ? V8SVGPoint:
:toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0); |
| 4451 V8TRYCATCH_VOID(unsigned, index, toUInt32(info[1])); | 4453 V8TRYCATCH_VOID(unsigned, index, toUInt32(info[1])); |
| 4452 if (!item) { | 4454 if (!item) { |
| 4453 throwTypeError(ExceptionMessages::failedToExecute("strictSVGPointMethod"
, "TestObject", "parameter 1 is not of type 'SVGPoint'."), info.GetIsolate()); | 4455 throwTypeError(ExceptionMessages::failedToExecute("strictSVGPointMethod"
, "TestObject", "parameter 1 is not of type 'SVGPoint'."), info.GetIsolate()); |
| 4454 return; | 4456 return; |
| 4455 } | 4457 } |
| 4456 SVGPoint result = imp->strictSVGPointMethod(item->propertyReference(), index
, exceptionState); | 4458 SVGPoint result = imp->strictSVGPointMethod(item->propertyReference(), index
, exceptionState); |
| 4457 if (exceptionState.throwIfNeeded()) | 4459 if (exceptionState.throwIfNeeded()) |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5435 fromInternalPointer(object)->deref(); | 5437 fromInternalPointer(object)->deref(); |
| 5436 } | 5438 } |
| 5437 | 5439 |
| 5438 template<> | 5440 template<> |
| 5439 v8::Handle<v8::Value> toV8NoInline(TestObj* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) | 5441 v8::Handle<v8::Value> toV8NoInline(TestObj* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) |
| 5440 { | 5442 { |
| 5441 return toV8(impl, creationContext, isolate); | 5443 return toV8(impl, creationContext, isolate); |
| 5442 } | 5444 } |
| 5443 | 5445 |
| 5444 } // namespace WebCore | 5446 } // namespace WebCore |
| OLD | NEW |