| Index: lib/html/scripts/generator.py
|
| diff --git a/lib/html/scripts/generator.py b/lib/html/scripts/generator.py
|
| index 8fabd064fc4d2aa8ccf426c22556c551affd2434..8b9712e467b56593792ce8d5c9bbb27beba5a5b8 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,9 +341,10 @@ class OperationInfo(object):
|
| param_infos: A list of ParamInfo.
|
| """
|
|
|
| - def ParametersInterfaceDeclaration(self, rename_type):
|
| + def ParametersInterfaceDeclaration(self, rename_type, force_optional=False):
|
| """Returns a formatted string declaring the parameters for the interface."""
|
| - return self._FormatParams(self.param_infos, rename_type, True)
|
| + return self._FormatParams(self.param_infos, rename_type, True,
|
| + force_optional=force_optional)
|
|
|
| def ParametersImplementationDeclaration(self, rename_type):
|
| """Returns a formatted string declaring the parameters for the
|
| @@ -363,7 +366,8 @@ class OperationInfo(object):
|
| lambda param_info: param_info.name,
|
| self.param_infos[:parameter_count]))
|
|
|
| - def _FormatParams(self, params, rename_type, provide_comments):
|
| + def _FormatParams(self, params, rename_type, provide_comments,
|
| + force_optional=False):
|
| def FormatParam(param):
|
| dart_type = rename_type(param.type_id) if param.type_id else 'Dynamic'
|
| type = TypeOrNothing(dart_type, param.type_id if provide_comments else None)
|
| @@ -381,7 +385,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 IsStatic(self):
|
|
|