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

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

Issue 10532027: Move interface members traverse logic to BaseGenerator. (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 | « no previous file | lib/dom/scripts/systembase.py » ('j') | lib/dom/scripts/systembase.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/dartgenerator.py
diff --git a/lib/dom/scripts/dartgenerator.py b/lib/dom/scripts/dartgenerator.py
index 46d1663c3b8ae216f82cb07c667a8980f1f75504..a2338bbf0b35a1d7058097361332efb35a2571cc 100755
--- a/lib/dom/scripts/dartgenerator.py
+++ b/lib/dom/scripts/dartgenerator.py
@@ -11,8 +11,8 @@ import logging
import os
import re
import shutil
+import systembase
from generator import *
-from systembase import *
_logger = logging.getLogger('dartgenerator')
@@ -272,67 +272,9 @@ class DartGenerator(object):
return
generator.StartInterface()
-
- for const in sorted(interface.constants, ConstantOutputOrder):
- generator.AddConstant(const)
-
- attributes = [attr for attr in interface.attributes
- if attr.type.id != 'EventListener']
- for (getter, setter) in _PairUpAttributes(attributes):
- generator.AddAttribute(getter, setter)
-
- # The implementation should define an indexer if the interface directly
- # extends List.
- (element_type, requires_indexer) = ListImplementationInfo(
- interface, self._database)
- if element_type:
- if requires_indexer:
- generator.AddIndexer(element_type)
- else:
- generator.AmendIndexer(element_type)
- # Group overloaded operations by id
- operationsById = {}
- for operation in interface.operations:
- if operation.id not in operationsById:
- operationsById[operation.id] = []
- operationsById[operation.id].append(operation)
-
- # Generate operations
- for id in sorted(operationsById.keys()):
- operations = operationsById[id]
- info = AnalyzeOperation(interface, operations)
- if info.IsStatic():
- generator.AddStaticOperation(info)
- else:
- generator.AddOperation(info)
-
- # 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.
-
- for parent_interface in self._TransitiveSecondaryParents(interface):
- if isinstance(parent_interface, str): # IsDartCollectionType(parent_interface)
- continue
- attributes = [attr for attr in parent_interface.attributes
- if not FindMatchingAttribute(interface, attr)]
- for (getter, setter) in _PairUpAttributes(attributes):
- generator.AddSecondaryAttribute(parent_interface, getter, setter)
-
- # Group overloaded operations by id
- operationsById = {}
- for operation in parent_interface.operations:
- if operation.id not in operationsById:
- operationsById[operation.id] = []
- operationsById[operation.id].append(operation)
-
- # Generate operations
- for id in sorted(operationsById.keys()):
- if not any(op.id == id for op in interface.operations):
- operations = operationsById[id]
- info = AnalyzeOperation(interface, operations)
- generator.AddSecondaryOperation(parent_interface, info)
-
+ generator.AddMembers(interface)
+ secondary_parents = self._TransitiveSecondaryParents(interface)
+ generator.AddSecondaryMembers(interface, secondary_parents)
generator.FinishInterface()
def _TransitiveSecondaryParents(self, interface):
@@ -385,24 +327,9 @@ class DartGenerator(object):
('InterfaceType', ('ScopedName', 'EventTarget'))]
interface.parents.append(idlnode.IDLParentInterface(ast))
-def _PairUpAttributes(attributes):
- """Returns a list of (getter, setter) pairs sorted by name.
-
- One element of the pair may be None.
- """
- names = sorted(set(attr.id for attr in attributes))
- getters = {}
- setters = {}
- for attr in attributes:
- if attr.is_fc_getter:
- getters[attr.id] = attr
- elif attr.is_fc_setter and 'Replaceable' not in attr.ext_attrs:
- setters[attr.id] = attr
- return [(getters.get(id), setters.get(id)) for id in names]
-
# ------------------------------------------------------------------------------
-class DummyImplementationSystem(System):
+class DummyImplementationSystem(systembase.System):
"""Generates a dummy implementation for use by the editor analysis.
All the code comes from hand-written library files.
@@ -439,10 +366,11 @@ class DummyImplementationSystem(System):
# ------------------------------------------------------------------------------
-class DummyInterfaceGenerator(object):
+class DummyInterfaceGenerator(systembase.BaseGenerator):
"""Generates dummy implementation."""
def __init__(self, system, interface):
+ super(DummyInterfaceGenerator, self).__init__(system._database)
self._system = system
self._interface = interface
@@ -465,32 +393,8 @@ class DummyInterfaceGenerator(object):
def FinishInterface(self):
pass
- def AddConstant(self, constant):
- pass
-
- def AddAttribute(self, getter, setter):
- pass
-
- def AddSecondaryAttribute(self, interface, getter, setter):
- pass
-
- def AddSecondaryOperation(self, interface, info):
- pass
-
- def AddIndexer(self, element_type):
- pass
-
- def AmendIndexer(sefl, element_type):
- pass
-
def AddTypedArrayConstructors(self, element_type):
pass
- def AddOperation(self, info):
- pass
-
- def AddStaticOperation(self, info):
- pass
-
def AddEventAttributes(self, event_attrs):
pass
« no previous file with comments | « no previous file | lib/dom/scripts/systembase.py » ('j') | lib/dom/scripts/systembase.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698