Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: tools/dom/scripts/databasebuilder.py

Issue 952133004: Changes to support roll 39 IDLs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/dom/scripts/database.py ('k') | tools/dom/scripts/fremontcutbuilder.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logging 8 import logging
9 import monitored 9 import monitored
10 import multiprocessing 10 import multiprocessing
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 return [match.groups() for match in implements_matches] 554 return [match.groups() for match in implements_matches]
555 555
556 # Compile the IDL file with the Blink compiler and remember each AST for the 556 # Compile the IDL file with the Blink compiler and remember each AST for the
557 # IDL. 557 # IDL.
558 def _blink_compile_idl_files(self, file_paths, import_options, is_dart_idl): 558 def _blink_compile_idl_files(self, file_paths, import_options, is_dart_idl):
559 if not(is_dart_idl): 559 if not(is_dart_idl):
560 start_time = time.time() 560 start_time = time.time()
561 561
562 # 2-stage computation: individual, then overall 562 # 2-stage computation: individual, then overall
563 for file_path in file_paths: 563 for file_path in file_paths:
564 compute_info_individual(file_path, 'dart') 564 compute_info_individual(file_path)
565 info_individuals = [info_individual()] 565 info_individuals = [info_individual()]
566 compute_interfaces_info_overall(info_individuals) 566 compute_interfaces_info_overall(info_individuals)
567 567
568 end_time = time.time() 568 end_time = time.time()
569 print 'Compute dependencies %s seconds' % round((end_time - start_time), 2 ) 569 print 'Compute dependencies %s seconds' % round((end_time - start_time), 2 )
570 else: 570 else:
571 # Compute the interface_info for dart.idl for implements defined. This 571 # Compute the interface_info for dart.idl for implements defined. This
572 # file is special in that more than one interface can exist in this file. 572 # file is special in that more than one interface can exist in this file.
573 implement_pairs = self._compute_dart_idl_implements(file_paths[0]) 573 implement_pairs = self._compute_dart_idl_implements(file_paths[0])
574 574
575 interfaces_info['__dart_idl___'] = { 575 interfaces_info['__dart_idl___'] = {
576 'implement_pairs': implement_pairs, 576 'implement_pairs': implement_pairs,
577 } 577 }
578 578
579 # Parse the IDL files serially. 579 # Parse the IDL files serially.
580 start_time = time.time() 580 start_time = time.time()
581 581
582 for file_path in file_paths: 582 for file_path in file_paths:
583 file_path = os.path.normpath(file_path) 583 file_path = os.path.normpath(file_path)
584 ast = _compile_idl_file(self.build, file_path, import_options) 584 ast = _compile_idl_file(self.build, file_path, import_options)
585 self._process_ast(os.path.splitext(os.path.basename(file_path))[0], ast) 585 self._process_ast(os.path.splitext(os.path.basename(file_path))[0], ast)
586 586
587 end_time = time.time() 587 end_time = time.time()
588 print 'Compiled %s IDL files in %s seconds' % (len(file_paths), 588 print 'Compiled %s IDL files in %s seconds' % (len(file_paths),
589 round((end_time - start_time), 2)) 589 round((end_time - start_time), 2))
590 590
591 def _process_ast(self, filename, ast): 591 def _process_ast(self, filename, ast):
592 if len(ast) == 1:
593 ast = ast.values()[0]
594 else:
595 print 'ERROR: Processing AST: ' + os.path.basename(file_name)
592 new_asts[filename] = ast 596 new_asts[filename] = ast
593 597
594 def import_idl_files(self, file_paths, import_options, is_dart_idl): 598 def import_idl_files(self, file_paths, import_options, is_dart_idl):
595 self._blink_compile_idl_files(file_paths, import_options, is_dart_idl) 599 self._blink_compile_idl_files(file_paths, import_options, is_dart_idl)
596 600
597 start_time = time.time() 601 start_time = time.time()
598 602
599 # Parse the IDL files in serial. 603 # Parse the IDL files in serial.
600 for file_path in file_paths: 604 for file_path in file_paths:
601 file_path = os.path.normpath(file_path) 605 file_path = os.path.normpath(file_path)
(...skipping 21 matching lines...) Expand all
623 % (interface.id, import_options.source)) 627 % (interface.id, import_options.source))
624 continue 628 continue
625 629
626 _logger.info('importing interface %s (source=%s file=%s)' 630 _logger.info('importing interface %s (source=%s file=%s)'
627 % (interface.id, import_options.source, os.path.basename(idl_file.filena me))) 631 % (interface.id, import_options.source, os.path.basename(idl_file.filena me)))
628 632
629 interface.attributes = filter(enabled, interface.attributes) 633 interface.attributes = filter(enabled, interface.attributes)
630 interface.operations = filter(enabled, interface.operations) 634 interface.operations = filter(enabled, interface.operations)
631 self._imported_interfaces.append((interface, import_options)) 635 self._imported_interfaces.append((interface, import_options))
632 636
633 for implStmt in idl_file.implementsStatements: 637 # If an IDL dictionary then there is no implementsStatements.
634 self._impl_stmts.append((implStmt, import_options)) 638 if hasattr(idl_file, 'implementsStatements'):
639 for implStmt in idl_file.implementsStatements:
640 self._impl_stmts.append((implStmt, import_options))
635 641
636 for enum in idl_file.enums: 642 for enum in idl_file.enums:
637 self._database.AddEnum(enum) 643 self._database.AddEnum(enum)
638 644
645 for dictionary in idl_file.dictionaries:
646 self._database.AddDictionary(dictionary)
647
639 648
640 def _is_node_enabled(self, node, idl_defines): 649 def _is_node_enabled(self, node, idl_defines):
641 if not 'Conditional' in node.ext_attrs: 650 if not 'Conditional' in node.ext_attrs:
642 return True 651 return True
643 652
644 def enabled(condition): 653 def enabled(condition):
645 return 'ENABLE_%s' % condition in idl_defines 654 return 'ENABLE_%s' % condition in idl_defines
646 655
647 conditional = node.ext_attrs['Conditional'] 656 conditional = node.ext_attrs['Conditional']
648 if conditional.find('&') != -1: 657 if conditional.find('&') != -1:
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 for name, value in annotation.items(): 732 for name, value in annotation.items():
724 if (name in top_level_annotation 733 if (name in top_level_annotation
725 and value == top_level_annotation[name]): 734 and value == top_level_annotation[name]):
726 del annotation[name] 735 del annotation[name]
727 736
728 map(normalize, interface.parents) 737 map(normalize, interface.parents)
729 map(normalize, interface.constants) 738 map(normalize, interface.constants)
730 map(normalize, interface.attributes) 739 map(normalize, interface.attributes)
731 map(normalize, interface.operations) 740 map(normalize, interface.operations)
732 741
742 def map_dictionaries(self):
743 """Changes the type of operations/constructors arguments from an IDL
744 dictionary to a Dictionary. The IDL dictionary is just an enums of
745 strings which are checked at run-time."""
746 def dictionary_to_map(type_node):
747 if self._database.HasDictionary(type_node.id):
748 type_node.dictionary = type_node.id
749 type_node.id = 'Dictionary'
750
751 def all_types(node):
752 map(dictionary_to_map, node.all(IDLType))
753
754 for interface in self._database.GetInterfaces():
755 map(all_types, interface.all(IDLExtAttrFunctionValue))
756 map(all_types, interface.operations)
757
733 def fetch_constructor_data(self, options): 758 def fetch_constructor_data(self, options):
734 window_interface = self._database.GetInterface('Window') 759 window_interface = self._database.GetInterface('Window')
735 for attr in window_interface.attributes: 760 for attr in window_interface.attributes:
736 type = attr.type.id 761 type = attr.type.id
737 if not type.endswith('Constructor'): 762 if not type.endswith('Constructor'):
738 continue 763 continue
739 type = re.sub('(Constructor)+$', '', type) 764 type = re.sub('(Constructor)+$', '', type)
740 # TODO(antonm): Ideally we'd like to have pristine copy of WebKit IDLs and fetch 765 # TODO(antonm): Ideally we'd like to have pristine copy of WebKit IDLs and fetch
741 # this information directly from it. Unfortunately right now database is massaged 766 # this information directly from it. Unfortunately right now database is massaged
742 # a lot so it's difficult to maintain necessary information on Window itse lf. 767 # a lot so it's difficult to maintain necessary information on Window itse lf.
743 interface = self._database.GetInterface(type) 768 interface = self._database.GetInterface(type)
744 if 'V8EnabledPerContext' in attr.ext_attrs: 769 if 'V8EnabledPerContext' in attr.ext_attrs:
745 interface.ext_attrs['synthesizedV8EnabledPerContext'] = \ 770 interface.ext_attrs['synthesizedV8EnabledPerContext'] = \
746 attr.ext_attrs['V8EnabledPerContext'] 771 attr.ext_attrs['V8EnabledPerContext']
747 if 'V8EnabledAtRuntime' in attr.ext_attrs: 772 if 'V8EnabledAtRuntime' in attr.ext_attrs:
748 interface.ext_attrs['synthesizedV8EnabledAtRuntime'] = \ 773 interface.ext_attrs['synthesizedV8EnabledAtRuntime'] = \
749 attr.ext_attrs['V8EnabledAtRuntime'] or attr.id 774 attr.ext_attrs['V8EnabledAtRuntime'] or attr.id
OLDNEW
« no previous file with comments | « tools/dom/scripts/database.py ('k') | tools/dom/scripts/fremontcutbuilder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698