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

Unified Diff: tools/dom/scripts/htmldartgenerator.py

Issue 22933003: Removing overloaded operations in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
Index: tools/dom/scripts/htmldartgenerator.py
diff --git a/tools/dom/scripts/htmldartgenerator.py b/tools/dom/scripts/htmldartgenerator.py
index 52d1de8e3ab088443839ffe0af5c66cfcc22efc5..c49e9f8b694941b4885cac73e74db4e3813e9f9d 100644
--- a/tools/dom/scripts/htmldartgenerator.py
+++ b/tools/dom/scripts/htmldartgenerator.py
@@ -93,6 +93,8 @@ class HtmlDartGenerator(object):
# Group overloaded operations by name.
self._AddRenamedOverloads(interface)
operationsByName = self._OperationsByName(interface)
+ if self.OmitOperationOverrides():
+ self._FilterOverloads(operationsByName, interface)
# Generate operations.
for id in sorted(operationsByName.keys()):
@@ -121,6 +123,9 @@ class HtmlDartGenerator(object):
# Group overloaded operations by name.
operationsByName =self._OperationsByName(parent_interface)
+ if self.OmitOperationOverrides():
+ self._FilterOverloads(operationsByName, interface)
+
# Generate operations.
for id in sorted(operationsByName.keys()):
if not any(op.id == id for op in interface.operations):
@@ -129,6 +134,20 @@ class HtmlDartGenerator(object):
self.SecondaryContext(parent_interface)
self.AddOperation(info)
+ def _FilterOverloads(self, operationsByName, interface):
sra1 2013/08/12 21:31:29 '_RemoveShadowingOperationsWithSameSignature'
blois 2013/08/13 00:22:15 Done.
+ if not interface.parents:
+ return
+
+ parent = self._database.GetInterface(interface.parents[0].type.id)
+ if parent == self._interface or parent == interface:
+ return
+ for operation in parent.operations:
+ if operation.id in operationsByName:
+ operations = operationsByName[operation.id]
+ for existing_operation in operations:
+ if existing_operation.ComparableTo(operation):
+ del operationsByName[operation.id]
+
def _AddRenamedOverloads(self, interface):
"""The IDL has a number of functions with the same name but that accept
different types. This is fine for JavaScript, but results in vague type
@@ -201,6 +220,9 @@ class HtmlDartGenerator(object):
operationsByName.setdefault(name, []).append(operation)
return operationsByName
+ def OmitOperationOverrides(self):
+ return False
+
def AddConstant(self, constant):
const_name = self._renamer.RenameMember(
self._interface.id, constant, constant.id, 'get:', dartify_name=False)

Powered by Google App Engine
This is Rietveld 408576698