def main():
    options, filepaths = parse_options()
    ir_map = IdentifierIRMap()
    ir_builder.load_and_register_idl_definitions(filepaths, ir_map)
    idl_compiler = IdlCompiler(ir_map)
    idl_database = idl_compiler.build_database()
    utilities.write_pickle_file(options.output, idl_database)
Example #2
0
def main():
    options, args = parse_options()

    # IDL files are passed in a file, due to OS command line length limits
    idl_files = read_idl_files_list_from_file(options.idl_files_list,
                                              is_gyp_format=False)

    # There may be other IDL files passed as positional arguments at the end.
    idl_files.extend(args)

    # Compute information for individual files
    # Information is stored in global variables interfaces_info and
    # partial_interface_files.
    info_collector = InterfaceInfoCollector(options.root_directory,
                                            options.extended_attributes,
                                            options.cache_directory)
    for idl_filename in idl_files:
        is_dependency = False
        if options.dependency_idl_files:
            is_dependency = idl_filename in options.dependency_idl_files
        info_collector.collect_info(idl_filename, is_dependency)

    write_pickle_file(options.interfaces_info_file,
                      info_collector.get_info_as_dict())
    write_pickle_file(options.component_info_file,
                      info_collector.get_component_info_as_dict())
Example #3
0
def main():
    options, _ = parse_options()
    idl_file_names = utilities.read_idl_files_list_from_file(options.idl_list_file)

    parser = blink_idl_parser.BlinkIDLParser()
    collector = Collector(component=options.component, parser=parser)
    collector.collect_from_idl_files(idl_file_names)
    utilities.write_pickle_file(options.output, collector.get_collection())
def main():
    _, args = parse_options()
    # args = Input1, Input2, ..., Output
    interfaces_info_filename = args.pop()
    info_individuals = read_pickle_files(args)

    compute_interfaces_info_overall(info_individuals)
    write_pickle_file(interfaces_info_filename, interfaces_info)
def main():
    _, args = parse_options()
    # args = Input1, Input2, ..., Output
    interfaces_info_filename = args.pop()
    info_individuals = read_pickle_files(args)

    compute_interfaces_info_overall(info_individuals)
    write_pickle_file(interfaces_info_filename, interfaces_info)
def main():
    options, args = parse_options()
    # args = Input1, Input2, ..., Output
    interfaces_info_filename = args.pop()
    info_individuals = read_interfaces_info(args)

    compute_interfaces_info_overall(info_individuals)
    write_pickle_file(interfaces_info_filename, interfaces_info,
                      options.write_file_only_if_changed)
def main():
    options, args = parse_options()
    # args = Input1, Input2, ..., Output
    interfaces_info_filename = args.pop()
    info_individuals = read_interfaces_info(args)

    compute_interfaces_info_overall(info_individuals)
    write_pickle_file(interfaces_info_filename,
                      interfaces_info,
                      options.write_file_only_if_changed)
def main():
    options, filepaths = parse_options()
    ir_map = IdentifierIRMap()
    ref_to_idl_type_factory = RefByIdFactory()
    ref_to_idl_def_factory = RefByIdFactory()
    load_and_register_idl_definitions(filepaths, ir_map.register,
                                      ref_to_idl_type_factory.create,
                                      ref_to_idl_def_factory.create)
    idl_compiler = IdlCompiler(ir_map)
    idl_database = idl_compiler.build_database()
    utilities.write_pickle_file(options.output, idl_database)
def main():
    options, filepaths = parse_options()

    # Incomplete IDL compiler produces a lot of errors, which break trybots.
    # So, we ignore all the errors for the time being.
    # TODO(bindings-team): Replace |report_error| with sys.exit once IDL
    # compiler completes.
    report_error = lambda message: None

    database = web_idl.build_database(filepaths=filepaths,
                                      report_error=report_error)

    utilities.write_pickle_file(options.output, database)
