| 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 if member.is_required and member.default_value: |
| 84 raise Exception( |
| 85 'Required member %s must not have a default value.' % member.name) |
| 86 |
| 83 def default_values(): | 87 def default_values(): |
| 84 if not member.default_value: | 88 if not member.default_value: |
| 85 return None, None | 89 return None, None |
| 86 if member.default_value.is_null: | 90 if member.default_value.is_null: |
| 87 return None, 'v8::Null(isolate)' | 91 return None, 'v8::Null(isolate)' |
| 88 cpp_default_value = unwrapped_idl_type.literal_cpp_value( | 92 cpp_default_value = unwrapped_idl_type.literal_cpp_value( |
| 89 member.default_value) | 93 member.default_value) |
| 90 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value( | 94 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value( |
| 91 cpp_value=cpp_default_value, isolate='isolate', | 95 cpp_value=cpp_default_value, isolate='isolate', |
| 92 creation_context='creationContext') | 96 creation_context='creationContext') |
| (...skipping 10 matching lines...) Expand all Loading... |
| 103 cpp_value='impl.%s()' % cpp_name, isolate='isolate', | 107 cpp_value='impl.%s()' % cpp_name, isolate='isolate', |
| 104 creation_context='creationContext', | 108 creation_context='creationContext', |
| 105 extended_attributes=member.extended_attributes), | 109 extended_attributes=member.extended_attributes), |
| 106 'deprecate_as': v8_utilities.deprecate_as(member), | 110 'deprecate_as': v8_utilities.deprecate_as(member), |
| 107 'enum_validation_expression': unwrapped_idl_type.enum_validation_express
ion, | 111 'enum_validation_expression': unwrapped_idl_type.enum_validation_express
ion, |
| 108 'has_method_name': has_method_name_for_dictionary_member(member), | 112 'has_method_name': has_method_name_for_dictionary_member(member), |
| 109 'idl_type': idl_type.base_type, | 113 'idl_type': idl_type.base_type, |
| 110 'is_interface_type': idl_type.is_interface_type and not idl_type.is_dict
ionary, | 114 'is_interface_type': idl_type.is_interface_type and not idl_type.is_dict
ionary, |
| 111 'is_nullable': idl_type.is_nullable, | 115 'is_nullable': idl_type.is_nullable, |
| 112 'is_object': unwrapped_idl_type.name == 'Object', | 116 'is_object': unwrapped_idl_type.name == 'Object', |
| 117 'is_required': member.is_required, |
| 113 'name': member.name, | 118 'name': member.name, |
| 114 'setter_name': setter_name_for_dictionary_member(member), | 119 'setter_name': setter_name_for_dictionary_member(member), |
| 115 'null_setter_name': null_setter_name_for_dictionary_member(member), | 120 'null_setter_name': null_setter_name_for_dictionary_member(member), |
| 116 'v8_default_value': v8_default_value, | 121 'v8_default_value': v8_default_value, |
| 117 'v8_value_to_local_cpp_value': unwrapped_idl_type.v8_value_to_local_cpp_
value( | 122 'v8_value_to_local_cpp_value': unwrapped_idl_type.v8_value_to_local_cpp_
value( |
| 118 member.extended_attributes, member.name + 'Value', | 123 member.extended_attributes, member.name + 'Value', |
| 119 member.name, isolate='isolate', use_exception_state=True), | 124 member.name, isolate='isolate', use_exception_state=True), |
| 120 } | 125 } |
| 121 | 126 |
| 122 | 127 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 'getter_expression': getter_expression(), | 196 'getter_expression': getter_expression(), |
| 192 'has_method_expression': has_method_expression(), | 197 'has_method_expression': has_method_expression(), |
| 193 'has_method_name': has_method_name_for_dictionary_member(member), | 198 'has_method_name': has_method_name_for_dictionary_member(member), |
| 194 'is_object': is_object, | 199 'is_object': is_object, |
| 195 'is_traceable': idl_type.is_traceable, | 200 'is_traceable': idl_type.is_traceable, |
| 196 'member_cpp_type': member_cpp_type(), | 201 'member_cpp_type': member_cpp_type(), |
| 197 'null_setter_name': null_setter_name_for_dictionary_member(member), | 202 'null_setter_name': null_setter_name_for_dictionary_member(member), |
| 198 '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), |
| 199 'setter_name': setter_name_for_dictionary_member(member), | 204 'setter_name': setter_name_for_dictionary_member(member), |
| 200 } | 205 } |
| OLD | NEW |