OLD | NEW |
---|---|
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}}. DO NOT MODIFY! | 5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY! |
6 | 6 |
7 #include "config.h" | 7 #include "config.h" |
8 #include "{{header_filename}}" | 8 #include "{{header_filename}}" |
9 | 9 |
10 {% macro assign_and_return_if_hasinstance(member) %} | 10 {% macro assign_and_return_if_hasinstance(member) %} |
(...skipping 18 matching lines...) Expand all Loading... | |
29 {% for member in container.members %} | 29 {% for member in container.members %} |
30 {{member.rvalue_cpp_type}} {{container.cpp_class}}::getAs{{member.type_name}}() const | 30 {{member.rvalue_cpp_type}} {{container.cpp_class}}::getAs{{member.type_name}}() const |
31 { | 31 { |
32 ASSERT(is{{member.type_name}}()); | 32 ASSERT(is{{member.type_name}}()); |
33 return m_{{member.cpp_name}}; | 33 return m_{{member.cpp_name}}; |
34 } | 34 } |
35 | 35 |
36 void {{container.cpp_class}}::set{{member.type_name}}({{member.rvalue_cpp_type}} value) | 36 void {{container.cpp_class}}::set{{member.type_name}}({{member.rvalue_cpp_type}} value) |
37 { | 37 { |
38 ASSERT(isNull()); | 38 ASSERT(isNull()); |
39 {% if member.enum_validation_expression %} | |
40 String string = value; | |
41 if (!({{member.enum_validation_expression}})) { | |
42 ASSERT_NOT_REACHED(); | |
43 return; | |
44 } | |
45 {% endif %} | |
39 m_{{member.cpp_name}} = value; | 46 m_{{member.cpp_name}} = value; |
40 m_type = {{member.specific_type_enum}}; | 47 m_type = {{member.specific_type_enum}}; |
41 } | 48 } |
42 | 49 |
43 {% endfor %} | 50 {% endfor %} |
44 {% if container.needs_trace %} | 51 {% if container.needs_trace %} |
45 void {{container.cpp_class}}::trace(Visitor* visitor) | 52 void {{container.cpp_class}}::trace(Visitor* visitor) |
46 { | 53 { |
47 {% for member in container.members if member.is_traceable %} | 54 {% for member in container.members if member.is_traceable %} |
48 visitor->trace(m_{{member.cpp_name}}); | 55 visitor->trace(m_{{member.cpp_name}}); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 | 128 |
122 {% endif %} | 129 {% endif %} |
123 {% if container.string_type %} | 130 {% if container.string_type %} |
124 {# 16. String #} | 131 {# 16. String #} |
125 { | 132 { |
126 {{container.string_type.v8_value_to_local_cpp_value}}; | 133 {{container.string_type.v8_value_to_local_cpp_value}}; |
127 impl.set{{container.string_type.type_name}}(cppValue); | 134 impl.set{{container.string_type.type_name}}(cppValue); |
128 return; | 135 return; |
129 } | 136 } |
130 | 137 |
138 {# 16.1 Enum #} | |
Jens Widell
2015/01/16 09:53:51
If we treat an enum as a string type, this block c
bashi
2015/01/16 10:11:58
Right. Will do when we decide to treat an enum as
| |
139 {% elif container.enum_type %} | |
140 { | |
141 {{container.enum_type.v8_value_to_local_cpp_value}}; | |
142 String string = cppValue; | |
143 if (!({{container.enum_type.enum_validation_expression}})) { | |
144 exceptionState.throwTypeError("'" + string + "' is not a valid enum value."); | |
145 return; | |
146 } | |
147 impl.set{{container.enum_type.type_name}}(cppValue); | |
148 return; | |
149 } | |
150 | |
131 {# 17. Number (fallback) #} | 151 {# 17. Number (fallback) #} |
132 {% elif container.numeric_type %} | 152 {% elif container.numeric_type %} |
133 { | 153 { |
134 {{container.numeric_type.v8_value_to_local_cpp_value}}; | 154 {{container.numeric_type.v8_value_to_local_cpp_value}}; |
135 impl.set{{container.numeric_type.type_name}}(cppValue); | 155 impl.set{{container.numeric_type.type_name}}(cppValue); |
136 return; | 156 return; |
137 } | 157 } |
138 | 158 |
139 {# 18. Boolean (fallback) #} | 159 {# 18. Boolean (fallback) #} |
140 {% elif container.boolean_type %} | 160 {% elif container.boolean_type %} |
(...skipping 26 matching lines...) Expand all Loading... | |
167 | 187 |
168 {{container.cpp_class}} NativeValueTraits<{{container.cpp_class}}>::nativeValue( const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& excepti onState) | 188 {{container.cpp_class}} NativeValueTraits<{{container.cpp_class}}>::nativeValue( const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& excepti onState) |
169 { | 189 { |
170 {{container.cpp_class}} impl; | 190 {{container.cpp_class}} impl; |
171 V8{{container.cpp_class}}::toImpl(isolate, value, impl, exceptionState); | 191 V8{{container.cpp_class}}::toImpl(isolate, value, impl, exceptionState); |
172 return impl; | 192 return impl; |
173 } | 193 } |
174 | 194 |
175 {% endfor %} | 195 {% endfor %} |
176 } // namespace blink | 196 } // namespace blink |
OLD | NEW |