Esempio n. 1
0
def setter_expression(interface, attribute, contents):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(attribute, extended_attributes.get('SetterCallWith'))

    this_setter_base_name = setter_base_name(attribute, arguments)
    setter_name = v8_utilities.scoped_name(interface, attribute, this_setter_base_name)

    if ('ImplementedBy' in extended_attributes and
        not attribute.is_static):
        arguments.append('imp')
    idl_type = attribute.idl_type
    if idl_type == 'EventHandler':
        # FIXME: pass the isolate instead of the isolated world
        isolated_world = 'isolatedWorldForIsolate(info.GetIsolate())'
        getter_name = v8_utilities.scoped_name(interface, attribute, cpp_name(attribute))
        getter_arguments = arguments + [isolated_world]
        contents['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(getter_arguments))
        arguments.extend(['V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)', isolated_world])
    elif v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type):
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append('WTF::getPtr(cppValue)')
    else:
        arguments.append('cppValue')
    if contents['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
def setter_expression(interface, attribute, contents):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(attribute, extended_attributes.get('SetterCallWith'))

    this_setter_base_name = setter_base_name(attribute, arguments)
    setter_name = v8_utilities.scoped_name(interface, attribute, this_setter_base_name)

    if ('ImplementedBy' in extended_attributes and
        not attribute.is_static):
        arguments.append('imp')
    idl_type = attribute.idl_type
    if idl_type == 'EventHandler':
        getter_name = v8_utilities.scoped_name(interface, attribute, cpp_name(attribute))
        contents['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope'] and
            attribute.name == 'onerror'):
            includes.add('bindings/v8/V8ErrorHandler.h')
            arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate())')
        else:
            arguments.append('V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)')
    elif v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type):
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append('WTF::getPtr(cppValue)')
    else:
        arguments.append('cppValue')
    if contents['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 3
0
def setter_expression(interface, attribute, contents):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(attribute, extended_attributes.get('SetterCallWith'))

    this_setter_base_name = setter_base_name(interface, attribute, arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in extended_attributes and
        not attribute.is_static):
        arguments.append('*impl')
    idl_type = attribute.idl_type
    if idl_type.base_type == 'EventHandler':
        getter_name = scoped_name(interface, attribute, cpp_name(attribute))
        contents['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope'] and
            attribute.name == 'onerror'):
            includes.add('bindings/v8/V8ErrorHandler.h')
            arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(v8Value, true, info.GetIsolate())')
        else:
            arguments.append('V8EventListenerList::getEventListener(v8Value, true, ListenerFindOrCreate)')
    elif idl_type.is_interface_type and not idl_type.array_type:
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append('WTF::getPtr(cppValue)')
    else:
        arguments.append('cppValue')
    if contents['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 4
0
def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(
        extended_attributes.get('SetterCallWith')
        or extended_attributes.get('CallWith'))

    forensics = ''

    this_setter_base_name = setter_base_name(interface, attribute, arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in extended_attributes
            and not attribute.is_static):
        arguments.append('*impl')
    idl_type = attribute.idl_type
    if idl_type.base_type == 'EventHandler':
        forensics = 'ScriptState* script_state_F = ' + \
            'ScriptState::ForRelevantRealm(info);\n'
        getter_name = scoped_name(interface, attribute, cpp_name(attribute))
        context['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope']
                and attribute.name == 'onerror'):
            includes.add('bindings/core/v8/V8ErrorHandler.h')
            arguments.append('V8EventListenerHelper::EnsureErrorHandler(' +
                             'ScriptState::ForRelevantRealm(info), v8Value)')
            forensics += 'V8EventListener* el_F = ' + \
                'V8EventListenerHelper::EnsureErrorHandler(' + \
                'script_state_F, v8Value);\n'
        else:
            arguments.append(
                'V8EventListenerHelper::GetEventListener(' +
                'ScriptState::ForRelevantRealm(info), v8Value, true, ' +
                'kListenerFindOrCreate)')
            forensics += 'V8EventListener* el_F = ' + \
                'V8EventListenerHelper::GetEventListener(' + \
                'script_state_F, v8Value, true, kListenerFindOrCreate);\n'
        forensics += '\n  '
        forensics += 'Forensics::DidCallV8SetAttributeEventListener('      + \
            'execution_context_F, interface_name_F, attribute_name_F,' + \
            'cpp_class_name_F, cpp_class_ptr_F, el_F, script_state_F);\n'
    else:
        arguments.append('cppValue')
    if idl_type.is_explicit_nullable:
        arguments.append('isNull')
    if context['is_setter_raises_exception']:
        arguments.append('exceptionState')

    ret_str = forensics + '\n  '
    ret_str += '%s(%s)' % (setter_name, ', '.join(arguments))
    return ret_str
