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

Unified Diff: lib/dom/scripts/systembase.py

Issue 10700006: Make per-interface generators an implementation detail of a system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 years, 6 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 | « lib/dom/scripts/generator.py ('k') | lib/dom/scripts/systemfrog.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/systembase.py
diff --git a/lib/dom/scripts/systembase.py b/lib/dom/scripts/systembase.py
index 89ab25ec109f5a17a7de17cf52445d44109e3137..9402d2d0c83f31abc5ef788c28b1b9f610246344 100644
--- a/lib/dom/scripts/systembase.py
+++ b/lib/dom/scripts/systembase.py
@@ -31,16 +31,9 @@ class System(object):
self._output_dir = output_dir
self._dart_callback_file_paths = []
- def InterfaceGenerator(self,
- interface,
- common_prefix,
- super_interface_name,
- source_filter):
- """Returns an interface generator for |interface|.
-
- Called once for each interface that is not a callback function.
- """
- return None
+ def ProcessInterface(self, interface):
+ """Processes an interface that is not a callback function."""
+ pass
def ProcessCallback(self, interface, info):
"""Processes an interface that is a callback function."""
@@ -110,8 +103,15 @@ class System(object):
return result;
class BaseGenerator(object):
- def __init__(self, database):
+ def __init__(self, database, interface):
self._database = database
+ self._interface = interface
+
+ def Generate(self):
+ self.StartInterface()
+ self.AddMembers(self._interface)
+ self.AddSecondaryMembers(self._interface)
+ self.FinishInterface()
def AddMembers(self, interface):
for const in sorted(interface.constants, ConstantOutputOrder):
@@ -147,12 +147,12 @@ class BaseGenerator(object):
else:
self.AddOperation(info)
- def AddSecondaryMembers(self, interface, secondary_parents):
+ def AddSecondaryMembers(self, interface):
# With multiple inheritance, attributes and operations of non-first
# interfaces need to be added. Sometimes the attribute or operation is
# defined in the current interface as well as a parent. In that case we
# avoid making a duplicate definition and pray that the signatures match.
-
+ secondary_parents = self._TransitiveSecondaryParents(interface)
for parent_interface in secondary_parents:
if isinstance(parent_interface, str): # IsDartCollectionType(parent_interface)
continue
@@ -199,6 +199,31 @@ class BaseGenerator(object):
def AddSecondaryOperation(self, interface, attr):
pass
+ def _TransitiveSecondaryParents(self, interface):
+ """Returns a list of all non-primary parents.
+
+ The list contains the interface objects for interfaces defined in the
+ database, and the name for undefined interfaces.
+ """
+ def walk(parents):
+ for parent in parents:
+ if IsDartCollectionType(parent.type.id):
+ result.append(parent.type.id)
+ continue
+ if self._database.HasInterface(parent.type.id):
+ parent_interface = self._database.GetInterface(parent.type.id)
+ result.append(parent_interface)
+ walk(parent_interface.parents)
+
+ result = []
+ if interface.parents:
+ parent = interface.parents[0]
+ if IsPureInterface(parent.type.id):
+ walk(interface.parents)
+ else:
+ walk(interface.parents[1:])
+ return result;
+
def _PairUpAttributes(attributes):
"""Returns a list of (getter, setter) pairs sorted by name.
« no previous file with comments | « lib/dom/scripts/generator.py ('k') | lib/dom/scripts/systemfrog.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698