Example #10
0
def main():
    options, args = parse_options()

    # Static IDL files are passed in a file (generated at GYP time), due to OS
    # command line length limits
    with open(options.idl_files_list) as idl_files_list:
        idl_files = [line.rstrip("\n") for line in idl_files_list]
    # Generated IDL files are passed at the command line, since these are in the
    # build directory, which is determined at build time, not GYP time, so these
    # cannot be included in the file listing static files
    idl_files.extend(args)

    compute_interfaces_info(idl_files)
    write_pickle_file(options.interfaces_info_file, interfaces_info, options.write_file_only_if_changed)
def main():
    options, args = parse_options()
    # args = Input1, Input2, ..., Output
    output_global_objects_filename = args.pop()
    interface_name_global_names = dict_union(
        existing_interface_name_global_names for existing_interface_name_global_names in read_pickle_files(args)
    )

    # Input IDL files are passed in a file, due to OS command line length
    # limits. This is generated at GYP time, which is ok b/c files are static.
    idl_files = read_file_to_list(options.idl_files_list)
    interface_name_global_names.update(idl_files_to_interface_name_global_names(idl_files))

    write_pickle_file(output_global_objects_filename, interface_name_global_names, options.write_file_only_if_changed)
def main():
    options, args = parse_options()

    # Static IDL files are passed in a file (generated at GYP time), due to OS
    # command line length limits
    with open(options.idl_files_list) as idl_files_list:
        idl_files = [line.rstrip('\n') for line in idl_files_list]
    # Generated IDL files are passed at the command line, since these are in the
    # build directory, which is determined at build time, not GYP time, so these
    # cannot be included in the file listing static files
    idl_files.extend(args)

    compute_interfaces_info(idl_files)
    write_pickle_file(options.interfaces_info_file, interfaces_info,
                      options.write_file_only_if_changed)
def main():
    options, args = parse_options()
    output_global_objects_filename = args.pop()
    interface_name_global_names = dict_union(
        existing_interface_name_global_names
        for existing_interface_name_global_names in read_pickle_files(
            options.global_objects_component_files))

    # File paths of input IDL files are passed in a file, which is generated at
    # GN time. It is OK because the target IDL files themselves are static.
    idl_files = read_file_to_list(options.idl_files_list)
    interface_name_global_names.update(
        idl_files_to_interface_name_global_names(idl_files))

    write_pickle_file(output_global_objects_filename,
                      interface_name_global_names)
def main():
    options, args = parse_options()
    output_global_objects_filename = args.pop()
    interface_name_global_names = dict_union(
        existing_interface_name_global_names
        for existing_interface_name_global_names in read_pickle_files(
            options.global_objects_component_files))

    # Input IDL files are passed in a file, due to OS command line length
    # limits. This is generated at GYP time, which is ok b/c files are static.
    idl_files = read_file_to_list(options.idl_files_list)
    interface_name_global_names.update(
        idl_files_to_interface_name_global_names(idl_files))

    write_pickle_file(output_global_objects_filename,
                      interface_name_global_names)
def main():
    options, _ = parse_options()

    # IDL files are passed in a file, due to OS command line length limits
    idl_files = read_idl_files_list_from_file(options.idl_files_list)

    # Compute information for individual files
    # Information is stored in global variables interfaces_info and
    # partial_interface_files.
    info_collector = InterfaceInfoCollector(options.cache_directory)
    for idl_filename in idl_files:
        info_collector.collect_info(idl_filename)

    write_pickle_file(options.interfaces_info_file,
                      info_collector.get_info_as_dict())
    write_pickle_file(options.component_info_file,
                      info_collector.get_component_info_as_dict())
def main():
    options, _ = parse_options()

    # IDL files are passed in a file, due to OS command line length limits
    idl_files = read_idl_files_list_from_file(options.idl_files_list, is_gyp_format=False)

    # Compute information for individual files
    # Information is stored in global variables interfaces_info and
    # partial_interface_files.
    info_collector = InterfaceInfoCollector(options.cache_directory)
    for idl_filename in idl_files:
        info_collector.collect_info(idl_filename)

    write_pickle_file(options.interfaces_info_file,
                      info_collector.get_info_as_dict())
    write_pickle_file(options.component_info_file,
                      info_collector.get_component_info_as_dict())
