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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 'is_save_same_object': ( | 138 'is_save_same_object': ( |
139 'SameObject' in attribute.extended_attributes and | 139 'SameObject' in attribute.extended_attributes and |
140 'SaveSameObject' in attribute.extended_attributes), | 140 'SaveSameObject' in attribute.extended_attributes), |
141 'is_static': attribute.is_static, | 141 'is_static': attribute.is_static, |
142 'is_url': 'URL' in extended_attributes, | 142 'is_url': 'URL' in extended_attributes, |
143 'is_unforgeable': is_unforgeable(interface, attribute), | 143 'is_unforgeable': is_unforgeable(interface, attribute), |
144 'on_instance': v8_utilities.on_instance(interface, attribute), | 144 'on_instance': v8_utilities.on_instance(interface, attribute), |
145 'on_interface': v8_utilities.on_interface(interface, attribute), | 145 'on_interface': v8_utilities.on_interface(interface, attribute), |
146 'on_prototype': v8_utilities.on_prototype(interface, attribute), | 146 'on_prototype': v8_utilities.on_prototype(interface, attribute), |
147 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct
ion_name(attribute), # [OriginTrialEnabled] | 147 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct
ion_name(attribute), # [OriginTrialEnabled] |
| 148 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attr
ibute), # [OriginTrialEnabled] |
148 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res
ult, | 149 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res
ult, |
149 'measure_as': v8_utilities.measure_as(attribute, interface), # [Measure
As] | 150 'measure_as': v8_utilities.measure_as(attribute, interface), # [Measure
As] |
150 'name': attribute.name, | 151 'name': attribute.name, |
151 'only_exposed_to_private_script': is_only_exposed_to_private_script, | 152 'only_exposed_to_private_script': is_only_exposed_to_private_script, |
152 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( | 153 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( |
153 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa
lse', isolate='scriptState->isolate()'), | 154 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa
lse', isolate='scriptState->isolate()'), |
154 'property_attributes': property_attributes(interface, attribute), | 155 'property_attributes': property_attributes(interface, attribute), |
155 'reflect_empty': extended_attributes.get('ReflectEmpty'), | 156 'reflect_empty': extended_attributes.get('ReflectEmpty'), |
156 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), | 157 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), |
157 'reflect_missing': extended_attributes.get('ReflectMissing'), | 158 'reflect_missing': extended_attributes.get('ReflectMissing'), |
158 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly
'), | 159 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly
'), |
159 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a
ttribute), # [RuntimeEnabled] | 160 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a
ttribute), # [RuntimeEnabled] |
160 'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), #
[RuntimeEnabled] | 161 'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), #
[RuntimeEnabled] |
161 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), | 162 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), |
162 'world_suffixes': ( | 163 'world_suffixes': ( |
163 ['', 'ForMainWorld'] | 164 ['', 'ForMainWorld'] |
164 if 'PerWorldBindings' in extended_attributes | 165 if 'PerWorldBindings' in extended_attributes |
165 else ['']), # [PerWorldBindings] | 166 else ['']), # [PerWorldBindings] |
166 } | 167 } |
167 | 168 |
168 if is_constructor_attribute(attribute): | 169 if is_constructor_attribute(attribute): |
169 update_constructor_attribute_context(interface, attribute, context) | 170 update_constructor_attribute_context(interface, attribute, context) |
170 if not has_custom_getter(attribute): | 171 if not has_custom_getter(attribute): |
171 getter_context(interface, attribute, context) | 172 getter_context(interface, attribute, context) |
172 if not has_custom_setter(attribute) and has_setter(interface, attribute): | 173 if not has_custom_setter(attribute) and has_setter(interface, attribute): |
173 setter_context(interface, attribute, context) | 174 setter_context(interface, attribute, context) |
174 | 175 |
| 176 # [OriginTrialEnabled] |
| 177 # TODO(iclelland): Allow origin trials on static interfaces |
| 178 # (crbug.com/614352) |
| 179 if context['origin_trial_feature_name'] and context['on_interface']: |
| 180 raise Exception('[OriginTrialEnabled] cannot be specified on static ' |
| 181 'attributes: %s.%s' % (interface.name, attribute.name)) |
| 182 |
175 return context | 183 return context |
176 | 184 |
177 | 185 |
178 def filter_has_accessor_configuration(attributes): | 186 def filter_has_accessor_configuration(attributes): |
179 return [attribute for attribute in attributes if | 187 return [attribute for attribute in attributes if |
180 not (attribute['exposed_test'] or | 188 not (attribute['exposed_test'] or |
| 189 attribute['origin_trial_enabled_function'] or |
181 attribute['runtime_enabled_function']) and | 190 attribute['runtime_enabled_function']) and |
182 not attribute['is_data_type_property'] and | 191 not attribute['is_data_type_property'] and |
183 attribute['should_be_exposed_to_script']] | 192 attribute['should_be_exposed_to_script']] |
184 | 193 |
185 | 194 |
186 def filter_has_attribute_configuration(attributes): | 195 def filter_has_attribute_configuration(attributes): |
187 return [attribute for attribute in attributes if | 196 return [attribute for attribute in attributes if |
188 not (attribute['exposed_test'] or | 197 not (attribute['exposed_test'] or |
| 198 attribute['origin_trial_enabled_function'] or |
189 attribute['runtime_enabled_function']) and | 199 attribute['runtime_enabled_function']) and |
190 attribute['is_data_type_property'] and | 200 attribute['is_data_type_property'] and |
191 attribute['should_be_exposed_to_script']] | 201 attribute['should_be_exposed_to_script']] |
192 | 202 |
193 | 203 |
| 204 def filter_origin_trial_enabled(attributes): |
| 205 return [attribute for attribute in attributes if |
| 206 attribute['origin_trial_feature_name'] and |
| 207 not attribute['exposed_test']] |
| 208 |
| 209 |
194 def filter_runtime_enabled(attributes): | 210 def filter_runtime_enabled(attributes): |
195 return [attribute for attribute in attributes if | 211 return [attribute for attribute in attributes if |
196 attribute['runtime_feature_name'] and | 212 attribute['runtime_feature_name'] and |
197 not attribute['exposed_test']] | 213 not attribute['exposed_test']] |
198 | 214 |
199 | 215 |
200 def attribute_filters(): | 216 def attribute_filters(): |
201 return {'has_accessor_configuration': filter_has_accessor_configuration, | 217 return {'has_accessor_configuration': filter_has_accessor_configuration, |
202 'has_attribute_configuration': filter_has_attribute_configuration, | 218 'has_attribute_configuration': filter_has_attribute_configuration, |
| 219 'origin_trial_enabled_attributes': filter_origin_trial_enabled, |
203 'runtime_enabled_attributes': filter_runtime_enabled, | 220 'runtime_enabled_attributes': filter_runtime_enabled, |
204 } | 221 } |
205 | 222 |
206 | 223 |
207 ################################################################################ | 224 ################################################################################ |
208 # Getter | 225 # Getter |
209 ################################################################################ | 226 ################################################################################ |
210 | 227 |
211 def getter_context(interface, attribute, context): | 228 def getter_context(interface, attribute, context): |
212 idl_type = attribute.idl_type | 229 idl_type = attribute.idl_type |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 # FIXME: replace this with a [ConstructorAttribute] extended attribute | 562 # FIXME: replace this with a [ConstructorAttribute] extended attribute |
546 lambda self: strip_suffix(self.base_type, 'Constructor')) | 563 lambda self: strip_suffix(self.base_type, 'Constructor')) |
547 | 564 |
548 | 565 |
549 def is_constructor_attribute(attribute): | 566 def is_constructor_attribute(attribute): |
550 # FIXME: replace this with [ConstructorAttribute] extended attribute | 567 # FIXME: replace this with [ConstructorAttribute] extended attribute |
551 return attribute.idl_type.name.endswith('Constructor') | 568 return attribute.idl_type.name.endswith('Constructor') |
552 | 569 |
553 | 570 |
554 def update_constructor_attribute_context(interface, attribute, context): | 571 def update_constructor_attribute_context(interface, attribute, context): |
555 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] or context['origin_trial_enabled_function'] # TODO(chasej):
Should/can this be true when OriginTrialEnabled is inherited from containing in
terface? | 572 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
OLD | NEW |