| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """This module provides shared functionality for the system to generate | 6 """This module provides shared functionality for the system to generate |
| 7 dart:html APIs from the IDL database.""" | 7 dart:html APIs from the IDL database.""" |
| 8 | 8 |
| 9 import emitter | 9 import emitter |
| 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ | 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 self.AddOperation(info, declare_only) | 104 self.AddOperation(info, declare_only) |
| 105 if ('%s.%s' % (interface.id, info.declared_name) in | 105 if ('%s.%s' % (interface.id, info.declared_name) in |
| 106 convert_to_future_members): | 106 convert_to_future_members): |
| 107 self.AddOperation(ConvertToFuture(info), declare_only) | 107 self.AddOperation(ConvertToFuture(info), declare_only) |
| 108 | 108 |
| 109 def AddSecondaryMembers(self, interface): | 109 def AddSecondaryMembers(self, interface): |
| 110 # With multiple inheritance, attributes and operations of non-first | 110 # With multiple inheritance, attributes and operations of non-first |
| 111 # interfaces need to be added. Sometimes the attribute or operation is | 111 # interfaces need to be added. Sometimes the attribute or operation is |
| 112 # defined in the current interface as well as a parent. In that case we | 112 # defined in the current interface as well as a parent. In that case we |
| 113 # avoid making a duplicate definition and pray that the signatures match. | 113 # avoid making a duplicate definition and pray that the signatures match. |
| 114 inherited_attrs = [] |
| 115 inherited_ops = [] |
| 114 secondary_parents = self._database.TransitiveSecondaryParents(interface) | 116 secondary_parents = self._database.TransitiveSecondaryParents(interface) |
| 115 for parent_interface in sorted(secondary_parents): | 117 for parent_interface in sorted(secondary_parents): |
| 116 if isinstance(parent_interface, str): | 118 if isinstance(parent_interface, str): |
| 117 continue | 119 continue |
| 118 for attr in sorted(parent_interface.attributes, ConstantOutputOrder): | 120 for attr in sorted(parent_interface.attributes, ConstantOutputOrder): |
| 119 if not FindMatchingAttribute(interface, attr): | 121 if (not FindMatchingAttribute(interface, attr) or |
| 122 attr.id not in inherited_attrs): |
| 120 if attr.type.id != 'EventHandler': | 123 if attr.type.id != 'EventHandler': |
| 121 self.SecondaryContext(parent_interface) | 124 self.SecondaryContext(parent_interface) |
| 122 self.AddAttribute(attr) | 125 self.AddAttribute(attr) |
| 126 inherited_attrs.append(attr.id) |
| 123 | 127 |
| 124 # Group overloaded operations by name. | 128 # Group overloaded operations by name. |
| 125 operationsByName =self._OperationsByName(parent_interface) | 129 operationsByName =self._OperationsByName(parent_interface) |
| 126 | 130 |
| 127 if self.OmitOperationOverrides(): | 131 if self.OmitOperationOverrides(): |
| 128 self._RemoveShadowingOperationsWithSameSignature(operationsByName, | 132 self._RemoveShadowingOperationsWithSameSignature(operationsByName, |
| 129 interface) | 133 interface) |
| 130 | 134 |
| 131 # Generate operations. | 135 # Generate operations. |
| 132 for id in sorted(operationsByName.keys()): | 136 for id in sorted(operationsByName.keys()): |
| 133 if not any(op.id == id for op in interface.operations): | 137 if (not any(op.id == id for op in interface.operations) |
| 138 or id not in inherited_ops): |
| 134 operations = operationsByName[id] | 139 operations = operationsByName[id] |
| 135 info = AnalyzeOperation(interface, operations) | 140 info = AnalyzeOperation(interface, operations) |
| 136 self.SecondaryContext(parent_interface) | 141 self.SecondaryContext(parent_interface) |
| 137 self.AddOperation(info) | 142 self.AddOperation(info) |
| 143 inherited_ops.append(id) |
| 138 | 144 |
| 139 def _RemoveShadowingOperationsWithSameSignature(self, operationsByName, | 145 def _RemoveShadowingOperationsWithSameSignature(self, operationsByName, |
| 140 interface): | 146 interface): |
| 141 if not interface.parents: | 147 if not interface.parents: |
| 142 return | 148 return |
| 143 | 149 |
| 144 parent = self._database.GetInterface(interface.parents[0].type.id) | 150 parent = self._database.GetInterface(interface.parents[0].type.id) |
| 145 if parent == self._interface or parent == interface: | 151 if parent == self._interface or parent == interface: |
| 146 return | 152 return |
| 147 for operation in parent.operations: | 153 for operation in parent.operations: |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 | 707 |
| 702 def SecureBaseName(self, type_name): | 708 def SecureBaseName(self, type_name): |
| 703 if type_name in _secure_base_types: | 709 if type_name in _secure_base_types: |
| 704 return _secure_base_types[type_name] | 710 return _secure_base_types[type_name] |
| 705 | 711 |
| 706 def _DartType(self, type_name): | 712 def _DartType(self, type_name): |
| 707 return self._type_registry.DartType(type_name) | 713 return self._type_registry.DartType(type_name) |
| 708 | 714 |
| 709 def _TypeInfo(self, type_name): | 715 def _TypeInfo(self, type_name): |
| 710 return self._type_registry.TypeInfo(type_name) | 716 return self._type_registry.TypeInfo(type_name) |
| OLD | NEW |