Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: Source/bindings/tests/results/core/UnionTypesCore.cpp

Issue 938733003: IDL: Fix exception handling when converting V8 value to union/dictionary (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6 6
7 #include "config.h" 7 #include "config.h"
8 #include "bindings/core/v8/UnionTypesCore.h" 8 #include "bindings/core/v8/UnionTypesCore.h"
9 9
10 #include "bindings/core/v8/Dictionary.h" 10 #include "bindings/core/v8/Dictionary.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return; 107 return;
108 } 108 }
109 109
110 if (V8ArrayBufferView::hasInstance(v8Value, isolate)) { 110 if (V8ArrayBufferView::hasInstance(v8Value, isolate)) {
111 RefPtr<TestArrayBufferView> cppValue = V8ArrayBufferView::toImpl(v8::Loc al<v8::Object>::Cast(v8Value)); 111 RefPtr<TestArrayBufferView> cppValue = V8ArrayBufferView::toImpl(v8::Loc al<v8::Object>::Cast(v8Value));
112 impl.setArrayBufferView(cppValue); 112 impl.setArrayBufferView(cppValue);
113 return; 113 return;
114 } 114 }
115 115
116 if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) { 116 if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) {
117 TONATIVE_VOID_EXCEPTIONSTATE(Dictionary, cppValue, Dictionary(v8Value, i solate, exceptionState), exceptionState); 117 TONATIVE_VOID_EXCEPTIONSTATE_NOTHROW(Dictionary, cppValue, Dictionary(v8 Value, isolate, exceptionState), exceptionState);
118 impl.setDictionary(cppValue); 118 impl.setDictionary(cppValue);
119 return; 119 return;
120 } 120 }
121 121
122 exceptionState.throwTypeError("The provided value is not of type '(ArrayBuff er or ArrayBufferView or Dictionary)'"); 122 exceptionState.throwTypeError("The provided value is not of type '(ArrayBuff er or ArrayBufferView or Dictionary)'");
123 } 123 }
124 124
125 v8::Local<v8::Value> toV8(const ArrayBufferOrArrayBufferViewOrDictionary& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) 125 v8::Local<v8::Value> toV8(const ArrayBufferOrArrayBufferViewOrDictionary& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
126 { 126 {
127 switch (impl.m_type) { 127 switch (impl.m_type) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 { 215 {
216 if (v8Value.IsEmpty()) 216 if (v8Value.IsEmpty())
217 return; 217 return;
218 218
219 if (v8Value->IsBoolean()) { 219 if (v8Value->IsBoolean()) {
220 impl.setBoolean(v8Value->ToBoolean()->Value()); 220 impl.setBoolean(v8Value->ToBoolean()->Value());
221 return; 221 return;
222 } 222 }
223 223
224 if (v8Value->IsNumber()) { 224 if (v8Value->IsNumber()) {
225 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti onState), exceptionState); 225 TONATIVE_VOID_EXCEPTIONSTATE_NOTHROW(double, cppValue, toDouble(v8Value, exceptionState), exceptionState);
226 impl.setUnrestrictedDouble(cppValue); 226 impl.setUnrestrictedDouble(cppValue);
227 return; 227 return;
228 } 228 }
229 229
230 { 230 {
231 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState); 231 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
232 impl.setString(cppValue); 232 impl.setString(cppValue);
233 return; 233 return;
234 } 234 }
235 235
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 container.setString(value); 303 container.setString(value);
304 return container; 304 return container;
305 } 305 }
306 306
307 void V8DoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , DoubleOrString& impl, ExceptionState& exceptionState) 307 void V8DoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , DoubleOrString& impl, ExceptionState& exceptionState)
308 { 308 {
309 if (v8Value.IsEmpty()) 309 if (v8Value.IsEmpty())
310 return; 310 return;
311 311
312 if (v8Value->IsNumber()) { 312 if (v8Value->IsNumber()) {
313 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState); 313 TONATIVE_VOID_EXCEPTIONSTATE_NOTHROW(double, cppValue, toRestrictedDoubl e(v8Value, exceptionState), exceptionState);
314 impl.setDouble(cppValue); 314 impl.setDouble(cppValue);
315 return; 315 return;
316 } 316 }
317 317
318 { 318 {
319 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState); 319 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
320 impl.setString(cppValue); 320 impl.setString(cppValue);
321 return; 321 return;
322 } 322 }
323 323
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 container.setDouble(value); 596 container.setDouble(value);
597 return container; 597 return container;
598 } 598 }
599 599
600 void V8StringOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , StringOrDouble& impl, ExceptionState& exceptionState) 600 void V8StringOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , StringOrDouble& impl, ExceptionState& exceptionState)
601 { 601 {
602 if (v8Value.IsEmpty()) 602 if (v8Value.IsEmpty())
603 return; 603 return;
604 604
605 if (v8Value->IsNumber()) { 605 if (v8Value->IsNumber()) {
606 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState); 606 TONATIVE_VOID_EXCEPTIONSTATE_NOTHROW(double, cppValue, toRestrictedDoubl e(v8Value, exceptionState), exceptionState);
607 impl.setDouble(cppValue); 607 impl.setDouble(cppValue);
608 return; 608 return;
609 } 609 }
610 610
611 { 611 {
612 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState); 612 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
613 impl.setString(cppValue); 613 impl.setString(cppValue);
614 return; 614 return;
615 } 615 }
616 616
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 container.setStringSequence(value); 682 container.setStringSequence(value);
683 return container; 683 return container;
684 } 684 }
685 685
686 void V8StringOrStringSequence::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrStringSequence& impl, ExceptionState& exceptionState) 686 void V8StringOrStringSequence::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrStringSequence& impl, ExceptionState& exceptionState)
687 { 687 {
688 if (v8Value.IsEmpty()) 688 if (v8Value.IsEmpty())
689 return; 689 return;
690 690
691 if (v8Value->IsArray()) { 691 if (v8Value->IsArray()) {
692 TONATIVE_VOID_EXCEPTIONSTATE(Vector<String>, cppValue, toImplArray<Strin g>(v8Value, 0, isolate, exceptionState), exceptionState); 692 TONATIVE_VOID_EXCEPTIONSTATE_NOTHROW(Vector<String>, cppValue, toImplArr ay<String>(v8Value, 0, isolate, exceptionState), exceptionState);
693 impl.setStringSequence(cppValue); 693 impl.setStringSequence(cppValue);
694 return; 694 return;
695 } 695 }
696 696
697 { 697 {
698 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState); 698 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
699 impl.setString(cppValue); 699 impl.setString(cppValue);
700 return; 700 return;
701 } 701 }
702 702
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 container.setDouble(value); 773 container.setDouble(value);
774 return container; 774 return container;
775 } 775 }
776 776
777 void V8TestEnumOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Val ue, TestEnumOrDouble& impl, ExceptionState& exceptionState) 777 void V8TestEnumOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Val ue, TestEnumOrDouble& impl, ExceptionState& exceptionState)
778 { 778 {
779 if (v8Value.IsEmpty()) 779 if (v8Value.IsEmpty())
780 return; 780 return;
781 781
782 if (v8Value->IsNumber()) { 782 if (v8Value->IsNumber()) {
783 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState); 783 TONATIVE_VOID_EXCEPTIONSTATE_NOTHROW(double, cppValue, toRestrictedDoubl e(v8Value, exceptionState), exceptionState);
784 impl.setDouble(cppValue); 784 impl.setDouble(cppValue);
785 return; 785 return;
786 } 786 }
787 787
788 { 788 {
789 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState); 789 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
790 String string = cppValue; 790 String string = cppValue;
791 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) { 791 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) {
792 exceptionState.throwTypeError("'" + string + "' is not a valid enum value."); 792 exceptionState.throwTypeError("'" + string + "' is not a valid enum value.");
793 return; 793 return;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 if (v8Value.IsEmpty()) 1048 if (v8Value.IsEmpty())
1049 return; 1049 return;
1050 1050
1051 if (V8TestInterface::hasInstance(v8Value, isolate)) { 1051 if (V8TestInterface::hasInstance(v8Value, isolate)) {
1052 RefPtr<TestInterfaceImplementation> cppValue = V8TestInterface::toImpl(v 8::Local<v8::Object>::Cast(v8Value)); 1052 RefPtr<TestInterfaceImplementation> cppValue = V8TestInterface::toImpl(v 8::Local<v8::Object>::Cast(v8Value));
1053 impl.setTestInterface(cppValue); 1053 impl.setTestInterface(cppValue);
1054 return; 1054 return;
1055 } 1055 }
1056 1056
1057 if (v8Value->IsNumber()) { 1057 if (v8Value->IsNumber()) {
1058 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionSt ate), exceptionState); 1058 TONATIVE_VOID_EXCEPTIONSTATE_NOTHROW(int, cppValue, toInt32(v8Value, exc eptionState), exceptionState);
1059 impl.setLong(cppValue); 1059 impl.setLong(cppValue);
1060 return; 1060 return;
1061 } 1061 }
1062 1062
1063 { 1063 {
1064 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionSt ate), exceptionState); 1064 TONATIVE_VOID_EXCEPTIONSTATE_NOTHROW(int, cppValue, toInt32(v8Value, exc eptionState), exceptionState);
1065 impl.setLong(cppValue); 1065 impl.setLong(cppValue);
1066 return; 1066 return;
1067 } 1067 }
1068 1068
1069 } 1069 }
1070 1070
1071 v8::Local<v8::Value> toV8(const TestInterfaceOrLong& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) 1071 v8::Local<v8::Value> toV8(const TestInterfaceOrLong& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
1072 { 1072 {
1073 switch (impl.m_type) { 1073 switch (impl.m_type) {
1074 case TestInterfaceOrLong::SpecificTypeNone: 1074 case TestInterfaceOrLong::SpecificTypeNone:
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 return; 1234 return;
1235 1235
1236 if (V8TestInterfaceWillBeGarbageCollected::hasInstance(v8Value, isolate)) { 1236 if (V8TestInterfaceWillBeGarbageCollected::hasInstance(v8Value, isolate)) {
1237 RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> cppValue = V8Tes tInterfaceWillBeGarbageCollected::toImpl(v8::Local<v8::Object>::Cast(v8Value)); 1237 RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> cppValue = V8Tes tInterfaceWillBeGarbageCollected::toImpl(v8::Local<v8::Object>::Cast(v8Value));
1238 impl.setTestInterfaceWillBeGarbageCollected(cppValue); 1238 impl.setTestInterfaceWillBeGarbageCollected(cppValue);
1239 return; 1239 return;
1240 } 1240 }
1241 1241
1242 if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) { 1242 if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) {
1243 TestDictionary cppValue; 1243 TestDictionary cppValue;
1244 TONATIVE_VOID_EXCEPTIONSTATE_ARGINTERNAL(V8TestDictionary::toImpl(isolat e, v8Value, cppValue, exceptionState), exceptionState); 1244 TONATIVE_VOID_EXCEPTIONSTATE_ARGINTERNAL_NOTHROW(V8TestDictionary::toImp l(isolate, v8Value, cppValue, exceptionState), exceptionState);
1245 impl.setTestDictionary(cppValue); 1245 impl.setTestDictionary(cppValue);
1246 return; 1246 return;
1247 } 1247 }
1248 1248
1249 exceptionState.throwTypeError("The provided value is not of type '(TestInter faceWillBeGarbageCollected or TestDictionary)'"); 1249 exceptionState.throwTypeError("The provided value is not of type '(TestInter faceWillBeGarbageCollected or TestDictionary)'");
1250 } 1250 }
1251 1251
1252 v8::Local<v8::Value> toV8(const TestInterfaceWillBeGarbageCollectedOrTestDiction ary& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) 1252 v8::Local<v8::Value> toV8(const TestInterfaceWillBeGarbageCollectedOrTestDiction ary& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
1253 { 1253 {
1254 switch (impl.m_type) { 1254 switch (impl.m_type) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 container.setString(value); 1315 container.setString(value);
1316 return container; 1316 return container;
1317 } 1317 }
1318 1318
1319 void V8UnrestrictedDoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Va lue> v8Value, UnrestrictedDoubleOrString& impl, ExceptionState& exceptionState) 1319 void V8UnrestrictedDoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Va lue> v8Value, UnrestrictedDoubleOrString& impl, ExceptionState& exceptionState)
1320 { 1320 {
1321 if (v8Value.IsEmpty()) 1321 if (v8Value.IsEmpty())
1322 return; 1322 return;
1323 1323
1324 if (v8Value->IsNumber()) { 1324 if (v8Value->IsNumber()) {
1325 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti onState), exceptionState); 1325 TONATIVE_VOID_EXCEPTIONSTATE_NOTHROW(double, cppValue, toDouble(v8Value, exceptionState), exceptionState);
1326 impl.setUnrestrictedDouble(cppValue); 1326 impl.setUnrestrictedDouble(cppValue);
1327 return; 1327 return;
1328 } 1328 }
1329 1329
1330 { 1330 {
1331 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState); 1331 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
1332 impl.setString(cppValue); 1332 impl.setString(cppValue);
1333 return; 1333 return;
1334 } 1334 }
1335 1335
(...skipping 15 matching lines...) Expand all
1351 } 1351 }
1352 1352
1353 UnrestrictedDoubleOrString NativeValueTraits<UnrestrictedDoubleOrString>::native Value(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& e xceptionState) 1353 UnrestrictedDoubleOrString NativeValueTraits<UnrestrictedDoubleOrString>::native Value(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& e xceptionState)
1354 { 1354 {
1355 UnrestrictedDoubleOrString impl; 1355 UnrestrictedDoubleOrString impl;
1356 V8UnrestrictedDoubleOrString::toImpl(isolate, value, impl, exceptionState); 1356 V8UnrestrictedDoubleOrString::toImpl(isolate, value, impl, exceptionState);
1357 return impl; 1357 return impl;
1358 } 1358 }
1359 1359
1360 } // namespace blink 1360 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_union.py ('k') | Source/bindings/tests/results/core/V8TestDictionary.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698