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 from systemfrog import * | 9 from systemfrog import * |
10 from systeminterface import * | 10 from systeminterface import * |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 def _TraverseParents(self, interface, callback): | 467 def _TraverseParents(self, interface, callback): |
468 for parent in interface.parents: | 468 for parent in interface.parents: |
469 parent_id = parent.type.id | 469 parent_id = parent.type.id |
470 if self._database.HasInterface(parent_id): | 470 if self._database.HasInterface(parent_id): |
471 parent_interface = self._database.GetInterface(parent_id) | 471 parent_interface = self._database.GetInterface(parent_id) |
472 callback(parent_interface) | 472 callback(parent_interface) |
473 self._TraverseParents(parent_interface, callback) | 473 self._TraverseParents(parent_interface, callback) |
474 | 474 |
475 # TODO(jacobr): this isn't quite right.... | 475 # TODO(jacobr): this isn't quite right.... |
476 def GetParentsEventsClasses(self, interface): | 476 def GetParentsEventsClasses(self, interface): |
477 # Ugly hack as we don't specify that Document inherits from Element | 477 # Ugly hack as we don't specify that Document and DocumentFragment inherit |
478 # in our IDL. | 478 # from Element in our IDL. |
479 if interface.id == 'Document': | 479 if interface.id == 'Document' or interface.id == 'DocumentFragment': |
480 return ['ElementEvents'] | 480 return ['ElementEvents'] |
Jacob
2012/03/06 05:09:00
Why are you hard coding the parent for 'Document'?
nweiz
2012/03/06 20:10:47
That was there prior to this change.
| |
481 | 481 |
482 interfaces_with_events = set() | 482 interfaces_with_events = set() |
483 def visit(parent): | 483 def visit(parent): |
484 if parent.id in self._event_classes: | 484 if parent.id in self._event_classes: |
485 interfaces_with_events.add(parent) | 485 interfaces_with_events.add(parent) |
486 | 486 |
487 self._TraverseParents(interface, visit) | 487 self._TraverseParents(interface, visit) |
488 if len(interfaces_with_events) == 0: | 488 if len(interfaces_with_events) == 0: |
489 return ['Events'] | 489 return ['Events'] |
490 else: | 490 else: |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1665 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee | 1665 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee |
1666 # that Y = Z-X, so we need to check for Y. | 1666 # that Y = Z-X, so we need to check for Y. |
1667 true_code = emitter.Emit( | 1667 true_code = emitter.Emit( |
1668 '$(INDENT)if ($COND) {\n' | 1668 '$(INDENT)if ($COND) {\n' |
1669 '$!TRUE' | 1669 '$!TRUE' |
1670 '$(INDENT)}\n', | 1670 '$(INDENT)}\n', |
1671 COND=test, INDENT=indent) | 1671 COND=test, INDENT=indent) |
1672 self.GenerateDispatch( | 1672 self.GenerateDispatch( |
1673 true_code, info, indent + ' ', position + 1, positive) | 1673 true_code, info, indent + ' ', position + 1, positive) |
1674 return True | 1674 return True |
OLD | NEW |