def record_global_constructors(idl_filename):
    interface_name = idl_filename_to_interface_name(idl_filename)
    full_path = os.path.realpath(idl_filename)
    idl_file_contents = get_file_contents(full_path)
    extended_attributes = get_interface_extended_attributes_from_idl(idl_file_contents)

    # An interface property is produced for every non-callback interface
    # that does not have [NoInterfaceObject].
    # Callback interfaces with constants also have interface properties,
    # but there are none of these in Blink.
    # http://heycam.github.io/webidl/#es-interfaces
    if (is_callback_interface_from_idl(idl_file_contents) or
        'NoInterfaceObject' in extended_attributes):
        return

    # The [Exposed] extended attribute MUST take an identifier list. Each
    # identifier in the list MUST be a global name. An interface or interface
    # member the extended attribute applies to will be exposed only on objects
    # associated with ECMAScript global environments whose global object
    # implements an interface that has a matching global name.
    # FIXME: In spec names are comma-separated, but that makes parsing very
    # difficult (https://www.w3.org/Bugs/Public/show_bug.cgi?id=24959).
    exposed_global_names = extended_attributes.get('Exposed', 'Window').split('&')
    new_constructors_list = generate_global_constructors_list(interface_name, extended_attributes)
    for exposed_global_name in exposed_global_names:
        global_name_to_constructors[exposed_global_name].extend(new_constructors_list)
def record_global_constructors(idl_filename):
    interface_name = idl_filename_to_interface_name(idl_filename)
    full_path = os.path.realpath(idl_filename)
    idl_file_contents = get_file_contents(full_path)
    extended_attributes = get_interface_extended_attributes_from_idl(idl_file_contents)

    # An interface property is produced for every non-callback interface
    # that does not have [NoInterfaceObject].
    # Callback interfaces with constants also have interface properties,
    # but there are none of these in Blink.
    # http://heycam.github.io/webidl/#es-interfaces
    if (is_callback_interface_from_idl(idl_file_contents) or
        'NoInterfaceObject' in extended_attributes):
        return

    exposed_arguments = get_interface_exposed_arguments(idl_file_contents)
    if exposed_arguments:
        # Exposed(Arguments) case
        for argument in exposed_arguments:
            if 'RuntimeEnabled' in extended_attributes:
                raise ValueError('RuntimeEnabled should not be used with Exposed(Arguments)')
            attributes = extended_attributes.copy()
            attributes['RuntimeEnabled'] = argument['runtime_enabled']
            new_constructors_list = generate_global_constructors_list(interface_name, attributes)
            global_name_to_constructors[argument['exposed']].extend(new_constructors_list)
    else:
        # Exposed=env or Exposed=(env1,...) case
        exposed_global_names = extended_attributes.get('Exposed', 'Window').strip('()').split(',')
        new_constructors_list = generate_global_constructors_list(interface_name, extended_attributes)
        for name in exposed_global_names:
            global_name_to_constructors[name].extend(new_constructors_list)
Esempio n. 3
0
def compute_individual_info(idl_filename):
    full_path = os.path.realpath(idl_filename)
    idl_file_contents = get_file_contents(full_path)

    extended_attributes = get_interface_extended_attributes_from_idl(idl_file_contents)
    implemented_as = extended_attributes.get("ImplementedAs")
    this_include_path = include_path(idl_filename, implemented_as)

    # Handle partial interfaces
    partial_interface_name = get_partial_interface_name_from_idl(idl_file_contents)
    if partial_interface_name:
        add_paths_to_partials_dict(partial_interface_name, full_path, this_include_path)
        return

    # If not a partial interface, the basename is the interface name
    interface_name, _ = os.path.splitext(os.path.basename(idl_filename))

    # 'implements' statements can be included in either the file for the
    # implement*ing* interface (lhs of 'implements') or implement*ed* interface
    # (rhs of 'implements'). Store both for now, then merge to implement*ing*
    # interface later.
    left_interfaces, right_interfaces = get_implements_from_idl(idl_file_contents, interface_name)

    interfaces_info[interface_name] = {
        "full_path": full_path,
        "implemented_as": implemented_as,
        "implemented_by_interfaces": left_interfaces,  # private, merged to next
        "implements_interfaces": right_interfaces,
        "include_path": this_include_path,
        # FIXME: temporary private field, while removing old treatement of
        # 'implements': http://crbug.com/360435
        "is_legacy_treat_as_partial_interface": "LegacyTreatAsPartialInterface" in extended_attributes,
        "is_callback_interface": is_callback_interface_from_idl(idl_file_contents),
        # Interfaces that are referenced (used as types) and that we introspect
        # during code generation (beyond interface-level data ([ImplementedAs],
        # is_callback_interface, ancestors, and inherited extended attributes):
        # deep dependencies.
        # These cause rebuilds of referrers, due to the dependency, so these
        # should be minimized; currently only targets of [PutForwards].
        "referenced_interfaces": get_put_forward_interfaces_from_idl(idl_file_contents),
    }

    # Record inheritance information
    inherited_extended_attributes_by_interface[interface_name] = dict(
        (key, value) for key, value in extended_attributes.iteritems() if key in INHERITED_EXTENDED_ATTRIBUTES
    )
    parent = get_parent_interface(idl_file_contents)
    if parent:
        parent_interfaces[interface_name] = parent
