Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
scripts.databasebuilder.DatabaseBuilder Class Reference
Inheritance diagram for scripts.databasebuilder.DatabaseBuilder:

Public Member Functions

def __init__ (self, database)
 
def merge_imported_interfaces (self)
 
def import_idl_files (self, file_paths, import_options, is_dart_idl)
 
def fix_displacements (self, source)
 
def normalize_annotations (self, sources)
 
def map_dictionaries (self)
 
def fetch_constructor_data (self, options)
 
def examine_database (self)
 

Public Attributes

 conditionals_met
 
 build
 
 global_type_defs
 

Detailed Description

Definition at line 173 of file databasebuilder.py.

Constructor & Destructor Documentation

◆ __init__()

def scripts.databasebuilder.DatabaseBuilder.__init__ (   self,
  database 
)
DatabaseBuilder is used for importing and merging interfaces into
the Database

Definition at line 175 of file databasebuilder.py.

175 def __init__(self, database):
176 """DatabaseBuilder is used for importing and merging interfaces into
177 the Database"""
178 self._info_collector = InterfaceInfoCollector()
179
180 self._database = database
181 self._imported_interfaces = []
182 self._impl_stmts = []
183 self.conditionals_met = set()
184
185 # Spin up the new IDL parser.
186 self.build = Build(self)
187
188 # Global typedef to mapping.
189 self.global_type_defs = monitored.Dict(
190 'databasebuilder.global_type_defs', {
191 'Transferable': 'MessagePort',
192 })
193
def Build(configs, env, options)
Definition: build.py:232
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76

Member Function Documentation

◆ examine_database()

def scripts.databasebuilder.DatabaseBuilder.examine_database (   self)

Definition at line 822 of file databasebuilder.py.

822 def examine_database(self):
823 # Contains list of dictionary structure: {'dictionary': dictionary, 'usages': []}
824 self._diag_dictionaries = []
825 self._dictionaries_used_types = []
826
827 # Record any dictionary.
828 for dictionary in self._database.GetDictionaries():
829 self._diag_dictionaries.append({
830 'dictionary': dictionary,
831 'usages': []
832 })
833
834 # Contains list of NoInterfaceObject structures: {'no_interface_object': dictionary, 'usages': []}
835 self._diag_no_interfaces = []
836 self._no_interfaces_used_types = []
837
838 # Record any interface with Blink IDL Extended Attribute 'NoInterfaceObject'.
839 for interface in self._database.GetInterfaces():
840 if interface.is_no_interface_object:
841 self._diag_no_interfaces.append({
842 'no_interface_object':
843 interface,
844 'usages': []
845 })
846
847 for interface in self._database.GetInterfaces():
848 self._constructors(interface)
849 self._constructors(interface, check_dictionaries=False)
850
851 for attribute in interface.attributes:
852 self._attribute_operation(interface, attribute)
853 self._attribute_operation(
854 interface, attribute, check_dictionaries=False)
855
856 for operation in interface.operations:
857 self._attribute_operation(interface, operation)
858 self._attribute_operation(
859 interface, operation, check_dictionaries=False)
860
861 # Report all dictionaries and their usage.
862 self._output_examination()
863 # Report all interface marked with NoInterfaceObject and their usage.
864 self._output_examination(check_dictionaries=False)
865
866 print('''
867Key:
868 (READ-ONLY) - read-only attribute has relationship
869 (GET/SET) - attribute has relationship
870 RETURN - operation\'s returned value has relationship
871 (ARGUMENT) - operation\'s argument(s) has relationship
872
873 (New) - After dictionary name if constructor(s) exist
874 (Ops,Props,New) after a NoInterfaceObject name is defined as:
875 Ops - number of operations for a NoInterfaceObject
876 Props - number of properties for a NoInterfaceObject
877 New - T(#) number constructors for a NoInterfaceObject
878 F no constructors for a NoInterfaceObject
879 e.g., an interface 5 operations, 3 properties and 2
880 constructors would display (5,3,T(2))
881
882
883Examination Complete
884''')
885
static void append(char **dst, size_t *count, const char *src, size_t n)
Definition: editor.cpp:211
def print(*args, **kwargs)
Definition: run_tests.py:49
#define T
Definition: precompiler.cc:65

◆ fetch_constructor_data()

def scripts.databasebuilder.DatabaseBuilder.fetch_constructor_data (   self,
  options 
)

