| 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 multiprocessing | 10 import multiprocessing |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 new_arg_name = new_arg.id | 390 new_arg_name = new_arg.id |
| 391 if (old_arg_name != new_arg_name | 391 if (old_arg_name != new_arg_name |
| 392 and (old_arg_name == 'arg' | 392 and (old_arg_name == 'arg' |
| 393 or old_arg_name.endswith('Arg') | 393 or old_arg_name.endswith('Arg') |
| 394 or import_options.rename_operation_arguments_on_merge)): | 394 or import_options.rename_operation_arguments_on_merge)): |
| 395 old_node.arguments[i].id = new_arg_name | 395 old_node.arguments[i].id = new_arg_name |
| 396 changed = True | 396 changed = True |
| 397 | 397 |
| 398 if self._merge_ext_attrs(old_arg.ext_attrs, new_arg.ext_attrs): | 398 if self._merge_ext_attrs(old_arg.ext_attrs, new_arg.ext_attrs): |
| 399 changed = True | 399 changed = True |
| 400 |
| 401 # Merge in [Default=Undefined] and DOMString a = null handling in |
| 402 # IDL. The IDL model (IDLArgument) coalesces these two different |
| 403 # default value syntaxes into the default_value* models. |
| 404 old_default_value = old_arg.default_value |
| 405 new_default_value = new_arg.default_value |
| 406 old_default_value_is_null = old_arg.default_value_is_null |
| 407 new_default_value_is_null = new_arg.default_value_is_null |
| 408 if old_default_value != new_default_value: |
| 409 old_arg.default_value = new_default_value |
| 410 changed = True |
| 411 if old_default_value_is_null != new_default_value_is_null: |
| 412 old_arg.default_value_is_null = new_default_value_is_null |
| 413 changed = True |
| 414 |
| 415 # Merge in any optional argument differences. |
| 416 old_optional = old_arg.optional |
| 417 new_optional = new_arg.optional |
| 418 if old_optional != new_optional: |
| 419 old_arg.optional = new_optional |
| 420 changed = True |
| 400 # Maybe merge annotations: | 421 # Maybe merge annotations: |
| 401 if (isinstance(old_node, IDLAttribute) or | 422 if (isinstance(old_node, IDLAttribute) or |
| 402 isinstance(old_node, IDLOperation)): | 423 isinstance(old_node, IDLOperation)): |
| 403 if self._merge_ext_attrs(old_node.ext_attrs, new_node.ext_attrs): | 424 if self._merge_ext_attrs(old_node.ext_attrs, new_node.ext_attrs): |
| 404 changed = True | 425 changed = True |
| 405 | 426 |
| 406 # Remove annotations on obsolete items from the same source | 427 # Remove annotations on obsolete items from the same source |
| 407 if import_options.obsolete_old_declarations: | 428 if import_options.obsolete_old_declarations: |
| 408 for (sig, old_node) in old_signatures_map.items(): | 429 for (sig, old_node) in old_signatures_map.items(): |
| 409 if (source in old_node.annotations | 430 if (source in old_node.annotations |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 else: | 544 else: |
| 524 _logger.warning("Supplemental target '%s' not found", target) | 545 _logger.warning("Supplemental target '%s' not found", target) |
| 525 | 546 |
| 526 # Step 4: Resolve 'implements' statements | 547 # Step 4: Resolve 'implements' statements |
| 527 for impl_stmt, import_options in self._impl_stmts: | 548 for impl_stmt, import_options in self._impl_stmts: |
| 528 self._merge_impl_stmt(impl_stmt, import_options) | 549 self._merge_impl_stmt(impl_stmt, import_options) |
| 529 | 550 |
| 530 self._impl_stmts = [] | 551 self._impl_stmts = [] |
| 531 self._imported_interfaces = [] | 552 self._imported_interfaces = [] |
| 532 | 553 |
| 554 def _compute_dart_idl_implements(self, idl_filename): |
| 555 full_path = os.path.realpath(idl_filename) |
| 556 |
| 557 with open(full_path) as f: |
| 558 idl_file_contents = f.read() |
| 559 |
| 560 implements_re = (r'^\s*' |
| 561 r'(\w+)\s+' |
| 562 r'implements\s+' |
| 563 r'(\w+)\s*' |
| 564 r';') |
| 565 |
| 566 implements_matches = re.finditer(implements_re, idl_file_contents, re.MULTIL
INE) |
| 567 return [match.groups() for match in implements_matches] |
| 568 |
| 533 # Compile the IDL file with the Blink compiler and remember each AST for the | 569 # Compile the IDL file with the Blink compiler and remember each AST for the |
| 534 # IDL. | 570 # IDL. |
| 535 def _blink_compile_idl_files(self, file_paths, import_options, parallel, is_da
rt_idl): | 571 def _blink_compile_idl_files(self, file_paths, import_options, parallel, is_da
rt_idl): |
| 536 if not(is_dart_idl): | 572 if not(is_dart_idl): |
| 537 start_time = time.time() | 573 start_time = time.time() |
| 538 | 574 |
| 539 # 2-stage computation: individual, then overall | 575 # 2-stage computation: individual, then overall |
| 540 for file_path in file_paths: | 576 for file_path in file_paths: |
| 541 filename = os.path.splitext(os.path.basename(file_path))[0] | |
| 542 compute_info_individual(file_path, 'dart') | 577 compute_info_individual(file_path, 'dart') |
| 543 info_individuals = [info_individual()] | 578 info_individuals = [info_individual()] |
| 544 compute_interfaces_info_overall(info_individuals) | 579 compute_interfaces_info_overall(info_individuals) |
| 545 | 580 |
| 546 end_time = time.time() | 581 end_time = time.time() |
| 547 print 'Compute dependencies %s seconds' % round((end_time - start_time), | 582 print 'Compute dependencies %s seconds' % round((end_time - start_time), 2
) |
| 548 2) | 583 else: |
| 584 # Compute the interface_info for dart.idl for implements defined. This |
| 585 # file is special in that more than one interface can exist in this file. |
| 586 implement_pairs = self._compute_dart_idl_implements(file_paths[0]) |
| 587 |
| 588 interfaces_info['__dart_idl___'] = { |
| 589 'implement_pairs': implement_pairs, |
| 590 } |
| 549 | 591 |
| 550 # use --parallel for async on a pool. Look at doing it like Blink | 592 # use --parallel for async on a pool. Look at doing it like Blink |
| 551 blink_compiler = _new_compile_idl_file | 593 blink_compiler = _new_compile_idl_file |
| 552 process_ast = self._process_ast | 594 process_ast = self._process_ast |
| 553 | 595 |
| 554 if parallel: | 596 if parallel: |
| 555 # Parse the IDL files in parallel. | 597 # Parse the IDL files in parallel. |
| 556 pool = multiprocessing.Pool() | 598 pool = multiprocessing.Pool() |
| 557 try: | 599 try: |
| 558 for file_path in file_paths: | 600 for file_path in file_paths: |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 # TODO(antonm): Ideally we'd like to have pristine copy of WebKit IDLs and
fetch | 797 # TODO(antonm): Ideally we'd like to have pristine copy of WebKit IDLs and
fetch |
| 756 # this information directly from it. Unfortunately right now database is
massaged | 798 # this information directly from it. Unfortunately right now database is
massaged |
| 757 # a lot so it's difficult to maintain necessary information on Window itse
lf. | 799 # a lot so it's difficult to maintain necessary information on Window itse
lf. |
| 758 interface = self._database.GetInterface(type) | 800 interface = self._database.GetInterface(type) |
| 759 if 'V8EnabledPerContext' in attr.ext_attrs: | 801 if 'V8EnabledPerContext' in attr.ext_attrs: |
| 760 interface.ext_attrs['synthesizedV8EnabledPerContext'] = \ | 802 interface.ext_attrs['synthesizedV8EnabledPerContext'] = \ |
| 761 attr.ext_attrs['V8EnabledPerContext'] | 803 attr.ext_attrs['V8EnabledPerContext'] |
| 762 if 'V8EnabledAtRuntime' in attr.ext_attrs: | 804 if 'V8EnabledAtRuntime' in attr.ext_attrs: |
| 763 interface.ext_attrs['synthesizedV8EnabledAtRuntime'] = \ | 805 interface.ext_attrs['synthesizedV8EnabledAtRuntime'] = \ |
| 764 attr.ext_attrs['V8EnabledAtRuntime'] or attr.id | 806 attr.ext_attrs['V8EnabledAtRuntime'] or attr.id |
| OLD | NEW |