예제 #1
0
def constructor_context(interface, constructor):
    # [RaisesException=Constructor]
    is_constructor_raises_exception = \
        interface.extended_attributes.get('RaisesException') == 'Constructor'

    return {
        'arguments': [v8_methods.argument_context(interface, constructor, argument, index)
                      for index, argument in enumerate(constructor.arguments)],
        'cpp_type': cpp_template_type(
            cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)),
            cpp_name(interface)),
        'cpp_value': v8_methods.cpp_value(
            interface, constructor, len(constructor.arguments)),
        'has_exception_state':
            is_constructor_raises_exception or
            any(argument for argument in constructor.arguments
                if argument.idl_type.name == 'SerializedScriptValue' or
                   argument.idl_type.v8_conversion_needs_exception_state),
        'is_call_with_document':
            # [ConstructorCallWith=Document]
            has_extended_attribute_value(interface,
                'ConstructorCallWith', 'Document'),
        'is_call_with_execution_context':
            # [ConstructorCallWith=ExecutionContext]
            has_extended_attribute_value(interface,
                'ConstructorCallWith', 'ExecutionContext'),
        'is_constructor': True,
        'is_named_constructor': False,
        'is_raises_exception': is_constructor_raises_exception,
        'number_of_required_arguments':
            number_of_required_arguments(constructor),
    }
예제 #2
0
def argument_context(interface, method, argument, index):
    context = v8_methods.argument_context(interface, method, argument, index)

    extended_attributes = argument.extended_attributes
    idl_type = argument.idl_type
    this_cpp_value = cpp_value(interface, method, index)
    auto_scope = not 'DartNoAutoScope' in extended_attributes
    arg_index = index + 1 if not method.is_static else index
    preprocessed_type = str(idl_type.preprocessed_type)
    local_cpp_type = idl_type.cpp_type_args(argument.extended_attributes,
                                            raw_type=True)
    default_value = argument.default_cpp_value
    if context['has_default']:
        default_value = (argument.default_cpp_value or
                         dart_types.default_cpp_value_for_cpp_type(idl_type))
    dart_type = dart_types.idl_type_to_dart_type(idl_type)
    dart_default_value = dart_types.dart_default_value(dart_type, argument)
    context.update({
        'cpp_type':
        idl_type.cpp_type_args(extended_attributes=extended_attributes,
                               raw_type=True,
                               used_in_cpp_sequence=False),
        'dart_type':
        dart_type,
        'implemented_as':
        idl_type.implemented_as,
        'cpp_value':
        this_cpp_value,
        'local_cpp_type':
        local_cpp_type,
        # FIXME: check that the default value's type is compatible with the argument's
        'default_value':
        default_value,
        'is_named':
        'Named' in extended_attributes,
        'dart_default_value':
        dart_default_value,
        'enum_validation_expression':
        idl_type.enum_validation_expression,
        'preprocessed_type':
        preprocessed_type,
        'is_array_or_sequence_type':
        not not idl_type.native_array_element_type,
        'is_strict_type_checking':
        'DartStrictTypeChecking' in extended_attributes,
        'dart_set_return_value_for_main_world':
        dart_set_return_value(interface.name,
                              method,
                              this_cpp_value,
                              for_main_world=True),
        'dart_set_return_value':
        dart_set_return_value(interface.name, method, this_cpp_value),
        'arg_index':
        arg_index,
        'dart_value_to_local_cpp_value':
        dart_value_to_local_cpp_value(interface,
                                      context['has_type_checking_interface'],
                                      argument, arg_index, auto_scope),
    })
    return context
예제 #3
0
def constructor_context(interface, constructor):
    arguments_need_try_catch = any(
        v8_methods.argument_needs_try_catch(constructor, argument)
        for argument in constructor.arguments)

    # [RaisesException=Constructor]
    is_constructor_raises_exception = \
        interface.extended_attributes.get('RaisesException') == 'Constructor'

    return {
        'arguments': [
            v8_methods.argument_context(interface, constructor, argument,
                                        index)
            for index, argument in enumerate(constructor.arguments)
        ],
        'arguments_need_try_catch':
        arguments_need_try_catch,
        'cpp_type':
        cpp_template_type(cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)),
                          cpp_name(interface)),
        'cpp_value':
        v8_methods.cpp_value(interface, constructor,
                             len(constructor.arguments)),
        'has_exception_state':
        is_constructor_raises_exception
        or any(argument for argument in constructor.arguments
               if argument.idl_type.name == 'SerializedScriptValue'
               or argument.idl_type.may_raise_exception_on_conversion),
        'is_call_with_document':
        # [ConstructorCallWith=Document]
        has_extended_attribute_value(interface, 'ConstructorCallWith',
                                     'Document'),
        'is_call_with_execution_context':
        # [ConstructorCallWith=ExecutionContext]
        has_extended_attribute_value(interface, 'ConstructorCallWith',
                                     'ExecutionContext'),
        'is_constructor':
        True,
        'is_named_constructor':
        False,
        'is_raises_exception':
        is_constructor_raises_exception,
        'number_of_required_arguments':
        number_of_required_arguments(constructor),
    }
