Chromium Code Reviews| Index: lib/html/scripts/generator.py |
| diff --git a/lib/html/scripts/generator.py b/lib/html/scripts/generator.py |
| index 5eec8873d3f9eeb4a8f51e83acc9c1ecdbce1a1e..4c12834a79ce5860d1ee61bc8673d2ec19a73313 100644 |
| --- a/lib/html/scripts/generator.py |
| +++ b/lib/html/scripts/generator.py |
| @@ -346,13 +346,7 @@ class OperationInfo(object): |
| def ParametersInterfaceDeclaration(self, rename_type): |
| """Returns a formatted string declaring the parameters for the interface.""" |
| - def type_function(param): |
| - # TODO(podivilov): replace param.dart_type field with param.is_optional |
| - dart_type = param.dart_type |
| - if dart_type != 'Dynamic': |
| - dart_type = rename_type(dart_type) |
| - return TypeOrNothing(dart_type, param.type_id) |
| - return self._FormatParams(self.param_infos, type_function) |
| + return self._FormatParams(self.param_infos, rename_type, True) |
| def ParametersImplementationDeclaration(self, rename_type): |
| """Returns a formatted string declaring the parameters for the |
| @@ -362,13 +356,7 @@ class OperationInfo(object): |
| rename_type: A function that allows the types to be renamed. |
| The function is applied to the parameter's dart_type. |
| """ |
| - def type_function(param): |
| - # TODO(podivilov): replace param.dart_type field with param.is_optional |
| - dart_type = param.dart_type |
| - if dart_type != 'Dynamic': |
| - dart_type = rename_type(dart_type) |
| - return TypeOrNothing(dart_type) |
| - return self._FormatParams(self.param_infos, type_function) |
| + return self._FormatParams(self.param_infos, rename_type, False) |
| def ParametersAsArgumentList(self, parameter_count = None): |
| """Returns a string of the parameter names suitable for passing the |
| @@ -380,10 +368,14 @@ class OperationInfo(object): |
| lambda param_info: param_info.name, |
| self.param_infos[:parameter_count])) |
| - def _FormatParams(self, params, type_fn): |
| + def _FormatParams(self, params, rename_type, provide_comments): |
|
Anton Muhin
2012/10/17 12:30:16
we can simplify logic even further if we unify int
podivilov
2012/10/17 12:38:04
I agree.
|
| def FormatParam(param): |
| - """Returns a parameter declaration fragment for an ParamInfo.""" |
| - return '%s%s' % (type_fn(param), param.name) |
| + # TODO(podivilov): replace param.dart_type field with param.is_optional |
| + dart_type = param.dart_type |
| + if dart_type != 'Dynamic': |
| + dart_type = rename_type(dart_type) |
| + type = TypeOrNothing(dart_type, param.type_id if provide_comments else None) |
| + return '%s%s' % (type, param.name) |
| required = [] |
| optional = [] |