Esempio n. 5
0
def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(
        extended_attributes.get('SetterCallWith')
        or extended_attributes.get('CallWith'))

    this_setter_base_name = setter_base_name(interface, attribute, arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in extended_attributes
            and not attribute.is_static):
        arguments.append('*impl')
    idl_type = attribute.idl_type
    if idl_type.base_type == 'EventHandler':
        handler_type = 'kEventHandler'
        if attribute.name == 'onerror':
            handler_type = 'kOnErrorEventHandler'
        elif attribute.name == 'onbeforeunload':
            handler_type = 'kOnBeforeUnloadEventHandler'
        arguments.append('JSEventHandler::CreateOrNull(' + 'v8_value, ' +
                         'JSEventHandler::HandlerType::' + handler_type + ')')
    elif idl_type.base_type == 'SerializedScriptValue':
        arguments.append('std::move(cpp_value)')
    else:
        arguments.append('cpp_value')
    if idl_type.is_explicit_nullable:
        arguments.append('is_null')
    if context['is_setter_raises_exception']:
        arguments.append('exception_state')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 6
0
def getter_expression(interface, attribute, context):
    arguments = []
    this_getter_base_name = getter_base_name(interface, attribute, arguments)
    getter_name = scoped_name(interface, attribute, this_getter_base_name)

    if 'ImplementedInPrivateScript' in attribute.extended_attributes:
        arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))')
        arguments.append('impl')
        arguments.append('&result')
    arguments.extend(v8_utilities.call_with_arguments(
        attribute.extended_attributes.get('CallWith')))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and
            'ImplementedInPrivateScript' not in attribute.extended_attributes and
            not attribute.is_static):
        arguments.append('*impl')
    if attribute.idl_type.is_explicit_nullable:
        arguments.append('isNull')
    if context['is_getter_raises_exception']:
        arguments.append('exceptionState')
    if attribute.idl_type.use_output_parameter_for_result:
        arguments.append('result')

    expression = '%s(%s)' % (getter_name, ', '.join(arguments))
    # Needed to handle getter expressions returning Type& as the
    # use site for |expression| expects Type*.
    if attribute.idl_type.is_interface_type and len(arguments) == 0:
        return 'WTF::getPtr(%s)' % expression
    return expression
Esempio n. 7
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if (v8_types.is_callback_interface(idl_type) or
            idl_type in ['NodeFilter', 'XPathNSResolver']):
            # FIXME: remove this special case
            return '%s.release()' % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = v8_utilities.call_with_arguments(method)
    if ('ImplementedBy' in method.extended_attributes and
        not method.is_static):
        cpp_arguments.append('imp')
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)
    this_union_arguments = union_arguments(method.idl_type)
    if this_union_arguments:
        cpp_arguments.extend(this_union_arguments)

    if 'RaisesException' in method.extended_attributes:
        cpp_arguments.append('exceptionState')

    cpp_method_name = v8_utilities.scoped_name(interface, method, v8_utilities.cpp_name(method))
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 8
0
def setter_expression(interface, attribute, contents):
    arguments = v8_utilities.call_with_arguments(
        attribute, attribute.extended_attributes.get('SetterCallWith'))

    this_setter_base_name = setter_base_name(attribute, arguments)
    setter_name = v8_utilities.scoped_name(interface, attribute,
                                           this_setter_base_name)

    idl_type = attribute.idl_type
    if idl_type == 'EventHandler':
        # FIXME: pass the isolate instead of the isolated world
        isolated_world = 'isolatedWorldForIsolate(info.GetIsolate())'
        arguments.extend([
            'V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)',
            isolated_world
        ])
        contents['event_handler_getter_expression'] = 'imp->%s(%s)' % (
            cpp_name(attribute), isolated_world)
    elif v8_types.is_interface_type(
            idl_type) and not v8_types.array_type(idl_type):
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append('WTF::getPtr(cppValue)')
    else:
        arguments.append('cppValue')
    if contents['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 9
0
def getter_expression(interface, attribute, context):
    arguments = []
    this_getter_base_name = getter_base_name(interface, attribute, arguments)
    getter_name = scoped_name(interface, attribute, this_getter_base_name)

    if "ImplementedInPrivateScript" in attribute.extended_attributes:
        arguments.append("toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))")
        arguments.append("impl")
        arguments.append("&result")
    arguments.extend(v8_utilities.call_with_arguments(attribute.extended_attributes.get("CallWith")))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if (
        "PartialInterfaceImplementedAs" in attribute.extended_attributes
        and not "ImplementedInPrivateScript" in attribute.extended_attributes
        and not attribute.is_static
    ):
        arguments.append("*impl")
    if attribute.idl_type.is_explicit_nullable:
        arguments.append("isNull")
    if context["is_getter_raises_exception"]:
        arguments.append("exceptionState")
    if attribute.idl_type.use_output_parameter_for_result:
        arguments.append("result")
    return "%s(%s)" % (getter_name, ", ".join(arguments))
Esempio n. 10
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if (v8_types.is_callback_interface(idl_type)
                or idl_type in ['NodeFilter', 'XPathNSResolver']):
            # FIXME: remove this special case
            return '%s.release()' % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = v8_utilities.call_with_arguments(method)
    if ('ImplementedBy' in method.extended_attributes
            and not method.is_static):
        cpp_arguments.append('imp')
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)
    this_union_arguments = union_arguments(method.idl_type)
    if this_union_arguments:
        cpp_arguments.extend(this_union_arguments)

    if 'RaisesException' in method.extended_attributes:
        cpp_arguments.append('exceptionState')

    cpp_method_name = v8_utilities.scoped_name(interface, method,
                                               v8_utilities.cpp_name(method))
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 11
0
def getter_expression(interface, attribute, context):
    arguments = []
    this_getter_base_name = getter_base_name(interface, attribute, arguments)
    getter_name = scoped_name(interface, attribute, this_getter_base_name)

    if 'ImplementedInPrivateScript' in attribute.extended_attributes:
        arguments.append(
            'toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))'
        )
        arguments.append('impl')
        arguments.append('&result')
    arguments.extend(
        v8_utilities.call_with_arguments(
            attribute.extended_attributes.get('CallWith')))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and
            not 'ImplementedInPrivateScript' in attribute.extended_attributes
            and not attribute.is_static):
        arguments.append('*impl')
    if attribute.idl_type.is_explicit_nullable:
        arguments.append('isNull')
    if context['is_getter_raises_exception']:
        arguments.append('exceptionState')
    if attribute.idl_type.use_output_parameter_for_result:
        arguments.append('result')
    return '%s(%s)' % (getter_name, ', '.join(arguments))
