| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, 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 """Module to manage IDL files.""" | 6 """Module to manage IDL files.""" |
| 7 | 7 |
| 8 import copy | 8 import copy |
| 9 import pickle | 9 import pickle |
| 10 import logging | 10 import logging |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 raise RuntimeError('Typedef %s already exists' % type_def_name) | 307 raise RuntimeError('Typedef %s already exists' % type_def_name) |
| 308 self._all_type_defs[type_def_name] = type_def | 308 self._all_type_defs[type_def_name] = type_def |
| 309 print ' Added typedef %s' % type_def_name | 309 print ' Added typedef %s' % type_def_name |
| 310 | 310 |
| 311 def TransitiveSecondaryParents(self, interface, propagate_event_target): | 311 def TransitiveSecondaryParents(self, interface, propagate_event_target): |
| 312 """Returns a list of all non-primary parents. | 312 """Returns a list of all non-primary parents. |
| 313 | 313 |
| 314 The list contains the interface objects for interfaces defined in the | 314 The list contains the interface objects for interfaces defined in the |
| 315 database, and the name for undefined interfaces. | 315 database, and the name for undefined interfaces. |
| 316 """ | 316 """ |
| 317 def walk(parents): | 317 def walk(parents, walk_result): |
| 318 for parent in parents: | 318 for parent in parents: |
| 319 parent_name = parent.type.id | 319 parent_name = parent.type.id |
| 320 if IsDartCollectionType(parent_name): | 320 if IsDartCollectionType(parent_name): |
| 321 result.append(parent_name) | 321 if not(parent_name in walk_result): |
| 322 walk_result.append(parent_name) |
| 322 continue | 323 continue |
| 323 if self.HasInterface(parent_name): | 324 if self.HasInterface(parent_name): |
| 324 parent_interface = self.GetInterface(parent_name) | 325 parent_interface = self.GetInterface(parent_name) |
| 325 result.append(parent_interface) | 326 if not(parent_interface in walk_result): |
| 326 walk(parent_interface.parents) | 327 # Interface has multi-inherited don't add interfaces more than once |
| 328 # to our parent result list. |
| 329 walk_result.append(parent_interface) |
| 330 walk(parent_interface.parents, walk_result) |
| 331 return walk_result |
| 327 | 332 |
| 328 result = [] | 333 result = [] |
| 329 if interface.parents: | 334 if interface.parents: |
| 330 parent = interface.parents[0] | 335 parent = interface.parents[0] |
| 331 if (IsPureInterface(parent.type.id) or | 336 if (IsPureInterface(parent.type.id) or |
| 332 (propagate_event_target and parent.type.id == 'EventTarget')): | 337 (propagate_event_target and parent.type.id == 'EventTarget')): |
| 333 walk(interface.parents) | 338 result = walk(interface.parents, []) |
| 334 else: | 339 else: |
| 335 walk(interface.parents[1:]) | 340 result = walk(interface.parents[1:], []) |
| 341 |
| 336 return result | 342 return result |
| 337 | 343 |
| OLD | NEW |