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

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

Issue 860353002: IDL: Add toRestricted{Float,Double}() helpers to V8Binding.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add FIXME comment Created 5 years, 11 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 m_string = value; 247 m_string = value;
248 m_type = SpecificTypeString; 248 m_type = SpecificTypeString;
249 } 249 }
250 250
251 void V8DoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , DoubleOrString& impl, ExceptionState& exceptionState) 251 void V8DoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , DoubleOrString& impl, ExceptionState& exceptionState)
252 { 252 {
253 if (v8Value.IsEmpty()) 253 if (v8Value.IsEmpty())
254 return; 254 return;
255 255
256 if (v8Value->IsNumber()) { 256 if (v8Value->IsNumber()) {
257 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti onState), exceptionState); 257 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState);
258 impl.setDouble(cppValue); 258 impl.setDouble(cppValue);
259 return; 259 return;
260 } 260 }
261 261
262 { 262 {
263 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState); 263 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
264 impl.setString(cppValue); 264 impl.setString(cppValue);
265 return; 265 return;
266 } 266 }
267 267
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 m_double = value; 491 m_double = value;
492 m_type = SpecificTypeDouble; 492 m_type = SpecificTypeDouble;
493 } 493 }
494 494
495 void V8StringOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , StringOrDouble& impl, ExceptionState& exceptionState) 495 void V8StringOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , StringOrDouble& impl, ExceptionState& exceptionState)
496 { 496 {
497 if (v8Value.IsEmpty()) 497 if (v8Value.IsEmpty())
498 return; 498 return;
499 499
500 if (v8Value->IsNumber()) { 500 if (v8Value->IsNumber()) {
501 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti onState), exceptionState); 501 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState);
502 impl.setDouble(cppValue); 502 impl.setDouble(cppValue);
503 return; 503 return;
504 } 504 }
505 505
506 { 506 {
507 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState); 507 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
508 impl.setString(cppValue); 508 impl.setString(cppValue);
509 return; 509 return;
510 } 510 }
511 511
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 m_double = value; 640 m_double = value;
641 m_type = SpecificTypeDouble; 641 m_type = SpecificTypeDouble;
642 } 642 }
643 643
644 void V8TestEnumOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Val ue, TestEnumOrDouble& impl, ExceptionState& exceptionState) 644 void V8TestEnumOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Val ue, TestEnumOrDouble& impl, ExceptionState& exceptionState)
645 { 645 {
646 if (v8Value.IsEmpty()) 646 if (v8Value.IsEmpty())
647 return; 647 return;
648 648
649 if (v8Value->IsNumber()) { 649 if (v8Value->IsNumber()) {
650 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti onState), exceptionState); 650 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState);
651 impl.setDouble(cppValue); 651 impl.setDouble(cppValue);
652 return; 652 return;
653 } 653 }
654 654
655 { 655 {
656 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState); 656 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
657 String string = cppValue; 657 String string = cppValue;
658 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) { 658 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) {
659 exceptionState.throwTypeError("'" + string + "' is not a valid enum value."); 659 exceptionState.throwTypeError("'" + string + "' is not a valid enum value.");
660 return; 660 return;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 return v8::Local<v8::Value>(); 1061 return v8::Local<v8::Value>();
1062 } 1062 }
1063 1063
1064 TestInterfaceWillBeGarbageCollectedOrTestDictionary NativeValueTraits<TestInterf aceWillBeGarbageCollectedOrTestDictionary>::nativeValue(const v8::Local<v8::Valu e>& value, v8::Isolate* isolate, ExceptionState& exceptionState) 1064 TestInterfaceWillBeGarbageCollectedOrTestDictionary NativeValueTraits<TestInterf aceWillBeGarbageCollectedOrTestDictionary>::nativeValue(const v8::Local<v8::Valu e>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
1065 { 1065 {
1066 TestInterfaceWillBeGarbageCollectedOrTestDictionary impl; 1066 TestInterfaceWillBeGarbageCollectedOrTestDictionary impl;
1067 V8TestInterfaceWillBeGarbageCollectedOrTestDictionary::toImpl(isolate, value , impl, exceptionState); 1067 V8TestInterfaceWillBeGarbageCollectedOrTestDictionary::toImpl(isolate, value , impl, exceptionState);
1068 return impl; 1068 return impl;
1069 } 1069 }
1070 1070
1071 UnrestrictedDoubleOrString::UnrestrictedDoubleOrString()
1072 : m_type(SpecificTypeNone)
1073 {
1074 }
1075
1076 double UnrestrictedDoubleOrString::getAsUnrestrictedDouble() const
1077 {
1078 ASSERT(isUnrestrictedDouble());
1079 return m_unrestrictedDouble;
1080 }
1081
1082 void UnrestrictedDoubleOrString::setUnrestrictedDouble(double value)
1083 {
1084 ASSERT(isNull());
1085 m_unrestrictedDouble = value;
1086 m_type = SpecificTypeUnrestrictedDouble;
1087 }
1088
1089 String UnrestrictedDoubleOrString::getAsString() const
1090 {
1091 ASSERT(isString());
1092 return m_string;
1093 }
1094
1095 void UnrestrictedDoubleOrString::setString(String value)
1096 {
1097 ASSERT(isNull());
1098 m_string = value;
1099 m_type = SpecificTypeString;
1100 }
1101
1102 void V8UnrestrictedDoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Va lue> v8Value, UnrestrictedDoubleOrString& impl, ExceptionState& exceptionState)
1103 {
1104 if (v8Value.IsEmpty())
1105 return;
1106
1107 if (v8Value->IsNumber()) {
1108 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti onState), exceptionState);
1109 impl.setUnrestrictedDouble(cppValue);
1110 return;
1111 }
1112
1113 {
1114 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
1115 impl.setString(cppValue);
1116 return;
1117 }
1118
1119 }
1120
1121 v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrString& impl, v8::Local<v8:: Object> creationContext, v8::Isolate* isolate)
1122 {
1123 switch (impl.m_type) {
1124 case UnrestrictedDoubleOrString::SpecificTypeNone:
1125 return v8::Null(isolate);
1126 case UnrestrictedDoubleOrString::SpecificTypeUnrestrictedDouble:
1127 return v8::Number::New(isolate, impl.getAsUnrestrictedDouble());
1128 case UnrestrictedDoubleOrString::SpecificTypeString:
1129 return v8String(isolate, impl.getAsString());
1130 default:
1131 ASSERT_NOT_REACHED();
1132 }
1133 return v8::Local<v8::Value>();
1134 }
1135
1136 UnrestrictedDoubleOrString NativeValueTraits<UnrestrictedDoubleOrString>::native Value(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& e xceptionState)
1137 {
1138 UnrestrictedDoubleOrString impl;
1139 V8UnrestrictedDoubleOrString::toImpl(isolate, value, impl, exceptionState);
1140 return impl;
1141 }
1142
1071 } // namespace blink 1143 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698