Esempio n. 12
0
def getter_expression(interface, attribute, context):
    extra_arguments = []
    this_getter_base_name = getter_base_name(interface, attribute,
                                             extra_arguments)
    getter_name = scoped_name(interface, attribute, this_getter_base_name)

    arguments = v8_utilities.call_with_arguments(
        attribute.extended_attributes.get('GetterCallWith')
        or attribute.extended_attributes.get('CallWith'))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in attribute.extended_attributes
            and not attribute.is_static):
        arguments.append('*impl')
    arguments.extend(extra_arguments)
    if context['is_getter_raises_exception']:
        arguments.append('exception_state')
    if attribute.idl_type.use_output_parameter_for_result:
        arguments.append('result')

    expression = '%s(%s)' % (getter_name, ', '.join(arguments))
    # Needed to handle getter expressions returning Type& as the
    # use site for |expression| expects Type*.
    if (attribute.idl_type.is_interface_type and len(arguments) == 0
            and not attribute.idl_type.is_array_buffer_view_or_typed_array):
        return 'WTF::GetPtr(%s)' % expression
    return expression
Esempio n. 13
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if idl_type.name == "EventListener":
            return argument.name
        if idl_type.is_dictionary:
            return "*%s" % argument.name
        if idl_type.name in ["NodeFilter", "NodeFilterOrNull", "XPathNSResolver", "XPathNSResolverOrNull"]:
            # FIXME: remove this special case
            return "%s.release()" % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []
    if "ImplementedInPrivateScript" in method.extended_attributes:
        cpp_arguments.append("toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())")
        cpp_arguments.append("impl")

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get("ConstructorCallWith")
    else:
        call_with_values = method.extended_attributes.get("CallWith")
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if (
        "PartialInterfaceImplementedAs" in method.extended_attributes
        and not "ImplementedInPrivateScript" in method.extended_attributes
        and not method.is_static
    ):
        cpp_arguments.append("*impl")
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)

    this_union_arguments = method.idl_type and method.idl_type.union_arguments
    if this_union_arguments:
        cpp_arguments.extend([member_argument["cpp_value"] for member_argument in this_union_arguments])

    if "ImplementedInPrivateScript" in method.extended_attributes:
        if method.idl_type.name != "void":
            cpp_arguments.append("&result")
    elif "RaisesException" in method.extended_attributes or (
        method.is_constructor and has_extended_attribute_value(interface, "RaisesException", "Constructor")
    ):
        cpp_arguments.append("exceptionState")

    if method.name == "Constructor":
        base_name = "create"
    elif method.name == "NamedConstructor":
        base_name = "createForJSConstructor"
    elif "ImplementedInPrivateScript" in method.extended_attributes:
        base_name = "%sMethod" % method.name
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return "%s(%s)" % (cpp_method_name, ", ".join(cpp_arguments))
Esempio n. 14
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if idl_type.name == 'EventListener':
            return argument.name
        if idl_type.is_dictionary:
            return '*%s' % argument.name
        if (idl_type.name in ['NodeFilter', 'NodeFilterOrNull',
                              'XPathNSResolver', 'XPathNSResolverOrNull']):
            # FIXME: remove this special case
            return '%s.release()' % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []
    if 'ImplementedInPrivateScript' in method.extended_attributes:
        cpp_arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())')
        cpp_arguments.append('impl')

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get('ConstructorCallWith')
    else:
        call_with_values = method.extended_attributes.get('CallWith')
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in method.extended_attributes and
        not 'ImplementedInPrivateScript' in method.extended_attributes and
        not method.is_static):
        cpp_arguments.append('*impl')
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)

    this_union_arguments = method.idl_type and method.idl_type.union_arguments
    if this_union_arguments:
        cpp_arguments.extend([member_argument['cpp_value']
                              for member_argument in this_union_arguments])

    if 'ImplementedInPrivateScript' in method.extended_attributes:
        if method.idl_type.name != 'void':
            cpp_arguments.append('&result')
    elif ('RaisesException' in method.extended_attributes or
        (method.is_constructor and
         has_extended_attribute_value(interface, 'RaisesException', 'Constructor'))):
        cpp_arguments.append('exceptionState')

    if method.name == 'Constructor':
        base_name = 'create'
    elif method.name == 'NamedConstructor':
        base_name = 'createForJSConstructor'
    elif 'ImplementedInPrivateScript' in method.extended_attributes:
        base_name = '%sMethod' % method.name
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 15
0
def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(
        extended_attributes.get('SetterCallWith')
        or extended_attributes.get('CallWith'))

    this_setter_base_name = setter_base_name(interface, attribute, arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in extended_attributes
            and not 'ImplementedInPrivateScript' in extended_attributes
            and not attribute.is_static):
        arguments.append('*impl')
    idl_type = attribute.idl_type
    if 'ImplementedInPrivateScript' in extended_attributes:
        arguments.append(
            'toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))'
        )
        arguments.append('impl')
        arguments.append('cppValue')
    elif idl_type.base_type == 'EventHandler':
        getter_name = scoped_name(interface, attribute, cpp_name(attribute))
        context['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope']
                and attribute.name == 'onerror'):
            includes.add('bindings/core/v8/V8ErrorHandler.h')
            arguments.append(
                'V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(v8Value, true, ScriptState::current(info.GetIsolate()))'
            )
        else:
            arguments.append(
                'V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate)'
            )
    elif idl_type.is_interface_type:
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append('WTF::getPtr(cppValue)')
    else:
        arguments.append('cppValue')
    if context['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 16
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if idl_type.name == 'EventListener':
            return argument.name
        if (idl_type.name in ['NodeFilter', 'NodeFilterOrNull',
                              'XPathNSResolver', 'XPathNSResolverOrNull']):
            # FIXME: remove this special case
            return '%s.release()' % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []
    if 'ImplementedInPrivateScript' in method.extended_attributes:
        cpp_arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))')
        cpp_arguments.append('impl')

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get('ConstructorCallWith')
    else:
        call_with_values = method.extended_attributes.get('CallWith')
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in method.extended_attributes and
        not 'ImplementedInPrivateScript' in method.extended_attributes and
        not method.is_static):
        cpp_arguments.append('*impl')
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)

    if 'ImplementedInPrivateScript' in method.extended_attributes:
        if method.idl_type.name != 'void':
            cpp_arguments.append('&result')
    elif ('RaisesException' in method.extended_attributes or
        (method.is_constructor and
         has_extended_attribute_value(interface, 'RaisesException', 'Constructor'))):
        cpp_arguments.append('exceptionState')

    # If a method returns an IDL dictionary or union type, the return value is
    # passed as an argument to impl classes.
    idl_type = method.idl_type
    if idl_type and idl_type.use_output_parameter_for_result:
        cpp_arguments.append('result')

    if method.name == 'Constructor':
        base_name = 'create'
    elif method.name == 'NamedConstructor':
        base_name = 'createForJSConstructor'
    elif 'ImplementedInPrivateScript' in method.extended_attributes:
        base_name = '%sMethod' % method.name
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 17
0
def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(
        extended_attributes.get("SetterCallWith") or extended_attributes.get("CallWith")
    )

    this_setter_base_name = setter_base_name(interface, attribute, arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if (
        "PartialInterfaceImplementedAs" in extended_attributes
        and not "ImplementedInPrivateScript" in extended_attributes
        and not attribute.is_static
    ):
        arguments.append("*impl")
    idl_type = attribute.idl_type
    if "ImplementedInPrivateScript" in extended_attributes:
        arguments.append("toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))")
        arguments.append("impl")
        arguments.append("cppValue")
    elif idl_type.base_type == "EventHandler":
        getter_name = scoped_name(interface, attribute, cpp_name(attribute))
        context["event_handler_getter_expression"] = "%s(%s)" % (getter_name, ", ".join(arguments))
        if interface.name in ["Window", "WorkerGlobalScope"] and attribute.name == "onerror":
            includes.add("bindings/core/v8/V8ErrorHandler.h")
            arguments.append(
                "V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(v8Value, true, ScriptState::current(info.GetIsolate()))"
            )
        else:
            arguments.append(
                "V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate)"
            )
    elif idl_type.is_interface_type:
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append("WTF::getPtr(cppValue)")
    else:
        arguments.append("cppValue")
    if context["is_setter_raises_exception"]:
        arguments.append("exceptionState")

    return "%s(%s)" % (setter_name, ", ".join(arguments))
Esempio n. 18
0
def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(
        extended_attributes.get('SetterCallWith') or
        extended_attributes.get('CallWith'))

    this_setter_base_name = setter_base_name(interface, attribute, arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in extended_attributes and
            'ImplementedInPrivateScript' not in extended_attributes and
            not attribute.is_static):
        arguments.append('*impl')
    idl_type = attribute.idl_type
    if 'ImplementedInPrivateScript' in extended_attributes:
        arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))')
        arguments.append('impl')
        arguments.append('cppValue')
    elif idl_type.base_type == 'EventHandler':
        getter_name = scoped_name(interface, attribute, cpp_name(attribute))
        context['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope'] and
                attribute.name == 'onerror'):
            includes.add('bindings/core/v8/V8ErrorHandler.h')
            arguments.append(
                'V8EventListenerHelper::ensureEventListener<V8ErrorHandler>(' +
                'v8Value, true, ScriptState::forReceiverObject(info))')
        else:
            arguments.append(
                'V8EventListenerHelper::getEventListener(' +
                'ScriptState::forReceiverObject(info), v8Value, true, ' +
                'ListenerFindOrCreate)')
    else:
        arguments.append('cppValue')
    if context['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 19
0
def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(
        extended_attributes.get('SetterCallWith') or
        extended_attributes.get('CallWith'))

    this_setter_base_name = setter_base_name(interface, attribute, arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in extended_attributes and
            not attribute.is_static):
        arguments.append('*impl')
    idl_type = attribute.idl_type
    if idl_type.base_type == 'EventHandler':
        getter_name = scoped_name(interface, attribute, cpp_name(attribute))
        context['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope'] and
                attribute.name == 'onerror'):
            includes.add('bindings/core/v8/v8_error_handler.h')
            arguments.append(
                'V8EventListenerHelper::EnsureErrorHandler(' +
                'ScriptState::ForRelevantRealm(info), v8Value)')
        else:
            arguments.append(
                'V8EventListenerHelper::GetEventListener(' +
                'ScriptState::ForRelevantRealm(info), v8Value, true, ' +
                'kListenerFindOrCreate)')
    elif idl_type.base_type == 'SerializedScriptValue':
        arguments.append('std::move(cppValue)')
    else:
        arguments.append('cppValue')
    if idl_type.is_explicit_nullable:
        arguments.append('isNull')
    if context['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 20
0
def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(
        extended_attributes.get('SetterCallWith') or
        extended_attributes.get('CallWith'))

    this_setter_base_name = setter_base_name(interface, attribute, arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in extended_attributes and
            not attribute.is_static):
        arguments.append('*impl')
    idl_type = attribute.idl_type
    if idl_type.base_type == 'EventHandler':
        getter_name = scoped_name(interface, attribute, cpp_name(attribute))
        context['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope'] and
                attribute.name == 'onerror'):
            includes.add('bindings/core/v8/V8ErrorHandler.h')
            arguments.append(
                'V8EventListenerHelper::EnsureErrorHandler(' +
                'ScriptState::ForRelevantRealm(info), v8Value)')
        else:
            arguments.append(
                'V8EventListenerHelper::GetEventListener(' +
                'ScriptState::ForRelevantRealm(info), v8Value, true, ' +
                'kListenerFindOrCreate)')
    else:
        arguments.append('cppValue')
    if idl_type.is_explicit_nullable:
        arguments.append('isNull')
    if context['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 21
0
def getter_expression(interface, attribute, contents):
    arguments = []
    this_getter_base_name = getter_base_name(attribute, arguments)
    getter_name = v8_utilities.scoped_name(interface, attribute, this_getter_base_name)

    arguments.extend(v8_utilities.call_with_arguments(attribute))
    if attribute.is_nullable:
        arguments.append('isNull')
    if contents['is_getter_raises_exception']:
        arguments.append('exceptionState')
    if attribute.idl_type == 'EventHandler':
        arguments.append('isolatedWorldForIsolate(info.GetIsolate())')
    return '%s(%s)' % (getter_name, ', '.join(arguments))
Esempio n. 22
0
def cpp_value(interface, method, number_of_arguments):
    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []
    if 'ImplementedInPrivateScript' in method.extended_attributes:
        cpp_arguments.append(
            'toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))'
        )
        cpp_arguments.append('impl')

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get(
            'ConstructorCallWith')
    else:
        call_with_values = method.extended_attributes.get('CallWith')
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in method.extended_attributes
            and 'ImplementedInPrivateScript' not in method.extended_attributes
            and not method.is_static):
        cpp_arguments.append('*impl')
    cpp_arguments.extend(argument.name for argument in arguments)

    if 'ImplementedInPrivateScript' in method.extended_attributes:
        if method.idl_type.name != 'void':
            cpp_arguments.append('&result')
    elif ('RaisesException' in method.extended_attributes
          or (method.is_constructor and has_extended_attribute_value(
              interface, 'RaisesException', 'Constructor'))):
        cpp_arguments.append('exceptionState')

    # If a method returns an IDL dictionary or union type, the return value is
    # passed as an argument to impl classes.
    idl_type = method.idl_type
    if idl_type and idl_type.use_output_parameter_for_result:
        cpp_arguments.append('result')

    if method.name == 'Constructor':
        base_name = 'create'
    elif method.name == 'NamedConstructor':
        base_name = 'createForJSConstructor'
    elif 'ImplementedInPrivateScript' in method.extended_attributes:
        base_name = '%sMethod' % method.name
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 23
0
def getter_expression(interface, attribute, contents):
    arguments = []
    this_getter_base_name = getter_base_name(attribute, arguments)
    getter_name = v8_utilities.scoped_name(interface, attribute, this_getter_base_name)

    arguments.extend(v8_utilities.call_with_arguments(attribute))
    if ('ImplementedBy' in attribute.extended_attributes and
        not attribute.is_static):
        arguments.append('imp')
    if attribute.is_nullable:
        arguments.append('isNull')
    if contents['is_getter_raises_exception']:
        arguments.append('exceptionState')
    return '%s(%s)' % (getter_name, ', '.join(arguments))
