Esempio n. 1
0
def member_context(member, interfaces_info):
    interface_info = interfaces_info.get(member.name, None)
    _update_includes_and_forward_decls(member, interface_info)
    if member.is_nullable:
        member = member.inner_type
    return {
        'cpp_name':
        v8_utilities.uncapitalize(member.name),
        'cpp_type':
        member.cpp_type_args(used_in_cpp_sequence=True),
        'cpp_local_type':
        member.cpp_type,
        'cpp_value_to_v8_value':
        member.cpp_value_to_v8_value(cpp_value='impl.getAs%s()' % member.name,
                                     isolate='isolate',
                                     creation_context='creationContext'),
        'enum_values':
        member.enum_values,
        'is_array_buffer_or_view_type':
        member.is_array_buffer_or_view,
        'is_traceable':
        member.is_traceable,
        'rvalue_cpp_type':
        member.cpp_type_args(used_as_rvalue_type=True),
        'specific_type_enum':
        'SpecificType' + member.name,
        'type_name':
        member.name,
        'v8_value_to_local_cpp_value':
        member.v8_value_to_local_cpp_value({},
                                           'v8Value',
                                           'cppValue',
                                           isolate='isolate',
                                           use_exception_state=True)
    }
Esempio n. 2
0
def member_context(member, interfaces_info):
    cpp_includes.update(member.includes_for_type)
    interface_info = interfaces_info.get(member.name, None)
    if interface_info:
        cpp_includes.update(
            interface_info.get('dependencies_include_paths', []))
        header_forward_decls.add(member.implemented_as)
    return {
        'cpp_name':
        v8_utilities.uncapitalize(member.name),
        'cpp_type':
        member.cpp_type_args(used_in_cpp_sequence=True),
        'cpp_local_type':
        member.cpp_type,
        'cpp_value_to_v8_value':
        member.cpp_value_to_v8_value(cpp_value='impl.getAs%s()' % member.name,
                                     isolate='isolate',
                                     creation_context='creationContext'),
        'is_traceable':
        member.is_traceable,
        'rvalue_cpp_type':
        member.cpp_type_args(used_as_rvalue_type=True),
        'specific_type_enum':
        'SpecificType' + member.name,
        'type_name':
        member.name,
        'v8_value_to_local_cpp_value':
        member.v8_value_to_local_cpp_value(
            {}, 'v8Value', 'cppValue', needs_exception_state_for_string=True),
    }
Esempio n. 3
0
def getter_base_name(interface, attribute, arguments):
    extended_attributes = attribute.extended_attributes

    if 'Reflect' not in extended_attributes:
        name = cpp_name(attribute)
        return name if 'ImplementedAs' in extended_attributes \
            else uncapitalize(name)

    content_attribute_name = (extended_attributes['Reflect']
                              or attribute.name.lower())
    if content_attribute_name in ['class', 'id', 'name']:
        # Special-case for performance optimization.
        return 'Get%sAttribute' % content_attribute_name.capitalize()

    arguments.append(scoped_content_attribute_name(interface, attribute))

    base_idl_type = attribute.idl_type.base_type
    if base_idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES:
        return CONTENT_ATTRIBUTE_GETTER_NAMES[base_idl_type]
    if 'URL' in attribute.extended_attributes:
        return 'GetURLAttribute'
    idl_type = attribute.idl_type
    if idl_type.is_frozen_array:
        return 'Get%sArrayAttribute' % idl_type.element_type
    return 'FastGetAttribute'
Esempio n. 4
0
def setter_base_name(interface, attribute, arguments):
    if 'ImplementedInPrivateScript' in attribute.extended_attributes:
        return '%sAttributeSetter' % uncapitalize(cpp_name(attribute))

    if 'Reflect' not in attribute.extended_attributes:
        return 'set%s' % capitalize(cpp_name(attribute))
    arguments.append(scoped_content_attribute_name(interface, attribute))

    base_idl_type = attribute.idl_type.base_type
    if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES:
        return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type]
    return 'setAttribute'
Esempio n. 5
0
def setter_base_name(interface, attribute, arguments):
    if "ImplementedInPrivateScript" in attribute.extended_attributes:
        return "%sAttributeSetter" % uncapitalize(cpp_name(attribute))

    if "Reflect" not in attribute.extended_attributes:
        return "set%s" % capitalize(cpp_name(attribute))
    arguments.append(scoped_content_attribute_name(interface, attribute))

    base_idl_type = attribute.idl_type.base_type
    if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES:
        return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type]
    return "setAttribute"
