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 = [] | |
116 secondary_parents = self._database.TransitiveSecondaryParents(interface) | 114 secondary_parents = self._database.TransitiveSecondaryParents(interface) |
117 for parent_interface in sorted(secondary_parents): | 115 for parent_interface in sorted(secondary_parents): |
118 if isinstance(parent_interface, str): | 116 if isinstance(parent_interface, str): |
119 continue | 117 continue |
120 for attr in sorted(parent_interface.attributes, ConstantOutputOrder): | 118 for attr in sorted(parent_interface.attributes, ConstantOutputOrder): |
121 if (not FindMatchingAttribute(interface, attr) or | 119 if not FindMatchingAttribute(interface, attr): |
122 attr.id not in inherited_attrs): | |
123 if attr.type.id != 'EventHandler': | 120 if attr.type.id != 'EventHandler': |
124 self.SecondaryContext(parent_interface) | 121 self.SecondaryContext(parent_interface) |
125 self.AddAttribute(attr) | 122 self.AddAttribute(attr) |
126 inherited_attrs.append(attr.id) | |
127 | 123 |
128 # Group overloaded operations by name. | 124 # Group overloaded operations by name. |
129 operationsByName =self._OperationsByName(parent_interface) | 125 operationsByName =self._OperationsByName(parent_interface) |
130 | 126 |
131 if self.OmitOperationOverrides(): | 127 if self.OmitOperationOverrides(): |
132 self._RemoveShadowingOperationsWithSameSignature(operationsByName, | 128 self._RemoveShadowingOperationsWithSameSignature(operationsByName, |
133 interface) | 129 interface) |
134 | 130 |
135 # Generate operations. | 131 # Generate operations. |
136 for id in sorted(operationsByName.keys()): | 132 for id in sorted(operationsByName.keys()): |
137 if (not any(op.id == id for op in interface.operations) | 133 if not any(op.id == id for op in interface.operations): |
138 or id not in inherited_ops): | |
139 operations = operationsByName[id] | 134 operations = operationsByName[id] |
140 info = AnalyzeOperation(interface, operations) | 135 info = AnalyzeOperation(interface, operations) |
141 self.SecondaryContext(parent_interface) | 136 self.SecondaryContext(parent_interface) |
142 self.AddOperation(info) | 137 self.AddOperation(info) |
143 inherited_ops.append(id) | |
144 | 138 |
145 def _RemoveShadowingOperationsWithSameSignature(self, operationsByName, | 139 def _RemoveShadowingOperationsWithSameSignature(self, operationsByName, |
146 interface): | 140 interface): |
147 if not interface.parents: | 141 if not interface.parents: |
148 return | 142 return |
149 | 143 |
150 parent = self._database.GetInterface(interface.parents[0].type.id) | 144 parent = self._database.GetInterface(interface.parents[0].type.id) |
151 if parent == self._interface or parent == interface: | 145 if parent == self._interface or parent == interface: |
152 return | 146 return |
153 for operation in parent.operations: | 147 for operation in parent.operations: |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 | 701 |
708 def SecureBaseName(self, type_name): | 702 def SecureBaseName(self, type_name): |
709 if type_name in _secure_base_types: | 703 if type_name in _secure_base_types: |
710 return _secure_base_types[type_name] | 704 return _secure_base_types[type_name] |
711 | 705 |
712 def _DartType(self, type_name): | 706 def _DartType(self, type_name): |
713 return self._type_registry.DartType(type_name) | 707 return self._type_registry.DartType(type_name) |
714 | 708 |
715 def _TypeInfo(self, type_name): | 709 def _TypeInfo(self, type_name): |
716 return self._type_registry.TypeInfo(type_name) | 710 return self._type_registry.TypeInfo(type_name) |
OLD | NEW |