| 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 NonThrowableExceptionState exceptionState; |
| 42 if (!({{member.enum_validation_expression}})) { | 43 {{declare_enum_validation_variable(member.enum_values) | indent}} |
| 44 if (!isValidEnum(value, validValues, WTF_ARRAY_LENGTH(validValues), exceptio
nState)) { |
| 43 ASSERT_NOT_REACHED(); | 45 ASSERT_NOT_REACHED(); |
| 44 return; | 46 return; |
| 45 } | 47 } |
| 46 {% endif %} | 48 {% endif %} |
| 47 m_{{member.cpp_name}} = value; | 49 m_{{member.cpp_name}} = value; |
| 48 m_type = {{member.specific_type_enum}}; | 50 m_type = {{member.specific_type_enum}}; |
| 49 } | 51 } |
| 50 | 52 |
| 51 {{container.cpp_class}} {{container.cpp_class}}::from{{member.type_name}}({{memb
er.rvalue_cpp_type}} value) | 53 {{container.cpp_class}} {{container.cpp_class}}::from{{member.type_name}}({{memb
er.rvalue_cpp_type}} value) |
| 52 { | 54 { |
| (...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)}} | 131 {{v8_value_to_local_cpp_value(container.numeric_type) | indent(8)}} |
| 130 impl.set{{container.numeric_type.type_name}}(cppValue); | 132 impl.set{{container.numeric_type.type_name}}(cppValue); |
| 131 return; | 133 return; |
| 132 } | 134 } |
| 133 | 135 |
| 134 {% endif %} | 136 {% endif %} |
| 135 {% if container.string_type %} | 137 {% if container.string_type %} |
| 136 {# 16. String #} | 138 {# 16. String #} |
| 137 { | 139 { |
| 138 {{v8_value_to_local_cpp_value(container.string_type) | indent(8)}} | 140 {{v8_value_to_local_cpp_value(container.string_type) | indent(8)}} |
| 139 {% if container.string_type.enum_validation_expression %} | 141 {% if container.string_type.enum_values %} |
| 140 String string = cppValue; | 142 {{declare_enum_validation_variable(container.string_type.enum_values) |
indent(8)}} |
| 141 if (!({{container.string_type.enum_validation_expression}})) { | 143 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), e
xceptionState)) |
| 142 exceptionState.throwTypeError("'" + string + "' is not a valid enum
value."); | |
| 143 return; | 144 return; |
| 144 } | |
| 145 {% endif %} | 145 {% endif %} |
| 146 impl.set{{container.string_type.type_name}}(cppValue); | 146 impl.set{{container.string_type.type_name}}(cppValue); |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 | 149 |
| 150 {# 17. Number (fallback) #} | 150 {# 17. Number (fallback) #} |
| 151 {% elif container.numeric_type %} | 151 {% elif container.numeric_type %} |
| 152 { | 152 { |
| 153 {{v8_value_to_local_cpp_value(container.numeric_type) | indent(8)}} | 153 {{v8_value_to_local_cpp_value(container.numeric_type) | indent(8)}} |
| 154 impl.set{{container.numeric_type.type_name}}(cppValue); | 154 impl.set{{container.numeric_type.type_name}}(cppValue); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 {{container.cpp_class}} NativeValueTraits<{{container.cpp_class}}>::nativeValue(
v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState
) | 187 {{container.cpp_class}} NativeValueTraits<{{container.cpp_class}}>::nativeValue(
v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState
) |
| 188 { | 188 { |
| 189 {{container.cpp_class}} impl; | 189 {{container.cpp_class}} impl; |
| 190 V8{{container.cpp_class}}::toImpl(isolate, value, impl, exceptionState); | 190 V8{{container.cpp_class}}::toImpl(isolate, value, impl, exceptionState); |
| 191 return impl; | 191 return impl; |
| 192 } | 192 } |
| 193 | 193 |
| 194 {% endfor %} | 194 {% endfor %} |
| 195 } // namespace blink | 195 } // namespace blink |
| OLD | NEW |