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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 'parent_v8_class': v8_types.v8_type(parent_cpp_class), | 73 'parent_v8_class': v8_types.v8_type(parent_cpp_class), |
74 }) | 74 }) |
75 return context | 75 return context |
76 | 76 |
77 | 77 |
78 def member_context(dictionary, member): | 78 def member_context(dictionary, member): |
79 idl_type = member.idl_type | 79 idl_type = member.idl_type |
80 idl_type.add_includes_for_type() | 80 idl_type.add_includes_for_type() |
81 unwrapped_idl_type = unwrap_nullable_if_needed(idl_type) | 81 unwrapped_idl_type = unwrap_nullable_if_needed(idl_type) |
82 | 82 |
83 restricted_float = ( | |
84 has_extended_attribute_value(dictionary, 'TypeChecking', 'Unrestricted')
or | |
85 has_extended_attribute_value(member, 'TypeChecking', 'Unrestricted')) | |
86 | |
87 def default_values(): | 83 def default_values(): |
88 if not member.default_value: | 84 if not member.default_value: |
89 return None, None | 85 return None, None |
90 if member.default_value.is_null: | 86 if member.default_value.is_null: |
91 return None, 'v8::Null(isolate)' | 87 return None, 'v8::Null(isolate)' |
92 cpp_default_value = unwrapped_idl_type.literal_cpp_value( | 88 cpp_default_value = unwrapped_idl_type.literal_cpp_value( |
93 member.default_value) | 89 member.default_value) |
94 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value( | 90 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value( |
95 cpp_value=cpp_default_value, isolate='isolate', | 91 cpp_value=cpp_default_value, isolate='isolate', |
96 creation_context='creationContext') | 92 creation_context='creationContext') |
(...skipping 16 matching lines...) Expand all Loading... |
113 'idl_type': idl_type.base_type, | 109 'idl_type': idl_type.base_type, |
114 'is_interface_type': idl_type.is_interface_type and not idl_type.is_dict
ionary, | 110 'is_interface_type': idl_type.is_interface_type and not idl_type.is_dict
ionary, |
115 'is_nullable': idl_type.is_nullable, | 111 'is_nullable': idl_type.is_nullable, |
116 'is_object': unwrapped_idl_type.name == 'Object', | 112 'is_object': unwrapped_idl_type.name == 'Object', |
117 'name': member.name, | 113 'name': member.name, |
118 'setter_name': setter_name_for_dictionary_member(member), | 114 'setter_name': setter_name_for_dictionary_member(member), |
119 'null_setter_name': null_setter_name_for_dictionary_member(member), | 115 'null_setter_name': null_setter_name_for_dictionary_member(member), |
120 'v8_default_value': v8_default_value, | 116 'v8_default_value': v8_default_value, |
121 'v8_value_to_local_cpp_value': unwrapped_idl_type.v8_value_to_local_cpp_
value( | 117 'v8_value_to_local_cpp_value': unwrapped_idl_type.v8_value_to_local_cpp_
value( |
122 member.extended_attributes, member.name + 'Value', | 118 member.extended_attributes, member.name + 'Value', |
123 member.name, isolate='isolate', use_exception_state=True, | 119 member.name, isolate='isolate', use_exception_state=True), |
124 restricted_float=restricted_float), | |
125 } | 120 } |
126 | 121 |
127 | 122 |
128 # Context for implementation classes | 123 # Context for implementation classes |
129 | 124 |
130 def dictionary_impl_context(dictionary, interfaces_info): | 125 def dictionary_impl_context(dictionary, interfaces_info): |
131 def remove_duplicate_members(members): | 126 def remove_duplicate_members(members): |
132 # When [ImplementedAs] is used, cpp_name can conflict. For example, | 127 # When [ImplementedAs] is used, cpp_name can conflict. For example, |
133 # dictionary D { long foo; [ImplementedAs=foo, DeprecateAs=Foo] long old
Foo; }; | 128 # dictionary D { long foo; [ImplementedAs=foo, DeprecateAs=Foo] long old
Foo; }; |
134 # This function removes such duplications, checking they have the same t
ype. | 129 # This function removes such duplications, checking they have the same t
ype. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 'getter_expression': getter_expression(), | 191 'getter_expression': getter_expression(), |
197 'has_method_expression': has_method_expression(), | 192 'has_method_expression': has_method_expression(), |
198 'has_method_name': has_method_name_for_dictionary_member(member), | 193 'has_method_name': has_method_name_for_dictionary_member(member), |
199 'is_object': is_object, | 194 'is_object': is_object, |
200 'is_traceable': idl_type.is_traceable, | 195 'is_traceable': idl_type.is_traceable, |
201 'member_cpp_type': member_cpp_type(), | 196 'member_cpp_type': member_cpp_type(), |
202 'null_setter_name': null_setter_name_for_dictionary_member(member), | 197 'null_setter_name': null_setter_name_for_dictionary_member(member), |
203 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), | 198 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), |
204 'setter_name': setter_name_for_dictionary_member(member), | 199 'setter_name': setter_name_for_dictionary_member(member), |
205 } | 200 } |
OLD | NEW |