Esempio n. 6
0
def getter_base_name(interface, attribute, arguments):
    extended_attributes = attribute.extended_attributes

    if "ImplementedInPrivateScript" in extended_attributes:
        return "%sAttributeGetter" % uncapitalize(cpp_name(attribute))

    if "Reflect" not in extended_attributes:
        return uncapitalize(cpp_name(attribute))

    content_attribute_name = extended_attributes["Reflect"] or attribute.name.lower()
    if content_attribute_name in ["class", "id", "name"]:
        # Special-case for performance optimization.
        return "get%sAttribute" % content_attribute_name.capitalize()

    arguments.append(scoped_content_attribute_name(interface, attribute))

    base_idl_type = attribute.idl_type.base_type
    if base_idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES:
        return CONTENT_ATTRIBUTE_GETTER_NAMES[base_idl_type]
    if "URL" in attribute.extended_attributes:
        return "getURLAttribute"
    return "fastGetAttribute"
Esempio n. 7
0
def getter_base_name(interface, attribute, arguments):
    extended_attributes = attribute.extended_attributes

    if 'ImplementedInPrivateScript' in extended_attributes:
        return '%sAttributeGetter' % uncapitalize(cpp_name(attribute))

    if 'Reflect' not in extended_attributes:
        return uncapitalize(cpp_name(attribute))

    content_attribute_name = extended_attributes['Reflect'] or attribute.name.lower()
    if content_attribute_name in ['class', 'id', 'name']:
        # Special-case for performance optimization.
        return 'get%sAttribute' % content_attribute_name.capitalize()

    arguments.append(scoped_content_attribute_name(interface, attribute))

    base_idl_type = attribute.idl_type.base_type
    if base_idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES:
        return CONTENT_ATTRIBUTE_GETTER_NAMES[base_idl_type]
    if 'URL' in attribute.extended_attributes:
        return 'getURLAttribute'
    return 'fastGetAttribute'
Esempio n. 8
0
def getter_base_name(interface, attribute, arguments):
    extended_attributes = attribute.extended_attributes

    if 'ImplementedInPrivateScript' in extended_attributes:
        return '%sAttributeGetter' % uncapitalize(cpp_name(attribute))

    if 'Reflect' not in extended_attributes:
        return uncapitalize(cpp_name(attribute))

    content_attribute_name = extended_attributes['Reflect'] or attribute.name.lower()
    if content_attribute_name in ['class', 'id', 'name']:
        # Special-case for performance optimization.
        return 'get%sAttribute' % content_attribute_name.capitalize()

    arguments.append(scoped_content_attribute_name(interface, attribute))

    base_idl_type = attribute.idl_type.base_type
    if base_idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES:
        return CONTENT_ATTRIBUTE_GETTER_NAMES[base_idl_type]
    if 'URL' in attribute.extended_attributes:
        return 'getURLAttribute'
    return 'fastGetAttribute'
def get_install_functions(interfaces, feature_names):
    """Construct a list of V8 bindings installation functions for each feature
    on each interface.

    interfaces is a list of ConditionalInterfaceInfo tuples
    feature_names is a list of strings, containing names of features which can
        be installed on those interfaces.
    """
    return [{
        "condition": 'OriginTrials::%sEnabled' % uncapitalize(feature_name),
        "name": feature_name,
        "install_method": "install%s" % feature_name,
        "v8_class": interface_info.v8_class,
        "v8_class_or_partial": interface_info.v8_class_or_partial
    } for feature_name in feature_names for interface_info in interfaces]
def get_install_functions(interfaces, feature_names):
    """Construct a list of V8 bindings installation functions for each feature
    on each interface.

    interfaces is a list of OriginTrialInterfaceInfo tuples
    feature_names is a list of strings, containing names of features which can
        be installed on those interfaces.
    """
    return [{
        'condition': 'OriginTrials::%sEnabled' % uncapitalize(feature_name),
        'name': feature_name,
        'install_method': 'install%s' % feature_name,
        'interface_is_global': interface_info.is_global,
        'v8_class': interface_info.v8_class,
        'v8_class_or_partial': interface_info.v8_class_or_partial
    } for feature_name in feature_names for interface_info in interfaces]
def get_install_functions(interfaces, feature_names):
    """Construct a list of V8 bindings installation functions for each feature
    on each interface.

    interfaces is a list of ConditionalInterfaceInfo tuples
    feature_names is a list of strings, containing names of features which can
        be installed on those interfaces.
    """
    return [
        {"condition": 'OriginTrials::%sEnabled' % uncapitalize(feature_name),
         "name": feature_name,
         "install_method": "install%s" % feature_name,
         "interface_is_global": interface_info.is_global,
         "v8_class": interface_info.v8_class,
         "v8_class_or_partial": interface_info.v8_class_or_partial}
        for feature_name in feature_names
        for interface_info in interfaces]
