def method_context(interface, method): context = v8_methods.method_context(interface, method) arguments = method.arguments extended_attributes = method.extended_attributes idl_type = method.idl_type # idl_type.add_includes_for_type() this_cpp_value = cpp_value(interface, method, len(arguments)) if context['is_call_with_script_state']: includes.add('bindings/core/dart/DartScriptState.h') if idl_type.union_arguments and len(idl_type.union_arguments) > 0: this_cpp_type = [] for cpp_type in idl_type.member_types: # FIXMEDART: we shouldn't just assume RefPtr. We should append # WillBeGC as appropriate. this_cpp_type.append("RefPtr<%s>" % cpp_type) else: this_cpp_type = idl_type.cpp_type is_auto_scope = not 'DartNoAutoScope' in extended_attributes arguments_data = [ argument_context(interface, method, argument, index) for index, argument in enumerate(arguments) ] union_arguments = [] if idl_type.union_arguments: union_arguments.extend( [union_arg['cpp_value'] for union_arg in idl_type.union_arguments]) is_custom = 'Custom' in extended_attributes or 'DartCustom' in extended_attributes context.update({ 'activity_logging_world_list': DartUtilities.activity_logging_world_list(method), # [ActivityLogging] 'arguments': arguments_data, 'cpp_type': this_cpp_type, 'cpp_value': this_cpp_value, 'dart_name': extended_attributes.get('DartName'), 'deprecate_as': DartUtilities.deprecate_as(method), # [DeprecateAs] 'do_not_check_signature': not (context['is_static'] or DartUtilities.has_extended_attribute(method, [ 'DoNotCheckSecurity', 'DoNotCheckSignature', 'NotEnumerable', 'ReadOnly', 'RuntimeEnabled', 'Unforgeable' ])), 'has_exception_state': context['is_raises_exception'] or context['is_check_security_for_frame'] or any(argument for argument in arguments if argument.idl_type.name == 'SerializedScriptValue' or argument.idl_type.is_integer_type), 'is_auto_scope': is_auto_scope, 'auto_scope': DartUtilities.bool_to_cpp(is_auto_scope), 'is_custom': is_custom, 'is_custom_dart': 'DartCustom' in extended_attributes, 'is_custom_dart_new': DartUtilities.has_extended_attribute_value(method, 'DartCustom', 'New'), # FIXME(terry): DartStrictTypeChecking no longer supported; TypeChecking is # new extended attribute. 'is_strict_type_checking': 'DartStrictTypeChecking' in extended_attributes or 'DartStrictTypeChecking' in interface.extended_attributes, 'measure_as': DartUtilities.measure_as(method), # [MeasureAs] 'suppressed': (arguments and arguments[-1].is_variadic), # FIXME: implement variadic 'union_arguments': union_arguments, 'dart_set_return_value': dart_set_return_value(interface.name, method, this_cpp_value), }) return context
def attribute_context(interface, attribute): # Call v8's implementation. context = v8_attributes.attribute_context(interface, attribute) extended_attributes = attribute.extended_attributes # Augment's Dart's information to context. idl_type = attribute.idl_type base_idl_type = idl_type.base_type # TODO(terry): Work around for DOMString[] base should be IDLTypeArray if base_idl_type == None: # Returns Array or Sequence. base_idl_type = idl_type.inner_name # [Custom] has_custom_getter = ( ('Custom' in extended_attributes and extended_attributes['Custom'] in [None, 'Getter']) or ('DartCustom' in extended_attributes and extended_attributes['DartCustom'] in [None, 'Getter', 'New'])) has_custom_setter = (not attribute.is_read_only and ( ('Custom' in extended_attributes and extended_attributes['Custom'] in [None, 'Setter']) or ('DartCustom' in extended_attributes and extended_attributes['DartCustom'] in [None, 'Setter', 'New']))) is_call_with_script_state = DartUtilities.has_extended_attribute_value( attribute, 'CallWith', 'ScriptState') is_auto_scope = not 'DartNoAutoScope' in extended_attributes context.update({ 'activity_logging_world_list_for_getter': DartUtilities.activity_logging_world_list( attribute, 'Getter'), # [ActivityLogging] 'activity_logging_world_list_for_setter': DartUtilities.activity_logging_world_list( attribute, 'Setter'), # [ActivityLogging] 'deprecate_as': DartUtilities.deprecate_as(attribute), # [DeprecateAs] 'has_custom_getter': has_custom_getter, 'has_custom_setter': has_custom_setter, 'is_auto_scope': is_auto_scope, # Used internally (outside of templates). 'is_call_with_script_state': is_call_with_script_state, 'auto_scope': DartUtilities.bool_to_cpp(is_auto_scope), 'measure_as': DartUtilities.measure_as(attribute), # [MeasureAs] 'v8_type': dart_types.v8_type(base_idl_type), }) if v8_attributes.is_constructor_attribute(attribute): v8_attributes.constructor_getter_context(interface, attribute, context) return context if not v8_attributes.has_custom_getter(attribute): getter_context(interface, attribute, context) if (not attribute.is_read_only): # FIXME: We did not previously support the PutForwards attribute, so I am # disabling it here for now to get things compiling. # We may wish to revisit this. # if (not has_custom_setter(attribute) and # (not attribute.is_read_only or 'PutForwards' in extended_attributes)): setter_context(interface, attribute, context) native_entry_getter = \ DartUtilities.generate_native_entry( interface.name, attribute.name, 'Getter', attribute.is_static, 0) native_entry_setter = \ DartUtilities.generate_native_entry( interface.name, attribute.name, 'Setter', attribute.is_static, 1) context.update({ 'native_entry_getter': native_entry_getter, 'native_entry_setter': native_entry_setter, }) return context