| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 continue | 227 continue |
| 228 | 228 |
| 229 if 'Callback' in interface.ext_attrs: | 229 if 'Callback' in interface.ext_attrs: |
| 230 handlers = [op for op in interface.operations if op.id == 'handleEvent'] | 230 handlers = [op for op in interface.operations if op.id == 'handleEvent'] |
| 231 info = AnalyzeOperation(interface, handlers) | 231 info = AnalyzeOperation(interface, handlers) |
| 232 system.ProcessCallback(interface, info) | 232 system.ProcessCallback(interface, info) |
| 233 else: | 233 else: |
| 234 _logger.info('Generating %s' % interface.id) | 234 _logger.info('Generating %s' % interface.id) |
| 235 system.ProcessInterface(interface) | 235 system.ProcessInterface(interface) |
| 236 | 236 |
| 237 system.GenerateLibraries() | |
| 238 system.Finish() | |
| 239 | |
| 240 def _PreOrderInterfaces(self, interfaces): | 237 def _PreOrderInterfaces(self, interfaces): |
| 241 """Returns the interfaces in pre-order, i.e. parents first.""" | 238 """Returns the interfaces in pre-order, i.e. parents first.""" |
| 242 seen = set() | 239 seen = set() |
| 243 ordered = [] | 240 ordered = [] |
| 244 def visit(interface): | 241 def visit(interface): |
| 245 if interface.id in seen: | 242 if interface.id in seen: |
| 246 return | 243 return |
| 247 seen.add(interface.id) | 244 seen.add(interface.id) |
| 248 for parent in interface.parents: | 245 for parent in interface.parents: |
| 249 if IsDartCollectionType(parent.type.id): | 246 if IsDartCollectionType(parent.type.id): |
| (...skipping 30 matching lines...) Expand all Loading... |
| 280 ast = [('Annotation', [('Id', 'WebKit')]), | 277 ast = [('Annotation', [('Id', 'WebKit')]), |
| 281 ('InterfaceType', ('ScopedName', 'EventTarget'))] | 278 ('InterfaceType', ('ScopedName', 'EventTarget'))] |
| 282 interface.parents.append(idlnode.IDLParentInterface(ast)) | 279 interface.parents.append(idlnode.IDLParentInterface(ast)) |
| 283 | 280 |
| 284 def AddMissingArguments(self, database): | 281 def AddMissingArguments(self, database): |
| 285 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'Object')), ('Id', 'arg')
]) | 282 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'Object')), ('Id', 'arg')
]) |
| 286 for interface in database.GetInterfaces(): | 283 for interface in database.GetInterfaces(): |
| 287 for operation in interface.operations: | 284 for operation in interface.operations: |
| 288 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|CallStack': | 285 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|CallStack': |
| 289 operation.arguments.append(ARG) | 286 operation.arguments.append(ARG) |
| OLD | NEW |