| 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 json | 10 import json |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 return info | 215 return info |
| 216 | 216 |
| 217 | 217 |
| 218 def AnalyzeConstructor(interface): | 218 def AnalyzeConstructor(interface): |
| 219 """Returns an OperationInfo object for the constructor. | 219 """Returns an OperationInfo object for the constructor. |
| 220 | 220 |
| 221 Returns None if the interface has no Constructor. | 221 Returns None if the interface has no Constructor. |
| 222 """ | 222 """ |
| 223 if 'Constructor' in interface.ext_attrs: | 223 if 'Constructor' in interface.ext_attrs: |
| 224 name = None | 224 name = None |
| 225 func_value = interface.ext_attrs.get('Constructor') | 225 overloads = interface.ext_attrs['Constructor'] |
| 226 if not func_value: | 226 idl_args = [[] if f is None else f.arguments for f in overloads] |
| 227 args = [] | |
| 228 idl_args = [] | |
| 229 elif 'NamedConstructor' in interface.ext_attrs: | 227 elif 'NamedConstructor' in interface.ext_attrs: |
| 230 func_value = interface.ext_attrs.get('NamedConstructor') | 228 func_value = interface.ext_attrs.get('NamedConstructor') |
| 229 idl_args = [func_value.arguments] |
| 231 name = func_value.id | 230 name = func_value.id |
| 232 else: | 231 else: |
| 233 return None | 232 return None |
| 234 | 233 |
| 235 if func_value: | |
| 236 idl_args = func_value.arguments | |
| 237 args =_BuildArguments([idl_args], interface, True) | |
| 238 | |
| 239 info = OperationInfo() | 234 info = OperationInfo() |
| 240 info.overloads = None | 235 info.overloads = None |
| 241 info.idl_args = idl_args | 236 info.idl_args = idl_args |
| 242 info.declared_name = name | 237 info.declared_name = name |
| 243 info.name = name | 238 info.name = name |
| 244 info.constructor_name = None | 239 info.constructor_name = None |
| 245 info.js_name = name | 240 info.js_name = name |
| 246 info.type_name = interface.id | 241 info.type_name = interface.id |
| 247 info.param_infos = args | 242 info.param_infos = _BuildArguments(idl_args, interface, constructor=True) |
| 248 info.requires_named_arguments = False | 243 info.requires_named_arguments = False |
| 249 info.pure_dart_constructor = False | 244 info.pure_dart_constructor = False |
| 250 return info | 245 return info |
| 251 | 246 |
| 252 def IsDartListType(type): | 247 def IsDartListType(type): |
| 253 return type == 'List' or type.startswith('sequence<') | 248 return type == 'List' or type.startswith('sequence<') |
| 254 | 249 |
| 255 def IsDartCollectionType(type): | 250 def IsDartCollectionType(type): |
| 256 return IsDartListType(type) | 251 return IsDartListType(type) |
| 257 | 252 |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 self) | 1441 self) |
| 1447 | 1442 |
| 1448 if type_data.clazz == 'SVGTearOff': | 1443 if type_data.clazz == 'SVGTearOff': |
| 1449 dart_interface_name = self._renamer.RenameInterface( | 1444 dart_interface_name = self._renamer.RenameInterface( |
| 1450 self._database.GetInterface(type_name)) | 1445 self._database.GetInterface(type_name)) |
| 1451 return SVGTearOffIDLTypeInfo( | 1446 return SVGTearOffIDLTypeInfo( |
| 1452 type_name, type_data, dart_interface_name, self) | 1447 type_name, type_data, dart_interface_name, self) |
| 1453 | 1448 |
| 1454 class_name = '%sIDLTypeInfo' % type_data.clazz | 1449 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1455 return globals()[class_name](type_name, type_data) | 1450 return globals()[class_name](type_name, type_data) |
| OLD | NEW |