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

Unified Diff: sdk/lib/html/scripts/systemhtml.py

Issue 11359142: Fixing an issue where optional parameters were having their types dropped. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporating review feedback. Created 8 years, 1 month 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/html/scripts/generator.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/scripts/systemhtml.py
diff --git a/sdk/lib/html/scripts/systemhtml.py b/sdk/lib/html/scripts/systemhtml.py
index 90729a9f82a41d5724aa514398e3abb42d4f5ef6..431f8007dec97c455fb18abb329fe90bbb65fe78 100644
--- a/sdk/lib/html/scripts/systemhtml.py
+++ b/sdk/lib/html/scripts/systemhtml.py
@@ -309,7 +309,7 @@ class HtmlDartInterfaceGenerator(object):
merged_interface = self._interface_type_info.merged_interface()
if merged_interface:
- self._backend.AddMembers(self._database.GetInterface(merged_interface),
+ self._backend.AddMembers(self._database.GetInterface(merged_interface),
not self._backend.ImplementsMergedMembers())
self._backend.AddMembers(self._interface)
@@ -637,7 +637,6 @@ class Dart2JSBackend(HtmlDartGenerator):
def _AddOperationWithConversions(self, info, html_name):
# Assert all operations have same return type.
assert len(set([op.type.id for op in info.operations])) == 1
- info = info.CopyAndWidenDefaultParameters()
output_conversion = self._OutputConversion(info.type_name,
info.declared_name)
if output_conversion:
@@ -705,14 +704,15 @@ class Dart2JSBackend(HtmlDartGenerator):
arguments.append(parameter_names[position])
param_type = self._NarrowInputType(arg.type.id)
# Verified by argument checking on entry to the dispatcher.
+
verified_type = InputType(info.param_infos[position].type_id)
+ # The native method does not need an argument type if we know the type.
+ # But we do need the native methods to have correct function types, so
+ # be conservative.
+ if param_type == verified_type:
+ if param_type in ['String', 'num', 'int', 'double', 'bool', 'Object']:
+ param_type = 'dynamic'
- # The native method does not need an argument type if we know the type.
- # But we do need the native methods to have correct function types, so
- # be conservative.
- if param_type == verified_type:
- if param_type in ['String', 'num', 'int', 'double', 'bool', 'Object']:
- param_type = 'dynamic'
target_parameters.append(
'%s%s' % (TypeOrNothing(param_type), param_name))
@@ -746,8 +746,9 @@ class Dart2JSBackend(HtmlDartGenerator):
if test_type in ['dynamic', 'Object']:
checks.append('?%s' % parameter_name)
elif test_type != parameter_types[i]:
- checks.append('(%s is %s || %s == null)' % (
- parameter_name, test_type, parameter_name))
+ checks.append('(?%s && (%s is %s || %s == null))' % (
+ parameter_name, parameter_name, test_type, parameter_name))
+
checks.extend(['!?%s' % name for name in parameter_names[argument_count:]])
# There can be multiple presence checks. We need them all since a later
# optional argument could have been passed by name, leaving 'holes'.
« no previous file with comments | « sdk/lib/html/scripts/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698