def compute_info_individual(idl_filename, component_dir):
    full_path = os.path.realpath(idl_filename)
    idl_file_contents = get_file_contents(full_path)

    extended_attributes = get_interface_extended_attributes_from_idl(idl_file_contents)
    implemented_as = extended_attributes.get('ImplementedAs')
    relative_dir = relative_dir_posix(idl_filename)
    this_include_path = None if 'NoImplHeader' in extended_attributes else include_path(idl_filename, implemented_as)

    # Handle partial interfaces
    partial_interface_name = get_partial_interface_name_from_idl(idl_file_contents)
    if partial_interface_name:
        add_paths_to_partials_dict(partial_interface_name, full_path, this_include_path)
        return

    # If not a partial interface, the basename is the interface name
    interface_name = idl_filename_to_interface_name(idl_filename)

    # 'implements' statements can be included in either the file for the
    # implement*ing* interface (lhs of 'implements') or implement*ed* interface
    # (rhs of 'implements'). Store both for now, then merge to implement*ing*
    # interface later.
    left_interfaces, right_interfaces = get_implements_from_idl(idl_file_contents, interface_name)

    interfaces_info[interface_name] = {
        'component_dir': component_dir,
        'extended_attributes': extended_attributes,
        'full_path': full_path,
        'implemented_as': implemented_as,
        'implemented_by_interfaces': left_interfaces,  # private, merged to next
        'implements_interfaces': right_interfaces,
        'include_path': this_include_path,
        'is_callback_interface': is_callback_interface_from_idl(idl_file_contents),
        'is_dictionary': is_dictionary_from_idl(idl_file_contents),
        # FIXME: temporary private field, while removing old treatement of
        # 'implements': http://crbug.com/360435
        'is_legacy_treat_as_partial_interface': 'LegacyTreatAsPartialInterface' in extended_attributes,
        'parent': get_parent_interface(idl_file_contents),
        # Interfaces that are referenced (used as types) and that we introspect
        # during code generation (beyond interface-level data ([ImplementedAs],
        # is_callback_interface, ancestors, and inherited extended attributes):
        # deep dependencies.
        # These cause rebuilds of referrers, due to the dependency, so these
        # should be minimized; currently only targets of [PutForwards].
        'referenced_interfaces': get_put_forward_interfaces_from_idl(idl_file_contents),
        'relative_dir': relative_dir,
    }
def record_global_constructors(idl_filename):
    interface_name, _ = os.path.splitext(os.path.basename(idl_filename))
    full_path = os.path.realpath(idl_filename)
    idl_file_contents = get_file_contents(full_path)
    extended_attributes = get_interface_extended_attributes_from_idl(idl_file_contents)

    # An interface property is produced for every non-callback interface
    # that does not have [NoInterfaceObject].
    # Callback interfaces with constants also have interface properties,
    # but there are none of these in Blink.
    # http://heycam.github.io/webidl/#es-interfaces
    if (is_callback_interface_from_idl(idl_file_contents) or
        'NoInterfaceObject' in extended_attributes):
        return

    global_contexts = extended_attributes.get('GlobalContext', 'Window').split('&')
    new_constructors_list = generate_global_constructors_list(interface_name, extended_attributes)
    for interface_name in global_contexts:
        global_objects[interface_name]['constructors'].extend(new_constructors_list)
