Exemple #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),
    }
def generate_constructor(interface, constructor):
    arguments_need_try_catch = any(
        v8_methods.argument_needs_try_catch(argument)
        for argument in constructor.arguments)

    return {
        'arguments': [
            v8_methods.generate_argument(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.is_integer_type),
        'is_constructor':
        True,
        'is_named_constructor':
        False,
        'number_of_required_arguments':
        number_of_required_arguments(constructor),
    }
Exemple #3
0
def constructor_argument(interface, constructor, argument, index):
    idl_type = argument.idl_type
    return {
        'cpp_value':
            v8_methods.cpp_value(interface, constructor, index),
        'has_default': 'Default' in argument.extended_attributes,
        # Dictionary is special-cased, but arrays and sequences shouldn't be
        'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type,
        'idl_type_object': idl_type,
        'index': index,
        'is_optional': argument.is_optional,
        'is_strict_type_checking': False,  # Required for overload resolution
        'name': argument.name,
        'v8_value_to_local_cpp_value':
            v8_methods.v8_value_to_local_cpp_value(argument, index),
    }
Exemple #4
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),
    }
Exemple #5
0
def generate_constructor(interface, constructor):
    arguments_need_try_catch = any(v8_methods.argument_needs_try_catch(argument)
                                   for argument in constructor.arguments)

    return {
        'arguments': [v8_methods.generate_argument(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.is_integer_type),
        'is_constructor': True,
        'is_named_constructor': False,
        'number_of_required_arguments':
            number_of_required_arguments(constructor),
    }