Esempio n. 24
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if idl_type.name == 'EventListener':
            if (interface.name == 'EventTarget'
                    and method.name == 'removeEventListener'):
                # FIXME: remove this special case by moving get() into
                # EventTarget::removeEventListener
                return '%s.get()' % argument.name
            return argument.name
        if (idl_type.is_callback_interface
                or idl_type.name in ['NodeFilter', 'XPathNSResolver']):
            # FIXME: remove this special case
            return '%s.release()' % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []
    if method.is_constructor:
        call_with_values = interface.extended_attributes.get(
            'ConstructorCallWith')
    else:
        call_with_values = method.extended_attributes.get('CallWith')
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in method.extended_attributes
            and not method.is_static):
        cpp_arguments.append('*impl')
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)
    this_union_arguments = method.idl_type and method.idl_type.union_arguments
    if this_union_arguments:
        cpp_arguments.extend(this_union_arguments)

    if ('RaisesException' in method.extended_attributes
            or (method.is_constructor and has_extended_attribute_value(
                interface, 'RaisesException', 'Constructor'))):
        cpp_arguments.append('exceptionState')

    if method.name == 'Constructor':
        base_name = 'create'
    elif method.name == 'NamedConstructor':
        base_name = 'createForJSConstructor'
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 25
0
def cpp_value(interface, method, number_of_arguments):
    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []
    if "ImplementedInPrivateScript" in method.extended_attributes:
        cpp_arguments.append("toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))")
        cpp_arguments.append("impl")

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get("ConstructorCallWith")
    else:
        call_with_values = method.extended_attributes.get("CallWith")
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if (
        "PartialInterfaceImplementedAs" in method.extended_attributes
        and "ImplementedInPrivateScript" not in method.extended_attributes
        and not method.is_static
    ):
        cpp_arguments.append("*impl")
    cpp_arguments.extend(argument.name for argument in arguments)

    if "ImplementedInPrivateScript" in method.extended_attributes:
        if method.idl_type.name != "void":
            cpp_arguments.append("&result")
    elif "RaisesException" in method.extended_attributes or (
        method.is_constructor and has_extended_attribute_value(interface, "RaisesException", "Constructor")
    ):
        cpp_arguments.append("exceptionState")

    # If a method returns an IDL dictionary or union type, the return value is
    # passed as an argument to impl classes.
    idl_type = method.idl_type
    if idl_type and idl_type.use_output_parameter_for_result:
        cpp_arguments.append("result")

    if method.name == "Constructor":
        base_name = "create"
    elif method.name == "NamedConstructor":
        base_name = "createForJSConstructor"
    elif "ImplementedInPrivateScript" in method.extended_attributes:
        base_name = "%sMethod" % method.name
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return "%s(%s)" % (cpp_method_name, ", ".join(cpp_arguments))
Esempio n. 26
0
def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(
        extended_attributes.get('SetterCallWith')
        or extended_attributes.get('CallWith'))

    extra_arguments = []
    this_setter_base_name = setter_base_name(interface, attribute,
                                             extra_arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in extended_attributes
            and not attribute.is_static):
        arguments.append('*impl')
    arguments.extend(extra_arguments)
    idl_type = attribute.idl_type
    if idl_type.base_type in ('EventHandler', 'OnBeforeUnloadEventHandler',
                              'OnErrorEventHandler'):
        if idl_type.base_type == 'EventHandler':
            handler_type = 'kEventHandler'
        elif idl_type.base_type == 'OnBeforeUnloadEventHandler':
            handler_type = 'kOnBeforeUnloadEventHandler'
        elif idl_type.base_type == 'OnErrorEventHandler':
            handler_type = 'kOnErrorEventHandler'
        arguments.append('JSEventHandler::CreateOrNull(' + 'v8_value, ' +
                         'JSEventHandler::HandlerType::' + handler_type + ')')
    else:
        arguments.append('cpp_value')
    if context['is_setter_raises_exception']:
        arguments.append('exception_state')
    if context['use_common_reflection_setter']:
        attr_name = scoped_content_attribute_name(interface, attribute)
        if idl_type.base_type == 'boolean':
            setter_name = 'V8SetReflectedBooleanAttribute'
            arguments = [
                'info',
                '"%s"' % interface.name,
                '"%s"' % attribute.name, attr_name
            ]
        elif idl_type.base_type == 'DOMString':
            if idl_type.is_nullable:
                setter_name = 'V8SetReflectedNullableDOMStringAttribute'
            else:
                setter_name = 'V8SetReflectedDOMStringAttribute'
            arguments = ['info', attr_name]

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 27
0
def getter_expression(interface, attribute, contents):
    arguments = []
    this_getter_base_name = getter_base_name(attribute, arguments)
    getter_name = v8_utilities.scoped_name(interface, attribute,
                                           this_getter_base_name)

    arguments.extend(v8_utilities.call_with_arguments(attribute))
    if attribute.is_nullable:
        arguments.append('isNull')
    if contents['is_getter_raises_exception']:
        arguments.append('exceptionState')
    if attribute.idl_type == 'EventHandler':
        arguments.append('isolatedWorldForIsolate(info.GetIsolate())')
    return '%s(%s)' % (getter_name, ', '.join(arguments))
