Chromium Code Reviews| Index: Source/bindings/tests/results/core/UnionTypesCore.cpp |
| diff --git a/Source/bindings/tests/results/core/UnionTypesCore.cpp b/Source/bindings/tests/results/core/UnionTypesCore.cpp |
| index 9ad9b6f00a0fc830a9710a2a250a81c723fb2ea6..95a846135311bbe9af50ac62626e5ba6d6d10a52 100644 |
| --- a/Source/bindings/tests/results/core/UnionTypesCore.cpp |
| +++ b/Source/bindings/tests/results/core/UnionTypesCore.cpp |
| @@ -96,30 +96,33 @@ ArrayBufferOrArrayBufferViewOrDictionary ArrayBufferOrArrayBufferViewOrDictionar |
| return container; |
| } |
| -void V8ArrayBufferOrArrayBufferViewOrDictionary::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, ArrayBufferOrArrayBufferViewOrDictionary& impl, ExceptionState& exceptionState) |
| +bool V8ArrayBufferOrArrayBufferViewOrDictionary::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, ArrayBufferOrArrayBufferViewOrDictionary& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (V8ArrayBuffer::hasInstance(v8Value, isolate)) { |
| RefPtr<TestArrayBuffer> cppValue = V8ArrayBuffer::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setArrayBuffer(cppValue); |
| - return; |
| + return true; |
| } |
| if (V8ArrayBufferView::hasInstance(v8Value, isolate)) { |
| RefPtr<TestArrayBufferView> cppValue = V8ArrayBufferView::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setArrayBufferView(cppValue); |
| - return; |
| + return true; |
| } |
| if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) { |
| - TONATIVE_VOID_EXCEPTIONSTATE(Dictionary, cppValue, Dictionary(v8Value, isolate, exceptionState), exceptionState); |
| + Dictionary cppValue = Dictionary(v8Value, isolate, exceptionState); |
| + if (exceptionState.hadException()) |
| + return false; |
| impl.setDictionary(cppValue); |
| - return; |
| + return true; |
| } |
| exceptionState.throwTypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView or Dictionary)'"); |
| + return false; |
| } |
| v8::Local<v8::Value> toV8(const ArrayBufferOrArrayBufferViewOrDictionary& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
| @@ -211,26 +214,30 @@ BooleanOrStringOrUnrestrictedDouble BooleanOrStringOrUnrestrictedDouble::fromUnr |
| return container; |
| } |
| -void V8BooleanOrStringOrUnrestrictedDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, BooleanOrStringOrUnrestrictedDouble& impl, ExceptionState& exceptionState) |
| +bool V8BooleanOrStringOrUnrestrictedDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, BooleanOrStringOrUnrestrictedDouble& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (v8Value->IsBoolean()) { |
| impl.setBoolean(v8Value->ToBoolean()->Value()); |
| - return; |
| + return true; |
| } |
| if (v8Value->IsNumber()) { |
| - TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState); |
| + double cppValue = toDouble(v8Value, exceptionState); |
| + if (exceptionState.hadException()) |
| + return false; |
| impl.setUnrestrictedDouble(cppValue); |
| - return; |
| + return true; |
| } |
| { |
| - TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exceptionState); |
| + V8StringResource<> cppValue = v8Value; |
| + if (!cppValue.prepare(exceptionState)) |
| + return false; |
| impl.setString(cppValue); |
| - return; |
| + return true; |
| } |
| } |
| @@ -304,21 +311,25 @@ DoubleOrString DoubleOrString::fromString(String value) |
| return container; |
| } |
| -void V8DoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, DoubleOrString& impl, ExceptionState& exceptionState) |
| +bool V8DoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, DoubleOrString& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (v8Value->IsNumber()) { |
| - TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Value, exceptionState), exceptionState); |
| + double cppValue = toRestrictedDouble(v8Value, exceptionState); |
| + if (exceptionState.hadException()) |
| + return false; |
| impl.setDouble(cppValue); |
| - return; |
| + return true; |
| } |
| { |
| - TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exceptionState); |
| + V8StringResource<> cppValue = v8Value; |
| + if (!cppValue.prepare(exceptionState)) |
| + return false; |
| impl.setString(cppValue); |
| - return; |
| + return true; |
| } |
| } |
| @@ -396,24 +407,25 @@ void NodeOrNodeList::trace(Visitor* visitor) |
| visitor->trace(m_nodeList); |
| } |
| -void V8NodeOrNodeList::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, NodeOrNodeList& impl, ExceptionState& exceptionState) |
| +bool V8NodeOrNodeList::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, NodeOrNodeList& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (V8Node::hasInstance(v8Value, isolate)) { |
| RefPtrWillBeRawPtr<Node> cppValue = V8Node::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setNode(cppValue); |
| - return; |
| + return true; |
| } |
| if (V8NodeList::hasInstance(v8Value, isolate)) { |
| RefPtrWillBeRawPtr<NodeList> cppValue = V8NodeList::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setNodeList(cppValue); |
| - return; |
| + return true; |
| } |
| exceptionState.throwTypeError("The provided value is not of type '(Node or NodeList)'"); |
| + return false; |
| } |
| v8::Local<v8::Value> toV8(const NodeOrNodeList& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
| @@ -503,27 +515,29 @@ StringOrArrayBufferOrArrayBufferView StringOrArrayBufferOrArrayBufferView::fromA |
| return container; |
| } |
| -void V8StringOrArrayBufferOrArrayBufferView::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrArrayBufferOrArrayBufferView& impl, ExceptionState& exceptionState) |
| +bool V8StringOrArrayBufferOrArrayBufferView::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrArrayBufferOrArrayBufferView& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (V8ArrayBuffer::hasInstance(v8Value, isolate)) { |
| RefPtr<TestArrayBuffer> cppValue = V8ArrayBuffer::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setArrayBuffer(cppValue); |
| - return; |
| + return true; |
| } |
| if (V8ArrayBufferView::hasInstance(v8Value, isolate)) { |
| RefPtr<TestArrayBufferView> cppValue = V8ArrayBufferView::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setArrayBufferView(cppValue); |
| - return; |
| + return true; |
| } |
| { |
| - TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exceptionState); |
| + V8StringResource<> cppValue = v8Value; |
| + if (!cppValue.prepare(exceptionState)) |
| + return false; |
| impl.setString(cppValue); |
| - return; |
| + return true; |
| } |
| } |
| @@ -597,21 +611,25 @@ StringOrDouble StringOrDouble::fromDouble(double value) |
| return container; |
| } |
| -void V8StringOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrDouble& impl, ExceptionState& exceptionState) |
| +bool V8StringOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrDouble& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (v8Value->IsNumber()) { |
| - TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Value, exceptionState), exceptionState); |
| + double cppValue = toRestrictedDouble(v8Value, exceptionState); |
| + if (exceptionState.hadException()) |
| + return false; |
| impl.setDouble(cppValue); |
| - return; |
| + return true; |
| } |
| { |
| - TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exceptionState); |
| + V8StringResource<> cppValue = v8Value; |
| + if (!cppValue.prepare(exceptionState)) |
| + return false; |
| impl.setString(cppValue); |
| - return; |
| + return true; |
| } |
| } |
| @@ -683,21 +701,25 @@ StringOrStringSequence StringOrStringSequence::fromStringSequence(const Vector<S |
| return container; |
| } |
| -void V8StringOrStringSequence::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrStringSequence& impl, ExceptionState& exceptionState) |
| +bool V8StringOrStringSequence::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrStringSequence& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (v8Value->IsArray()) { |
| - TONATIVE_VOID_EXCEPTIONSTATE(Vector<String>, cppValue, toImplArray<String>(v8Value, 0, isolate, exceptionState), exceptionState); |
| + Vector<String> cppValue = toImplArray<String>(v8Value, 0, isolate, exceptionState); |
| + if (exceptionState.hadException()) |
| + return false; |
| impl.setStringSequence(cppValue); |
| - return; |
| + return true; |
| } |
| { |
| - TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exceptionState); |
| + V8StringResource<> cppValue = v8Value; |
| + if (!cppValue.prepare(exceptionState)) |
| + return false; |
| impl.setString(cppValue); |
| - return; |
| + return true; |
| } |
| } |
| @@ -774,26 +796,30 @@ TestEnumOrDouble TestEnumOrDouble::fromDouble(double value) |
| return container; |
| } |
| -void V8TestEnumOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestEnumOrDouble& impl, ExceptionState& exceptionState) |
| +bool V8TestEnumOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestEnumOrDouble& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (v8Value->IsNumber()) { |
| - TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Value, exceptionState), exceptionState); |
| + double cppValue = toRestrictedDouble(v8Value, exceptionState); |
| + if (exceptionState.hadException()) |
| + return false; |
| impl.setDouble(cppValue); |
| - return; |
| + return true; |
| } |
| { |
| - TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exceptionState); |
| + V8StringResource<> cppValue = v8Value; |
| + if (!cppValue.prepare(exceptionState)) |
|
haraken
2015/02/24 12:44:57
Would it be possible to write this like:
V8Stri
Jens Widell
2015/02/24 13:36:07
It would. But do you mean only this form of prepar
|
| + return false; |
| String string = cppValue; |
| if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || string == "EnumValue3")) { |
| exceptionState.throwTypeError("'" + string + "' is not a valid enum value."); |
| - return; |
| + return false; |
| } |
| impl.setTestEnum(cppValue); |
| - return; |
| + return true; |
| } |
| } |
| @@ -865,24 +891,25 @@ TestInterface2OrUint8Array TestInterface2OrUint8Array::fromUint8Array(PassRefPtr |
| return container; |
| } |
| -void V8TestInterface2OrUint8Array::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterface2OrUint8Array& impl, ExceptionState& exceptionState) |
| +bool V8TestInterface2OrUint8Array::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterface2OrUint8Array& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (V8TestInterface2::hasInstance(v8Value, isolate)) { |
| RefPtr<TestInterface2> cppValue = V8TestInterface2::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setTestInterface2(cppValue); |
| - return; |
| + return true; |
| } |
| if (V8Uint8Array::hasInstance(v8Value, isolate)) { |
| RefPtr<DOMUint8Array> cppValue = V8Uint8Array::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setUint8Array(cppValue); |
| - return; |
| + return true; |
| } |
| exceptionState.throwTypeError("The provided value is not of type '(TestInterface2 or Uint8Array)'"); |
| + return false; |
| } |
| v8::Local<v8::Value> toV8(const TestInterface2OrUint8Array& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
| @@ -957,21 +984,23 @@ void TestInterfaceGarbageCollectedOrString::trace(Visitor* visitor) |
| visitor->trace(m_testInterfaceGarbageCollected); |
| } |
| -void V8TestInterfaceGarbageCollectedOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceGarbageCollectedOrString& impl, ExceptionState& exceptionState) |
| +bool V8TestInterfaceGarbageCollectedOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceGarbageCollectedOrString& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (V8TestInterfaceGarbageCollected::hasInstance(v8Value, isolate)) { |
| RawPtr<TestInterfaceGarbageCollected> cppValue = V8TestInterfaceGarbageCollected::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setTestInterfaceGarbageCollected(cppValue); |
| - return; |
| + return true; |
| } |
| { |
| - TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exceptionState); |
| + V8StringResource<> cppValue = v8Value; |
| + if (!cppValue.prepare(exceptionState)) |
| + return false; |
| impl.setString(cppValue); |
| - return; |
| + return true; |
| } |
| } |
| @@ -1043,27 +1072,31 @@ TestInterfaceOrLong TestInterfaceOrLong::fromLong(int value) |
| return container; |
| } |
| -void V8TestInterfaceOrLong::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceOrLong& impl, ExceptionState& exceptionState) |
| +bool V8TestInterfaceOrLong::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceOrLong& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (V8TestInterface::hasInstance(v8Value, isolate)) { |
| RefPtr<TestInterfaceImplementation> cppValue = V8TestInterface::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setTestInterface(cppValue); |
| - return; |
| + return true; |
| } |
| if (v8Value->IsNumber()) { |
| - TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); |
| + int cppValue = toInt32(v8Value, exceptionState); |
| + if (exceptionState.hadException()) |
| + return false; |
| impl.setLong(cppValue); |
| - return; |
| + return true; |
| } |
| { |
| - TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); |
| + int cppValue = toInt32(v8Value, exceptionState); |
| + if (exceptionState.hadException()) |
| + return false; |
| impl.setLong(cppValue); |
| - return; |
| + return true; |
| } |
| } |
| @@ -1135,24 +1168,25 @@ TestInterfaceOrTestInterfaceEmpty TestInterfaceOrTestInterfaceEmpty::fromTestInt |
| return container; |
| } |
| -void V8TestInterfaceOrTestInterfaceEmpty::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceOrTestInterfaceEmpty& impl, ExceptionState& exceptionState) |
| +bool V8TestInterfaceOrTestInterfaceEmpty::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceOrTestInterfaceEmpty& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (V8TestInterface::hasInstance(v8Value, isolate)) { |
| RefPtr<TestInterfaceImplementation> cppValue = V8TestInterface::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setTestInterface(cppValue); |
| - return; |
| + return true; |
| } |
| if (V8TestInterfaceEmpty::hasInstance(v8Value, isolate)) { |
| RefPtr<TestInterfaceEmpty> cppValue = V8TestInterfaceEmpty::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setTestInterfaceEmpty(cppValue); |
| - return; |
| + return true; |
| } |
| exceptionState.throwTypeError("The provided value is not of type '(TestInterface or TestInterfaceEmpty)'"); |
| + return false; |
| } |
| v8::Local<v8::Value> toV8(const TestInterfaceOrTestInterfaceEmpty& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
| @@ -1228,25 +1262,28 @@ void TestInterfaceWillBeGarbageCollectedOrTestDictionary::trace(Visitor* visitor |
| visitor->trace(m_testDictionary); |
| } |
| -void V8TestInterfaceWillBeGarbageCollectedOrTestDictionary::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceWillBeGarbageCollectedOrTestDictionary& impl, ExceptionState& exceptionState) |
| +bool V8TestInterfaceWillBeGarbageCollectedOrTestDictionary::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceWillBeGarbageCollectedOrTestDictionary& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (V8TestInterfaceWillBeGarbageCollected::hasInstance(v8Value, isolate)) { |
| RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> cppValue = V8TestInterfaceWillBeGarbageCollected::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| impl.setTestInterfaceWillBeGarbageCollected(cppValue); |
| - return; |
| + return true; |
| } |
| if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) { |
| TestDictionary cppValue; |
| - TONATIVE_VOID_EXCEPTIONSTATE_ARGINTERNAL(V8TestDictionary::toImpl(isolate, v8Value, cppValue, exceptionState), exceptionState); |
| + TestDictionary cppValue; |
| + if (!V8TestDictionary::toImpl(isolate, v8Value, cppValue, exceptionState)) |
| + return false; |
| impl.setTestDictionary(cppValue); |
| - return; |
| + return true; |
| } |
| exceptionState.throwTypeError("The provided value is not of type '(TestInterfaceWillBeGarbageCollected or TestDictionary)'"); |
| + return false; |
| } |
| v8::Local<v8::Value> toV8(const TestInterfaceWillBeGarbageCollectedOrTestDictionary& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
| @@ -1316,21 +1353,25 @@ UnrestrictedDoubleOrString UnrestrictedDoubleOrString::fromString(String value) |
| return container; |
| } |
| -void V8UnrestrictedDoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, UnrestrictedDoubleOrString& impl, ExceptionState& exceptionState) |
| +bool V8UnrestrictedDoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, UnrestrictedDoubleOrString& impl, ExceptionState& exceptionState) |
| { |
| if (v8Value.IsEmpty()) |
| - return; |
| + return true; |
| if (v8Value->IsNumber()) { |
| - TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState); |
| + double cppValue = toDouble(v8Value, exceptionState); |
| + if (exceptionState.hadException()) |
| + return false; |
| impl.setUnrestrictedDouble(cppValue); |
| - return; |
| + return true; |
| } |
| { |
| - TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exceptionState); |
| + V8StringResource<> cppValue = v8Value; |
| + if (!cppValue.prepare(exceptionState)) |
| + return false; |
| impl.setString(cppValue); |
| - return; |
| + return true; |
| } |
| } |