def main():
    options, args = parse_options()

    # Static IDL files are passed in a file (generated at GYP time), due to OS
    # command line length limits
    idl_files = read_file_to_list(options.idl_files_list)
    # Generated IDL files are passed at the command line, since these are in the
    # build directory, which is determined at build time, not GYP time, so these
    # cannot be included in the file listing static files
    idl_files.extend(args)

    # Compute information for individual files
    # Information is stored in global variables interfaces_info and
    # partial_interface_files.
    for idl_filename in idl_files:
        compute_info_individual(idl_filename, options.component_dir)

    write_pickle_file(options.interfaces_info_file, info_individual(), options.write_file_only_if_changed)
Example #18
0
def main():
    options, args = parse_options()

    # Static IDL files are passed in a file (generated at GYP time), due to OS
    # command line length limits
    idl_files = read_file_to_list(options.idl_files_list)
    # Generated IDL files are passed at the command line, since these are in the
    # build directory, which is determined at build time, not GYP time, so these
    # cannot be included in the file listing static files
    idl_files.extend(args)

    # Compute information for individual files
    # Information is stored in global variables interfaces_info and
    # partial_interface_files.
    for idl_filename in idl_files:
        compute_info_individual(idl_filename, options.component_dir)

    write_pickle_file(options.interfaces_info_file, info_individual(),
                      options.write_file_only_if_changed)
Example #19
0
    def generate_code(self, definitions, interface_name,
                      idl_filename, idl_pickle_filename, only_if_changed):
        """Returns .h/.cpp/.dart code as (header_text, cpp_text, dart_text)."""
        try:
            interface = definitions.interfaces[interface_name]
        except KeyError:
            raise Exception('%s not in IDL definitions' % interface_name)

        # Store other interfaces for introspection
        interfaces.update(definitions.interfaces)

        # Set local type info
        IdlType.set_callback_functions(definitions.callback_functions.keys())
        IdlType.set_enums((enum.name, enum.values)
                          for enum in definitions.enumerations.values())

        # Select appropriate Jinja template and contents function
        if interface.is_callback:
            header_template_filename = 'callback_interface_h.template'
            cpp_template_filename = 'callback_interface_cpp.template'
            dart_template_filename = 'callback_interface_dart.template'
            generate_contents = dart_callback_interface.generate_callback_interface
        else:
            header_template_filename = 'interface_h.template'
            cpp_template_filename = 'interface_cpp.template'
            dart_template_filename = 'interface_dart.template'
            generate_contents = dart_interface.interface_context
        header_template = self.jinja_env.get_template(header_template_filename)
        cpp_template = self.jinja_env.get_template(cpp_template_filename)
        dart_template = self.jinja_env.get_template(dart_template_filename)

        # Generate contents (input parameters for Jinja)
        template_contents = generate_contents(interface)
        template_contents['code_generator'] = module_pyname

        # Add includes for interface itself and any dependencies
        interface_info = self.interfaces_info[interface_name]
        template_contents['header_includes'].add(interface_info['include_path'])
        template_contents['header_includes'] = sorted(template_contents['header_includes'])
        includes.update(interface_info.get('dependencies_include_paths', []))

        template_contents['cpp_includes'] = sorted(includes)

        # If PrivateDart is set, read the custom dart file and add it to our
        # template parameters.
        if 'PrivateDart' in interface.extended_attributes:
          template_contents['private_dart'] = True

        idl_world = {'interface': None, 'callback': None}

        # Load the pickle file for this IDL.
        if os.path.isfile(idl_pickle_filename):
            with open(idl_pickle_filename) as idl_pickle_file:
                idl_global_data = pickle.load(idl_pickle_file)
                idl_pickle_file.close()
            idl_world['interface'] = idl_global_data['interface']
            idl_world['callback'] = idl_global_data['callback']

        if 'interface_name' in template_contents:
            interface_global = {'component_dir': interface_info['component_dir'],
                                'name': template_contents['interface_name'],
                                'parent_interface': template_contents['parent_interface'],
                                'is_active_dom_object': template_contents['is_active_dom_object'],
                                'has_resolver': template_contents['interface_name'],
                                'native_entries': sorted(template_contents['native_entries'], key=lambda(x): x['blink_entry']),
                               }
            idl_world['interface'] = interface_global
        else:
            callback_global = {'name': template_contents['cpp_class']}
            idl_world['callback'] = callback_global

        write_pickle_file(idl_pickle_filename,  idl_world, only_if_changed)

        # Render Jinja templates
        header_text = header_template.render(template_contents)
        cpp_text = cpp_template.render(template_contents)
        dart_text = dart_template.render(template_contents)

        return header_text, cpp_text, dart_text
