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 3102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3113 { | 3113 { |
3114 ExceptionState exceptionState(ExceptionState::ExecutionContext, "methodThatR
equiresAllArgsAndThrows", "TestObject", info.Holder(), info.GetIsolate()); | 3114 ExceptionState exceptionState(ExceptionState::ExecutionContext, "methodThatR
equiresAllArgsAndThrows", "TestObject", info.Holder(), info.GetIsolate()); |
3115 if (UNLIKELY(info.Length() < 2)) { | 3115 if (UNLIKELY(info.Length() < 2)) { |
3116 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); | 3116 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); |
3117 exceptionState.throwIfNeeded(); | 3117 exceptionState.throwIfNeeded(); |
3118 return; | 3118 return; |
3119 } | 3119 } |
3120 TestObj* imp = V8TestObject::toNative(info.Holder()); | 3120 TestObj* imp = V8TestObject::toNative(info.Holder()); |
3121 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); | 3121 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); |
3122 if (info.Length() <= 1 || !info[1]->IsFunction()) { | 3122 if (info.Length() <= 1 || !info[1]->IsFunction()) { |
3123 throwTypeError(ExceptionMessages::failedToExecute("methodThatRequiresAll
ArgsAndThrows", "TestObject", "The callback provided as parameter 2 is not a fun
ction."), info.GetIsolate()); | 3123 exceptionState.throwTypeError("The callback provided as parameter 2 is n
ot a function."); |
| 3124 exceptionState.throwIfNeeded(); |
3124 return; | 3125 return; |
3125 } | 3126 } |
3126 OwnPtr<TestObject> objArg = V8TestObject::create(v8::Handle<v8::Function>::C
ast(info[1]), getExecutionContext()); | 3127 OwnPtr<TestObject> objArg = V8TestObject::create(v8::Handle<v8::Function>::C
ast(info[1]), getExecutionContext()); |
3127 RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, obj
Arg.release(), exceptionState); | 3128 RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, obj
Arg.release(), exceptionState); |
3128 if (exceptionState.throwIfNeeded()) | 3129 if (exceptionState.throwIfNeeded()) |
3129 return; | 3130 return; |
3130 v8SetReturnValue(info, result.release()); | 3131 v8SetReturnValue(info, result.release()); |
3131 } | 3132 } |
3132 | 3133 |
3133 static void methodThatRequiresAllArgsAndThrowsMethodCallback(const v8::FunctionC
allbackInfo<v8::Value>& info) | 3134 static void methodThatRequiresAllArgsAndThrowsMethodCallback(const v8::FunctionC
allbackInfo<v8::Value>& info) |
(...skipping 16 matching lines...) Expand all Loading... |
3150 | 3151 |
3151 static void methodQueryListListenerMethodCallback(const v8::FunctionCallbackInfo
<v8::Value>& info) | 3152 static void methodQueryListListenerMethodCallback(const v8::FunctionCallbackInfo
<v8::Value>& info) |
3152 { | 3153 { |
3153 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 3154 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
3154 TestObjV8Internal::methodQueryListListenerMethod(info); | 3155 TestObjV8Internal::methodQueryListListenerMethod(info); |
3155 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 3156 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
3156 } | 3157 } |
3157 | 3158 |
3158 static void serializedValueMethod(const v8::FunctionCallbackInfo<v8::Value>& inf
o) | 3159 static void serializedValueMethod(const v8::FunctionCallbackInfo<v8::Value>& inf
o) |
3159 { | 3160 { |
| 3161 ExceptionState exceptionState(ExceptionState::ExecutionContext, "serializedV
alue", "TestObject", info.Holder(), info.GetIsolate()); |
3160 if (UNLIKELY(info.Length() < 1)) { | 3162 if (UNLIKELY(info.Length() < 1)) { |
3161 throwTypeError(ExceptionMessages::failedToExecute("serializedValue", "Te
stObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIso
late()); | 3163 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
| 3164 exceptionState.throwIfNeeded(); |
3162 return; | 3165 return; |
3163 } | 3166 } |
3164 TestObj* imp = V8TestObject::toNative(info.Holder()); | 3167 TestObj* imp = V8TestObject::toNative(info.Holder()); |
3165 bool serializedArgDidThrow = false; | 3168 RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(
info[0], 0, 0, exceptionState, info.GetIsolate()); |
3166 RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(
info[0], 0, 0, serializedArgDidThrow, info.GetIsolate()); | 3169 if (exceptionState.throwIfNeeded()) |
3167 if (serializedArgDidThrow) | |
3168 return; | 3170 return; |
3169 imp->serializedValue(serializedArg); | 3171 imp->serializedValue(serializedArg); |
3170 } | 3172 } |
3171 | 3173 |
3172 static void serializedValueMethodCallback(const v8::FunctionCallbackInfo<v8::Val
ue>& info) | 3174 static void serializedValueMethodCallback(const v8::FunctionCallbackInfo<v8::Val
ue>& info) |
3173 { | 3175 { |
3174 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 3176 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
3175 TestObjV8Internal::serializedValueMethod(info); | 3177 TestObjV8Internal::serializedValueMethod(info); |
3176 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 3178 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
3177 } | 3179 } |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3669 { | 3671 { |
3670 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 3672 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
3671 TestObjV8Internal::methodWithNonCallbackArgAndCallbackInterfaceArgMethod(inf
o); | 3673 TestObjV8Internal::methodWithNonCallbackArgAndCallbackInterfaceArgMethod(inf
o); |
3672 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 3674 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
3673 } | 3675 } |
3674 | 3676 |
3675 static void methodWithCallbackInterfaceAndOptionalArgMethod(const v8::FunctionCa
llbackInfo<v8::Value>& info) | 3677 static void methodWithCallbackInterfaceAndOptionalArgMethod(const v8::FunctionCa
llbackInfo<v8::Value>& info) |
3676 { | 3678 { |
3677 TestObj* imp = V8TestObject::toNative(info.Holder()); | 3679 TestObj* imp = V8TestObject::toNative(info.Holder()); |
3678 OwnPtr<TestCallbackInterface> callbackInterface; | 3680 OwnPtr<TestCallbackInterface> callbackInterface; |
3679 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) { | 3681 if (info.Length() > 0 && !isUndefinedOrNull(info[0])) { |
3680 if (!info[0]->IsFunction()) { | 3682 if (!info[0]->IsFunction()) { |
3681 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbac
kInterfaceAndOptionalArg", "TestObject", "The callback provided as parameter 1 i
s not a function."), info.GetIsolate()); | 3683 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbac
kInterfaceAndOptionalArg", "TestObject", "The callback provided as parameter 1 i
s not a function."), info.GetIsolate()); |
3682 return; | 3684 return; |
3683 } | 3685 } |
3684 callbackInterface = V8TestCallbackInterface::create(v8::Handle<v8::Funct
ion>::Cast(info[0]), getExecutionContext()); | 3686 callbackInterface = V8TestCallbackInterface::create(v8::Handle<v8::Funct
ion>::Cast(info[0]), getExecutionContext()); |
3685 } | 3687 } |
3686 imp->methodWithCallbackInterfaceAndOptionalArg(callbackInterface.release()); | 3688 imp->methodWithCallbackInterfaceAndOptionalArg(callbackInterface.release()); |
3687 } | 3689 } |
3688 | 3690 |
3689 static void methodWithCallbackInterfaceAndOptionalArgMethodCallback(const v8::Fu
nctionCallbackInfo<v8::Value>& info) | 3691 static void methodWithCallbackInterfaceAndOptionalArgMethodCallback(const v8::Fu
nctionCallbackInfo<v8::Value>& info) |
(...skipping 21 matching lines...) Expand all Loading... |
3711 static void methodWithNullableCallbackInterfaceArgMethodCallback(const v8::Funct
ionCallbackInfo<v8::Value>& info) | 3713 static void methodWithNullableCallbackInterfaceArgMethodCallback(const v8::Funct
ionCallbackInfo<v8::Value>& info) |
3712 { | 3714 { |
3713 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 3715 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
3714 TestObjV8Internal::methodWithNullableCallbackInterfaceArgMethod(info); | 3716 TestObjV8Internal::methodWithNullableCallbackInterfaceArgMethod(info); |
3715 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 3717 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
3716 } | 3718 } |
3717 | 3719 |
3718 static void staticMethodWithCallbackAndOptionalArgMethod(const v8::FunctionCallb
ackInfo<v8::Value>& info) | 3720 static void staticMethodWithCallbackAndOptionalArgMethod(const v8::FunctionCallb
ackInfo<v8::Value>& info) |
3719 { | 3721 { |
3720 OwnPtr<TestCallbackInterface> callbackInterface; | 3722 OwnPtr<TestCallbackInterface> callbackInterface; |
3721 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) { | 3723 if (info.Length() > 0 && !isUndefinedOrNull(info[0])) { |
3722 if (!info[0]->IsFunction()) { | 3724 if (!info[0]->IsFunction()) { |
3723 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithC
allbackAndOptionalArg", "TestObject", "The callback provided as parameter 1 is n
ot a function."), info.GetIsolate()); | 3725 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithC
allbackAndOptionalArg", "TestObject", "The callback provided as parameter 1 is n
ot a function."), info.GetIsolate()); |
3724 return; | 3726 return; |
3725 } | 3727 } |
3726 callbackInterface = V8TestCallbackInterface::create(v8::Handle<v8::Funct
ion>::Cast(info[0]), getExecutionContext()); | 3728 callbackInterface = V8TestCallbackInterface::create(v8::Handle<v8::Funct
ion>::Cast(info[0]), getExecutionContext()); |
3727 } | 3729 } |
3728 TestObj::staticMethodWithCallbackAndOptionalArg(callbackInterface.release())
; | 3730 TestObj::staticMethodWithCallbackAndOptionalArg(callbackInterface.release())
; |
3729 } | 3731 } |
3730 | 3732 |
3731 static void staticMethodWithCallbackAndOptionalArgMethodCallback(const v8::Funct
ionCallbackInfo<v8::Value>& info) | 3733 static void staticMethodWithCallbackAndOptionalArgMethodCallback(const v8::Funct
ionCallbackInfo<v8::Value>& info) |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4168 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); | 4170 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); |
4169 imp->overloadedMethodB(strArg); | 4171 imp->overloadedMethodB(strArg); |
4170 } | 4172 } |
4171 | 4173 |
4172 static void overloadedMethodBMethod(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) | 4174 static void overloadedMethodBMethod(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) |
4173 { | 4175 { |
4174 if (((info.Length() == 1))) { | 4176 if (((info.Length() == 1))) { |
4175 overloadedMethodB1Method(info); | 4177 overloadedMethodB1Method(info); |
4176 return; | 4178 return; |
4177 } | 4179 } |
4178 if (((info.Length() == 1) && (info[0]->IsNull() || info[0]->IsUndefined() ||
info[0]->IsString() || info[0]->IsObject()))) { | 4180 if (((info.Length() == 1) && (isUndefinedOrNull(info[0]) || info[0]->IsStrin
g() || info[0]->IsObject()))) { |
4179 overloadedMethodB2Method(info); | 4181 overloadedMethodB2Method(info); |
4180 return; | 4182 return; |
4181 } | 4183 } |
4182 ExceptionState exceptionState(ExceptionState::ExecutionContext, "overloadedM
ethodB", "TestObject", info.Holder(), info.GetIsolate()); | 4184 ExceptionState exceptionState(ExceptionState::ExecutionContext, "overloadedM
ethodB", "TestObject", info.Holder(), info.GetIsolate()); |
4183 if (UNLIKELY(info.Length() < 1)) { | 4185 if (UNLIKELY(info.Length() < 1)) { |
4184 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | 4186 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
4185 exceptionState.throwIfNeeded(); | 4187 exceptionState.throwIfNeeded(); |
4186 return; | 4188 return; |
4187 } | 4189 } |
4188 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); | 4190 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... |
4467 static void strictSVGPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>
& info) | 4469 static void strictSVGPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>
& info) |
4468 { | 4470 { |
4469 ExceptionState exceptionState(ExceptionState::ExecutionContext, "strictSVGPo
intMethod", "TestObject", info.Holder(), info.GetIsolate()); | 4471 ExceptionState exceptionState(ExceptionState::ExecutionContext, "strictSVGPo
intMethod", "TestObject", info.Holder(), info.GetIsolate()); |
4470 if (UNLIKELY(info.Length() < 2)) { | 4472 if (UNLIKELY(info.Length() < 2)) { |
4471 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); | 4473 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); |
4472 exceptionState.throwIfNeeded(); | 4474 exceptionState.throwIfNeeded(); |
4473 return; | 4475 return; |
4474 } | 4476 } |
4475 TestObj* imp = V8TestObject::toNative(info.Holder()); | 4477 TestObj* imp = V8TestObject::toNative(info.Holder()); |
4476 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8SVGPoint::hasInst
ance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { | 4478 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8SVGPoint::hasInst
ance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { |
4477 throwTypeError(ExceptionMessages::failedToExecute("strictSVGPointMethod"
, "TestObject", "parameter 1 is not of type 'SVGPoint'."), info.GetIsolate()); | 4479 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'."); |
| 4480 exceptionState.throwIfNeeded(); |
4478 return; | 4481 return; |
4479 } | 4482 } |
4480 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); | 4483 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); |
4481 V8TRYCATCH_VOID(unsigned, index, toUInt32(info[1])); | 4484 V8TRYCATCH_VOID(unsigned, index, toUInt32(info[1])); |
4482 if (!item) { | 4485 if (!item) { |
4483 throwTypeError(ExceptionMessages::failedToExecute("strictSVGPointMethod"
, "TestObject", "parameter 1 is not of type 'SVGPoint'."), info.GetIsolate()); | 4486 throwTypeError(ExceptionMessages::failedToExecute("strictSVGPointMethod"
, "TestObject", "parameter 1 is not of type 'SVGPoint'."), info.GetIsolate()); |
4484 return; | 4487 return; |
4485 } | 4488 } |
4486 SVGPoint result = imp->strictSVGPointMethod(item->propertyReference(), index
, exceptionState); | 4489 SVGPoint result = imp->strictSVGPointMethod(item->propertyReference(), index
, exceptionState); |
4487 if (exceptionState.throwIfNeeded()) | 4490 if (exceptionState.throwIfNeeded()) |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5466 fromInternalPointer(object)->deref(); | 5469 fromInternalPointer(object)->deref(); |
5467 } | 5470 } |
5468 | 5471 |
5469 template<> | 5472 template<> |
5470 v8::Handle<v8::Value> toV8NoInline(TestObj* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) | 5473 v8::Handle<v8::Value> toV8NoInline(TestObj* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) |
5471 { | 5474 { |
5472 return toV8(impl, creationContext, isolate); | 5475 return toV8(impl, creationContext, isolate); |
5473 } | 5476 } |
5474 | 5477 |
5475 } // namespace WebCore | 5478 } // namespace WebCore |
OLD | NEW |