def extract_meta_data(file_paths):
    """Extracts interface name from each IDL file."""
    meta_data_list = []

    for file_path in file_paths:
        if not file_path.endswith('.idl'):
            print 'WARNING: non-IDL file passed: "%s"' % file_path
            continue
        if not os.path.exists(file_path):
            print 'WARNING: file not found: "%s"' % file_path
            continue

        idl_file_contents = get_file_contents(file_path)
        if not should_generate_impl_file_from_idl(idl_file_contents):
            continue

        # Extract interface name from file name
        interface_name = idl_filename_to_interface_name(file_path)

        meta_data = {
            'name': interface_name,
        }
        meta_data_list.append(meta_data)

    return meta_data_list
Example #2
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 extract_meta_data(file_paths):
    """Extracts conditional and interface name from each IDL file."""
    meta_data_list = []

    for file_path in file_paths:
        if not file_path.endswith('.idl'):
            print 'WARNING: non-IDL file passed: "%s"' % file_path
            continue
        if not os.path.exists(file_path):
            print 'WARNING: file not found: "%s"' % file_path
            continue

        idl_file_contents = get_file_contents(file_path)
        if not should_generate_impl_file_from_idl(idl_file_contents):
            continue

        # Extract interface name from file name
        interface_name = idl_filename_to_interface_name(file_path)

        meta_data = {
            'conditional': extract_conditional(idl_file_contents),
            'name': interface_name,
        }
        meta_data_list.append(meta_data)

    return meta_data_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 ((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 record_global_constructors(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)
    interface_name = get_first_interface_name_from_idl(idl_file_contents)

    # An interface property is produced for every non-callback interface
    # that does not have [NoInterfaceObject].
    # http://heycam.github.io/webidl/#es-interfaces
    if (not should_generate_impl_file_from_idl(idl_file_contents)
            or is_non_legacy_callback_interface_from_idl(idl_file_contents)
            or is_interface_mixin_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)
    elif 'Exposed' in extended_attributes:
        # Exposed=env or Exposed=(env1,...) case
        exposed_value = extended_attributes.get('Exposed')
        exposed_global_names = map(str.strip,
                                   exposed_value.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)