Definition at line 801 of file databasebuilder.py.

801 def fetch_constructor_data(self, options):
802 window_interface = self._database.GetInterface('Window')
803 for attr in window_interface.attributes:
804 type = attr.type.id
805 if not type.endswith('Constructor'):
806 continue
807 type = re.sub('(Constructor)+$', '', type)
808 # TODO(antonm): Ideally we'd like to have pristine copy of WebKit IDLs and fetch
809 # this information directly from it. Unfortunately right now database is massaged
810 # a lot so it's difficult to maintain necessary information on Window itself.
811 interface = self._database.GetInterface(type)
812 if 'V8EnabledPerContext' in attr.ext_attrs:
813 interface.ext_attrs['synthesizedV8EnabledPerContext'] = \
814 attr.ext_attrs['V8EnabledPerContext']
815 if 'V8EnabledAtRuntime' in attr.ext_attrs:
816 interface.ext_attrs['synthesizedV8EnabledAtRuntime'] = \
817 attr.ext_attrs['V8EnabledAtRuntime'] or attr.id
818

◆ fix_displacements()

def scripts.databasebuilder.DatabaseBuilder.fix_displacements (   self,
  source 
)
E.g. In W3C, something is declared on HTMLDocument but in WebKit
its on Document, so we need to mark that something in HTMLDocument
with @WebKit(via=Document). The 'via' attribute specifies the
parent interface that has the declaration.

Definition at line 711 of file databasebuilder.py.

711 def fix_displacements(self, source):
712 """E.g. In W3C, something is declared on HTMLDocument but in WebKit
713 its on Document, so we need to mark that something in HTMLDocument
714 with @WebKit(via=Document). The 'via' attribute specifies the
715 parent interface that has the declaration."""
716
717 for interface in self._database.GetInterfaces():
718 changed = False
719
720 _logger.info('fixing displacements in %s' % interface.id)
721
722 for parent_interface in self._get_parent_interfaces(interface):
723 _logger.info('scanning parent %s of %s' % (parent_interface.id,
724 interface.id))
725
726 def fix_nodes(local_list, parent_list):
727 changed = False
728 parent_signatures_map = self._build_signatures_map(
729 parent_list)
730 for idl_node in local_list:
731 sig = self._sign(idl_node)
732 if sig in parent_signatures_map:
733 parent_member = parent_signatures_map[sig]
734 if (source in parent_member.annotations and
735 source not in idl_node.annotations and
736 _VIA_ANNOTATION_ATTR_NAME not in
737 parent_member.annotations[source]):
738 idl_node.annotations[source] = IDLAnnotation({
739 _VIA_ANNOTATION_ATTR_NAME:
740 parent_interface.id
741 })
742 changed = True
743 return changed
744
745 changed = fix_nodes(interface.constants,
746 parent_interface.constants) or changed
747 changed = fix_nodes(interface.attributes,
748 parent_interface.attributes) or changed
749 changed = fix_nodes(interface.operations,
750 parent_interface.operations) or changed
751 if changed:
752 _logger.info(
753 'fixed displaced declarations in %s' % interface.id)
754

◆ import_idl_files()

def scripts.databasebuilder.DatabaseBuilder.import_idl_files (   self,
  file_paths,
  import_options,
  is_dart_idl 
)

Definition at line 628 of file databasebuilder.py.

628 def import_idl_files(self, file_paths, import_options, is_dart_idl):
629 self._blink_compile_idl_files(file_paths, import_options, is_dart_idl)
630
631 start_time = time.time()
632
633 # Parse the IDL files in serial.
634 for file_path in file_paths:
635 file_path = os.path.normpath(file_path)
636 idl_file = _load_idl_file(self.build, file_path, import_options)
637 _logger.info('Processing %s' % os.path.splitext(
638 os.path.basename(file_path))[0])
639 self._process_idl_file(idl_file, import_options, is_dart_idl)
640
641 end_time = time.time()
642
643 for warning in report_unions_to_any():
644 _logger.warning(warning)
645
646 print('Total %s files %sprocessed in databasebuilder in %s seconds' % \
647 (len(file_paths), '', round((end_time - start_time), 2)))
648
static void round(SkPoint *p)
def report_unions_to_any()
Definition: idlnode.py:20

◆ map_dictionaries()

def scripts.databasebuilder.DatabaseBuilder.map_dictionaries (   self)
Changes the type of operations/constructors arguments from an IDL
dictionary to a Dictionary.  The IDL dictionary is just an enums of
strings which are checked at run-time.