Esempio n. 28
0
def setter_expression(interface, attribute, contents):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(
        attribute, extended_attributes.get('SetterCallWith'))

    this_setter_base_name = setter_base_name(attribute, arguments)
    setter_name = v8_utilities.scoped_name(interface, attribute,
                                           this_setter_base_name)

    if ('ImplementedBy' in extended_attributes and not attribute.is_static):
        arguments.append('imp')
    idl_type = attribute.idl_type
    if idl_type == 'EventHandler':
        getter_name = v8_utilities.scoped_name(interface, attribute,
                                               cpp_name(attribute))
        contents['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope']
                and attribute.name == 'onerror'):
            includes.add('bindings/v8/V8ErrorHandler.h')
            arguments.append(
                'V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate())'
            )
        else:
            arguments.append(
                'V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)'
            )
    elif v8_types.is_interface_type(
            idl_type) and not v8_types.array_type(idl_type):
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append('WTF::getPtr(cppValue)')
    else:
        arguments.append('cppValue')
    if contents['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
Esempio n. 29
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if idl_type.name == 'EventListener':
            if (interface.name == 'EventTarget' and
                method.name == 'removeEventListener'):
                # FIXME: remove this special case by moving get() into
                # EventTarget::removeEventListener
                return '%s.get()' % argument.name
            return argument.name
        if (idl_type.is_callback_interface or
            idl_type.name in ['NodeFilter', 'XPathNSResolver']):
            # FIXME: remove this special case
            return '%s.release()' % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []
    if method.is_constructor:
        call_with_values = interface.extended_attributes.get('ConstructorCallWith')
    else:
        call_with_values = method.extended_attributes.get('CallWith')
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in method.extended_attributes and
        not method.is_static):
        cpp_arguments.append('*impl')
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)
    this_union_arguments = method.idl_type and method.idl_type.union_arguments
    if this_union_arguments:
        cpp_arguments.extend(this_union_arguments)

    if ('RaisesException' in method.extended_attributes or
        (method.is_constructor and
         has_extended_attribute_value(interface, 'RaisesException', 'Constructor'))):
        cpp_arguments.append('exceptionState')

    if method.name == 'Constructor':
        base_name = 'create'
    elif method.name == 'NamedConstructor':
        base_name = 'createForJSConstructor'
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 30
0
def getter_expression(interface, attribute, contents):
    arguments = []
    this_getter_base_name = getter_base_name(attribute, arguments)
    getter_name = v8_utilities.scoped_name(interface, attribute,
                                           this_getter_base_name)

    arguments.extend(v8_utilities.call_with_arguments(attribute))
    if ('ImplementedBy' in attribute.extended_attributes
            and not attribute.is_static):
        arguments.append('imp')
    if attribute.is_nullable:
        arguments.append('isNull')
    if contents['is_getter_raises_exception']:
        arguments.append('exceptionState')
    return '%s(%s)' % (getter_name, ', '.join(arguments))
