def write_header_and_cpp(self):
        interface = self.interface
        template_contents = self.generate_contents(interface)
        template_contents['conditional_string'] = generate_conditional_string(interface)
        template_contents['header_includes'].add(self.include_for_cpp_class)
        template_contents['header_includes'] = sorted(template_contents['header_includes'])
        template_contents['cpp_includes'] = sorted(template_contents['cpp_includes'])

        header_basename = v8_class_name(interface) + '.h'
        header_file_text = self.header_template.render(template_contents)
        self.write_file(header_basename, header_file_text)

        cpp_basename = v8_class_name(interface) + '.cpp'
        cpp_file_text = self.cpp_template.render(template_contents)
        self.write_file(cpp_basename, cpp_file_text)
Esempio n. 2
0
    def write_header_and_cpp(self):
        interface = self.interface
        template_contents = self.generate_contents(interface)
        template_contents['conditional_string'] = generate_conditional_string(
            interface)
        template_contents['header_includes'].add(self.include_for_cpp_class)
        template_contents['header_includes'] = sorted(
            template_contents['header_includes'])
        template_contents['cpp_includes'] = sorted(includes)

        header_basename = v8_class_name(interface) + '.h'
        header_file_text = self.header_template.render(template_contents)
        self.write_file(header_basename, header_file_text)

        cpp_basename = v8_class_name(interface) + '.cpp'
        cpp_file_text = self.cpp_template.render(template_contents)
        self.write_file(cpp_basename, cpp_file_text)
Esempio n. 3
0
def generate_attribute(interface, attribute):
    idl_type = attribute.idl_type
    extended_attributes = attribute.extended_attributes

    has_custom_getter = has_extended_attribute(attribute, ('Custom', 'CustomGetter'))
    has_custom_setter = not attribute.is_read_only and has_extended_attribute(attribute, ('Custom', 'CustomSetter'))
    contents = {
        'access_control_list': access_control_list(attribute),
        'activity_logging_world_list_for_getter': v8_utilities.activity_logging_world_list(attribute, 'Getter'),  # [ActivityLogging]
        'activity_logging_world_list_for_setter': v8_utilities.activity_logging_world_list(attribute, 'Setter'),  # [ActivityLogging]
        'cached_attribute_validation_method': extended_attributes.get('CachedAttribute'),
        'conditional_string': v8_utilities.generate_conditional_string(attribute),
        'cpp_type': v8_types.cpp_type(idl_type),
        'getter_callback_name': getter_callback_name(interface, attribute),
        'getter_callback_name_for_main_world': getter_callback_name_for_main_world(interface, attribute),
        'has_custom_getter': has_custom_getter,
        'has_custom_setter': has_custom_setter,
        'idl_type': idl_type,
        'is_constructor': is_constructor_attribute(attribute),
        'is_getter_raises_exception': has_extended_attribute(attribute, ('GetterRaisesException', 'RaisesException')),
        'is_keep_alive_for_gc': is_keep_alive_for_gc(attribute),
        'is_nullable': attribute.is_nullable,
        'is_read_only': attribute.is_read_only,
        'is_replaceable': 'Replaceable' in attribute.extended_attributes,
        'is_setter_raises_exception': has_extended_attribute(attribute, ('RaisesException', 'SetterRaisesException')),
        'is_static': attribute.is_static,
        'name': attribute.name,
        'per_context_enabled_function_name': v8_utilities.per_context_enabled_function_name(attribute),  # [PerContextEnabled]
        'property_attributes': property_attributes(attribute),
        'setter_callback_name': setter_callback_name(interface, attribute),
        'setter_callback_name_for_main_world': setter_callback_name_for_main_world(interface, attribute),
        'v8_type': v8_types.v8_type(idl_type),
        'runtime_enabled_function_name': v8_utilities.runtime_enabled_function_name(attribute),  # [RuntimeEnabled]
        'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended_attributes else [''],  # [PerWorldBindings]
        'wrapper_type_info': wrapper_type_info(attribute),
    }
    if is_constructor_attribute(attribute):
        includes.update(v8_types.includes_for_type(idl_type))
        return contents
    if not has_custom_getter:
        generate_getter(interface, attribute, contents)
    if not attribute.is_read_only and not has_custom_setter:
        generate_setter(interface, attribute, contents)

    return contents
