| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 type_name: A string, the name of the return type of the operation. | 350 type_name: A string, the name of the return type of the operation. |
| 351 param_infos: A list of ParamInfo. | 351 param_infos: A list of ParamInfo. |
| 352 """ | 352 """ |
| 353 | 353 |
| 354 def ParametersInterfaceDeclaration(self, rename_type): | 354 def ParametersInterfaceDeclaration(self, rename_type): |
| 355 """Returns a formatted string declaring the parameters for the interface.""" | 355 """Returns a formatted string declaring the parameters for the interface.""" |
| 356 return self._FormatParams( | 356 return self._FormatParams( |
| 357 self.param_infos, None, | 357 self.param_infos, None, |
| 358 lambda param: TypeOrNothing(rename_type(param.dart_type), param.type_id)
) | 358 lambda param: TypeOrNothing(rename_type(param.dart_type), param.type_id)
) |
| 359 | 359 |
| 360 def ParametersImplementationDeclaration( | 360 def ParametersImplementationDeclaration(self, rename_type): |
| 361 self, rename_type, default_value='null'): | |
| 362 """Returns a formatted string declaring the parameters for the | 361 """Returns a formatted string declaring the parameters for the |
| 363 implementation. | 362 implementation. |
| 364 | 363 |
| 365 Args: | 364 Args: |
| 366 rename_type: A function that allows the types to be renamed. | 365 rename_type: A function that allows the types to be renamed. |
| 367 The function is applied to the parameter's dart_type. | 366 The function is applied to the parameter's dart_type. |
| 368 """ | 367 """ |
| 369 return self._FormatParams( | 368 return self._FormatParams( |
| 370 self.param_infos, default_value, | 369 self.param_infos, 'null', |
| 371 lambda param: TypeOrNothing(rename_type(param.dart_type))) | 370 lambda param: TypeOrNothing(rename_type(param.dart_type))) |
| 372 | 371 |
| 373 def ParametersAsArgumentList(self): | 372 def ParametersAsArgumentList(self): |
| 374 """Returns a string of the parameter names suitable for passing the | 373 """Returns a string of the parameter names suitable for passing the |
| 375 parameters as arguments. | 374 parameters as arguments. |
| 376 """ | 375 """ |
| 377 return ', '.join(map(lambda param_info: param_info.name, self.param_infos)) | 376 return ', '.join(map(lambda param_info: param_info.name, self.param_infos)) |
| 378 | 377 |
| 379 def _FormatParams(self, params, default_value, type_fn): | 378 def _FormatParams(self, params, default_value, type_fn): |
| 380 def FormatParam(param): | 379 def FormatParam(param): |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 if match: | 868 if match: |
| 870 if type_name == 'DOMString[]': | 869 if type_name == 'DOMString[]': |
| 871 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) | 870 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) |
| 872 item_info = self.TypeInfo(match.group(1) or match.group(2)) | 871 item_info = self.TypeInfo(match.group(1) or match.group(2)) |
| 873 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) | 872 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) |
| 874 if not type_name in _idl_type_registry: | 873 if not type_name in _idl_type_registry: |
| 875 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) | 874 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) |
| 876 type_data = _idl_type_registry.get(type_name) | 875 type_data = _idl_type_registry.get(type_name) |
| 877 class_name = '%sIDLTypeInfo' % type_data.clazz | 876 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 878 return globals()[class_name](type_name, type_data) | 877 return globals()[class_name](type_name, type_data) |
| OLD | NEW |