| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """This module provides shared functionality for systems to generate | 6 """This module provides shared functionality for systems to generate |
| 7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
| 8 | 8 |
| 9 import copy | 9 import copy |
| 10 import re | 10 import re |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 def ParametersAsArgumentList(self): | 418 def ParametersAsArgumentList(self): |
| 419 """Returns a string of the parameter names suitable for passing the | 419 """Returns a string of the parameter names suitable for passing the |
| 420 parameters as arguments. | 420 parameters as arguments. |
| 421 """ | 421 """ |
| 422 return ', '.join(map(lambda param_info: param_info.name, self.param_infos)) | 422 return ', '.join(map(lambda param_info: param_info.name, self.param_infos)) |
| 423 | 423 |
| 424 def _FormatParams(self, params, default_value, type_fn): | 424 def _FormatParams(self, params, default_value, type_fn): |
| 425 def FormatParam(param): | 425 def FormatParam(param): |
| 426 """Returns a parameter declaration fragment for an ParamInfo.""" | 426 """Returns a parameter declaration fragment for an ParamInfo.""" |
| 427 type = type_fn(param) | 427 type = type_fn(param) |
| 428 if param.is_optional and default_value: | 428 if param.is_optional and default_value and default_value != 'null': |
| 429 return '%s%s = %s' % (type, param.name, default_value) | 429 return '%s%s = %s' % (type, param.name, default_value) |
| 430 return '%s%s' % (type, param.name) | 430 return '%s%s' % (type, param.name) |
| 431 | 431 |
| 432 required = [] | 432 required = [] |
| 433 optional = [] | 433 optional = [] |
| 434 for param_info in params: | 434 for param_info in params: |
| 435 if param_info.is_optional: | 435 if param_info.is_optional: |
| 436 optional.append(param_info) | 436 optional.append(param_info) |
| 437 else: | 437 else: |
| 438 if optional: | 438 if optional: |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 | 836 |
| 837 match = re.match(r'sequence<(\w+)>$', idl_type_name) | 837 match = re.match(r'sequence<(\w+)>$', idl_type_name) |
| 838 if match: | 838 if match: |
| 839 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) | 839 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) |
| 840 | 840 |
| 841 match = re.match(r'(\w+)\[\]$', idl_type_name) | 841 match = re.match(r'(\w+)\[\]$', idl_type_name) |
| 842 if match: | 842 if match: |
| 843 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) | 843 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) |
| 844 | 844 |
| 845 return IDLTypeInfo(idl_type_name) | 845 return IDLTypeInfo(idl_type_name) |
| OLD | NEW |