Esempio n. 31
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        if argument.idl_type in ['NodeFilter', 'XPathNSResolver']:
            # FIXME: remove this special case
            return '%s.release()' % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = v8_utilities.call_with_arguments(method)
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)
    if 'RaisesException' in method.extended_attributes:
        cpp_arguments.append('exceptionState')

    cpp_method_name = v8_utilities.scoped_name(interface, method, v8_utilities.cpp_name(method))
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 32
0
def getter_expression(interface, attribute, context):
    arguments = []
    this_getter_base_name = getter_base_name(interface, attribute, arguments)
    getter_name = scoped_name(interface, attribute, this_getter_base_name)

    arguments.extend(v8_utilities.call_with_arguments(attribute.extended_attributes.get("CallWith")))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if "PartialInterfaceImplementedAs" in attribute.extended_attributes and not attribute.is_static:
        arguments.append("*impl")
    if attribute.idl_type.is_explicit_nullable:
        arguments.append("isNull")
    if context["is_getter_raises_exception"]:
        arguments.append("exceptionState")
    return "%s(%s)" % (getter_name, ", ".join(arguments))
Esempio n. 33
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        if argument.idl_type in ['NodeFilter', 'XPathNSResolver']:
            # FIXME: remove this special case
            return '%s.release()' % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = v8_utilities.call_with_arguments(method)
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)
    if 'RaisesException' in method.extended_attributes:
        cpp_arguments.append('exceptionState')

    cpp_method_name = v8_utilities.scoped_name(interface, method,
                                               v8_utilities.cpp_name(method))
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 34
0
def getter_expression(interface, attribute, contents):
    arguments = []
    this_getter_base_name = getter_base_name(interface, attribute, arguments)
    getter_name = scoped_name(interface, attribute, this_getter_base_name)

    arguments.extend(v8_utilities.call_with_arguments(attribute))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and
        not attribute.is_static):
        arguments.append('*impl')
    if attribute.idl_type.is_nullable and not contents['has_strict_type_checking']:
        arguments.append('isNull')
    if contents['is_getter_raises_exception']:
        arguments.append('exceptionState')
    return '%s(%s)' % (getter_name, ', '.join(arguments))
