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

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

Issue 1047993002: bindings: Add validation for enum Sequence or Array (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 751
752 String TestEnumOrDouble::getAsTestEnum() const 752 String TestEnumOrDouble::getAsTestEnum() const
753 { 753 {
754 ASSERT(isTestEnum()); 754 ASSERT(isTestEnum());
755 return m_testEnum; 755 return m_testEnum;
756 } 756 }
757 757
758 void TestEnumOrDouble::setTestEnum(String value) 758 void TestEnumOrDouble::setTestEnum(String value)
759 { 759 {
760 ASSERT(isNull()); 760 ASSERT(isNull());
761 String string = value; 761 const char* validValues[] = {
762 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) { 762 "",
763 "EnumValue1",
764 "EnumValue2",
765 "EnumValue3",
766 };
767 if (!isValidEnum(value, validValues, 4)) {
haraken 2015/03/31 06:11:17 Or you can use WTF_ARRAY_LENGTH(validValues).
bashi 2015/04/01 00:17:31 Done.
763 ASSERT_NOT_REACHED(); 768 ASSERT_NOT_REACHED();
764 return; 769 return;
765 } 770 }
766 m_testEnum = value; 771 m_testEnum = value;
767 m_type = SpecificTypeTestEnum; 772 m_type = SpecificTypeTestEnum;
768 } 773 }
769 774
770 TestEnumOrDouble TestEnumOrDouble::fromTestEnum(String value) 775 TestEnumOrDouble TestEnumOrDouble::fromTestEnum(String value)
771 { 776 {
772 TestEnumOrDouble container; 777 TestEnumOrDouble container;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 if (exceptionState.hadException()) 809 if (exceptionState.hadException())
805 return; 810 return;
806 impl.setDouble(cppValue); 811 impl.setDouble(cppValue);
807 return; 812 return;
808 } 813 }
809 814
810 { 815 {
811 V8StringResource<> cppValue = v8Value; 816 V8StringResource<> cppValue = v8Value;
812 if (!cppValue.prepare(exceptionState)) 817 if (!cppValue.prepare(exceptionState))
813 return; 818 return;
814 String string = cppValue; 819 const char* validValues[] = {
815 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) { 820 "",
816 exceptionState.throwTypeError("'" + string + "' is not a valid enum value."); 821 "EnumValue1",
822 "EnumValue2",
823 "EnumValue3",
824 };
825 if (!isValidEnum(cppValue, validValues, 4)) {
826 exceptionState.throwTypeError("'" + String(cppValue) + "' is not a v alid enum value.");
817 return; 827 return;
818 } 828 }
819 impl.setTestEnum(cppValue); 829 impl.setTestEnum(cppValue);
820 return; 830 return;
821 } 831 }
822 832
823 } 833 }
824 834
825 v8::Local<v8::Value> toV8(const TestEnumOrDouble& impl, v8::Local<v8::Object> cr eationContext, v8::Isolate* isolate) 835 v8::Local<v8::Value> toV8(const TestEnumOrDouble& impl, v8::Local<v8::Object> cr eationContext, v8::Isolate* isolate)
826 { 836 {
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 } 1397 }
1388 1398
1389 UnrestrictedDoubleOrString NativeValueTraits<UnrestrictedDoubleOrString>::native Value(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptio nState) 1399 UnrestrictedDoubleOrString NativeValueTraits<UnrestrictedDoubleOrString>::native Value(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptio nState)
1390 { 1400 {
1391 UnrestrictedDoubleOrString impl; 1401 UnrestrictedDoubleOrString impl;
1392 V8UnrestrictedDoubleOrString::toImpl(isolate, value, impl, exceptionState); 1402 V8UnrestrictedDoubleOrString::toImpl(isolate, value, impl, exceptionState);
1393 return impl; 1403 return impl;
1394 } 1404 }
1395 1405
1396 } // namespace blink 1406 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698