| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 if self._database.HasInterface(parent.type.id): | 92 if self._database.HasInterface(parent.type.id): |
| 93 parent_interface = self._database.GetInterface(parent.type.id) | 93 parent_interface = self._database.GetInterface(parent.type.id) |
| 94 for attr in parent_interface.attributes: | 94 for attr in parent_interface.attributes: |
| 95 result.add(attr.id) | 95 result.add(attr.id) |
| 96 for op in parent_interface.operations: | 96 for op in parent_interface.operations: |
| 97 result.add(op.id) | 97 result.add(op.id) |
| 98 WalkParentChain(parent_interface) | 98 WalkParentChain(parent_interface) |
| 99 | 99 |
| 100 result = set() | 100 result = set() |
| 101 WalkParentChain(interface) | 101 WalkParentChain(interface) |
| 102 return result; | 102 return result |
| 103 | 103 |
| 104 class BaseGenerator(object): | 104 class BaseGenerator(object): |
| 105 def __init__(self, database, interface): | 105 def __init__(self, database, interface): |
| 106 self._database = database | 106 self._database = database |
| 107 self._interface = interface | 107 self._interface = interface |
| 108 | 108 |
| 109 def Generate(self): | 109 def Generate(self): |
| 110 self.StartInterface() | 110 self.StartInterface() |
| 111 self.AddMembers(self._interface) | 111 self.AddMembers(self._interface) |
| 112 self.AddSecondaryMembers(self._interface) | 112 self.AddSecondaryMembers(self._interface) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 result.append(parent_interface) | 214 result.append(parent_interface) |
| 215 walk(parent_interface.parents) | 215 walk(parent_interface.parents) |
| 216 | 216 |
| 217 result = [] | 217 result = [] |
| 218 if interface.parents: | 218 if interface.parents: |
| 219 parent = interface.parents[0] | 219 parent = interface.parents[0] |
| 220 if IsPureInterface(parent.type.id): | 220 if IsPureInterface(parent.type.id): |
| 221 walk(interface.parents) | 221 walk(interface.parents) |
| 222 else: | 222 else: |
| 223 walk(interface.parents[1:]) | 223 walk(interface.parents[1:]) |
| 224 return result; | 224 return result |
| 225 | 225 |
| 226 | 226 |
| 227 def _PairUpAttributes(attributes): | 227 def _PairUpAttributes(attributes): |
| 228 """Returns a list of (getter, setter) pairs sorted by name. | 228 """Returns a list of (getter, setter) pairs sorted by name. |
| 229 | 229 |
| 230 One element of the pair may be None. | 230 One element of the pair may be None. |
| 231 """ | 231 """ |
| 232 names = sorted(set(attr.id for attr in attributes)) | 232 names = sorted(set(attr.id for attr in attributes)) |
| 233 getters = {} | 233 getters = {} |
| 234 setters = {} | 234 setters = {} |
| 235 for attr in attributes: | 235 for attr in attributes: |
| 236 if attr.is_fc_getter: | 236 if attr.is_fc_getter: |
| 237 getters[attr.id] = attr | 237 getters[attr.id] = attr |
| 238 elif attr.is_fc_setter and 'Replaceable' not in attr.ext_attrs: | 238 elif attr.is_fc_setter and 'Replaceable' not in attr.ext_attrs: |
| 239 setters[attr.id] = attr | 239 setters[attr.id] = attr |
| 240 return [(getters.get(id), setters.get(id)) for id in names] | 240 return [(getters.get(id), setters.get(id)) for id in names] |
| OLD | NEW |