| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, 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 import copy | 6 import copy |
| 7 import database | 7 import database |
| 8 import idlparser | 8 import idlparser |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 else: | 264 else: |
| 265 # Merge old and new nodes: | 265 # Merge old and new nodes: |
| 266 old_node = old_signatures_map[sig] | 266 old_node = old_signatures_map[sig] |
| 267 if (source not in old_node.annotations | 267 if (source not in old_node.annotations |
| 268 and source in new_node.annotations): | 268 and source in new_node.annotations): |
| 269 old_node.annotations[source] = new_node.annotations[source] | 269 old_node.annotations[source] = new_node.annotations[source] |
| 270 changed = True | 270 changed = True |
| 271 # Maybe rename arguments: | 271 # Maybe rename arguments: |
| 272 if isinstance(old_node, IDLOperation): | 272 if isinstance(old_node, IDLOperation): |
| 273 for i in range(0, len(old_node.arguments)): | 273 for i in range(0, len(old_node.arguments)): |
| 274 old_arg_name = old_node.arguments[i].id | 274 old_arg = old_node.arguments[i] |
| 275 new_arg_name = new_node.arguments[i].id | 275 new_arg = new_node.arguments[i] |
| 276 |
| 277 old_arg_name = old_arg.id |
| 278 new_arg_name = new_arg.id |
| 276 if (old_arg_name != new_arg_name | 279 if (old_arg_name != new_arg_name |
| 277 and (old_arg_name == 'arg' | 280 and (old_arg_name == 'arg' |
| 278 or old_arg_name.endswith('Arg') | 281 or old_arg_name.endswith('Arg') |
| 279 or import_options.rename_operation_arguments_on_merge)): | 282 or import_options.rename_operation_arguments_on_merge)): |
| 280 old_node.arguments[i].id = new_arg_name | 283 old_node.arguments[i].id = new_arg_name |
| 281 changed = True | 284 changed = True |
| 285 |
| 286 if self._merge_ext_attrs(old_arg.ext_attrs, new_arg.ext_attrs): |
| 287 changed = True |
| 282 # Maybe merge annotations: | 288 # Maybe merge annotations: |
| 283 if (isinstance(old_node, IDLAttribute) or | 289 if (isinstance(old_node, IDLAttribute) or |
| 284 isinstance(old_node, IDLOperation)): | 290 isinstance(old_node, IDLOperation)): |
| 285 if self._merge_ext_attrs(old_node.ext_attrs, new_node.ext_attrs): | 291 if self._merge_ext_attrs(old_node.ext_attrs, new_node.ext_attrs): |
| 286 changed = True | 292 changed = True |
| 287 | 293 |
| 288 # Remove annotations on obsolete items from the same source | 294 # Remove annotations on obsolete items from the same source |
| 289 if import_options.obsolete_old_declarations: | 295 if import_options.obsolete_old_declarations: |
| 290 for (sig, old_node) in old_signatures_map.items(): | 296 for (sig, old_node) in old_signatures_map.items(): |
| 291 if (source in old_node.annotations | 297 if (source in old_node.annotations |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 import_options.source_attributes) | 374 import_options.source_attributes) |
| 369 return | 375 return |
| 370 # not found, so add new one | 376 # not found, so add new one |
| 371 parent = IDLParentInterface(None) | 377 parent = IDLParentInterface(None) |
| 372 parent.type = IDLType(implemented_name) | 378 parent.type = IDLType(implemented_name) |
| 373 if source: | 379 if source: |
| 374 parent.annotations[source] = IDLAnnotation( | 380 parent.annotations[source] = IDLAnnotation( |
| 375 import_options.source_attributes) | 381 import_options.source_attributes) |
| 376 interface.parents.append(parent) | 382 interface.parents.append(parent) |
| 377 | 383 |
| 378 def merge_imported_interfaces(self, optional_argument_whitelist): | 384 def merge_imported_interfaces(self): |
| 379 """Merges all imported interfaces and loads them into the DB.""" | 385 """Merges all imported interfaces and loads them into the DB.""" |
| 380 | 386 |
| 381 # Step 1: Pre process imported interfaces | 387 # Step 1: Pre process imported interfaces |
| 382 for interface, module_name, import_options in self._imported_interfaces: | 388 for interface, module_name, import_options in self._imported_interfaces: |
| 383 # Add 'Optional' attribute to whitelisted arguments. | |
| 384 for op in interface.operations: | |
| 385 for argument in op.arguments: | |
| 386 in_optional_whitelist = (interface.id, op.id, argument.id) in optional
_argument_whitelist | |
| 387 if in_optional_whitelist: | |
| 388 argument.ext_attrs['Optional'] = None | |
| 389 self._annotate(interface, module_name, import_options) | 389 self._annotate(interface, module_name, import_options) |
| 390 | 390 |
| 391 # Step 2: Add all new interfaces and merge overlapping ones | 391 # Step 2: Add all new interfaces and merge overlapping ones |
| 392 for interface, module_name, import_options in self._imported_interfaces: | 392 for interface, module_name, import_options in self._imported_interfaces: |
| 393 if not interface.is_supplemental: | 393 if not interface.is_supplemental: |
| 394 if self._database.HasInterface(interface.id): | 394 if self._database.HasInterface(interface.id): |
| 395 old_interface = self._database.GetInterface(interface.id) | 395 old_interface = self._database.GetInterface(interface.id) |
| 396 self._merge_interfaces(old_interface, interface, import_options) | 396 self._merge_interfaces(old_interface, interface, import_options) |
| 397 else: | 397 else: |
| 398 if import_options.add_new_interfaces: | 398 if import_options.add_new_interfaces: |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 # TODO(antonm): Ideally we'd like to have pristine copy of WebKit IDLs and
fetch | 550 # TODO(antonm): Ideally we'd like to have pristine copy of WebKit IDLs and
fetch |
| 551 # this information directly from it. Unfortunately right now database is
massaged | 551 # this information directly from it. Unfortunately right now database is
massaged |
| 552 # a lot so it's difficult to maintain necessary information on DOMWindow i
tself. | 552 # a lot so it's difficult to maintain necessary information on DOMWindow i
tself. |
| 553 interface = self._database.GetInterface(options.type_rename_map.get(type,
type)) | 553 interface = self._database.GetInterface(options.type_rename_map.get(type,
type)) |
| 554 if 'V8EnabledPerContext' in attr.ext_attrs: | 554 if 'V8EnabledPerContext' in attr.ext_attrs: |
| 555 interface.ext_attrs['synthesizedV8EnabledPerContext'] = \ | 555 interface.ext_attrs['synthesizedV8EnabledPerContext'] = \ |
| 556 attr.ext_attrs['V8EnabledPerContext'] | 556 attr.ext_attrs['V8EnabledPerContext'] |
| 557 if 'V8EnabledAtRuntime' in attr.ext_attrs: | 557 if 'V8EnabledAtRuntime' in attr.ext_attrs: |
| 558 interface.ext_attrs['synthesizedV8EnabledAtRuntime'] = \ | 558 interface.ext_attrs['synthesizedV8EnabledAtRuntime'] = \ |
| 559 attr.ext_attrs['V8EnabledAtRuntime'] or attr.id | 559 attr.ext_attrs['V8EnabledAtRuntime'] or attr.id |
| OLD | NEW |