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 """Generate template contexts of dictionaries for both v8 bindings and | 5 """Generate template contexts of dictionaries for both v8 bindings and |
6 implementation classes that are used by blink's core/modules. | 6 implementation classes that are used by blink's core/modules. |
7 """ | 7 """ |
8 | 8 |
9 import operator | 9 import operator |
10 from idl_types import IdlType | 10 from idl_types import IdlType |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 restricted_float = ( | 83 restricted_float = ( |
84 has_extended_attribute_value(dictionary, 'TypeChecking', 'Unrestricted')
or | 84 has_extended_attribute_value(dictionary, 'TypeChecking', 'Unrestricted')
or |
85 has_extended_attribute_value(member, 'TypeChecking', 'Unrestricted')) | 85 has_extended_attribute_value(member, 'TypeChecking', 'Unrestricted')) |
86 | 86 |
87 def default_values(): | 87 def default_values(): |
88 if not member.default_value: | 88 if not member.default_value: |
89 return None, None | 89 return None, None |
90 if member.default_value.is_null: | 90 if member.default_value.is_null: |
91 return None, 'v8::Null(isolate)' | 91 return None, 'v8::Null(isolate)' |
92 cpp_default_value = str(member.default_value) | 92 cpp_default_value = unwrapped_idl_type.literal_cpp_value( |
| 93 member.default_value) |
93 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value( | 94 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value( |
94 cpp_value=cpp_default_value, isolate='isolate', | 95 cpp_value=cpp_default_value, isolate='isolate', |
95 creation_context='creationContext') | 96 creation_context='creationContext') |
96 return cpp_default_value, v8_default_value | 97 return cpp_default_value, v8_default_value |
97 | 98 |
98 cpp_default_value, v8_default_value = default_values() | 99 cpp_default_value, v8_default_value = default_values() |
99 cpp_name = v8_utilities.cpp_name(member) | 100 cpp_name = v8_utilities.cpp_name(member) |
100 | 101 |
101 return { | 102 return { |
102 'cpp_default_value': cpp_default_value, | 103 'cpp_default_value': cpp_default_value, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return 'm_%s' % cpp_name | 180 return 'm_%s' % cpp_name |
180 | 181 |
181 def member_cpp_type(): | 182 def member_cpp_type(): |
182 member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True) | 183 member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True) |
183 if idl_type.impl_should_use_nullable_container: | 184 if idl_type.impl_should_use_nullable_container: |
184 return v8_types.cpp_template_type('Nullable', member_cpp_type) | 185 return v8_types.cpp_template_type('Nullable', member_cpp_type) |
185 return member_cpp_type | 186 return member_cpp_type |
186 | 187 |
187 cpp_default_value = None | 188 cpp_default_value = None |
188 if member.default_value and not member.default_value.is_null: | 189 if member.default_value and not member.default_value.is_null: |
189 cpp_default_value = str(member.default_value) | 190 cpp_default_value = idl_type.literal_cpp_value(member.default_value) |
190 | 191 |
191 header_includes.update(idl_type.impl_includes_for_type(interfaces_info)) | 192 header_includes.update(idl_type.impl_includes_for_type(interfaces_info)) |
192 return { | 193 return { |
193 'cpp_default_value': cpp_default_value, | 194 'cpp_default_value': cpp_default_value, |
194 'cpp_name': cpp_name, | 195 'cpp_name': cpp_name, |
195 'getter_expression': getter_expression(), | 196 'getter_expression': getter_expression(), |
196 'has_method_expression': has_method_expression(), | 197 'has_method_expression': has_method_expression(), |
197 'has_method_name': has_method_name_for_dictionary_member(member), | 198 'has_method_name': has_method_name_for_dictionary_member(member), |
198 'is_object': is_object, | 199 'is_object': is_object, |
199 'is_traceable': idl_type.is_traceable, | 200 'is_traceable': idl_type.is_traceable, |
200 'member_cpp_type': member_cpp_type(), | 201 'member_cpp_type': member_cpp_type(), |
201 'null_setter_name': null_setter_name_for_dictionary_member(member), | 202 'null_setter_name': null_setter_name_for_dictionary_member(member), |
202 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), | 203 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), |
203 'setter_name': setter_name_for_dictionary_member(member), | 204 'setter_name': setter_name_for_dictionary_member(member), |
204 } | 205 } |
OLD | NEW |