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

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

Issue 11688005: Start unification of overload dispatcher generation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « sdk/lib/indexed_db/dartium/indexed_db_dartium.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/htmldartgenerator.py
diff --git a/tools/dom/scripts/htmldartgenerator.py b/tools/dom/scripts/htmldartgenerator.py
index d09d91d638e72bc83c2b368af09057305f18e828..46ba4ba34edb21bce4e63a4c2d33b8cea05b974f 100644
--- a/tools/dom/scripts/htmldartgenerator.py
+++ b/tools/dom/scripts/htmldartgenerator.py
@@ -193,6 +193,26 @@ class HtmlDartGenerator(object):
else:
self.EmitOperation(info, method_name)
+ def _OverloadChecks(self,
+ operation,
+ parameter_names,
+ argument_count,
+ can_omit_type_check=lambda type, pos: False):
+ checks = []
+ for i in range(0, argument_count):
+ argument = operation.arguments[i]
+ parameter_name = parameter_names[i]
+ test_type = self._DartType(argument.type.id)
+ if test_type in ['dynamic', 'Object']:
+ checks.append('?%s' % parameter_name)
+ elif not can_omit_type_check(test_type, i):
+ checks.append('(%s is %s || %s == null)' % (
+ parameter_name, test_type, parameter_name))
+ # There can be multiple presence checks. We need them all since a later
+ # optional argument could have been passed by name, leaving 'holes'.
+ checks.extend(['!?%s' % name for name in parameter_names[argument_count:]])
+ return checks
+
def AdditionalImplementedInterfaces(self):
# TODO: Include all implemented interfaces, including other Lists.
implements = []
« no previous file with comments | « sdk/lib/indexed_db/dartium/indexed_db_dartium.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698