Esempio n. 12
0
def getter_base_name(interface, attribute, arguments):
    extended_attributes = attribute.extended_attributes

    return uncapitalize(cpp_name(attribute))

    content_attribute_name = attribute.name.lower()
    if content_attribute_name in ['class', 'id']:
        # Special-case for performance optimization.
        return 'get%sAttribute' % content_attribute_name.capitalize()

    arguments.append(scoped_content_attribute_name(interface, attribute))

    base_idl_type = attribute.idl_type.base_type
    if base_idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES:
        return CONTENT_ATTRIBUTE_GETTER_NAMES[base_idl_type]
    if 'URL' in attribute.extended_attributes:
        return 'getURLAttribute'
    return 'getAttribute'
def member_context(member, interfaces_info):
    interface_info = interfaces_info.get(member.name, None)
    _update_includes_and_forward_decls(member, interface_info)
    if member.is_nullable:
        member = member.inner_type
    return {
        'cpp_name': v8_utilities.uncapitalize(member.name),
        'cpp_type': member.cpp_type_args(used_in_cpp_sequence=True),
        'cpp_local_type': member.cpp_type,
        'cpp_value_to_v8_value': member.cpp_value_to_v8_value(
            cpp_value='impl.getAs%s()' % member.name, isolate='isolate',
            creation_context='creationContext'),
        'enum_values': member.enum_values,
        'is_traceable': member.is_traceable,
        'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True),
        'specific_type_enum': 'SpecificType' + member.name,
        'type_name': member.name,
        'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value(
            {}, 'v8Value', 'cppValue', isolate='isolate',
            use_exception_state=True, restricted_float=True),
    }
Esempio n. 14
0
def member_context(member, info_provider):
    _update_includes_and_forward_decls(member, info_provider)
    if member.is_nullable:
        member = member.inner_type
    return {
        'cpp_name': v8_utilities.uncapitalize(member.name),
        'cpp_type': member.cpp_type_args(used_in_cpp_sequence=True),
        'cpp_local_type': member.cpp_type,
        'cpp_value_to_v8_value': member.cpp_value_to_v8_value(
            cpp_value='impl.getAs%s()' % member.name, isolate='isolate',
            creation_context='creationContext'),
        'enum_values': member.enum_values,
        'is_array_buffer_or_view_type': member.is_array_buffer_or_view,
        'is_array_buffer_view_or_typed_array': member.is_array_buffer_view_or_typed_array,
        'is_traceable': member.is_traceable,
        'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True),
        'specific_type_enum': 'SpecificType' + member.name,
        'type_name': member.name,
        'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value(
            {}, 'v8Value', 'cppValue', isolate='isolate',
            use_exception_state=True)
    }
Esempio n. 15
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. 16
0
def member_context(member, interfaces_info):
    cpp_includes.update(member.includes_for_type)
    interface_info = interfaces_info.get(member.name, None)
    if interface_info:
        cpp_includes.update(interface_info.get('dependencies_include_paths', []))
        header_forward_decls.add(member.implemented_as)
    if member.is_nullable:
        member = member.inner_type
    return {
        'cpp_name': v8_utilities.uncapitalize(member.name),
        'cpp_type': member.cpp_type_args(used_in_cpp_sequence=True),
        'cpp_local_type': member.cpp_type,
        'cpp_value_to_v8_value': member.cpp_value_to_v8_value(
            cpp_value='impl.getAs%s()' % member.name, isolate='isolate',
            creation_context='creationContext'),
        'is_traceable': member.is_traceable,
        'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True),
        'specific_type_enum': 'SpecificType' + member.name,
        'type_name': member.name,
        'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value(
            {}, 'v8Value', 'cppValue', isolate='isolate',
            needs_exception_state_for_string=True),
    }
Esempio n. 17
0
def member_context(member, interfaces_info):
    cpp_includes.update(member.includes_for_type())
    interface_info = interfaces_info.get(member.name, None)
    if interface_info:
        cpp_includes.update(interface_info.get("dependencies_include_paths", []))
        header_forward_decls.add(member.implemented_as)
    if member.is_nullable:
        member = member.inner_type
    return {
        "cpp_name": v8_utilities.uncapitalize(member.name),
        "cpp_type": member.cpp_type_args(used_in_cpp_sequence=True),
        "cpp_local_type": member.cpp_type,
        "cpp_value_to_v8_value": member.cpp_value_to_v8_value(
            cpp_value="impl.getAs%s()" % member.name, isolate="isolate", creation_context="creationContext"
        ),
        "enum_values": member.enum_values,
        "is_traceable": member.is_traceable,
        "rvalue_cpp_type": member.cpp_type_args(used_as_rvalue_type=True),
        "specific_type_enum": "SpecificType" + member.name,
        "type_name": member.name,
        "v8_value_to_local_cpp_value": member.v8_value_to_local_cpp_value(
            {}, "v8Value", "cppValue", isolate="isolate", use_exception_state=True, restricted_float=True
        ),
    }