| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 'only_exposed_to_private_script': is_only_exposed_to_private_script, | 126 'only_exposed_to_private_script': is_only_exposed_to_private_script, |
| 127 'per_context_enabled_function': v8_utilities.per_context_enabled_functio
n_name(attribute), # [PerContextEnabled] | 127 'per_context_enabled_function': v8_utilities.per_context_enabled_functio
n_name(attribute), # [PerContextEnabled] |
| 128 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( | 128 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( |
| 129 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa
lse', isolate='scriptState->isolate()'), | 129 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa
lse', isolate='scriptState->isolate()'), |
| 130 'property_attributes': property_attributes(interface, attribute), | 130 'property_attributes': property_attributes(interface, attribute), |
| 131 'reflect_empty': extended_attributes.get('ReflectEmpty'), | 131 'reflect_empty': extended_attributes.get('ReflectEmpty'), |
| 132 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), | 132 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), |
| 133 'reflect_missing': extended_attributes.get('ReflectMissing'), | 133 'reflect_missing': extended_attributes.get('ReflectMissing'), |
| 134 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly
'), | 134 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly
'), |
| 135 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a
ttribute), # [RuntimeEnabled] | 135 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a
ttribute), # [RuntimeEnabled] |
| 136 'setter_callback': setter_callback_name(interface, attribute), | |
| 137 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), | 136 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), |
| 138 'world_suffixes': ['', 'ForMainWorld'] | 137 'world_suffixes': ['', 'ForMainWorld'] |
| 139 if 'PerWorldBindings' in extended_attributes | 138 if 'PerWorldBindings' in extended_attributes |
| 140 else [''], # [PerWorldBindings] | 139 else [''], # [PerWorldBindings] |
| 141 } | 140 } |
| 142 | 141 |
| 143 if is_constructor_attribute(attribute): | 142 if is_constructor_attribute(attribute): |
| 144 constructor_getter_context(interface, attribute, context) | 143 constructor_getter_context(interface, attribute, context) |
| 145 return context | |
| 146 if not has_custom_getter(attribute): | 144 if not has_custom_getter(attribute): |
| 147 getter_context(interface, attribute, context) | 145 getter_context(interface, attribute, context) |
| 148 if not has_custom_setter(attribute) and has_setter(attribute): | 146 if not has_custom_setter(attribute) and has_setter(attribute): |
| 149 setter_context(interface, attribute, context) | 147 setter_context(interface, attribute, context) |
| 150 | 148 |
| 151 return context | 149 return context |
| 152 | 150 |
| 153 | 151 |
| 154 ################################################################################ | 152 ################################################################################ |
| 155 # Getter | 153 # Getter |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 interface = interfaces[target_interface_name] | 297 interface = interfaces[target_interface_name] |
| 300 try: | 298 try: |
| 301 attribute = next(candidate | 299 attribute = next(candidate |
| 302 for candidate in interface.attributes | 300 for candidate in interface.attributes |
| 303 if candidate.name == target_attribute_name) | 301 if candidate.name == target_attribute_name) |
| 304 except StopIteration: | 302 except StopIteration: |
| 305 raise Exception('[PutForward] target not found:\n' | 303 raise Exception('[PutForward] target not found:\n' |
| 306 'Attribute "%s" is not present in interface "%s"' % | 304 'Attribute "%s" is not present in interface "%s"' % |
| 307 (target_attribute_name, target_interface_name)) | 305 (target_attribute_name, target_interface_name)) |
| 308 | 306 |
| 309 if 'Replaceable' in attribute.extended_attributes: | 307 if ('Replaceable' in attribute.extended_attributes or |
| 308 is_constructor_attribute(attribute)): |
| 310 context['cpp_setter'] = '%sForceSetAttributeOnThis(propertyName, v8Value
, info)' % cpp_name(interface) | 309 context['cpp_setter'] = '%sForceSetAttributeOnThis(propertyName, v8Value
, info)' % cpp_name(interface) |
| 311 return | 310 return |
| 312 | 311 |
| 313 extended_attributes = attribute.extended_attributes | 312 extended_attributes = attribute.extended_attributes |
| 314 idl_type = attribute.idl_type | 313 idl_type = attribute.idl_type |
| 315 | 314 |
| 316 # [RaisesException], [RaisesException=Setter] | 315 # [RaisesException], [RaisesException=Setter] |
| 317 is_setter_raises_exception = ( | 316 is_setter_raises_exception = ( |
| 318 'RaisesException' in extended_attributes and | 317 'RaisesException' in extended_attributes and |
| 319 extended_attributes['RaisesException'] in [None, 'Setter']) | 318 extended_attributes['RaisesException'] in [None, 'Setter']) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 else: | 421 else: |
| 423 namespace = 'HTMLNames' | 422 namespace = 'HTMLNames' |
| 424 includes.add('core/%s.h' % namespace) | 423 includes.add('core/%s.h' % namespace) |
| 425 return '%s::%sAttr' % (namespace, content_attribute_name) | 424 return '%s::%sAttr' % (namespace, content_attribute_name) |
| 426 | 425 |
| 427 | 426 |
| 428 ################################################################################ | 427 ################################################################################ |
| 429 # Attribute configuration | 428 # Attribute configuration |
| 430 ################################################################################ | 429 ################################################################################ |
| 431 | 430 |
| 432 def setter_callback_name(interface, attribute): | |
| 433 cpp_class_name = cpp_name(interface) | |
| 434 cpp_class_name_or_partial = cpp_name_or_partial(interface) | |
| 435 | |
| 436 if not has_setter(attribute): | |
| 437 return '0' | |
| 438 if (is_constructor_attribute(attribute)): | |
| 439 return '%sV8Internal::%sForceSetAttributeOnThisCallback' % ( | |
| 440 cpp_class_name_or_partial, cpp_class_name) | |
| 441 return '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_name_or_partia
l, attribute.name) | |
| 442 | |
| 443 | |
| 444 # [PutForwards], [Replaceable] | 431 # [PutForwards], [Replaceable] |
| 445 def has_setter(attribute): | 432 def has_setter(attribute): |
| 446 return (not attribute.is_read_only or | 433 return (not attribute.is_read_only or |
| 447 'PutForwards' in attribute.extended_attributes or | 434 'PutForwards' in attribute.extended_attributes or |
| 448 'Replaceable' in attribute.extended_attributes) | 435 'Replaceable' in attribute.extended_attributes) |
| 449 | 436 |
| 450 | 437 |
| 451 # [DoNotCheckSecurity], [Unforgeable] | 438 # [DoNotCheckSecurity], [Unforgeable] |
| 452 def access_control_list(interface, attribute): | 439 def access_control_list(interface, attribute): |
| 453 extended_attributes = attribute.extended_attributes | 440 extended_attributes = attribute.extended_attributes |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 lambda self: strip_suffix(self.base_type, 'Constructor')) | 488 lambda self: strip_suffix(self.base_type, 'Constructor')) |
| 502 | 489 |
| 503 | 490 |
| 504 def is_constructor_attribute(attribute): | 491 def is_constructor_attribute(attribute): |
| 505 # FIXME: replace this with [ConstructorAttribute] extended attribute | 492 # FIXME: replace this with [ConstructorAttribute] extended attribute |
| 506 return attribute.idl_type.name.endswith('Constructor') | 493 return attribute.idl_type.name.endswith('Constructor') |
| 507 | 494 |
| 508 | 495 |
| 509 def constructor_getter_context(interface, attribute, context): | 496 def constructor_getter_context(interface, attribute, context): |
| 510 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 497 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
| OLD | NEW |