def _GetUseCounter(self, member, parent, ext_attrs): assert isinstance(ext_attrs, web_idl.ExtendedAttributes) assert parent is None or hasattr(parent, 'identifier') if 'MeasureAs' in ext_attrs: return ext_attrs.value_of('MeasureAs') if 'Measure' not in ext_attrs: return None if parent is not None: prefix = '%s_%s' % (capitalize( parent.identifier), capitalize(member.identifier)) else: prefix = capitalize(member.identifier) suffix = "" if isinstance(member, web_idl.FunctionLike): if len(member.arguments) == 0 and member.is_getter: suffix = "AttributeGetter" elif len(member.arguments) == 1 and member.is_setter: suffix = "AttributeSetter" else: suffix = "Method" elif isinstance(member, web_idl.Attribute): suffix = "AttributeGetter" else: assert False, repr(member) return "V8" + prefix + "_" + suffix
def _GetUseCounter(self, parent, measure, measure_as): if measure_as: return measure_as.value if measure: use_counter = capitalize(parent.identifier) if not isinstance(parent, web_idl.Interface): use_counter = (capitalize(parent.owner.identifier) + '_' + use_counter) return use_counter return None
def record(csv_writer, entity): interface = '' name = '' entity_type = '' use_counter = '' secure_context = '' high_entropy = '' idl_type = '' syntactic_form = '' secure_context = ('SecureContext' in entity.extended_attributes) high_entropy = ('HighEntropy' in entity.extended_attributes) if 'Measure' in entity.extended_attributes: use_counter = capitalize(entity.identifier) if not isinstance(entity, web_idl.Interface): use_counter = (capitalize(entity.owner.identifier) + '_' + use_counter) elif 'MeasureAs' in entity.extended_attributes: use_counter = entity.extended_attributes.value_of('MeasureAs') if isinstance(entity, web_idl.Interface): interface = entity.identifier name = '' entity_type = 'interface' else: interface = entity.owner.identifier name = entity.identifier if isinstance(entity, web_idl.Attribute): entity_type = 'attribute' idl_type, syntactic_form = get_idl_type_name(entity.idl_type) elif isinstance(entity, web_idl.Operation): entity_type = 'operation' idl_type, syntactic_form = get_idl_type_name(entity.return_type) elif isinstance(entity, web_idl.Constant): entity_type = 'constant' idl_type, syntactic_form = get_idl_type_name(entity.idl_type) else: assert False, "Unexpected IDL construct" csv_writer.writerow({ 'interface': interface, 'name': name, 'entity_type': entity_type, 'idl_type': idl_type, 'syntactic_form': syntactic_form, 'use_counter': use_counter, 'secure_context': secure_context, 'high_entropy': high_entropy })
def setter_base_name(interface, attribute, arguments): if "Reflect" not in attribute.extended_attributes: return "set%s" % capitalize(cpp_name(attribute)) arguments.append(scoped_content_attribute_name(interface, attribute)) base_idl_type = attribute.idl_type.base_type if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type] return "setAttribute"
def setter_base_name(attribute, arguments): if 'Reflect' not in attribute.extended_attributes: return 'set%s' % capitalize(cpp_name(attribute)) arguments.append(scoped_content_attribute_name(attribute)) idl_type = attribute.idl_type if idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: return CONTENT_ATTRIBUTE_SETTER_NAMES[idl_type] return 'setAttribute'
def setter_base_name(interface, attribute, arguments): if 'Reflect' not in attribute.extended_attributes: return 'set%s' % capitalize(cpp_name(attribute)) arguments.append(scoped_content_attribute_name(interface, attribute)) base_idl_type = attribute.idl_type.base_type if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type] return 'setAttribute'
def setter_base_name(interface, attribute, arguments): if 'ImplementedInPrivateScript' in attribute.extended_attributes: return '%sAttributeSetter' % uncapitalize(cpp_name(attribute)) if 'Reflect' not in attribute.extended_attributes: return 'set%s' % capitalize(cpp_name(attribute)) arguments.append(scoped_content_attribute_name(interface, attribute)) base_idl_type = attribute.idl_type.base_type if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type] return 'setAttribute'
def has_method_name_for_dictionary_member(member): name = v8_utilities.cpp_name(member) return 'has%s' % v8_utilities.capitalize(name)
def setter_name_for_dictionary_member(member): name = v8_utilities.cpp_name(member) return 'set%s' % v8_utilities.capitalize(name)
def null_setter_name_for_dictionary_member(member): if member.idl_type.is_nullable: name = v8_utilities.cpp_name(member) return 'set%sToNull' % v8_utilities.capitalize(name) return None
def getter_name_for_dictionary_member(member): name = v8_utilities.cpp_name(member) if 'PrefixGet' in member.extended_attributes: return 'get%s' % v8_utilities.capitalize(name) return name
def setter_name_for_dictionary_member(member): return 'set%s' % v8_utilities.capitalize(member.name)
def setter_name_for_dictionary_member(member): name = v8_utilities.cpp_name(member) return "set%s" % v8_utilities.capitalize(name)
def record(csv_writer, entity): interface = '' name = '' entity_type = '' use_counter = '' secure_context = '' high_entropy = '' idl_type = '' arguments = '' syntactic_form = '' source_file = '' source_line = '' secure_context = ('SecureContext' in entity.extended_attributes) if 'HighEntropy' in entity.extended_attributes: high_entropy = entity.extended_attributes.value_of('HighEntropy') if not high_entropy: high_entropy = '(True)' if 'Measure' in entity.extended_attributes: use_counter = capitalize(entity.identifier) if not isinstance(entity, web_idl.Interface): use_counter = (capitalize(entity.owner.identifier) + '_' + use_counter) elif 'MeasureAs' in entity.extended_attributes: use_counter = entity.extended_attributes.value_of('MeasureAs') for location in entity.debug_info.all_locations: if location.line_number: source_file = location.filepath source_line = location.line_number break if not source_file: location = entity.debug_info.location source_file = location.filepath if isinstance(entity, web_idl.FunctionLike): arguments = arguments_to_str(entity.arguments) if isinstance(entity, web_idl.Interface): interface = entity.identifier name = '' entity_type = 'interface' else: interface = entity.owner.identifier name = entity.identifier if isinstance(entity, web_idl.Attribute): entity_type = 'attribute' idl_type, syntactic_form = get_idl_type_name(entity.idl_type) elif isinstance(entity, web_idl.Operation): entity_type = 'operation' idl_type, syntactic_form = get_idl_type_name(entity.return_type) elif isinstance(entity, web_idl.Constant): entity_type = 'constant' idl_type, syntactic_form = get_idl_type_name(entity.idl_type) else: assert False, "Unexpected IDL construct" csv_writer.writerow({ 'interface': interface, 'name': name, 'entity_type': entity_type, 'arguments': arguments, 'idl_type': idl_type, 'syntactic_form': syntactic_form, 'use_counter': use_counter, 'secure_context': true_or_nothing(secure_context), 'high_entropy': high_entropy, 'source_file': source_file, 'source_line': source_line })
def has_method_name_for_dictionary_member(member): return 'has%s' % v8_utilities.capitalize(member.name)
def setter_base_name(interface, attribute, arguments): return 'set%s' % capitalize(cpp_name(attribute))
def has_method_name_for_dictionary_member(member): name = v8_utilities.cpp_name(member) return "has%s" % v8_utilities.capitalize(name)
def generate_attribute(interface, attribute): idl_type = attribute.idl_type extended_attributes = attribute.extended_attributes v8_types.add_includes_for_type(idl_type) # [CheckSecurity] is_check_security_for_node = 'CheckSecurity' in extended_attributes if is_check_security_for_node: includes.add('bindings/v8/BindingSecurity.h') # [Custom] has_custom_getter = ('Custom' in extended_attributes and extended_attributes['Custom'] in [None, 'Getter']) has_custom_setter = (not attribute.is_read_only and 'Custom' in extended_attributes and extended_attributes['Custom'] in [None, 'Setter']) # [RaisesException] is_getter_raises_exception = ( 'RaisesException' in extended_attributes and extended_attributes['RaisesException'] in [None, 'Getter']) if is_check_security_for_node or is_getter_raises_exception: includes.update(set(['bindings/v8/ExceptionMessages.h', 'bindings/v8/ExceptionState.h'])) # [Reflect] is_reflect = 'Reflect' in extended_attributes if is_reflect: includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') if (idl_type == 'EventHandler' and interface.name in ['Window', 'WorkerGlobalScope'] and attribute.name == 'onerror'): includes.add('bindings/v8/V8ErrorHandler.h') contents = { 'access_control_list': access_control_list(attribute), 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_world_list(attribute, 'Getter'), # [ActivityLogging] 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_world_list(attribute, 'Setter'), # [ActivityLogging] 'cached_attribute_validation_method': extended_attributes.get('CachedAttribute'), 'conditional_string': v8_utilities.conditional_string(attribute), 'constructor_type': v8_types.constructor_type(idl_type) if is_constructor_attribute(attribute) else None, 'cpp_name': cpp_name(attribute), 'cpp_type': v8_types.cpp_type(idl_type), 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 'enum_validation_expression': v8_utilities.enum_validation_expression(idl_type), 'has_custom_getter': has_custom_getter, 'has_custom_setter': has_custom_setter, 'has_strict_type_checking': ( 'StrictTypeChecking' in extended_attributes and v8_types.is_interface_type(idl_type)), 'idl_type': idl_type, 'is_call_with_execution_context': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'), 'is_check_security_for_node': is_check_security_for_node, 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes, 'is_getter_raises_exception': ( 'RaisesException' in extended_attributes and extended_attributes['RaisesException'] in [None, 'Getter']), 'is_initialized_by_event_constructor': 'InitializedByEventConstructor' in extended_attributes, 'is_keep_alive_for_gc': is_keep_alive_for_gc(attribute), 'is_nullable': attribute.is_nullable, 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, 'is_read_only': attribute.is_read_only, 'is_reflect': is_reflect, 'is_replaceable': 'Replaceable' in attribute.extended_attributes, 'is_setter_raises_exception': ( 'RaisesException' in extended_attributes and extended_attributes['RaisesException'] in [None, 'Setter']), 'is_static': attribute.is_static, 'is_unforgeable': 'Unforgeable' in extended_attributes, 'measure_as': v8_utilities.measure_as(attribute), # [MeasureAs] 'name': attribute.name, 'per_context_enabled_function': v8_utilities.per_context_enabled_function_name(attribute), # [PerContextEnabled] 'property_attributes': property_attributes(attribute), 'set_serialized_script_value': 'setSerialized' + capitalize(attribute.name), # [EventConstructor] on interface 'setter_callback': setter_callback_name(interface, attribute), 'v8_type': v8_types.v8_type(idl_type), 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(attribute), # [RuntimeEnabled] 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended_attributes else [''], # [PerWorldBindings] } if is_constructor_attribute(attribute): return contents if not has_custom_getter: generate_getter(interface, attribute, contents) if not(attribute.is_read_only or has_custom_setter): contents.update({ 'cpp_setter': setter_expression(interface, attribute, contents), 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value( idl_type, extended_attributes, 'jsValue', 'cppValue'), }) return contents