Esempio n. 4
0
def generate_attribute_and_includes(attribute):
    idl_type = attribute.data_type
    # FIXME: need to check should_keep_attribute_alive, but for now sufficient
    # to check if primitive.
    should_keep_attribute_alive = not v8_types.primitive_type(idl_type)
    if should_keep_attribute_alive:
        return_v8_value_statement = None  # unused
        includes = v8_types.includes_for_type(idl_type)
        includes.add('bindings/v8/V8HiddenPropertyName.h')
    else:
        cpp_value = 'imp->%s()' % uncapitalize(attribute.name)
        return_v8_value_statement = v8_types.v8_set_return_value(idl_type, cpp_value, callback_info='info')
        includes = []
    contents = {
        'name': attribute.name,
        'conditional_string': generate_conditional_string(attribute),
        'cpp_method_name': cpp_method_name(attribute),
        'cpp_type': v8_types.cpp_type(idl_type, pointer_type='RefPtr'),
        'should_keep_attribute_alive': should_keep_attribute_alive,
        'return_v8_value_statement': return_v8_value_statement,
        'v8_type': v8_types.v8_type(idl_type),
    }
    return contents, includes
Esempio n. 5
0
def generate_attribute(interface, attribute):
    idl_type = attribute.idl_type
    extended_attributes = attribute.extended_attributes

    has_custom_getter = has_extended_attribute(attribute,
                                               ('Custom', 'CustomGetter'))
    has_custom_setter = not attribute.is_read_only and has_extended_attribute(
        attribute, ('Custom', 'CustomSetter'))
    contents = {
        'access_control_list':
        access_control_list(attribute),
        'activity_logging_world_list_for_getter':
        v8_utilities.activity_logging_world_list(
            attribute, 'Getter'),  # [ActivityLogging]
        'activity_logging_world_list_for_setter':
        v8_utilities.activity_logging_world_list(
            attribute, 'Setter'),  # [ActivityLogging]
        'cached_attribute_validation_method':
        extended_attributes.get('CachedAttribute'),
        'conditional_string':
        v8_utilities.generate_conditional_string(attribute),
        'cpp_type':
        v8_types.cpp_type(idl_type),
        'getter_callback_name':
        getter_callback_name(interface, attribute),
        'getter_callback_name_for_main_world':
        getter_callback_name_for_main_world(interface, attribute),
        'has_custom_getter':
        has_custom_getter,
        'has_custom_setter':
        has_custom_setter,
        'idl_type':
        idl_type,
        'is_constructor':
        is_constructor_attribute(attribute),
        'is_getter_raises_exception':
        has_extended_attribute(attribute,
                               ('GetterRaisesException', 'RaisesException')),
        'is_keep_alive_for_gc':
        is_keep_alive_for_gc(attribute),
        'is_nullable':
        attribute.is_nullable,
        'is_read_only':
        attribute.is_read_only,
        'is_replaceable':
        'Replaceable' in attribute.extended_attributes,
        'is_setter_raises_exception':
        has_extended_attribute(attribute,
                               ('RaisesException', 'SetterRaisesException')),
        'is_static':
        attribute.is_static,
        'name':
        attribute.name,
        'per_context_enabled_function_name':
        v8_utilities.per_context_enabled_function_name(
            attribute),  # [PerContextEnabled]
        'property_attributes':
        property_attributes(attribute),
        'setter_callback_name':
        setter_callback_name(interface, attribute),
        'setter_callback_name_for_main_world':
        setter_callback_name_for_main_world(interface, attribute),
        'v8_type':
        v8_types.v8_type(idl_type),
        'runtime_enabled_function_name':
        v8_utilities.runtime_enabled_function_name(
            attribute),  # [RuntimeEnabled]
        'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings'
        in extended_attributes else [''],  # [PerWorldBindings]
        'wrapper_type_info':
        wrapper_type_info(attribute),
    }
    if is_constructor_attribute(attribute):
        includes.update(v8_types.includes_for_type(idl_type))
        return contents
    if not has_custom_getter:
        generate_getter(interface, attribute, contents)
    if not attribute.is_read_only and not has_custom_setter:
        generate_setter(interface, attribute, contents)

    return contents