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)
    else:
        # Exposed=env or Exposed=(env1,...) case
        exposed_value = extended_attributes.get('Exposed', 'Window')
        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)
コード例 #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].
    # 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
        '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)