def includes_for_type(idl_type, extended_attributes=None): idl_type = idl_type.preprocessed_type extended_attributes = extended_attributes or {} # Simple types base_idl_type = idl_type.base_type if base_idl_type in INCLUDES_FOR_TYPE: return INCLUDES_FOR_TYPE[base_idl_type] if base_idl_type in TYPED_ARRAY_TYPES: return INCLUDES_FOR_TYPE['ArrayBufferView'].union( set(['bindings/%s/v8/%s' % (component_dir[base_idl_type], binding_header_filename(base_idl_type))]) ) if idl_type.is_basic_type: return set(['bindings/core/v8/idl_types.h', 'bindings/core/v8/native_value_traits_impl.h']) if base_idl_type.endswith('ConstructorConstructor'): # FIXME: rename to NamedConstructor # FIXME: replace with a [NamedConstructorAttribute] extended attribute # Ending with 'ConstructorConstructor' indicates a named constructor, # and these do not have header files, as they are part of the generated # bindings for the interface return set() if base_idl_type.endswith('Constructor'): # FIXME: replace with a [ConstructorAttribute] extended attribute base_idl_type = idl_type.constructor_type_name if idl_type.is_custom_callback_function: return set() if idl_type.is_callback_function: component = IdlType.callback_functions[base_idl_type]['component_dir'] return set(['bindings/%s/v8/%s' % (component, binding_header_filename(base_idl_type))]) if base_idl_type not in component_dir: return set() return set(['bindings/%s/v8/%s' % (component_dir[base_idl_type], binding_header_filename(base_idl_type))])
def impl_includes_for_type(idl_type, interfaces_info): includes_for_type = set() idl_type = idl_type.preprocessed_type native_array_element_type = idl_type.native_array_element_type if native_array_element_type: includes_for_type.update(impl_includes_for_type( native_array_element_type, interfaces_info)) includes_for_type.add('platform/wtf/vector.h') base_idl_type = idl_type.base_type if idl_type.is_string_type: includes_for_type.add('platform/wtf/text/wtf_string.h') if idl_type.is_callback_function: component = IdlType.callback_functions[base_idl_type]['component_dir'] return set(['bindings/%s/v8/%s' % (component, binding_header_filename(base_idl_type))]) if base_idl_type in interfaces_info: interface_info = interfaces_info[base_idl_type] includes_for_type.add(interface_info['include_path']) if base_idl_type in INCLUDES_FOR_TYPE: includes_for_type.update(INCLUDES_FOR_TYPE[base_idl_type]) if idl_type.is_array_buffer_view_or_typed_array: return set(['core/typed_arrays/dom_typed_array.h', 'core/typed_arrays/array_buffer_view_helpers.h']) return includes_for_type
def origin_trial_features_info(info_provider, reader, idl_filenames, target_component): """Read a set of IDL files and compile the mapping between interfaces and the conditional features defined on them. Returns a tuple (features_for_type, types_for_feature, includes): - features_for_type is a mapping of interface->feature - types_for_feature is the reverse mapping: feature->interface - includes is a set of header files which need to be included in the generated implementation code. """ features_for_type = defaultdict(set) types_for_feature = defaultdict(set) include_files = set() runtime_features = info_provider.component_info['runtime_enabled_features'] for idl_filename in idl_filenames: interface, includes = read_idl_file(reader, idl_filename) feature_names = get_origin_trial_feature_names_from_interface( interface, runtime_features) # If this interface is a mixin, we don't generate V8 bindings code for # it. if interface.is_mixin: continue # If this interface include another one, # it inherits any conditional features from it. for include in includes: assert include.interface == interface.name mixin, _ = read_idl_file( reader, info_provider.interfaces_info[include.mixin].get('full_path')) feature_names |= get_origin_trial_feature_names_from_interface( mixin, runtime_features) feature_names = list(feature_names) if feature_names: is_global = interface_is_global(interface) if interface.is_partial: # For partial interfaces, we need to generate different # |include_files| if the parent interface is in a different # component. parent_interface_info = \ info_provider.interfaces_info[interface.name] parent_interface, _ = read_idl_file( reader, parent_interface_info.get('full_path')) is_global = is_global or interface_is_global(parent_interface) parent_component = idl_filename_to_component( parent_interface_info.get('full_path')) if interface.is_partial and target_component != parent_component: include_files.add('bindings/%s/v8/%s' % (parent_component, binding_header_filename(interface.name))) include_files.add( 'bindings/%s/v8/%s' % (target_component, binding_header_filename(interface.name + 'Partial'))) else: include_files.add('bindings/%s/v8/%s' % (target_component, binding_header_filename(interface.name))) # If this is a partial interface in the same component as # its parent, then treat it as a non-partial interface. interface.is_partial = False interface_info = OriginTrialInterfaceInfo( interface.name, v8_class_name(interface), v8_class_name_or_partial(interface), is_global) for feature_name in feature_names: features_for_type[interface_info].add(feature_name) types_for_feature[feature_name].add(interface_info) return features_for_type, types_for_feature, include_files
def origin_trial_features_info(info_provider, reader, idl_filenames, target_component): """Read a set of IDL files and compile the mapping between interfaces and the conditional features defined on them. Returns a tuple (features_for_type, types_for_feature, includes): - features_for_type is a mapping of interface->feature - types_for_feature is the reverse mapping: feature->interface - includes is a set of header files which need to be included in the generated implementation code. """ features_for_type = defaultdict(set) types_for_feature = defaultdict(set) includes = set() # Gather interfaces which are implemented by other interfaces. implemented_interfaces = set() for name, interface_info in info_provider.interfaces_info.iteritems(): # Skip special entries such as 'dictionaries' or 'ancestors'. if name.lower() == name: continue implemented_interfaces.update(interface_info.get('implements_interfaces')) for idl_filename in idl_filenames: interface, implements = read_idl_file(reader, idl_filename) feature_names = get_origin_trial_feature_names_from_interface(interface) # If this interface is implemented by other interfaces, we don't generate # V8 bindings code for it. if interface.name in implemented_interfaces: continue # If this interface implements another one, # it inherits any conditional features from it. for implement in implements: assert implement.left_interface == interface.name implemented_interface, _ = read_idl_file( reader, info_provider.interfaces_info[implement.right_interface].get('full_path')) feature_names |= get_origin_trial_feature_names_from_interface(implemented_interface) feature_names = list(feature_names) if feature_names: is_global = interface_is_global(interface) if interface.is_partial: # For partial interfaces, we need to generate different # includes if the parent interface is in a different # component. parent_interface_info = info_provider.interfaces_info[interface.name] parent_interface, _ = read_idl_file( reader, parent_interface_info.get('full_path')) is_global = is_global or interface_is_global(parent_interface) parent_component = idl_filename_to_component( parent_interface_info.get('full_path')) if interface.is_partial and target_component != parent_component: includes.add('bindings/%s/v8/%s' % (parent_component, binding_header_filename(interface.name))) includes.add('bindings/%s/v8/%s' % (target_component, binding_header_filename(interface.name + 'Partial'))) else: includes.add('bindings/%s/v8/%s' % (target_component, binding_header_filename(interface.name))) # If this is a partial interface in the same component as # its parent, then treat it as a non-partial interface. interface.is_partial = False interface_info = OriginTrialInterfaceInfo(interface.name, v8_class_name(interface), v8_class_name_or_partial( interface), is_global) for feature_name in feature_names: features_for_type[interface_info].add(feature_name) types_for_feature[feature_name].add(interface_info) return features_for_type, types_for_feature, includes
def origin_trial_features_info(info_provider, reader, idl_filenames, target_component): """Read a set of IDL files and compile the mapping between interfaces and the conditional features defined on them. Returns a tuple (features_for_type, types_for_feature, includes): - features_for_type is a mapping of interface->feature - types_for_feature is the reverse mapping: feature->interface - includes is a set of header files which need to be included in the generated implementation code. """ features_for_type = defaultdict(set) types_for_feature = defaultdict(set) includes = set() for idl_filename in idl_filenames: interface, implements = read_idl_file(reader, idl_filename) feature_names = get_origin_trial_feature_names_from_interface( interface) # If this interface has NoInterfaceObject then we don't want to add # includes for it because it is a base interface to be implemented # by other interfaces, and does not generate an ECMAScript binding. if 'NoInterfaceObject' in interface.extended_attributes: continue # If this interface implements another one, # it inherits any conditional features from it. for implement in implements: assert implement.left_interface == interface.name implemented_interface, _ = read_idl_file( reader, info_provider.interfaces_info[ implement.right_interface].get('full_path')) feature_names |= get_origin_trial_feature_names_from_interface( implemented_interface) feature_names = list(feature_names) if feature_names: is_global = interface_is_global(interface) if interface.is_partial: # For partial interfaces, we need to generate different # includes if the parent interface is in a different # component. parent_interface_info = info_provider.interfaces_info[ interface.name] parent_interface, _ = read_idl_file( reader, parent_interface_info.get('full_path')) is_global = is_global or interface_is_global(parent_interface) parent_component = idl_filename_to_component( parent_interface_info.get('full_path')) if interface.is_partial and target_component != parent_component: includes.add('bindings/%s/v8/%s' % (parent_component, binding_header_filename(interface.name))) includes.add( 'bindings/%s/v8/%s' % (target_component, binding_header_filename(interface.name + 'Partial'))) else: includes.add('bindings/%s/v8/%s' % (target_component, binding_header_filename(interface.name))) # If this is a partial interface in the same component as # its parent, then treat it as a non-partial interface. interface.is_partial = False interface_info = OriginTrialInterfaceInfo( interface.name, v8_class_name(interface), v8_class_name_or_partial(interface), is_global) for feature_name in feature_names: features_for_type[interface_info].add(feature_name) types_for_feature[feature_name].add(interface_info) return features_for_type, types_for_feature, includes