Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: client/dom/scripts/dartgenerator.py

Issue 9370012: Process IDL interfaces in pre-order so that parents are seen first (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/scripts/dartgenerator.py
diff --git a/client/dom/scripts/dartgenerator.py b/client/dom/scripts/dartgenerator.py
index a17687c2975b45203cfaf1d1c985adddc76f6b48..acff25a3a3adfcb94f860b2b7ed5d5664169e9d6 100755
--- a/client/dom/scripts/dartgenerator.py
+++ b/client/dom/scripts/dartgenerator.py
@@ -439,16 +439,21 @@ class DartGenerator(object):
html_system._interface_system = html_interface_system
self._systems.append(html_system)
- # Render all interfaces into Dart and save them in files.
- for interface in database.GetInterfaces():
-
- super_interface = None
- super_name = interface.id
+ # Collect interfaces
+ interfaces = []
+ for interface in database.GetInterfaces():
if not _MatchSourceFilter(source_filter, interface):
# Skip this interface since it's not present in the required source
_logger.info('Omitting interface - %s' % interface.id)
continue
+ interfaces.append(interface)
+
+ # Render all interfaces into Dart and save them in files.
+ for interface in self._PreOrderInterfaces(interfaces):
+
+ super_interface = None
+ super_name = interface.id
if super_name in super_map:
super_name = super_map[super_name]
@@ -484,6 +489,27 @@ class DartGenerator(object):
system.Finish()
+ def _PreOrderInterfaces(self, interfaces):
+ """Returns the interfaces in pre-order, i.e. parents first."""
+ seen = set()
+ ordered = []
+ def visit(interface):
+ if interface.id in seen:
+ return
+ seen.add(interface.id)
+ for parent in interface.parents:
+ if _IsDartCollectionType(parent.type.id):
+ continue
+ if self._database.HasInterface(parent.type.id):
+ parent_interface = self._database.GetInterface(parent.type.id)
+ visit(parent_interface)
+ ordered.append(interface)
+
+ for interface in interfaces:
+ visit(interface)
+ return ordered
+
+
def _ProcessInterface(self, interface, super_interface_name,
source_filter,
common_prefix):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698