Chromium Code Reviews| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 continue | 193 continue |
| 194 if self._database.HasInterface(parent.type.id): | 194 if self._database.HasInterface(parent.type.id): |
| 195 parent_interface = self._database.GetInterface(parent.type.id) | 195 parent_interface = self._database.GetInterface(parent.type.id) |
| 196 visit(parent_interface) | 196 visit(parent_interface) |
| 197 ordered.append(interface) | 197 ordered.append(interface) |
| 198 | 198 |
| 199 for interface in interfaces: | 199 for interface in interfaces: |
| 200 visit(interface) | 200 visit(interface) |
| 201 return ordered | 201 return ordered |
| 202 | 202 |
| 203 def IsEventTarget(self, database, interface): | |
| 204 if interface.id == 'EventTarget': | |
| 205 return True | |
| 206 for parent in interface.parents: | |
| 207 parent_name = parent.type.id | |
| 208 if database.HasInterface(parent_name): | |
| 209 parent_interface = database.GetInterface(parent.type.id) | |
| 210 if self.IsEventTarget(database, parent_interface): | |
| 211 return True | |
| 212 return False | |
| 213 | |
| 203 def FixEventTargets(self, database): | 214 def FixEventTargets(self, database): |
| 204 for interface in database.GetInterfaces(): | 215 for interface in database.GetInterfaces(): |
| 205 # Create fake EventTarget parent interface for interfaces that have | 216 if self.IsEventTarget(database, interface): |
| 206 # 'EventTarget' extended attribute. | 217 # Add as an attribute for easy querying in |
|
Jacob
2013/08/08 21:15:29
nit: make comment one line
| |
| 207 if 'EventTarget' in interface.ext_attrs and interface.id != 'EventTarget': | 218 # generation code. |
| 219 interface.ext_attrs['EventTarget'] = None | |
| 220 elif 'EventTarget' in interface.ext_attrs: | |
| 221 # Create fake EventTarget parent interface for interfaces that have | |
| 222 # 'EventTarget' extended attribute. | |
| 208 ast = [('Annotation', [('Id', 'WebKit')]), | 223 ast = [('Annotation', [('Id', 'WebKit')]), |
| 209 ('InterfaceType', ('ScopedName', 'EventTarget'))] | 224 ('InterfaceType', ('ScopedName', 'EventTarget'))] |
| 210 interface.parents.append(idlnode.IDLParentInterface(ast)) | 225 interface.parents.append(idlnode.IDLParentInterface(ast)) |
| 211 | 226 |
| 212 def AddMissingArguments(self, database): | 227 def AddMissingArguments(self, database): |
| 213 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg') ]) | 228 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg') ]) |
| 214 for interface in database.GetInterfaces(): | 229 for interface in database.GetInterfaces(): |
| 215 for operation in interface.operations: | 230 for operation in interface.operations: |
| 216 call_with = (operation.ext_attrs.get('CallWith', '').split('|') + | 231 call_with = (operation.ext_attrs.get('CallWith', '').split('|') + |
| 217 operation.ext_attrs.get('ConstructorCallWith', '').split('| ') + | 232 operation.ext_attrs.get('ConstructorCallWith', '').split('| ') + |
| 218 operation.ext_attrs.get('CallWith', '').split('&') + | 233 operation.ext_attrs.get('CallWith', '').split('&') + |
| 219 operation.ext_attrs.get('ConstructorCallWith', '').split('& ')) | 234 operation.ext_attrs.get('ConstructorCallWith', '').split('& ')) |
| 220 if 'ScriptArguments' in call_with: | 235 if 'ScriptArguments' in call_with: |
| 221 operation.arguments.append(ARG) | 236 operation.arguments.append(ARG) |
| OLD | NEW |