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 setter_context(interface, attribute, context): v8_attributes.setter_context(interface, attribute, context) def target_attribute(): target_interface_name = attribute.idl_type.base_type target_attribute_name = extended_attributes['PutForwards'] target_interface = interfaces[target_interface_name] try: return next(attribute for attribute in target_interface.attributes if attribute.name == target_attribute_name) except StopIteration: raise Exception('[PutForward] target not found:\n' 'Attribute "%s" is not present in interface "%s"' % (target_attribute_name, target_interface_name)) extended_attributes = attribute.extended_attributes if 'PutForwards' in extended_attributes: # Use target attribute in place of original attribute attribute = target_attribute() this_cpp_type = 'DartStringAdapter' else: this_cpp_type = context['cpp_type'] idl_type = attribute.idl_type # TODO(terry): Should be able to eliminate suppress_setter as we move from # IGNORE_MEMBERS to DartSuppress in the IDL. suppress = (suppress_setter(interface.name, attribute.name) or DartUtilities.has_extended_attribute_value( attribute, 'DartSuppress', 'Setter')) context.update({ 'has_setter_exception_state': (context['is_setter_raises_exception'] or context['has_type_checking_interface'] or idl_type.is_integer_type), 'is_setter_suppressed': suppress, 'setter_lvalue': dart_types.check_reserved_name(attribute.name), 'cpp_type': this_cpp_type, 'local_cpp_type': idl_type.cpp_type_args(attribute.extended_attributes, raw_type=True), 'dart_value_to_local_cpp_value': attribute.idl_type.dart_value_to_local_cpp_value( extended_attributes, attribute.name, False, context['has_type_checking_interface'], 1, context['is_auto_scope']), }) # setter_expression() depends on context values we set above. context['cpp_setter'] = setter_expression(interface, attribute, context)
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.is_callback_interface: return '%s.release()' % argument_name return argument_name
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_context(interface, attribute, context): v8_attributes.setter_context(interface, attribute, context) def target_attribute(): target_interface_name = attribute.idl_type.base_type target_attribute_name = extended_attributes['PutForwards'] target_interface = interfaces[target_interface_name] try: return next(attribute for attribute in target_interface.attributes if attribute.name == target_attribute_name) except StopIteration: raise Exception('[PutForward] target not found:\n' 'Attribute "%s" is not present in interface "%s"' % (target_attribute_name, target_interface_name)) extended_attributes = attribute.extended_attributes if 'PutForwards' in extended_attributes: # Use target attribute in place of original attribute attribute = target_attribute() this_cpp_type = 'DartStringAdapter' else: this_cpp_type = context['cpp_type'] idl_type = attribute.idl_type context.update({ 'has_setter_exception_state': ( context['is_setter_raises_exception'] or context['has_type_checking_interface'] or idl_type.is_integer_type), 'setter_lvalue': dart_types.check_reserved_name(attribute.name), 'cpp_type': this_cpp_type, 'local_cpp_type': idl_type.cpp_type_args(attribute.extended_attributes, raw_type=True), 'dart_value_to_local_cpp_value': attribute.idl_type.dart_value_to_local_cpp_value( extended_attributes, attribute.name, False, context['has_type_checking_interface'], 1, context['is_auto_scope']), }) # setter_expression() depends on context values we set above. context['cpp_setter'] = setter_expression(interface, attribute, context)
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 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
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
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))