Example #20
0
from underthesea import word_tokenize
import json
from utilities import write_pickle_file, filter_stopword

if __name__ == "__main__":
    with open('data/intents.json') as file:
        intents = json.load(file)
        bag_of_words = []
        documents = []
        labels = []
        for intent in intents:
            tag = intent['tag']
            for pattern in intent['patterns']:
                temp = word_tokenize(pattern)
                pattern_words = [
                    w.lower().replace('_', ' ') for w in temp
                    if filter_stopword(w.lower()) and w
                ]
                if pattern_words:
                    bag_of_words.extend(pattern_words)
                    documents.append(pattern_words)
                    labels.append(tag)
        write_pickle_file('data/documents.pkl', documents)
        write_pickle_file('data/labels.pkl', labels)
        write_pickle_file('data/words.pkl', sorted(list(set(bag_of_words))))
        write_pickle_file('data/tags.pkl', sorted(list(set(labels))))
        write_pickle_file('data/intents.pkl', intents)
Example #21
0
    def generate_code(self, definitions, interface_name, idl_pickle_filename,
                      only_if_changed):
        """Returns .h/.cpp code as (header_text, cpp_text)."""
        try:
            interface = definitions.interfaces[interface_name]
        except KeyError:
            raise Exception('%s not in IDL definitions' % interface_name)

        # Store other interfaces for introspection
        interfaces.update(definitions.interfaces)

        # Set local type info
        IdlType.set_callback_functions(definitions.callback_functions.keys())
        IdlType.set_enums((enum.name, enum.values)
                          for enum in definitions.enumerations.values())

        # Select appropriate Jinja template and contents function
        if interface.is_callback:
            header_template_filename = 'callback_interface_h.template'
            cpp_template_filename = 'callback_interface_cpp.template'
            generate_contents = dart_callback_interface.generate_callback_interface
        else:
            header_template_filename = 'interface_h.template'
            cpp_template_filename = 'interface_cpp.template'
            generate_contents = dart_interface.generate_interface
        header_template = self.jinja_env.get_template(header_template_filename)
        cpp_template = self.jinja_env.get_template(cpp_template_filename)

        # Generate contents (input parameters for Jinja)
        template_contents = generate_contents(interface)
        template_contents['code_generator'] = module_pyname

        # Add includes for interface itself and any dependencies
        interface_info = self.interfaces_info[interface_name]
        template_contents['header_includes'].add(
            interface_info['include_path'])
        template_contents['header_includes'] = sorted(
            template_contents['header_includes'])
        includes.update(interface_info.get('dependencies_include_paths', []))

        # Remove includes that are not needed for Dart and trigger fatal
        # compile warnings if included. These IDL files need to be
        # imported by Dart to generate the list of events but the
        # associated header files do not contain any code used by Dart.
        includes.discard('core/dom/GlobalEventHandlers.h')
        includes.discard('core/frame/DOMWindowEventHandlers.h')

        template_contents['cpp_includes'] = sorted(includes)

        idl_world = {'interface': None, 'callback': None}

        # Load the pickle file for this IDL.
        if os.path.isfile(idl_pickle_filename):
            with open(idl_pickle_filename) as idl_pickle_file:
                idl_global_data = pickle.load(idl_pickle_file)
                idl_pickle_file.close()
            idl_world['interface'] = idl_global_data['interface']
            idl_world['callback'] = idl_global_data['callback']

        if 'interface_name' in template_contents:
            interface_global = {
                'name': template_contents['interface_name'],
                'parent_interface': template_contents['parent_interface'],
                'is_active_dom_object':
                template_contents['is_active_dom_object'],
                'is_event_target': template_contents['is_event_target'],
                'has_resolver': template_contents['interface_name']
                not in INTERFACES_WITHOUT_RESOLVERS,
                'is_node': template_contents['is_node'],
                'conditional_string': template_contents['conditional_string'],
            }
            idl_world['interface'] = interface_global
        else:
            callback_global = {'name': template_contents['cpp_class']}
            idl_world['callback'] = callback_global

        write_pickle_file(idl_pickle_filename, idl_world, only_if_changed)

        # Render Jinja templates
        header_text = header_template.render(template_contents)
        cpp_text = cpp_template.render(template_contents)
        return header_text, cpp_text
    def generate_code(self, definitions, interface_name, idl_filename,
                      idl_pickle_filename, only_if_changed):
        """Returns .h/.cpp/.dart code as (header_text, cpp_text, dart_text)."""
        try:
            interface = definitions.interfaces[interface_name]
        except KeyError:
            raise Exception('%s not in IDL definitions' % interface_name)

        # Store other interfaces for introspection
        interfaces.update(definitions.interfaces)

        # Set local type info
        IdlType.set_callback_functions(definitions.callback_functions.keys())
        IdlType.set_enums((enum.name, enum.values)
                          for enum in definitions.enumerations.values())

        # Select appropriate Jinja template and contents function
        if interface.is_callback:
            header_template_filename = 'callback_interface_h.template'
            cpp_template_filename = 'callback_interface_cpp.template'
            dart_template_filename = 'callback_interface_dart.template'
            generate_contents = dart_callback_interface.generate_callback_interface
        else:
            header_template_filename = 'interface_h.template'
            cpp_template_filename = 'interface_cpp.template'
            dart_template_filename = 'interface_dart.template'
            generate_contents = dart_interface.interface_context
        header_template = self.jinja_env.get_template(header_template_filename)
        cpp_template = self.jinja_env.get_template(cpp_template_filename)
        dart_template = self.jinja_env.get_template(dart_template_filename)

        # Generate contents (input parameters for Jinja)
        template_contents = generate_contents(interface)
        template_contents['code_generator'] = module_pyname

        # Add includes for interface itself and any dependencies
        interface_info = self.interfaces_info[interface_name]
        template_contents['header_includes'].add(
            interface_info['include_path'])
        template_contents['header_includes'] = sorted(
            template_contents['header_includes'])
        includes.update(interface_info.get('dependencies_include_paths', []))

        template_contents['cpp_includes'] = sorted(includes)

        # If PrivateDart is set, read the custom dart file and add it to our
        # template parameters.
        if 'PrivateDart' in interface.extended_attributes:
            template_contents['private_dart'] = True

        idl_world = {'interface': None, 'callback': None}

        # Load the pickle file for this IDL.
        if os.path.isfile(idl_pickle_filename):
            with open(idl_pickle_filename) as idl_pickle_file:
                idl_global_data = pickle.load(idl_pickle_file)
                idl_pickle_file.close()
            idl_world['interface'] = idl_global_data['interface']
            idl_world['callback'] = idl_global_data['callback']

        if 'interface_name' in template_contents:
            interface_global = {
                'component_dir':
                interface_info['component_dir'],
                'name':
                template_contents['interface_name'],
                'parent_interface':
                template_contents['parent_interface'],
                'has_resolver':
                template_contents['interface_name'],
                'native_entries':
                sorted(template_contents['native_entries'],
                       key=lambda (x): x['blink_entry']),
            }
            idl_world['interface'] = interface_global
        else:
            callback_global = {'name': template_contents['cpp_class']}
            idl_world['callback'] = callback_global

        write_pickle_file(idl_pickle_filename, idl_world, only_if_changed)

        # Render Jinja templates
        header_text = header_template.render(template_contents)
        cpp_text = cpp_template.render(template_contents)
        dart_text = dart_template.render(template_contents)

        return header_text, cpp_text, dart_text
