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 generates Dart APIs from the IDL database.""" | 6 """This module generates Dart APIs from the IDL database.""" |
7 | 7 |
8 import emitter | 8 import emitter |
9 import idlnode | 9 import idlnode |
10 import logging | 10 import logging |
(...skipping 10 matching lines...) Expand all Loading... |
21 if not node.has_attribute(attribute): | 21 if not node.has_attribute(attribute): |
22 node.attributes.append(attribute) | 22 node.attributes.append(attribute) |
23 | 23 |
24 node.constants.extend(other.constants) | 24 node.constants.extend(other.constants) |
25 | 25 |
26 class DartGenerator(object): | 26 class DartGenerator(object): |
27 """Utilities to generate Dart APIs and corresponding JavaScript.""" | 27 """Utilities to generate Dart APIs and corresponding JavaScript.""" |
28 | 28 |
29 def __init__(self, logging_level=logging.WARNING): | 29 def __init__(self, logging_level=logging.WARNING): |
30 self._auxiliary_files = {} | 30 self._auxiliary_files = {} |
31 self._dart_templates_re = re.compile(r'[\w.:]+<([\w\.<>:]+)>') | 31 self._dart_templates_re = re.compile(r'[\w.:]+<([\w \.<>:]+)>') |
32 _logger.setLevel(logging_level) | 32 _logger.setLevel(logging_level) |
33 | 33 |
34 def _StripModules(self, type_name): | 34 def _StripModules(self, type_name): |
35 return type_name.split('::')[-1] | 35 return type_name.split('::')[-1] |
36 | 36 |
37 def _IsCompoundType(self, database, type_name): | 37 def _IsCompoundType(self, database, type_name): |
38 if IsRegisteredType(type_name): | 38 if IsRegisteredType(type_name): |
39 return True | 39 return True |
40 | 40 |
41 if type_name.endswith('?'): | 41 if type_name.endswith('?'): |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 def AddMissingArguments(self, database): | 228 def AddMissingArguments(self, database): |
229 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) | 229 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) |
230 for interface in database.GetInterfaces(): | 230 for interface in database.GetInterfaces(): |
231 for operation in interface.operations: | 231 for operation in interface.operations: |
232 call_with = (operation.ext_attrs.get('CallWith', '').split('|') + | 232 call_with = (operation.ext_attrs.get('CallWith', '').split('|') + |
233 operation.ext_attrs.get('ConstructorCallWith', '').split('|
') + | 233 operation.ext_attrs.get('ConstructorCallWith', '').split('|
') + |
234 operation.ext_attrs.get('CallWith', '').split('&') + | 234 operation.ext_attrs.get('CallWith', '').split('&') + |
235 operation.ext_attrs.get('ConstructorCallWith', '').split('&
')) | 235 operation.ext_attrs.get('ConstructorCallWith', '').split('&
')) |
236 if 'ScriptArguments' in call_with: | 236 if 'ScriptArguments' in call_with: |
237 operation.arguments.append(ARG) | 237 operation.arguments.append(ARG) |
OLD | NEW |