| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 def Generate(self): | 65 def Generate(self): |
| 66 self.StartInterface() | 66 self.StartInterface() |
| 67 self.AddMembers(self._interface) | 67 self.AddMembers(self._interface) |
| 68 self.AddSecondaryMembers(self._interface) | 68 self.AddSecondaryMembers(self._interface) |
| 69 self.FinishInterface() | 69 self.FinishInterface() |
| 70 | 70 |
| 71 def AddMembers(self, interface): | 71 def AddMembers(self, interface): |
| 72 for const in sorted(interface.constants, ConstantOutputOrder): | 72 for const in sorted(interface.constants, ConstantOutputOrder): |
| 73 self.AddConstant(const) | 73 self.AddConstant(const) |
| 74 | 74 |
| 75 for attr in interface.attributes: | 75 for attr in sorted(interface.attributes, ConstantOutputOrder): |
| 76 if attr.type.id != 'EventListener': | 76 if attr.type.id != 'EventListener': |
| 77 self.AddAttribute(attr) | 77 self.AddAttribute(attr) |
| 78 | 78 |
| 79 # The implementation should define an indexer if the interface directly | 79 # The implementation should define an indexer if the interface directly |
| 80 # extends List. | 80 # extends List. |
| 81 (element_type, requires_indexer) = ListImplementationInfo( | 81 (element_type, requires_indexer) = ListImplementationInfo( |
| 82 interface, self._database) | 82 interface, self._database) |
| 83 if element_type: | 83 if element_type: |
| 84 if requires_indexer: | 84 if requires_indexer: |
| 85 self.AddIndexer(element_type) | 85 self.AddIndexer(element_type) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 100 | 100 |
| 101 def AddSecondaryMembers(self, interface): | 101 def AddSecondaryMembers(self, interface): |
| 102 # With multiple inheritance, attributes and operations of non-first | 102 # With multiple inheritance, attributes and operations of non-first |
| 103 # interfaces need to be added. Sometimes the attribute or operation is | 103 # interfaces need to be added. Sometimes the attribute or operation is |
| 104 # defined in the current interface as well as a parent. In that case we | 104 # defined in the current interface as well as a parent. In that case we |
| 105 # avoid making a duplicate definition and pray that the signatures match. | 105 # avoid making a duplicate definition and pray that the signatures match. |
| 106 secondary_parents = self._TransitiveSecondaryParents(interface) | 106 secondary_parents = self._TransitiveSecondaryParents(interface) |
| 107 for parent_interface in secondary_parents: | 107 for parent_interface in secondary_parents: |
| 108 if isinstance(parent_interface, str): # IsDartCollectionType(parent_inter
face) | 108 if isinstance(parent_interface, str): # IsDartCollectionType(parent_inter
face) |
| 109 continue | 109 continue |
| 110 for attr in parent_interface.attributes: | 110 for attr in sorted(parent_interface.attributes, ConstantOutputOrder): |
| 111 if not FindMatchingAttribute(interface, attr): | 111 if not FindMatchingAttribute(interface, attr): |
| 112 self.AddSecondaryAttribute(parent_interface, attr) | 112 self.AddSecondaryAttribute(parent_interface, attr) |
| 113 | 113 |
| 114 # Group overloaded operations by id | 114 # Group overloaded operations by id |
| 115 operationsById = {} | 115 operationsById = {} |
| 116 for operation in parent_interface.operations: | 116 for operation in parent_interface.operations: |
| 117 if operation.id not in operationsById: | 117 if operation.id not in operationsById: |
| 118 operationsById[operation.id] = [] | 118 operationsById[operation.id] = [] |
| 119 operationsById[operation.id].append(operation) | 119 operationsById[operation.id].append(operation) |
| 120 | 120 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 class GeneratorOptions(object): | 178 class GeneratorOptions(object): |
| 179 def __init__(self, templates, database, type_registry, renamer): | 179 def __init__(self, templates, database, type_registry, renamer): |
| 180 self.templates = templates | 180 self.templates = templates |
| 181 self.database = database | 181 self.database = database |
| 182 self.type_registry = type_registry | 182 self.type_registry = type_registry |
| 183 self.renamer = renamer | 183 self.renamer = renamer |
| 184 | 184 |
| 185 | 185 |
| 186 def IsReadOnly(attribute): | 186 def IsReadOnly(attribute): |
| 187 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs | 187 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs |
| OLD | NEW |