def compute_individual_info(idl_filename):
    full_path = os.path.realpath(idl_filename)
    idl_file_contents = get_file_contents(full_path)

    extended_attributes = get_interface_extended_attributes_from_idl(idl_file_contents)
    implemented_as = extended_attributes.get('ImplementedAs')
    this_include_path = (include_path(idl_filename, implemented_as)
                         if 'ImplementedInBaseClass' not in extended_attributes
                         else None)

    # Handle partial interfaces
    partial_interface_name = get_partial_interface_name_from_idl(idl_file_contents)
    if partial_interface_name:
        add_paths_to_partials_dict(partial_interface_name, full_path, this_include_path)
        return

    # If not a partial interface, the basename is the interface name
    interface_name, _ = os.path.splitext(os.path.basename(idl_filename))

    interfaces_info[interface_name] = {
        'full_path': full_path,
        'implemented_as': implemented_as,
        'implements_interfaces': get_implemented_interfaces_from_idl(idl_file_contents, interface_name),
        'include_path': this_include_path,
        'is_callback_interface': is_callback_interface_from_idl(idl_file_contents),
        # Interfaces that are referenced (used as types) and that we introspect
        # during code generation (beyond interface-level data ([ImplementedAs],
        # is_callback_interface, ancestors, and inherited extended attributes):
        # deep dependencies.
        # These cause rebuilds of referrers, due to the dependency, so these
        # should be minimized; currently only targets of [PutForwards].
        'referenced_interfaces': get_put_forward_interfaces_from_idl(idl_file_contents),
    }

    # Record inheritance information
    inherited_extended_attributes_by_interface[interface_name] = dict(
            (key, value)
            for key, value in extended_attributes.iteritems()
            if key in INHERITED_EXTENDED_ATTRIBUTES)
    parent = get_parent_interface(idl_file_contents)
    if parent:
        parent_interfaces[interface_name] = parent
Esempio n. 7
0
def record_global_constructors(idl_filename):
    interface_name = idl_filename_to_interface_name(idl_filename)
    full_path = os.path.realpath(idl_filename)
    idl_file_contents = get_file_contents(full_path)
    extended_attributes = get_interface_extended_attributes_from_idl(
        idl_file_contents)

    # An interface property is produced for every non-callback interface
    # that does not have [NoInterfaceObject].
    # Callback interfaces with constants also have interface properties,
    # but there are none of these in Blink.
    # http://heycam.github.io/webidl/#es-interfaces
    if ((not should_generate_impl_file_from_idl(idl_file_contents))
            or is_callback_interface_from_idl(idl_file_contents)
            or 'NoInterfaceObject' in extended_attributes):
        return

    exposed_arguments = get_interface_exposed_arguments(idl_file_contents)
    if exposed_arguments:
        # Exposed(Arguments) case
        for argument in exposed_arguments:
            if 'RuntimeEnabled' in extended_attributes:
                raise ValueError(
                    'RuntimeEnabled should not be used with Exposed(Arguments)'
                )
            attributes = extended_attributes.copy()
            attributes['RuntimeEnabled'] = argument['runtime_enabled']
            new_constructors_list = generate_global_constructors_list(
                interface_name, attributes)
            global_name_to_constructors[argument['exposed']].extend(
                new_constructors_list)
    else:
        # Exposed=env or Exposed=(env1,...) case
        exposed_global_names = extended_attributes.get(
            'Exposed', 'Window').strip('()').split(',')
        new_constructors_list = generate_global_constructors_list(
            interface_name, extended_attributes)
        for name in exposed_global_names:
            global_name_to_constructors[name].extend(new_constructors_list)
