| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return True | 141 return True |
| 142 | 142 |
| 143 if HasAnnotations(interface): | 143 if HasAnnotations(interface): |
| 144 interface.constants = filter(HasAnnotations, interface.constants) | 144 interface.constants = filter(HasAnnotations, interface.constants) |
| 145 interface.attributes = filter(HasAnnotations, interface.attributes) | 145 interface.attributes = filter(HasAnnotations, interface.attributes) |
| 146 interface.operations = filter(HasAnnotations, interface.operations) | 146 interface.operations = filter(HasAnnotations, interface.operations) |
| 147 interface.parents = filter(HasAnnotations, interface.parents) | 147 interface.parents = filter(HasAnnotations, interface.parents) |
| 148 else: | 148 else: |
| 149 database.DeleteInterface(interface.id) | 149 database.DeleteInterface(interface.id) |
| 150 | 150 |
| 151 # Ugly temporary hack | 151 # Ugly temporary hack |
| 152 websocket_interface = database.GetInterface('WebSocket') | 152 websocket_interface = database.GetInterface('WebSocket') |
| 153 def make_object(**fields): | 153 def make_object(**fields): |
| 154 o = type('Anon', (object,), {})() | 154 o = type('Anon', (object,), {})() |
| 155 for k, v in fields.items(): setattr(o, k, v) | 155 for k, v in fields.items(): setattr(o, k, v) |
| 156 o.ext_attrs = {} | 156 o.ext_attrs = {} |
| 157 return o | 157 return o |
| 158 arg = make_object(id = 'url', type = make_object(id = 'DOMString')) | 158 arg = make_object(id = 'url', type = make_object(id = 'DOMString')) |
| 159 websocket_interface.ext_attrs['Constructor'] = make_object(arguments = [ar
g]) | 159 websocket_interface.ext_attrs['Constructor'] = make_object(arguments = [arg]
) |
| 160 websocket_interface.ext_attrs['CustomConstructor'] = True | 160 websocket_interface.ext_attrs['CustomConstructor'] = True |
| 161 | 161 |
| 162 self.FilterMembersWithUnidentifiedTypes(database) | 162 self.FilterMembersWithUnidentifiedTypes(database) |
| 163 | 163 |
| 164 def Generate(self, database, super_database, generate_interface): | 164 def Generate(self, database, super_database, generate_interface): |
| 165 self._database = database | 165 self._database = database |
| 166 | 166 |
| 167 # Collect interfaces | 167 # Collect interfaces |
| 168 interfaces = [] | 168 interfaces = [] |
| 169 for interface in database.GetInterfaces(): | 169 for interface in database.GetInterfaces(): |
| 170 if not MatchSourceFilter(interface): | 170 if not MatchSourceFilter(interface): |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 ast = [('Annotation', [('Id', 'WebKit')]), | 232 ast = [('Annotation', [('Id', 'WebKit')]), |
| 233 ('InterfaceType', ('ScopedName', 'EventTarget'))] | 233 ('InterfaceType', ('ScopedName', 'EventTarget'))] |
| 234 interface.parents.append(idlnode.IDLParentInterface(ast)) | 234 interface.parents.append(idlnode.IDLParentInterface(ast)) |
| 235 | 235 |
| 236 def AddMissingArguments(self, database): | 236 def AddMissingArguments(self, database): |
| 237 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) | 237 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) |
| 238 for interface in database.GetInterfaces(): | 238 for interface in database.GetInterfaces(): |
| 239 for operation in interface.operations: | 239 for operation in interface.operations: |
| 240 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|ScriptState': | 240 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|ScriptState': |
| 241 operation.arguments.append(ARG) | 241 operation.arguments.append(ARG) |
| OLD | NEW |