Chromium Code Reviews| Index: lib/html/scripts/generator.py |
| diff --git a/lib/html/scripts/generator.py b/lib/html/scripts/generator.py |
| index 8fabd064fc4d2aa8ccf426c22556c551affd2434..9bd9b3474c68192c0713c1c6e8e0845051929ba2 100644 |
| --- a/lib/html/scripts/generator.py |
| +++ b/lib/html/scripts/generator.py |
| @@ -339,39 +339,14 @@ class OperationInfo(object): |
| param_infos: A list of ParamInfo. |
| """ |
| - def ParametersInterfaceDeclaration(self, rename_type): |
| - """Returns a formatted string declaring the parameters for the interface.""" |
| - return self._FormatParams(self.param_infos, rename_type, True) |
| - |
| - def ParametersImplementationDeclaration(self, rename_type): |
| - """Returns a formatted string declaring the parameters for the |
| - implementation. |
| - |
| - Args: |
| - rename_type: A function that allows the types to be renamed. |
| - The function is applied to the parameter's dart_type. |
| - """ |
| - 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 |
| - parameters as arguments. |
| - """ |
| - if parameter_count is None: |
| - parameter_count = len(self.param_infos) |
| - return ', '.join(map( |
| - lambda param_info: param_info.name, |
| - self.param_infos[:parameter_count])) |
| - |
| - def _FormatParams(self, params, rename_type, provide_comments): |
| + def ParametersDeclaration(self, rename_type): |
| 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) |
| - return '%s%s' % (type, param.name) |
| + return '%s%s' % (TypeOrNothing(dart_type, param.type_id), param.name) |
| required = [] |
| optional = [] |
| - for param_info in params: |
| + for param_info in self.param_infos: |
| if param_info.is_optional: |
| optional.append(param_info) |
| else: |
| @@ -384,6 +359,16 @@ class OperationInfo(object): |
| argtexts.append('[' + ', '.join(map(FormatParam, optional)) + ']') |
| return ', '.join(argtexts) |
| + def ParametersAsArgumentList(self, parameter_count = None): |
|
podivilov
2012/10/17 14:21:16
Please move back to reduce the diff.
Anton Muhin
2012/10/17 14:26:30
Cannot, it's a single function :)
|
| + """Returns a string of the parameter names suitable for passing the |
| + parameters as arguments. |
| + """ |
| + if parameter_count is None: |
| + parameter_count = len(self.param_infos) |
| + return ', '.join(map( |
| + lambda param_info: param_info.name, |
| + self.param_infos[:parameter_count])) |
| + |
| def IsStatic(self): |
| is_static = self.overloads[0].is_static |
| assert any([is_static == o.is_static for o in self.overloads]) |
| @@ -409,7 +394,7 @@ class OperationInfo(object): |
| ' factory $CTOR($PARAMS) => ' |
| '$FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n', |
| CTOR=self._ConstructorFullName(rename_type), |
| - PARAMS=self.ParametersInterfaceDeclaration(rename_type), |
| + PARAMS=self.ParametersDeclaration(rename_type), |
| FACTORY=factory_provider, |
| CTOR_FACTORY_NAME=factory_name, |
| FACTORY_PARAMS=self.ParametersAsArgumentList()) |
| @@ -422,7 +407,7 @@ class OperationInfo(object): |
| ' return $FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n' |
| ' }\n', |
| CTOR=self._ConstructorFullName(rename_type), |
| - PARAMS=self.ParametersInterfaceDeclaration(rename_type), |
| + PARAMS=self.ParametersDeclaration(rename_type), |
| FACTORY=factory_provider, |
| CTOR_FACTORY_NAME=factory_name, |
| FACTORY_PARAMS=self.ParametersAsArgumentList()) |