| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 # Collect interfaces | 163 # Collect interfaces |
| 164 interfaces = [] | 164 interfaces = [] |
| 165 for interface in database.GetInterfaces(): | 165 for interface in database.GetInterfaces(): |
| 166 if not MatchSourceFilter(interface): | 166 if not MatchSourceFilter(interface): |
| 167 # Skip this interface since it's not present in the required source | 167 # Skip this interface since it's not present in the required source |
| 168 _logger.info('Omitting interface - %s' % interface.id) | 168 _logger.info('Omitting interface - %s' % interface.id) |
| 169 continue | 169 continue |
| 170 interfaces.append(interface) | 170 interfaces.append(interface) |
| 171 | 171 |
| 172 # Render all interfaces into Dart and save them in files. | 172 # Render all interfaces into Dart and save them in files. |
| 173 cid = 0; |
| 173 for interface in self._PreOrderInterfaces(interfaces): | 174 for interface in self._PreOrderInterfaces(interfaces): |
| 174 interface_name = interface.id | 175 interface_name = interface.id |
| 175 auxiliary_file = self._auxiliary_files.get(interface_name) | 176 auxiliary_file = self._auxiliary_files.get(interface_name) |
| 176 if auxiliary_file is not None: | 177 if auxiliary_file is not None: |
| 177 _logger.info('Skipping %s because %s exists' % ( | 178 _logger.info('Skipping %s because %s exists' % ( |
| 178 interface_name, auxiliary_file)) | 179 interface_name, auxiliary_file)) |
| 179 continue | 180 continue |
| 180 | 181 |
| 181 _logger.info('Generating %s' % interface.id) | 182 _logger.info('Generating %s' % interface.id) |
| 182 generate_interface(interface) | 183 generate_interface(interface, cid) |
| 184 cid = cid + 1 |
| 183 | 185 |
| 184 def _PreOrderInterfaces(self, interfaces): | 186 def _PreOrderInterfaces(self, interfaces): |
| 185 """Returns the interfaces in pre-order, i.e. parents first.""" | 187 """Returns the interfaces in pre-order, i.e. parents first.""" |
| 186 seen = set() | 188 seen = set() |
| 187 ordered = [] | 189 ordered = [] |
| 188 def visit(interface): | 190 def visit(interface): |
| 189 if interface.id in seen: | 191 if interface.id in seen: |
| 190 return | 192 return |
| 191 seen.add(interface.id) | 193 seen.add(interface.id) |
| 192 for parent in interface.parents: | 194 for parent in interface.parents: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 def AddMissingArguments(self, database): | 229 def AddMissingArguments(self, database): |
| 228 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) | 230 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) |
| 229 for interface in database.GetInterfaces(): | 231 for interface in database.GetInterfaces(): |
| 230 for operation in interface.operations: | 232 for operation in interface.operations: |
| 231 call_with = (operation.ext_attrs.get('CallWith', '').split('|') + | 233 call_with = (operation.ext_attrs.get('CallWith', '').split('|') + |
| 232 operation.ext_attrs.get('ConstructorCallWith', '').split('|
') + | 234 operation.ext_attrs.get('ConstructorCallWith', '').split('|
') + |
| 233 operation.ext_attrs.get('CallWith', '').split('&') + | 235 operation.ext_attrs.get('CallWith', '').split('&') + |
| 234 operation.ext_attrs.get('ConstructorCallWith', '').split('&
')) | 236 operation.ext_attrs.get('ConstructorCallWith', '').split('&
')) |
| 235 if 'ScriptArguments' in call_with: | 237 if 'ScriptArguments' in call_with: |
| 236 operation.arguments.append(ARG) | 238 operation.arguments.append(ARG) |
| OLD | NEW |