Definition at line 783 of file databasebuilder.py.

783 def map_dictionaries(self):
784 """Changes the type of operations/constructors arguments from an IDL
785 dictionary to a Dictionary. The IDL dictionary is just an enums of
786 strings which are checked at run-time."""
787
788 def dictionary_to_map(type_node):
789 if self._database.HasDictionary(type_node.id):
790 type_node.dictionary = type_node.id
791 type_node.id = 'Dictionary'
792
793 def all_types(node):
794 list(map(dictionary_to_map, node.all(IDLType)))
795
796 for interface in self._database.GetInterfaces():
797 list(map(all_types, interface.all(IDLExtAttrFunctionValue)))
798 list(map(all_types, interface.attributes))
799 list(map(all_types, interface.operations))
800
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition: SkVx.h:680

◆ merge_imported_interfaces()

def scripts.databasebuilder.DatabaseBuilder.merge_imported_interfaces (   self)
Merges all imported interfaces and loads them into the DB.

Definition at line 534 of file databasebuilder.py.

534 def merge_imported_interfaces(self):
535 """Merges all imported interfaces and loads them into the DB."""
536 imported_interfaces = self._imported_interfaces
537
538 # Step 1: Pre process imported interfaces
539 for interface, import_options in imported_interfaces:
540 self._annotate(interface, import_options)
541
542 # Step 2: Add all new interfaces and merge overlapping ones
543 for interface, import_options in imported_interfaces:
544 if not interface.is_supplemental:
545 if self._database.HasInterface(interface.id):
546 old_interface = self._database.GetInterface(interface.id)
547 self._merge_interfaces(old_interface, interface,
548 import_options)
549 else:
550 if import_options.add_new_interfaces:
551 self._database.AddInterface(interface)
552
553 # Step 3: Merge in supplemental interfaces
554 for interface, import_options in imported_interfaces:
555 if interface.is_supplemental:
556 target = interface.id
557 if self._database.HasInterface(target):
558 old_interface = self._database.GetInterface(target)
559 self._merge_interfaces(old_interface, interface,
560 import_options)
561 else:
562 _logger.warning("Supplemental target '%s' not found",
563 target)
564
565 # Step 4: Resolve 'implements' statements
566 for impl_stmt, import_options in self._impl_stmts:
567 self._merge_impl_stmt(impl_stmt, import_options)
568
569 self._impl_stmts = []
570 self._imported_interfaces = []
571

◆ normalize_annotations()

def scripts.databasebuilder.DatabaseBuilder.normalize_annotations (   self,
  sources 
)
Makes the IDLs less verbose by removing annotation attributes
that are identical to the ones defined at the interface level.

Args:
sources -- list of source names to normalize.

Definition at line 755 of file databasebuilder.py.

755 def normalize_annotations(self, sources):
756 """Makes the IDLs less verbose by removing annotation attributes
757 that are identical to the ones defined at the interface level.
758
759 Args:
760 sources -- list of source names to normalize."""
761 for interface in self._database.GetInterfaces():
762 _logger.debug('normalizing annotations for %s' % interface.id)
763 for source in sources:
764 if (source not in interface.annotations or
765 not interface.annotations[source]):
766 continue
767 top_level_annotation = interface.annotations[source]
768
769 def normalize(idl_node):
770 if (source in idl_node.annotations and
771 idl_node.annotations[source]):
772 annotation = idl_node.annotations[source]
773 for name, value in list(annotation.items()):
774 if (name in top_level_annotation and
775 value == top_level_annotation[name]):
776 del annotation[name]
777
778 list(map(normalize, interface.parents))
779 list(map(normalize, interface.constants))
780 list(map(normalize, interface.attributes))
781 list(map(normalize, interface.operations))
782
SIN Vec< N, float > normalize(const Vec< N, float > &v)
Definition: SkVx.h:995

Member Data Documentation

◆ build

scripts.databasebuilder.DatabaseBuilder.build

Definition at line 186 of file databasebuilder.py.

◆ conditionals_met

scripts.databasebuilder.DatabaseBuilder.conditionals_met

Definition at line 183 of file databasebuilder.py.

◆ global_type_defs

scripts.databasebuilder.DatabaseBuilder.global_type_defs

Definition at line 189 of file databasebuilder.py.


The documentation for this class was generated from the following file: