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

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

Issue 10913167: Rework overloads/optionals dispatch to use new ?a syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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/html/scripts/systemhtml.py ('k') | lib/html/templates/html/dart2js/html_dart2js.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/html/scripts/systemnative.py
diff --git a/lib/html/scripts/systemnative.py b/lib/html/scripts/systemnative.py
index 11514404f573ff59a3cb9ffd945e1a58d35a3af7..07abe5f674288daa11f7f5ced5fb54ca6b7dc840 100644
--- a/lib/html/scripts/systemnative.py
+++ b/lib/html/scripts/systemnative.py
@@ -582,18 +582,12 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, argument) for argument in operation.arguments)
needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_optional_arguments)
- if not needs_dispatcher:
- type_renamer = self._DartType
- default_value = 'null'
- else:
- type_renamer = lambda x: 'Dynamic'
- default_value = '_null'
-
dart_declaration = '%s%s %s(%s)' % (
'static ' if info.IsStatic() else '',
self._DartType(info.type_name),
html_name,
- info.ParametersImplementationDeclaration(type_renamer, default_value))
+ info.ParametersImplementationDeclaration(
+ (lambda x: 'Dynamic') if needs_dispatcher else self._DartType))
if not needs_dispatcher:
# Bind directly to native implementation
@@ -642,7 +636,7 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
self._GenerateOperationNativeCallback(operation, operation.arguments[:argument_count], cpp_callback_name)
def GenerateChecksAndCall(operation, argument_count):
- checks = ['%s === _null' % name for name in argument_names]
+ checks = ['!?%s' % name for name in argument_names]
for i in range(0, argument_count):
argument = operation.arguments[i]
argument_name = argument_names[i]
@@ -663,14 +657,14 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
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]
+ check = '?%s' % argument_names[position]
# argument_count instead of position + 1 is used here to cover one
# complicated case with the effectively optional argument in the middle.
# Consider foo(x, [Optional] y, [Optional=DefaultIsNullString] z)
# (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).
+ # In this case, if y was actually passed, 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, [])
« no previous file with comments | « lib/html/scripts/systemhtml.py ('k') | lib/html/templates/html/dart2js/html_dart2js.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698