예제 #4
0
def argument_context(interface, method, argument, index):
    context = v8_methods.argument_context(interface, method, argument, index)

    extended_attributes = argument.extended_attributes
    idl_type = argument.idl_type
    this_cpp_value = cpp_value(interface, method, index)
    auto_scope = not 'DartNoAutoScope' in extended_attributes
    arg_index = index + 1 if not method.is_static else index
    preprocessed_type = str(idl_type.preprocessed_type)
    local_cpp_type = idl_type.cpp_type_args(argument.extended_attributes, raw_type=True)
    default_value = argument.default_cpp_value
    if context['has_default']:
        default_value = (argument.default_cpp_value or
            dart_types.default_cpp_value_for_cpp_type(idl_type))
    dart_type = dart_types.idl_type_to_dart_type(idl_type)
    dart_default_value = dart_types.dart_default_value(dart_type, argument)
    context.update({
        'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attributes,
                                           raw_type=True,
                                           used_in_cpp_sequence=False),
        'dart_type': dart_type,
        'implemented_as': idl_type.implemented_as,
        'cpp_value': this_cpp_value,
        'local_cpp_type': local_cpp_type,
        # FIXME: check that the default value's type is compatible with the argument's
        'default_value': default_value,
        'is_named': 'Named' in extended_attributes,
        'dart_default_value': dart_default_value,
        'enum_validation_expression': idl_type.enum_validation_expression,
        'preprocessed_type': preprocessed_type,
        'is_array_or_sequence_type': not not idl_type.native_array_element_type,
        'is_strict_type_checking': 'DartStrictTypeChecking' in extended_attributes,
        'dart_set_return_value_for_main_world': dart_set_return_value(interface.name, method,
                                                                      this_cpp_value, for_main_world=True),
        'dart_set_return_value': dart_set_return_value(interface.name, method, this_cpp_value),
        'arg_index': arg_index,
        'dart_value_to_local_cpp_value': dart_value_to_local_cpp_value(interface,
                                                                       context['has_type_checking_interface'],
                                                                       argument, arg_index, auto_scope),
    })
    return context
예제 #5
0
def constructor_context(interface, constructor):
    arguments_need_try_catch = any(v8_methods.argument_needs_try_catch(argument)
                                   for argument in constructor.arguments)

    return {
        'arguments': [v8_methods.argument_context(interface, constructor, argument, index)
                      for index, argument in enumerate(constructor.arguments)],
        'arguments_need_try_catch': arguments_need_try_catch,
        'cpp_type': cpp_template_type(
            cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)),
            cpp_name(interface)),
        'cpp_value': v8_methods.cpp_value(
            interface, constructor, len(constructor.arguments)),
        'has_exception_state':
            # [RaisesException=Constructor]
            interface.extended_attributes.get('RaisesException') == 'Constructor' or
            any(argument for argument in constructor.arguments
                if argument.idl_type.name == 'SerializedScriptValue' or
                   argument.idl_type.may_raise_exception_on_conversion),
        'is_constructor': True,
        'is_named_constructor': False,
        'number_of_required_arguments':
            number_of_required_arguments(constructor),
    }
예제 #6
0
def argument_context(interface, method, argument, index):
    context = v8_methods.argument_context(interface, method, argument, index)

    extended_attributes = argument.extended_attributes
    idl_type = argument.idl_type
    this_cpp_value = cpp_value(interface, method, index)
    use_heap_vector_type = context[
        'is_variadic_wrapper_type'] and idl_type.is_will_be_garbage_collected
    auto_scope = not 'DartNoAutoScope' in extended_attributes
    arg_index = index + 1 if not (method.is_static
                                  or method.is_constructor) else index
    preprocessed_type = str(idl_type.preprocessed_type)
    local_cpp_type = idl_type.cpp_type_args(argument.extended_attributes,
                                            raw_type=True)
    default_value = argument.default_cpp_value
    if context['has_default']:
        default_value = (argument.default_cpp_value or
                         dart_types.default_cpp_value_for_cpp_type(idl_type))
    # FIXMEDART: handle the drift between preprocessed type names in 1847 and
    # 1985 dartium builds in a more generic way.
    if preprocessed_type == 'unrestricted float':
        preprocessed_type = 'float'
    if preprocessed_type == 'unrestricted double':
        preprocessed_type = 'double'
    context.update({
        'cpp_type':
        idl_type.cpp_type_args(extended_attributes=extended_attributes,
                               raw_type=True,
                               used_in_cpp_sequence=use_heap_vector_type),
        'cpp_value':
        this_cpp_value,
        'local_cpp_type':
        local_cpp_type,
        # FIXME: check that the default value's type is compatible with the argument's
        'default_value':
        default_value,
        'enum_validation_expression':
        idl_type.enum_validation_expression,
        'preprocessed_type':
        preprocessed_type,
        'is_array_or_sequence_type':
        not not idl_type.native_array_element_type,
        'is_strict_type_checking':
        'DartStrictTypeChecking' in extended_attributes,
        'vector_type':
        'WillBeHeapVector' if use_heap_vector_type else 'Vector',
        'dart_set_return_value_for_main_world':
        dart_set_return_value(interface.name,
                              method,
                              this_cpp_value,
                              for_main_world=True),
        'dart_set_return_value':
        dart_set_return_value(interface.name, method, this_cpp_value),
        'arg_index':
        arg_index,
        'dart_value_to_local_cpp_value':
        dart_value_to_local_cpp_value(interface,
                                      context['has_type_checking_interface'],
                                      argument, arg_index, auto_scope),
    })
    return context