Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 'SVGStylable', | 26 'SVGStylable', |
| 27 'SVGTests', | 27 'SVGTests', |
| 28 'SVGTransformable', | 28 'SVGTransformable', |
| 29 'SVGURIReference', | 29 'SVGURIReference', |
| 30 'SVGZoomAndPan', | 30 'SVGZoomAndPan', |
| 31 'TimeoutHandler']) | 31 'TimeoutHandler']) |
| 32 | 32 |
| 33 def IsPureInterface(interface_name): | 33 def IsPureInterface(interface_name): |
| 34 return interface_name in _pure_interfaces | 34 return interface_name in _pure_interfaces |
| 35 | 35 |
| 36 | |
|
Emily Fortuna
2012/10/19 19:48:34
nit: probably don't need two lines of whitespace h
| |
| 37 _methods_with_named_formals = set([ | |
| 38 'DirectoryEntry.getDirectory', | |
| 39 ]) | |
|
vsm
2012/10/19 19:53:28
One thing that worries me about named params is th
Anton Muhin
2012/10/23 13:59:53
That's true, but my feeling is the chance of param
| |
| 40 | |
| 36 # | 41 # |
| 37 # Renames for attributes that have names that are not legal Dart names. | 42 # Renames for attributes that have names that are not legal Dart names. |
| 38 # | 43 # |
| 39 _dart_attribute_renames = { | 44 _dart_attribute_renames = { |
| 40 'default': 'defaultValue', | 45 'default': 'defaultValue', |
| 41 'final': 'finalValue', | 46 'final': 'finalValue', |
| 42 } | 47 } |
| 43 | 48 |
| 44 # | 49 # |
| 45 # Interface version of the DOM needs to delegate typed array constructors to a | 50 # Interface version of the DOM needs to delegate typed array constructors to a |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 # to a dart argument. | 235 # to a dart argument. |
| 231 info = OperationInfo() | 236 info = OperationInfo() |
| 232 info.operations = operations | 237 info.operations = operations |
| 233 info.overloads = split_operations | 238 info.overloads = split_operations |
| 234 info.declared_name = operations[0].id | 239 info.declared_name = operations[0].id |
| 235 info.name = operations[0].ext_attrs.get('DartName', info.declared_name) | 240 info.name = operations[0].ext_attrs.get('DartName', info.declared_name) |
| 236 info.constructor_name = None | 241 info.constructor_name = None |
| 237 info.js_name = info.declared_name | 242 info.js_name = info.declared_name |
| 238 info.type_name = operations[0].type.id # TODO: widen. | 243 info.type_name = operations[0].type.id # TODO: widen. |
| 239 info.param_infos = _BuildArguments([op.arguments for op in split_operations], interface) | 244 info.param_infos = _BuildArguments([op.arguments for op in split_operations], interface) |
| 240 info.requires_named_arguments = False | 245 full_name = '%s.%s' % (interface.id, info.declared_name) |
| 246 info.requires_named_arguments = full_name in _methods_with_named_formals | |
| 241 return info | 247 return info |
| 242 | 248 |
| 243 | 249 |
| 244 def AnalyzeConstructor(interface): | 250 def AnalyzeConstructor(interface): |
| 245 """Returns an OperationInfo object for the constructor. | 251 """Returns an OperationInfo object for the constructor. |
| 246 | 252 |
| 247 Returns None if the interface has no Constructor. | 253 Returns None if the interface has no Constructor. |
| 248 """ | 254 """ |
| 249 if 'Constructor' in interface.ext_attrs: | 255 if 'Constructor' in interface.ext_attrs: |
| 250 name = None | 256 name = None |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1083 self._database.GetInterface(type_name)) | 1089 self._database.GetInterface(type_name)) |
| 1084 else: | 1090 else: |
| 1085 dart_interface_name = type_name | 1091 dart_interface_name = type_name |
| 1086 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name) | 1092 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name) |
| 1087 | 1093 |
| 1088 if type_data.clazz == 'ListLike': | 1094 if type_data.clazz == 'ListLike': |
| 1089 return ListLikeIDLTypeInfo(type_name, type_data, self.TypeInfo(type_data.i tem_type)) | 1095 return ListLikeIDLTypeInfo(type_name, type_data, self.TypeInfo(type_data.i tem_type)) |
| 1090 | 1096 |
| 1091 class_name = '%sIDLTypeInfo' % type_data.clazz | 1097 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1092 return globals()[class_name](type_name, type_data) | 1098 return globals()[class_name](type_name, type_data) |
| OLD | NEW |