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 22 matching lines...) Expand all Loading... |
33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
34 """ | 34 """ |
35 | 35 |
36 import idl_types | 36 import idl_types |
37 from idl_types import inherits_interface | 37 from idl_types import inherits_interface |
38 from v8_globals import includes, interfaces | 38 from v8_globals import includes, interfaces |
39 import v8_types | 39 import v8_types |
40 import v8_utilities | 40 import v8_utilities |
41 from v8_utilities import (cpp_name_or_partial, capitalize, cpp_name, has_extende
d_attribute, | 41 from v8_utilities import (cpp_name_or_partial, capitalize, cpp_name, has_extende
d_attribute, |
42 has_extended_attribute_value, scoped_name, strip_suffi
x, | 42 has_extended_attribute_value, scoped_name, strip_suffi
x, |
43 uncapitalize, extended_attribute_value_as_list) | 43 uncapitalize, extended_attribute_value_as_list, is_unf
orgeable) |
44 | 44 |
45 | 45 |
46 def attribute_context(interface, attribute): | 46 def attribute_context(interface, attribute): |
47 idl_type = attribute.idl_type | 47 idl_type = attribute.idl_type |
48 base_idl_type = idl_type.base_type | 48 base_idl_type = idl_type.base_type |
49 extended_attributes = attribute.extended_attributes | 49 extended_attributes = attribute.extended_attributes |
50 | 50 |
51 idl_type.add_includes_for_type() | 51 idl_type.add_includes_for_type() |
52 | 52 |
53 # [CheckSecurity] | 53 # [CheckSecurity] |
(...skipping 17 matching lines...) Expand all Loading... |
71 | 71 |
72 # [OnlyExposedToPrivateScript] | 72 # [OnlyExposedToPrivateScript] |
73 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended
_attributes | 73 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended
_attributes |
74 | 74 |
75 if (base_idl_type == 'EventHandler' and | 75 if (base_idl_type == 'EventHandler' and |
76 interface.name in ['Window', 'WorkerGlobalScope'] and | 76 interface.name in ['Window', 'WorkerGlobalScope'] and |
77 attribute.name == 'onerror'): | 77 attribute.name == 'onerror'): |
78 includes.add('bindings/core/v8/V8ErrorHandler.h') | 78 includes.add('bindings/core/v8/V8ErrorHandler.h') |
79 | 79 |
80 context = { | 80 context = { |
81 'access_control_list': access_control_list(attribute), | 81 'access_control_list': access_control_list(interface, attribute), |
82 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] | 82 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] |
83 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] | 83 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] |
84 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] | 84 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] |
85 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), | 85 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), |
86 'cached_attribute_validation_method': extended_attributes.get('CachedAtt
ribute'), | 86 'cached_attribute_validation_method': extended_attributes.get('CachedAtt
ribute'), |
87 'conditional_string': v8_utilities.conditional_string(attribute), | 87 'conditional_string': v8_utilities.conditional_string(attribute), |
88 'constructor_type': idl_type.constructor_type_name | 88 'constructor_type': idl_type.constructor_type_name |
89 if is_constructor_attribute(attribute) else None, | 89 if is_constructor_attribute(attribute) else None, |
90 'cpp_name': cpp_name(attribute), | 90 'cpp_name': cpp_name(attribute), |
91 'cpp_type': idl_type.cpp_type, | 91 'cpp_type': idl_type.cpp_type, |
(...skipping 19 matching lines...) Expand all Loading... |
111 'is_nullable': idl_type.is_nullable, | 111 'is_nullable': idl_type.is_nullable, |
112 'is_explicit_nullable': idl_type.is_explicit_nullable, | 112 'is_explicit_nullable': idl_type.is_explicit_nullable, |
113 'is_partial_interface_member': | 113 'is_partial_interface_member': |
114 'PartialInterfaceImplementedAs' in extended_attributes, | 114 'PartialInterfaceImplementedAs' in extended_attributes, |
115 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | 115 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, |
116 'is_read_only': attribute.is_read_only, | 116 'is_read_only': attribute.is_read_only, |
117 'is_reflect': is_reflect, | 117 'is_reflect': is_reflect, |
118 'is_replaceable': 'Replaceable' in attribute.extended_attributes, | 118 'is_replaceable': 'Replaceable' in attribute.extended_attributes, |
119 'is_static': attribute.is_static, | 119 'is_static': attribute.is_static, |
120 'is_url': 'URL' in extended_attributes, | 120 'is_url': 'URL' in extended_attributes, |
121 'is_unforgeable': 'Unforgeable' in extended_attributes, | 121 'is_unforgeable': is_unforgeable(interface, attribute), |
122 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res
ult, | 122 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res
ult, |
123 'measure_as': v8_utilities.measure_as(attribute), # [MeasureAs] | 123 'measure_as': v8_utilities.measure_as(attribute), # [MeasureAs] |
124 'name': attribute.name, | 124 'name': attribute.name, |
125 'only_exposed_to_private_script': is_only_exposed_to_private_script, | 125 'only_exposed_to_private_script': is_only_exposed_to_private_script, |
126 'per_context_enabled_function': v8_utilities.per_context_enabled_functio
n_name(attribute), # [PerContextEnabled] | 126 'per_context_enabled_function': v8_utilities.per_context_enabled_functio
n_name(attribute), # [PerContextEnabled] |
127 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( | 127 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( |
128 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is
olate()', used_in_private_script=True), | 128 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is
olate()', used_in_private_script=True), |
129 'property_attributes': property_attributes(attribute), | 129 'property_attributes': property_attributes(interface, attribute), |
130 'put_forwards': 'PutForwards' in extended_attributes, | 130 'put_forwards': 'PutForwards' in extended_attributes, |
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), | 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), | 137 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), |
138 'world_suffixes': ['', 'ForMainWorld'] | 138 'world_suffixes': ['', 'ForMainWorld'] |
139 if 'PerWorldBindings' in extended_attributes | 139 if 'PerWorldBindings' in extended_attributes |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 'PutForwards' not in extended_attributes) or | 436 'PutForwards' not in extended_attributes) or |
437 is_constructor_attribute(attribute)): | 437 is_constructor_attribute(attribute)): |
438 return '%sV8Internal::%sForceSetAttributeOnThisCallback' % ( | 438 return '%sV8Internal::%sForceSetAttributeOnThisCallback' % ( |
439 cpp_class_name_or_partial, cpp_class_name) | 439 cpp_class_name_or_partial, cpp_class_name) |
440 if attribute.is_read_only and 'PutForwards' not in extended_attributes: | 440 if attribute.is_read_only and 'PutForwards' not in extended_attributes: |
441 return '0' | 441 return '0' |
442 return '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_name_or_partia
l, attribute.name) | 442 return '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_name_or_partia
l, attribute.name) |
443 | 443 |
444 | 444 |
445 # [DoNotCheckSecurity], [Unforgeable] | 445 # [DoNotCheckSecurity], [Unforgeable] |
446 def access_control_list(attribute): | 446 def access_control_list(interface, attribute): |
447 extended_attributes = attribute.extended_attributes | 447 extended_attributes = attribute.extended_attributes |
448 access_control = [] | 448 access_control = [] |
449 if 'DoNotCheckSecurity' in extended_attributes: | 449 if 'DoNotCheckSecurity' in extended_attributes: |
450 do_not_check_security = extended_attributes['DoNotCheckSecurity'] | 450 do_not_check_security = extended_attributes['DoNotCheckSecurity'] |
451 if do_not_check_security == 'Setter': | 451 if do_not_check_security == 'Setter': |
452 access_control.append('v8::ALL_CAN_WRITE') | 452 access_control.append('v8::ALL_CAN_WRITE') |
453 else: | 453 else: |
454 access_control.append('v8::ALL_CAN_READ') | 454 access_control.append('v8::ALL_CAN_READ') |
455 if (not attribute.is_read_only or | 455 if (not attribute.is_read_only or |
456 'Replaceable' in extended_attributes): | 456 'Replaceable' in extended_attributes): |
457 access_control.append('v8::ALL_CAN_WRITE') | 457 access_control.append('v8::ALL_CAN_WRITE') |
458 if 'Unforgeable' in extended_attributes: | 458 if is_unforgeable(interface, attribute): |
459 access_control.append('v8::PROHIBITS_OVERWRITING') | 459 access_control.append('v8::PROHIBITS_OVERWRITING') |
460 return access_control or ['v8::DEFAULT'] | 460 return access_control or ['v8::DEFAULT'] |
461 | 461 |
462 | 462 |
463 # [NotEnumerable], [Unforgeable] | 463 # [NotEnumerable], [Unforgeable] |
464 def property_attributes(attribute): | 464 def property_attributes(interface, attribute): |
465 extended_attributes = attribute.extended_attributes | 465 extended_attributes = attribute.extended_attributes |
466 property_attributes_list = [] | 466 property_attributes_list = [] |
467 if ('NotEnumerable' in extended_attributes or | 467 if ('NotEnumerable' in extended_attributes or |
468 is_constructor_attribute(attribute)): | 468 is_constructor_attribute(attribute)): |
469 property_attributes_list.append('v8::DontEnum') | 469 property_attributes_list.append('v8::DontEnum') |
470 if 'Unforgeable' in extended_attributes: | 470 if is_unforgeable(interface, attribute): |
471 property_attributes_list.append('v8::DontDelete') | 471 property_attributes_list.append('v8::DontDelete') |
472 return property_attributes_list or ['v8::None'] | 472 return property_attributes_list or ['v8::None'] |
473 | 473 |
474 | 474 |
475 # [Custom], [Custom=Getter] | 475 # [Custom], [Custom=Getter] |
476 def has_custom_getter(attribute): | 476 def has_custom_getter(attribute): |
477 extended_attributes = attribute.extended_attributes | 477 extended_attributes = attribute.extended_attributes |
478 return ('Custom' in extended_attributes and | 478 return ('Custom' in extended_attributes and |
479 extended_attributes['Custom'] in [None, 'Getter']) | 479 extended_attributes['Custom'] in [None, 'Getter']) |
480 | 480 |
(...skipping 15 matching lines...) Expand all Loading... |
496 lambda self: strip_suffix(self.base_type, 'Constructor')) | 496 lambda self: strip_suffix(self.base_type, 'Constructor')) |
497 | 497 |
498 | 498 |
499 def is_constructor_attribute(attribute): | 499 def is_constructor_attribute(attribute): |
500 # FIXME: replace this with [ConstructorAttribute] extended attribute | 500 # FIXME: replace this with [ConstructorAttribute] extended attribute |
501 return attribute.idl_type.name.endswith('Constructor') | 501 return attribute.idl_type.name.endswith('Constructor') |
502 | 502 |
503 | 503 |
504 def constructor_getter_context(interface, attribute, context): | 504 def constructor_getter_context(interface, attribute, context): |
505 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 505 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
OLD | NEW |