def compute_individual_info(idl_filename):
    full_path = os.path.realpath(idl_filename)
    idl_file_contents = get_file_contents(full_path)

    extended_attributes = get_interface_extended_attributes_from_idl(
        idl_file_contents)
    implemented_as = extended_attributes.get('ImplementedAs')
    this_include_path = include_path(idl_filename, implemented_as)

    # Handle partial interfaces
    partial_interface_name = get_partial_interface_name_from_idl(
        idl_file_contents)
    if partial_interface_name:
        add_paths_to_partials_dict(partial_interface_name, full_path,
                                   this_include_path)
        return

    # If not a partial interface, the basename is the interface name
    interface_name, _ = os.path.splitext(os.path.basename(idl_filename))

    # 'implements' statements can be included in either the file for the
    # implement*ing* interface (lhs of 'implements') or implement*ed* interface
    # (rhs of 'implements'). Store both for now, then merge to implement*ing*
    # interface later.
    left_interfaces, right_interfaces = get_implements_from_idl(
        idl_file_contents, interface_name)

    interfaces_info[interface_name] = {
        'full_path':
        full_path,
        'implemented_as':
        implemented_as,
        'implemented_by_interfaces':
        left_interfaces,  # private, merged to next
        'implements_interfaces':
        right_interfaces,
        'include_path':
        this_include_path,
        # FIXME: temporary private field, while removing old treatement of
        # 'implements': http://crbug.com/360435
        'is_legacy_treat_as_partial_interface':
        'LegacyTreatAsPartialInterface' in extended_attributes,
        'is_callback_interface':
        is_callback_interface_from_idl(idl_file_contents),
        # Interfaces that are referenced (used as types) and that we introspect
        # during code generation (beyond interface-level data ([ImplementedAs],
        # is_callback_interface, ancestors, and inherited extended attributes):
        # deep dependencies.
        # These cause rebuilds of referrers, due to the dependency, so these
        # should be minimized; currently only targets of [PutForwards].
        'referenced_interfaces':
        get_put_forward_interfaces_from_idl(idl_file_contents),
    }

    # Record inheritance information
    inherited_extended_attributes_by_interface[interface_name] = dict(
        (key, value) for key, value in extended_attributes.iteritems()
        if key in INHERITED_EXTENDED_ATTRIBUTES)
    parent = get_parent_interface(idl_file_contents)
    if parent:
        parent_interfaces[interface_name] = parent
def compute_info_individual(idl_filename, component_dir):
    full_path = os.path.realpath(idl_filename)
    idl_file_contents = get_file_contents(full_path)

    extended_attributes = get_interface_extended_attributes_from_idl(
        idl_file_contents)
    implemented_as = extended_attributes.get('ImplementedAs')
    relative_dir = relative_dir_posix(idl_filename)
    this_include_path = None if 'NoImplHeader' in extended_attributes else include_path(
        idl_filename, implemented_as)

    # Handle partial interfaces
    partial_interface_name = get_partial_interface_name_from_idl(
        idl_file_contents)
    if partial_interface_name:
        add_paths_to_partials_dict(partial_interface_name, full_path,
                                   this_include_path)
        return

    # If not a partial interface, the basename is the interface name
    interface_name = idl_filename_to_interface_name(idl_filename)

    # 'implements' statements can be included in either the file for the
    # implement*ing* interface (lhs of 'implements') or implement*ed* interface
    # (rhs of 'implements'). Store both for now, then merge to implement*ing*
    # interface later.
    left_interfaces, right_interfaces = get_implements_from_idl(
        idl_file_contents, interface_name)

    interfaces_info[interface_name] = {
        'component_dir':
        component_dir,
        'extended_attributes':
        extended_attributes,
        'full_path':
        full_path,
        'implemented_as':
        implemented_as,
        'implemented_by_interfaces':
        left_interfaces,  # private, merged to next
        'implements_interfaces':
        right_interfaces,
        'include_path':
        this_include_path,
        'is_callback_interface':
        is_callback_interface_from_idl(idl_file_contents),
        # FIXME: temporary private field, while removing old treatement of
        # 'implements': http://crbug.com/360435
        'is_legacy_treat_as_partial_interface':
        'LegacyTreatAsPartialInterface' in extended_attributes,
        'parent':
        get_parent_interface(idl_file_contents),
        # Interfaces that are referenced (used as types) and that we introspect
        # during code generation (beyond interface-level data ([ImplementedAs],
        # is_callback_interface, ancestors, and inherited extended attributes):
        # deep dependencies.
        # These cause rebuilds of referrers, due to the dependency, so these
        # should be minimized; currently only targets of [PutForwards].
        'referenced_interfaces':
        get_put_forward_interfaces_from_idl(idl_file_contents),
        'relative_dir':
        relative_dir,
    }