| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 | 66 |
| 67 def generate_attribute_and_includes(interface, attribute): | 67 def generate_attribute_and_includes(interface, attribute): |
| 68 idl_type = attribute.data_type | 68 idl_type = attribute.data_type |
| 69 extended_attributes = attribute.extended_attributes | 69 extended_attributes = attribute.extended_attributes |
| 70 | 70 |
| 71 has_custom_getter = has_extended_attribute(attribute, ('Custom', 'CustomGett
er')) | 71 has_custom_getter = has_extended_attribute(attribute, ('Custom', 'CustomGett
er')) |
| 72 has_setter = not attribute.is_read_only # FIXME: support [PutForwards], [Re
flect], and [Replaceable] | 72 has_setter = not attribute.is_read_only # FIXME: support [PutForwards], [Re
flect], and [Replaceable] |
| 73 has_custom_setter = has_setter and has_extended_attribute(attribute, ('Custo
m', 'CustomSetter')) | 73 has_custom_setter = has_setter and has_extended_attribute(attribute, ('Custo
m', 'CustomSetter')) |
| 74 includes = set() |
| 74 contents = { | 75 contents = { |
| 75 'access_control_list': access_control_list(attribute), | 76 'access_control_list': access_control_list(attribute), |
| 77 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, includes, 'Getter'), # [ActivityLogging] |
| 78 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, includes, 'Setter'), # [ActivityLogging] |
| 76 'cached_attribute_validation_method': extended_attributes.get('CachedAtt
ribute'), | 79 'cached_attribute_validation_method': extended_attributes.get('CachedAtt
ribute'), |
| 77 'conditional_string': v8_utilities.generate_conditional_string(attribute
), | 80 'conditional_string': v8_utilities.generate_conditional_string(attribute
), |
| 78 'cpp_type': v8_types.cpp_type(idl_type), | 81 'cpp_type': v8_types.cpp_type(idl_type), |
| 79 'getter_callback_name': getter_callback_name(interface, attribute), | 82 'getter_callback_name': getter_callback_name(interface, attribute), |
| 80 'getter_callback_name_for_main_world': getter_callback_name_for_main_wor
ld(interface, attribute), | 83 'getter_callback_name_for_main_world': getter_callback_name_for_main_wor
ld(interface, attribute), |
| 81 'has_custom_getter': has_custom_getter, | 84 'has_custom_getter': has_custom_getter, |
| 82 'has_custom_setter': has_custom_setter, | 85 'has_custom_setter': has_custom_setter, |
| 83 'has_setter': has_setter, | 86 'has_setter': has_setter, |
| 84 'idl_type': idl_type, | 87 'idl_type': idl_type, |
| 85 'is_getter_raises_exception': has_extended_attribute(attribute, ('Getter
RaisesException', 'RaisesException')), | 88 'is_getter_raises_exception': has_extended_attribute(attribute, ('Getter
RaisesException', 'RaisesException')), |
| 86 'is_keep_alive_for_gc': is_keep_alive_for_gc(attribute), | 89 'is_keep_alive_for_gc': is_keep_alive_for_gc(attribute), |
| 87 'is_nullable': attribute.is_nullable, | 90 'is_nullable': attribute.is_nullable, |
| 88 'is_static': attribute.is_static, | 91 'is_static': attribute.is_static, |
| 89 'name': attribute.name, | 92 'name': attribute.name, |
| 90 'per_context_enabled_function_name': v8_utilities.per_context_enabled_fu
nction_name(attribute), # [PerContextEnabled] | 93 'per_context_enabled_function_name': v8_utilities.per_context_enabled_fu
nction_name(attribute), # [PerContextEnabled] |
| 91 'property_attributes': property_attributes(attribute), | 94 'property_attributes': property_attributes(attribute), |
| 92 'setter_callback_name': setter_callback_name(interface, attribute), | 95 'setter_callback_name': setter_callback_name(interface, attribute), |
| 93 'setter_callback_name_for_main_world': setter_callback_name_for_main_wor
ld(interface, attribute), | 96 'setter_callback_name_for_main_world': setter_callback_name_for_main_wor
ld(interface, attribute), |
| 94 'v8_type': v8_types.v8_type(idl_type), | 97 'v8_type': v8_types.v8_type(idl_type), |
| 95 'runtime_enabled_function_name': v8_utilities.runtime_enabled_function_n
ame(attribute), # [RuntimeEnabled] | 98 'runtime_enabled_function_name': v8_utilities.runtime_enabled_function_n
ame(attribute), # [RuntimeEnabled] |
| 96 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings] | 99 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings] |
| 97 } | 100 } |
| 98 includes = set() | |
| 99 if not has_custom_getter: | 101 if not has_custom_getter: |
| 100 generate_getter(interface, attribute, contents, includes) | 102 generate_getter(interface, attribute, contents, includes) |
| 101 if has_setter and not has_custom_setter: | 103 if has_setter and not has_custom_setter: |
| 102 generate_setter(interface, attribute, contents, includes) | 104 generate_setter(interface, attribute, contents, includes) |
| 103 | 105 |
| 104 return contents, includes | 106 return contents, includes |
| 105 | 107 |
| 106 | 108 |
| 107 def generate_getter(interface, attribute, contents, includes): | 109 def generate_getter(interface, attribute, contents, includes): |
| 108 idl_type = attribute.data_type | 110 idl_type = attribute.data_type |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 includes.add('bindings/v8/BindingSecurity.h') | 144 includes.add('bindings/v8/BindingSecurity.h') |
| 143 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA
s] | 145 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA
s] |
| 144 | 146 |
| 145 # [DeprecateAs] | 147 # [DeprecateAs] |
| 146 v8_utilities.generate_deprecate_as(attribute, contents, includes) | 148 v8_utilities.generate_deprecate_as(attribute, contents, includes) |
| 147 if is_check_security_for_node or contents['is_getter_raises_exception']: | 149 if is_check_security_for_node or contents['is_getter_raises_exception']: |
| 148 includes.update(set(['bindings/v8/ExceptionMessages.h', | 150 includes.update(set(['bindings/v8/ExceptionMessages.h', |
| 149 'bindings/v8/ExceptionState.h'])) | 151 'bindings/v8/ExceptionState.h'])) |
| 150 | 152 |
| 151 contents.update({ | 153 contents.update({ |
| 152 'activity_logging_getter': v8_utilities.has_activity_logging(attribute,
includes, 'Getter'), # [ActivityLogging] | |
| 153 'is_check_security_for_node': is_check_security_for_node, | 154 'is_check_security_for_node': is_check_security_for_node, |
| 154 'is_unforgeable': 'Unforgeable' in extended_attributes, | 155 'is_unforgeable': 'Unforgeable' in extended_attributes, |
| 155 }) | 156 }) |
| 156 | 157 |
| 157 | 158 |
| 158 def getter_expression(interface, attribute, contents, includes): | 159 def getter_expression(interface, attribute, contents, includes): |
| 159 arguments = [] | 160 arguments = [] |
| 160 if 'Reflect' in attribute.extended_attributes: | 161 if 'Reflect' in attribute.extended_attributes: |
| 161 getter_base_name = content_attribute_getter_base_name(attribute, include
s, arguments) | 162 getter_base_name = content_attribute_getter_base_name(attribute, include
s, arguments) |
| 162 else: | 163 else: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return 'fastGetAttribute' | 202 return 'fastGetAttribute' |
| 202 | 203 |
| 203 | 204 |
| 204 def generate_setter(interface, attribute, contents, includes): | 205 def generate_setter(interface, attribute, contents, includes): |
| 205 idl_type = attribute.data_type | 206 idl_type = attribute.data_type |
| 206 if v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type
): | 207 if v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type
): |
| 207 cpp_value = 'WTF::getPtr(cppValue)' | 208 cpp_value = 'WTF::getPtr(cppValue)' |
| 208 else: | 209 else: |
| 209 cpp_value = 'cppValue' | 210 cpp_value = 'cppValue' |
| 210 contents.update({ | 211 contents.update({ |
| 211 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value(idl_
type, attribute.extended_attributes, 'jsValue', 'cppValue', includes, 'info.GetI
solate()'), | |
| 212 'cpp_setter': setter_expression(interface, attribute, contents), | 212 'cpp_setter': setter_expression(interface, attribute, contents), |
| 213 'enum_validation_expression': enum_validation_expression(idl_type), | 213 'enum_validation_expression': enum_validation_expression(idl_type), |
| 214 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value(idl_
type, attribute.extended_attributes, 'jsValue', 'cppValue', includes, 'info.GetI
solate()'), |
| 214 }) | 215 }) |
| 215 | 216 |
| 216 | 217 |
| 217 def setter_expression(interface, attribute, contents): | 218 def setter_expression(interface, attribute, contents): |
| 218 arguments = v8_utilities.call_with_arguments(attribute, contents) | 219 arguments = v8_utilities.call_with_arguments(attribute, contents) |
| 219 idl_type = attribute.data_type | 220 idl_type = attribute.data_type |
| 220 # FIXME: should be able to eliminate WTF::getPtr in most or all cases | 221 # FIXME: should be able to eliminate WTF::getPtr in most or all cases |
| 221 cpp_value = 'WTF::getPtr(cppValue)' if v8_types.is_interface_type(idl_type)
and not v8_types.array_type(idl_type) else 'cppValue' | 222 cpp_value = 'WTF::getPtr(cppValue)' if v8_types.is_interface_type(idl_type)
and not v8_types.array_type(idl_type) else 'cppValue' |
| 222 arguments.append(cpp_value) | 223 arguments.append(cpp_value) |
| 223 setter_name = scoped_name(interface, attribute, 'set%s' % capitalize(cpp_nam
e(attribute))) | 224 setter_name = scoped_name(interface, attribute, 'set%s' % capitalize(cpp_nam
e(attribute))) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 if 'PerWorldBindings' not in attribute.extended_attributes: | 302 if 'PerWorldBindings' not in attribute.extended_attributes: |
| 302 return '0' | 303 return '0' |
| 303 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int
erface), attribute.name) | 304 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int
erface), attribute.name) |
| 304 | 305 |
| 305 | 306 |
| 306 def setter_callback_name_for_main_world(interface, attribute): | 307 def setter_callback_name_for_main_world(interface, attribute): |
| 307 if ('PerWorldBindings' not in attribute.extended_attributes or | 308 if ('PerWorldBindings' not in attribute.extended_attributes or |
| 308 attribute.is_read_only): | 309 attribute.is_read_only): |
| 309 return '0' | 310 return '0' |
| 310 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int
erface), attribute.name) | 311 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int
erface), attribute.name) |
| OLD | NEW |