Esempio n. 35
0
def cpp_value(interface, method, number_of_arguments):
    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get(
            'ConstructorCallWith')
    else:
        call_with_values = method.extended_attributes.get('CallWith')
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in method.extended_attributes
            and not method.is_static):
        cpp_arguments.append('*impl')
    for argument in arguments:
        variable_name = NameStyleConverter(argument.name).to_snake_case()
        if argument.idl_type.base_type == 'SerializedScriptValue':
            cpp_arguments.append('std::move(%s)' % variable_name)
        else:
            cpp_arguments.append(variable_name)

    if ('RaisesException' in method.extended_attributes
            or (method.is_constructor and has_extended_attribute_value(
                interface, 'RaisesException', 'Constructor'))):
        cpp_arguments.append('exception_state')

    # If a method returns an IDL dictionary or union type, the return value is
    # passed as an argument to impl classes.
    idl_type = method.idl_type
    if idl_type and idl_type.use_output_parameter_for_result:
        cpp_arguments.append('result')

    if method.name == 'Constructor':
        base_name = 'Create'
    elif method.name == 'NamedConstructor':
        base_name = 'CreateForJSConstructor'
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 36
0
def getter_expression(interface, attribute, contents):
    arguments = []
    this_getter_base_name = getter_base_name(interface, attribute, arguments)
    getter_name = scoped_name(interface, attribute, this_getter_base_name)

    arguments.extend(v8_utilities.call_with_arguments(attribute))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in attribute.extended_attributes
            and not attribute.is_static):
        arguments.append('*impl')
    if attribute.idl_type.is_nullable and not contents[
            'has_type_checking_nullable']:
        arguments.append('isNull')
    if contents['is_getter_raises_exception']:
        arguments.append('exceptionState')
    return '%s(%s)' % (getter_name, ', '.join(arguments))
