def setter_expression(interface, attribute, context): extended_attributes = attribute.extended_attributes arguments = DartUtilities.call_with_arguments( extended_attributes.get('SetterCallWith') or extended_attributes.get('CallWith')) this_setter_base_name = v8_attributes.setter_base_name(interface, attribute, arguments) setter_name = DartUtilities.scoped_name(interface, attribute, this_setter_base_name) if ('PartialInterfaceImplementedAs' in extended_attributes and not attribute.is_static): arguments.append('*receiver') idl_type = attribute.idl_type if idl_type.base_type == 'EventHandler': getter_name = DartUtilities.scoped_name(interface, attribute, DartUtilities.cpp_name(attribute)) context['event_handler_getter_expression'] = '%s(%s)' % ( getter_name, ', '.join(arguments)) # FIXME(vsm): Do we need to support this? If so, what's our analogue of # V8EventListenerList? arguments.append('nullptr') else: attribute_name = dart_types.check_reserved_name(attribute.name) arguments.append(attribute_name) if context['is_setter_raises_exception']: arguments.append('es') return '%s(%s)' % (setter_name, ', '.join(arguments))
def cpp_value(interface, method, number_of_arguments): def cpp_argument(argument): argument_name = dart_types.check_reserved_name(argument.name) idl_type = argument.idl_type if idl_type.is_typed_array_type: return '%s.get()' % argument_name # TODO(eseidel): This should check cpp_type.endswith('Handle') if idl_type.name == 'MojoDataPipeConsumer': return '%s.Pass()' % argument_name 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: return '%s.release()' % argument_name return argument_name # Truncate omitted optional arguments arguments = method.arguments[:number_of_arguments] if method.is_constructor: call_with_values = interface.extended_attributes.get( 'ConstructorCallWith') else: call_with_values = method.extended_attributes.get('CallWith') cpp_arguments = DartUtilities.call_with_arguments(call_with_values) if ('PartialInterfaceImplementedAs' in method.extended_attributes and not method.is_static): cpp_arguments.append('*receiver') 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 DartUtilities.has_extended_attribute_value( interface, 'RaisesException', 'Constructor'))): cpp_arguments.append('es') if method.name == 'Constructor': base_name = 'create' elif method.name == 'NamedConstructor': base_name = 'createForJSConstructor' else: base_name = DartUtilities.cpp_name(method) cpp_method_name = DartUtilities.scoped_name(interface, method, base_name) return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
def cpp_value(interface, method, number_of_arguments): def cpp_argument(argument): argument_name = dart_types.check_reserved_name(argument.name) idl_type = argument.idl_type if idl_type.is_typed_array_type: return '%s.get()' % argument_name # TODO(eseidel): This should check cpp_type.endswith('Handle') if idl_type.name == 'MojoDataPipeConsumer': return '%s.Pass()' % argument_name 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: return '%s.release()' % argument_name return argument_name # Truncate omitted optional arguments arguments = method.arguments[:number_of_arguments] if method.is_constructor: call_with_values = interface.extended_attributes.get('ConstructorCallWith') else: call_with_values = method.extended_attributes.get('CallWith') cpp_arguments = DartUtilities.call_with_arguments(call_with_values) if ('PartialInterfaceImplementedAs' in method.extended_attributes and not method.is_static): cpp_arguments.append('*receiver') 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 DartUtilities.has_extended_attribute_value(interface, 'RaisesException', 'Constructor'))): cpp_arguments.append('es') if method.name == 'Constructor': base_name = 'create' elif method.name == 'NamedConstructor': base_name = 'createForJSConstructor' else: base_name = DartUtilities.cpp_name(method) cpp_method_name = DartUtilities.scoped_name(interface, method, base_name) return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
def setter_expression(interface, attribute, context): extended_attributes = attribute.extended_attributes arguments = DartUtilities.call_with_arguments( extended_attributes.get('SetterCallWith') or extended_attributes.get('CallWith')) this_setter_base_name = v8_attributes.setter_base_name(interface, attribute, arguments) setter_name = DartUtilities.scoped_name(interface, attribute, this_setter_base_name) if ('PartialInterfaceImplementedAs' in extended_attributes and not attribute.is_static): arguments.append('*receiver') idl_type = attribute.idl_type attribute_name = dart_types.check_reserved_name(attribute.name) arguments.append(attribute_name) if context['is_setter_raises_exception']: arguments.append('es') return '%s(%s)' % (setter_name, ', '.join(arguments))
def getter_expression(interface, attribute, context): v8_attributes.getter_expression(interface, attribute, context) arguments = [] this_getter_base_name = v8_attributes.getter_base_name(interface, attribute, arguments) getter_name = DartUtilities.scoped_name(interface, attribute, this_getter_base_name) arguments.extend(DartUtilities.call_with_arguments( attribute.extended_attributes.get('CallWith'))) if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and not attribute.is_static): # Pass by reference. arguments.append('*receiver') if attribute.idl_type.is_explicit_nullable: arguments.append('is_null') if context['is_getter_raises_exception']: arguments.append('es') return '%s(%s)' % (getter_name, ', '.join(arguments))
def setter_expression(interface, attribute, context): extended_attributes = attribute.extended_attributes arguments = DartUtilities.call_with_arguments( extended_attributes.get('SetterCallWith') or extended_attributes.get('CallWith')) this_setter_base_name = v8_attributes.setter_base_name( interface, attribute, arguments) setter_name = DartUtilities.scoped_name(interface, attribute, this_setter_base_name) if ('PartialInterfaceImplementedAs' in extended_attributes and not attribute.is_static): arguments.append('*receiver') idl_type = attribute.idl_type attribute_name = dart_types.check_reserved_name(attribute.name) arguments.append(attribute_name) if context['is_setter_raises_exception']: arguments.append('es') return '%s(%s)' % (setter_name, ', '.join(arguments))
def setter_expression(interface, attribute, context): extended_attributes = attribute.extended_attributes arguments = DartUtilities.call_with_arguments( extended_attributes.get('SetterCallWith') or extended_attributes.get('CallWith')) this_setter_base_name = v8_attributes.setter_base_name( interface, attribute, arguments) setter_name = DartUtilities.scoped_name(interface, attribute, this_setter_base_name) if ('PartialInterfaceImplementedAs' in extended_attributes and not attribute.is_static): arguments.append('*receiver') idl_type = attribute.idl_type if idl_type.base_type == 'EventHandler': getter_name = DartUtilities.scoped_name( interface, attribute, DartUtilities.cpp_name(attribute)) context['event_handler_getter_expression'] = '%s(%s)' % ( getter_name, ', '.join(arguments)) # FIXME(vsm): Do we need to support this? If so, what's our analogue of # V8EventListenerList? arguments.append('nullptr') # if (interface.name in ['Window', 'WorkerGlobalScope'] and # attribute.name == 'onerror'): # includes.add('bindings/core/v8/V8ErrorHandler.h') # arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate())') # else: # arguments.append('V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)') else: attribute_name = dart_types.check_reserved_name(attribute.name) arguments.append(attribute_name) if context['is_setter_raises_exception']: arguments.append('es') return '%s(%s)' % (setter_name, ', '.join(arguments))