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

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

Issue 11196020: Force named arguments in constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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/dartium/html_dartium.dart ('k') | lib/html/scripts/systemhtml.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/html/scripts/generator.py
diff --git a/lib/html/scripts/generator.py b/lib/html/scripts/generator.py
index e6afec7b097948d4972404dbaaa1e17f0f85389d..c8ab91a4c35ffc3b4db187da30cf6a3d16ef29ed 100644
--- a/lib/html/scripts/generator.py
+++ b/lib/html/scripts/generator.py
@@ -237,6 +237,7 @@ def AnalyzeOperation(interface, operations):
info.js_name = info.declared_name
info.type_name = operations[0].type.id # TODO: widen.
info.param_infos = _BuildArguments([op.arguments for op in split_operations], interface)
+ info.requires_named_arguments = False
return info
@@ -270,6 +271,7 @@ def AnalyzeConstructor(interface):
info.js_name = name
info.type_name = interface.id
info.param_infos = args
+ info.requires_named_arguments = False
return info
def IsDartListType(type):
@@ -339,7 +341,7 @@ class OperationInfo(object):
param_infos: A list of ParamInfo.
"""
- def ParametersDeclaration(self, rename_type):
+ def ParametersDeclaration(self, rename_type, force_optional=False):
def FormatParam(param):
dart_type = rename_type(param.type_id) if param.type_id else 'Dynamic'
return '%s%s' % (TypeOrNothing(dart_type, param.type_id), param.name)
@@ -356,7 +358,12 @@ class OperationInfo(object):
required.append(param_info)
argtexts = map(FormatParam, required)
if optional:
- argtexts.append('[' + ', '.join(map(FormatParam, optional)) + ']')
+ needs_named = self.requires_named_arguments and not force_optional
+ left_bracket, right_bracket = '{}' if needs_named else '[]'
+ argtexts.append(
+ left_bracket +
+ ', '.join(map(FormatParam, optional)) +
+ right_bracket)
return ', '.join(argtexts)
def ParametersAsArgumentList(self, parameter_count = None):
« no previous file with comments | « lib/html/dartium/html_dartium.dart ('k') | lib/html/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698