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

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

Issue 11191024: Refactor common functionality. (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 | « no previous file | no next file » | 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 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 = []
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698