Example #23
0
    def generate_code(self, definitions, interface_name, idl_pickle_filename,
                      only_if_changed):
        """Returns .h/.cpp code as (header_text, cpp_text)."""
        try:
            interface = definitions.interfaces[interface_name]
        except KeyError:
            raise Exception('%s not in IDL definitions' % interface_name)

        # Store other interfaces for introspection
        interfaces.update(definitions.interfaces)

        # Set local type info
        IdlType.set_callback_functions(definitions.callback_functions.keys())
        IdlType.set_enums((enum.name, enum.values)
                          for enum in definitions.enumerations.values())

        # Select appropriate Jinja template and contents function
        if interface.is_callback:
            header_template_filename = 'callback_interface_h.template'
            cpp_template_filename = 'callback_interface_cpp.template'
            generate_contents = dart_callback_interface.generate_callback_interface
        else:
            header_template_filename = 'interface_h.template'
            cpp_template_filename = 'interface_cpp.template'
            generate_contents = dart_interface.generate_interface
        header_template = self.jinja_env.get_template(header_template_filename)
        cpp_template = self.jinja_env.get_template(cpp_template_filename)

        # Generate contents (input parameters for Jinja)
        template_contents = generate_contents(interface)
        template_contents['code_generator'] = module_pyname

        # Add includes for interface itself and any dependencies
        interface_info = self.interfaces_info[interface_name]
        template_contents['header_includes'].add(interface_info['include_path'])
        template_contents['header_includes'] = sorted(template_contents['header_includes'])
        includes.update(interface_info.get('dependencies_include_paths', []))

        # Remove includes that are not needed for Dart and trigger fatal
        # compile warnings if included. These IDL files need to be
        # imported by Dart to generate the list of events but the
        # associated header files do not contain any code used by Dart.
        includes.discard('core/dom/GlobalEventHandlers.h')
        includes.discard('core/frame/DOMWindowEventHandlers.h')

        template_contents['cpp_includes'] = sorted(includes)

        idl_world = {'interface': None, 'callback': None}

        # Load the pickle file for this IDL.
        if os.path.isfile(idl_pickle_filename):
            with open(idl_pickle_filename) as idl_pickle_file:
                idl_global_data = pickle.load(idl_pickle_file)
                idl_pickle_file.close()
            idl_world['interface'] = idl_global_data['interface']
            idl_world['callback'] = idl_global_data['callback']

        if 'interface_name' in template_contents:
            interface_global = {'name': template_contents['interface_name'],
                                'parent_interface': template_contents['parent_interface'],
                                'is_active_dom_object': template_contents['is_active_dom_object'],
                                'is_event_target': template_contents['is_event_target'],
                                'has_resolver': template_contents['interface_name'] not in INTERFACES_WITHOUT_RESOLVERS,
                                'is_node': template_contents['is_node'],
                                'conditional_string': template_contents['conditional_string'],
                               }
            idl_world['interface'] = interface_global
        else:
            callback_global = {'name': template_contents['cpp_class']}
            idl_world['callback'] = callback_global

        write_pickle_file(idl_pickle_filename,  idl_world, only_if_changed)

        # Render Jinja templates
        header_text = header_template.render(template_contents)
        cpp_text = cpp_template.render(template_contents)
        return header_text, cpp_text