OLD | NEW |
| 1 {% from 'conversions.cpp' import declare_enum_validation_variable %} |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 4 // found in the LICENSE file. |
4 | 5 |
5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY! | 6 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY! |
6 | 7 |
7 #include "config.h" | 8 #include "config.h" |
8 #include "{{header_filename}}" | 9 #include "{{header_filename}}" |
9 | 10 |
10 {% from 'conversions.cpp' import v8_value_to_local_cpp_value %} | 11 {% from 'conversions.cpp' import v8_value_to_local_cpp_value %} |
(...skipping 19 matching lines...) Expand all Loading... |
30 {% for member in container.members %} | 31 {% for member in container.members %} |
31 {{member.rvalue_cpp_type}} {{container.cpp_class}}::getAs{{member.type_name}}()
const | 32 {{member.rvalue_cpp_type}} {{container.cpp_class}}::getAs{{member.type_name}}()
const |
32 { | 33 { |
33 ASSERT(is{{member.type_name}}()); | 34 ASSERT(is{{member.type_name}}()); |
34 return m_{{member.cpp_name}}; | 35 return m_{{member.cpp_name}}; |
35 } | 36 } |
36 | 37 |
37 void {{container.cpp_class}}::set{{member.type_name}}({{member.rvalue_cpp_type}}
value) | 38 void {{container.cpp_class}}::set{{member.type_name}}({{member.rvalue_cpp_type}}
value) |
38 { | 39 { |
39 ASSERT(isNull()); | 40 ASSERT(isNull()); |
40 {% if member.enum_validation_expression %} | 41 {% if member.enum_values %} |
41 String string = value; | 42 {{declare_enum_validation_variable(member.enum_values) | indent}} |
42 if (!({{member.enum_validation_expression}})) { | 43 if (!isValidEnum(value, validValues, {{member.enum_values|length}})) { |
43 ASSERT_NOT_REACHED(); | 44 ASSERT_NOT_REACHED(); |
44 return; | 45 return; |
45 } | 46 } |
46 {% endif %} | 47 {% endif %} |
47 m_{{member.cpp_name}} = value; | 48 m_{{member.cpp_name}} = value; |
48 m_type = {{member.specific_type_enum}}; | 49 m_type = {{member.specific_type_enum}}; |
49 } | 50 } |
50 | 51 |
51 {{container.cpp_class}} {{container.cpp_class}}::from{{member.type_name}}({{memb
er.rvalue_cpp_type}} value) | 52 {{container.cpp_class}} {{container.cpp_class}}::from{{member.type_name}}({{memb
er.rvalue_cpp_type}} value) |
52 { | 53 { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 {{v8_value_to_local_cpp_value(container.numeric_type) | indent(8)}} | 130 {{v8_value_to_local_cpp_value(container.numeric_type) | indent(8)}} |
130 impl.set{{container.numeric_type.type_name}}(cppValue); | 131 impl.set{{container.numeric_type.type_name}}(cppValue); |
131 return; | 132 return; |
132 } | 133 } |
133 | 134 |
134 {% endif %} | 135 {% endif %} |
135 {% if container.string_type %} | 136 {% if container.string_type %} |
136 {# 16. String #} | 137 {# 16. String #} |
137 { | 138 { |
138 {{v8_value_to_local_cpp_value(container.string_type) | indent(8)}} | 139 {{v8_value_to_local_cpp_value(container.string_type) | indent(8)}} |
139 {% if container.string_type.enum_validation_expression %} | 140 {% if container.string_type.enum_values %} |
140 String string = cppValue; | 141 {{declare_enum_validation_variable(container.string_type.enum_values) |
indent(8)}} |
141 if (!({{container.string_type.enum_validation_expression}})) { | 142 if (!isValidEnum(cppValue, validValues, {{container.string_type.enum_val
ues|length}})) { |
142 exceptionState.throwTypeError("'" + string + "' is not a valid enum
value."); | 143 exceptionState.throwTypeError("'" + String(cppValue) + "' is not a v
alid enum value."); |
143 return; | 144 return; |
144 } | 145 } |
145 {% endif %} | 146 {% endif %} |
146 impl.set{{container.string_type.type_name}}(cppValue); | 147 impl.set{{container.string_type.type_name}}(cppValue); |
147 return; | 148 return; |
148 } | 149 } |
149 | 150 |
150 {# 17. Number (fallback) #} | 151 {# 17. Number (fallback) #} |
151 {% elif container.numeric_type %} | 152 {% elif container.numeric_type %} |
152 { | 153 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 187 |
187 {{container.cpp_class}} NativeValueTraits<{{container.cpp_class}}>::nativeValue(
v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState
) | 188 {{container.cpp_class}} NativeValueTraits<{{container.cpp_class}}>::nativeValue(
v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState
) |
188 { | 189 { |
189 {{container.cpp_class}} impl; | 190 {{container.cpp_class}} impl; |
190 V8{{container.cpp_class}}::toImpl(isolate, value, impl, exceptionState); | 191 V8{{container.cpp_class}}::toImpl(isolate, value, impl, exceptionState); |
191 return impl; | 192 return impl; |
192 } | 193 } |
193 | 194 |
194 {% endfor %} | 195 {% endfor %} |
195 } // namespace blink | 196 } // namespace blink |
OLD | NEW |