| 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 base functionality for systems to generate | 6 """This module provides base functionality for systems to generate |
| 7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 from generator import * | 10 from generator import * |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 self.AddSecondaryMembers(self._interface) | 71 self.AddSecondaryMembers(self._interface) |
| 72 self.FinishInterface() | 72 self.FinishInterface() |
| 73 | 73 |
| 74 def GenerateCallback(self, info): | 74 def GenerateCallback(self, info): |
| 75 pass | 75 pass |
| 76 | 76 |
| 77 def AddMembers(self, interface): | 77 def AddMembers(self, interface): |
| 78 for const in sorted(interface.constants, ConstantOutputOrder): | 78 for const in sorted(interface.constants, ConstantOutputOrder): |
| 79 self.AddConstant(const) | 79 self.AddConstant(const) |
| 80 | 80 |
| 81 for attr in interface.attributes: | 81 for attr in sorted(interface.attributes, ConstantOutputOrder): |
| 82 if attr.type.id != 'EventListener': | 82 if attr.type.id != 'EventListener': |
| 83 self.AddAttribute(attr) | 83 self.AddAttribute(attr) |
| 84 | 84 |
| 85 # The implementation should define an indexer if the interface directly | 85 # The implementation should define an indexer if the interface directly |
| 86 # extends List. | 86 # extends List. |
| 87 (element_type, requires_indexer) = ListImplementationInfo( | 87 (element_type, requires_indexer) = ListImplementationInfo( |
| 88 interface, self._database) | 88 interface, self._database) |
| 89 if element_type: | 89 if element_type: |
| 90 if requires_indexer: | 90 if requires_indexer: |
| 91 self.AddIndexer(element_type) | 91 self.AddIndexer(element_type) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 106 | 106 |
| 107 def AddSecondaryMembers(self, interface): | 107 def AddSecondaryMembers(self, interface): |
| 108 # With multiple inheritance, attributes and operations of non-first | 108 # With multiple inheritance, attributes and operations of non-first |
| 109 # interfaces need to be added. Sometimes the attribute or operation is | 109 # interfaces need to be added. Sometimes the attribute or operation is |
| 110 # defined in the current interface as well as a parent. In that case we | 110 # defined in the current interface as well as a parent. In that case we |
| 111 # avoid making a duplicate definition and pray that the signatures match. | 111 # avoid making a duplicate definition and pray that the signatures match. |
| 112 secondary_parents = self._TransitiveSecondaryParents(interface) | 112 secondary_parents = self._TransitiveSecondaryParents(interface) |
| 113 for parent_interface in secondary_parents: | 113 for parent_interface in secondary_parents: |
| 114 if isinstance(parent_interface, str): # IsDartCollectionType(parent_inter
face) | 114 if isinstance(parent_interface, str): # IsDartCollectionType(parent_inter
face) |
| 115 continue | 115 continue |
| 116 for attr in parent_interface.attributes: | 116 for attr in sorted(parent_interface.attributes, ConstantOutputOrder): |
| 117 if not FindMatchingAttribute(interface, attr): | 117 if not FindMatchingAttribute(interface, attr): |
| 118 self.AddSecondaryAttribute(parent_interface, attr) | 118 self.AddSecondaryAttribute(parent_interface, attr) |
| 119 | 119 |
| 120 # Group overloaded operations by id | 120 # Group overloaded operations by id |
| 121 operationsById = {} | 121 operationsById = {} |
| 122 for operation in parent_interface.operations: | 122 for operation in parent_interface.operations: |
| 123 if operation.id not in operationsById: | 123 if operation.id not in operationsById: |
| 124 operationsById[operation.id] = [] | 124 operationsById[operation.id] = [] |
| 125 operationsById[operation.id].append(operation) | 125 operationsById[operation.id].append(operation) |
| 126 | 126 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 class GeneratorOptions(object): | 187 class GeneratorOptions(object): |
| 188 def __init__(self, templates, database, type_registry, renamer): | 188 def __init__(self, templates, database, type_registry, renamer): |
| 189 self.templates = templates | 189 self.templates = templates |
| 190 self.database = database | 190 self.database = database |
| 191 self.type_registry = type_registry | 191 self.type_registry = type_registry |
| 192 self.renamer = renamer | 192 self.renamer = renamer |
| 193 | 193 |
| 194 | 194 |
| 195 def IsReadOnly(attribute): | 195 def IsReadOnly(attribute): |
| 196 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs | 196 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs |
| OLD | NEW |