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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 ' }\n', | 394 ' }\n', |
395 OPT_PARAM_NAME=self.param_infos[index].name, | 395 OPT_PARAM_NAME=self.param_infos[index].name, |
396 FACTORY=factory_provider, | 396 FACTORY=factory_provider, |
397 CTOR_FACTORY_NAME=factory_name, | 397 CTOR_FACTORY_NAME=factory_name, |
398 FACTORY_PARAMS=self.ParametersAsArgumentList(index)) | 398 FACTORY_PARAMS=self.ParametersAsArgumentList(index)) |
399 | 399 |
400 for index, param_info in enumerate(self.param_infos): | 400 for index, param_info in enumerate(self.param_infos): |
401 if param_info.is_optional: | 401 if param_info.is_optional: |
402 EmitOptionalParameterInvocation(index) | 402 EmitOptionalParameterInvocation(index) |
403 | 403 |
404 | |
405 def CopyAndWidenDefaultParameters(self): | |
406 """Returns equivalent OperationInfo, but default parameters are dynamic.""" | |
407 info = copy.copy(self) | |
408 info.param_infos = [param.Copy() for param in self.param_infos] | |
409 for param in info.param_infos: | |
410 if param.is_optional: | |
411 param.type_id = None | |
412 return info | |
413 | |
414 | |
415 def ConstantOutputOrder(a, b): | 404 def ConstantOutputOrder(a, b): |
416 """Canonical output ordering for constants.""" | 405 """Canonical output ordering for constants.""" |
417 if a.id < b.id: return -1 | 406 if a.id < b.id: return -1 |
418 if a.id > b.id: return 1 | 407 if a.id > b.id: return 1 |
419 return 0 | 408 return 0 |
420 | 409 |
421 | 410 |
422 def _FormatNameList(names): | 411 def _FormatNameList(names): |
423 """Returns JavaScript array literal expression with one name per line.""" | 412 """Returns JavaScript array literal expression with one name per line.""" |
424 #names = sorted(names) | 413 #names = sorted(names) |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 else: | 1084 else: |
1096 dart_interface_name = type_name | 1085 dart_interface_name = type_name |
1097 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name, | 1086 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name, |
1098 self) | 1087 self) |
1099 | 1088 |
1100 if type_data.clazz == 'SVGTearOff': | 1089 if type_data.clazz == 'SVGTearOff': |
1101 return SVGTearOffIDLTypeInfo(type_name, type_data, self) | 1090 return SVGTearOffIDLTypeInfo(type_name, type_data, self) |
1102 | 1091 |
1103 class_name = '%sIDLTypeInfo' % type_data.clazz | 1092 class_name = '%sIDLTypeInfo' % type_data.clazz |
1104 return globals()[class_name](type_name, type_data) | 1093 return globals()[class_name](type_name, type_data) |
OLD | NEW |