Chromium Code Reviews| Index: Source/bindings/scripts/unstable/v8_attributes.py |
| diff --git a/Source/bindings/scripts/unstable/v8_attributes.py b/Source/bindings/scripts/unstable/v8_attributes.py |
| index dad1622f805ea577fde8d0316d8d263b8a46b6e1..02f18d1ea86ea5350a2411cd7f767cecd188e10b 100644 |
| --- a/Source/bindings/scripts/unstable/v8_attributes.py |
| +++ b/Source/bindings/scripts/unstable/v8_attributes.py |
| @@ -37,7 +37,7 @@ For details, see bug http://crbug.com/239771 |
| import v8_types |
| import v8_utilities |
| -from v8_utilities import capitalize, cpp_name, has_extended_attribute, uncapitalize |
| +from v8_utilities import capitalize, cpp_name, has_extended_attribute, strip_suffix, uncapitalize |
| def generate_attributes(interface): |
| @@ -57,6 +57,7 @@ def generate_attributes_common(interface, attributes): |
| v8_class_name = v8_utilities.v8_class_name(interface) |
| return { |
| 'has_per_context_enabled_attributes': any(attribute['per_context_enabled_function_name'] for attribute in attributes), |
| + 'has_constructor_getter': any(attribute['is_constructor'] for attribute in attributes), |
| 'has_replaceable_attributes': any(attribute['is_replaceable'] for attribute in attributes), |
| 'has_runtime_enabled_attributes': any(attribute['runtime_enabled_function_name'] for attribute in attributes), |
| 'installed_attributes': '%sAttributes' % v8_class_name if attributes else '0', |
| @@ -82,11 +83,13 @@ def generate_attribute_and_includes(interface, attribute): |
| 'cached_attribute_validation_method': extended_attributes.get('CachedAttribute'), |
| 'conditional_string': v8_utilities.generate_conditional_string(attribute), |
| 'cpp_type': v8_types.cpp_type(idl_type), |
| + 'data': installation_data(attribute), |
| 'getter_callback_name': getter_callback_name(interface, attribute), |
| 'getter_callback_name_for_main_world': getter_callback_name_for_main_world(interface, attribute), |
| 'has_custom_getter': has_custom_getter, |
| 'has_custom_setter': has_custom_setter, |
| 'idl_type': idl_type, |
| + 'is_constructor': is_constructor(attribute), |
| 'is_getter_raises_exception': has_extended_attribute(attribute, ('GetterRaisesException', 'RaisesException')), |
| 'is_keep_alive_for_gc': is_keep_alive_for_gc(attribute), |
| 'is_nullable': attribute.is_nullable, |
| @@ -103,6 +106,9 @@ def generate_attribute_and_includes(interface, attribute): |
| 'runtime_enabled_function_name': v8_utilities.runtime_enabled_function_name(attribute), # [RuntimeEnabled] |
| 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended_attributes else [''], # [PerWorldBindings] |
| } |
| + if is_constructor(attribute): |
| + includes.update(v8_types.includes_for_type(idl_type)) |
| + return contents, includes |
| if not has_custom_getter: |
| generate_getter(interface, attribute, contents, includes) |
| if not (attribute.is_read_only or has_custom_setter): |
| @@ -111,6 +117,8 @@ def generate_attribute_and_includes(interface, attribute): |
| return contents, includes |
| +# Getter |
| + |
| def generate_getter(interface, attribute, contents, includes): |
| idl_type = attribute.data_type |
| includes.update(v8_types.includes_for_type(idl_type)) |
| @@ -225,6 +233,8 @@ def is_keep_alive_for_gc(attribute): |
| idl_type.startswith('HTML')))) |
| +# Setter |
| + |
| def generate_setter(interface, attribute, contents, includes): |
| idl_type = attribute.data_type |
| extended_attributes = attribute.extended_attributes |
| @@ -308,18 +318,24 @@ def scoped_name(interface, attribute, base_name): |
| return 'imp->%s' % base_name |
| +# Attribute configuration |
|
Nils Barth (inactive)
2013/10/23 11:31:34
(Reordered in order of the configuration line.)
|
| + |
| def getter_callback_name(interface, attribute): |
| + if attribute.data_type.endswith('Constructor'): |
| + return '{0}V8Internal::{0}ConstructorGetter'.format(cpp_name(interface)) |
| return '%sV8Internal::%sAttributeGetterCallback' % (cpp_name(interface), attribute.name) |
| +# [Replaceable] |
| def setter_callback_name(interface, attribute): |
| if (attribute.is_read_only and |
| 'Replaceable' not in attribute.extended_attributes): |
| # FIXME: support [PutForwards] |
| return '0' |
| cpp_class_name = cpp_name(interface) |
| - if ('Replaceable' in attribute.extended_attributes and |
| - not has_extended_attribute(attribute, ('Custom', 'CustomSetter'))): |
| + if (('Replaceable' in attribute.extended_attributes and |
| + not has_extended_attribute(attribute, ('Custom', 'CustomSetter'))) or |
| + attribute.data_type.endswith('Constructor')): |
| # Non-custom replaceable attributes have a single interface-level |
| # setter callback (rather than individual attribute-level callbacks), |
| # but custom replaceable attributes have individual callbacks, as usual. |
| @@ -327,6 +343,26 @@ def setter_callback_name(interface, attribute): |
| return '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_name, attribute.name) |
| +# [PerWorldBindings] |
| +def getter_callback_name_for_main_world(interface, attribute): |
| + if 'PerWorldBindings' not in attribute.extended_attributes: |
| + return '0' |
| + return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(interface), attribute.name) |
| + |
| + |
| +def setter_callback_name_for_main_world(interface, attribute): |
| + if ('PerWorldBindings' not in attribute.extended_attributes or |
| + attribute.is_read_only): |
| + return '0' |
| + return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(interface), attribute.name) |
| + |
| + |
| +def installation_data(attribute): |
| + if not is_constructor(attribute): |
| + return '0' |
| + return '&V8%s::info' % v8_types.constructor_type(attribute.data_type) |
| + |
| + |
| # [DoNotCheckSecurity], [DoNotCheckSecurityOnGetter], [DoNotCheckSecurityOnSetter], [Unforgeable] |
| def access_control_list(attribute): |
| extended_attributes = attribute.extended_attributes |
| @@ -348,22 +384,13 @@ def access_control_list(attribute): |
| def property_attributes(attribute): |
| extended_attributes = attribute.extended_attributes |
| property_attributes_list = [] |
| - if 'NotEnumerable' in extended_attributes: |
| + if ('NotEnumerable' in extended_attributes or |
| + is_constructor(attribute)): |
| property_attributes_list.append('v8::DontEnum') |
| if 'Unforgeable' in extended_attributes: |
| property_attributes_list.append('v8::DontDelete') |
| return property_attributes_list or ['v8::None'] |
| -# [PerWorldBindings] |
| -def getter_callback_name_for_main_world(interface, attribute): |
| - if 'PerWorldBindings' not in attribute.extended_attributes: |
| - return '0' |
| - return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(interface), attribute.name) |
| - |
| - |
| -def setter_callback_name_for_main_world(interface, attribute): |
| - if ('PerWorldBindings' not in attribute.extended_attributes or |
| - attribute.is_read_only): |
| - return '0' |
| - return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(interface), attribute.name) |
| +def is_constructor(attribute): |
| + return attribute.data_type.endswith('Constructor') |