Esempio n. 37
0
def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if idl_type.is_callback_interface or idl_type.name in ["NodeFilter", "NodeFilterOrNull"]:
            # FIXME: remove this special case
            return "%s.release()" % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get("ConstructorCallWith")
    else:
        call_with_values = method.extended_attributes.get("CallWith")
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if "PartialInterfaceImplementedAs" in method.extended_attributes and not method.is_static:
        cpp_arguments.append("*impl")
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)

    this_union_arguments = method.idl_type and method.idl_type.union_arguments
    if this_union_arguments:
        cpp_arguments.extend([member_argument["cpp_value"] for member_argument in this_union_arguments])

    if "RaisesException" in method.extended_attributes or (
        method.is_constructor and has_extended_attribute_value(interface, "RaisesException", "Constructor")
    ):
        cpp_arguments.append("exceptionState")

    if method.name == "Constructor":
        base_name = "create"
    elif method.name == "NamedConstructor":
        base_name = "createForJSConstructor"
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return "%s(%s)" % (cpp_method_name, ", ".join(cpp_arguments))
Esempio n. 38
0
def cpp_value(interface, method, number_of_arguments):
    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get('ConstructorCallWith')
    else:
        call_with_values = method.extended_attributes.get('CallWith')
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in method.extended_attributes and
            not method.is_static):
        cpp_arguments.append('*impl')
    cpp_arguments.extend(argument.name for argument in arguments)

    if ('RaisesException' in method.extended_attributes or
          (method.is_constructor and
           has_extended_attribute_value(interface, 'RaisesException', 'Constructor'))):
        cpp_arguments.append('exceptionState')

    # If a method returns an IDL dictionary or union type, the return value is
    # passed as an argument to impl classes.
    idl_type = method.idl_type
    if idl_type and idl_type.use_output_parameter_for_result:
        cpp_arguments.append('result')

    if method.name == 'Constructor':
        base_name = 'Create'
    elif method.name == 'NamedConstructor':
        base_name = 'CreateForJSConstructor'
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
Esempio n. 39
0
def getter_expression(interface, attribute, context):
    arguments = []
    this_getter_base_name = getter_base_name(interface, attribute, arguments)
    getter_name = scoped_name(interface, attribute, this_getter_base_name)

    if 'ImplementedInPrivateScript' in attribute.extended_attributes:
        arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())')
        arguments.append('impl')
        arguments.append('&result')
    arguments.extend(v8_utilities.call_with_arguments(
        attribute.extended_attributes.get('CallWith')))
    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and
        not attribute.is_static):
        arguments.append('*impl')
    if attribute.idl_type.is_nullable and not context['is_nullable_simple']:
        arguments.append('isNull')
    if context['is_getter_raises_exception']:
        arguments.append('exceptionState')
    return '%s(%s)' % (getter_name, ', '.join(arguments))
def setter_expression(interface, attribute, contents):
    arguments = v8_utilities.call_with_arguments(attribute, attribute.extended_attributes.get('SetterCallWith'))

    this_setter_base_name = setter_base_name(attribute, arguments)
    setter_name = v8_utilities.scoped_name(interface, attribute, this_setter_base_name)

    idl_type = attribute.idl_type
    if idl_type == 'EventHandler':
        # FIXME: move V8EventListenerList.h to INCLUDES_FOR_TYPE
        includes.add('bindings/v8/V8EventListenerList.h')
        # FIXME: pass the isolate instead of the isolated world
        isolated_world = 'isolatedWorldForIsolate(info.GetIsolate())'
        arguments.extend(['V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)', isolated_world])
        contents['event_handler_getter_expression'] = 'imp->%s(%s)' % (cpp_name(attribute), isolated_world)
    elif v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type):
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append('WTF::getPtr(cppValue)')
    else:
        arguments.append('cppValue')
    if contents['is_setter_raises_exception']:
        arguments.append('es')

    return '%s(%s)' % (setter_name, ', '.join(arguments))