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

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

Issue 10832300: Proper dispatch in the presence of optional arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« 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: lib/dom/scripts/systemnative.py
diff --git a/lib/dom/scripts/systemnative.py b/lib/dom/scripts/systemnative.py
index b7b1a85760e26b0031d671640ab3d02e98d68eee..df28efcba4c71677a4ee44ef808e46bb8be883bd 100644
--- a/lib/dom/scripts/systemnative.py
+++ b/lib/dom/scripts/systemnative.py
@@ -655,11 +655,19 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
body.Emit(' throw "Incorrect number or type of arguments";\n');
else:
operation = operations[0]
+ argument_count = len(operation.arguments)
for position, argument in list(enumerate(operation.arguments))[::-1]:
if self._IsArgumentOptionalInWebCore(operation, argument):
- check = '%s === _null' % argument_names[position]
- GenerateCall(operation, position, [check])
- GenerateCall(operation, len(operation.arguments), [])
+ check = '%s !== _null' % argument_names[position]
+ # argument_count instead of position + 1 is used here to cover one
+ # complicated case. Consider foo(x, [Optional] y, [Optional=DefaultIsNullString] z)
podivilov 2012/08/21 13:46:57 I think it's exactly the optional in the middle pr
Anton Muhin 2012/08/21 18:14:34 Yes, this _null/null distinction is another of pro
+ # (as of now it's modelled after HTMLMediaElement.webkitAddKey).
+ # y is optional in WebCore, while z is not.
+ # In this case, if y !== _null, we'd like to emit foo(x, y, z) invocation, not
+ # foo(x, y).
+ GenerateCall(operation, argument_count, [check])
+ argument_count = position
+ GenerateCall(operation, argument_count, [])
def SecondaryContext(self, interface):
pass
« 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