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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 constructor_type = idl_type.constructor_type_name if is_constructor_attribut
e(attribute) else None | 86 constructor_type = idl_type.constructor_type_name if is_constructor_attribut
e(attribute) else None |
87 # [CEReactions] | 87 # [CEReactions] |
88 is_ce_reactions = 'CEReactions' in extended_attributes | 88 is_ce_reactions = 'CEReactions' in extended_attributes |
89 if is_ce_reactions: | 89 if is_ce_reactions: |
90 includes.add('core/dom/custom/CEReactionsScope.h') | 90 includes.add('core/dom/custom/CEReactionsScope.h') |
91 # [CustomElementCallbacks], [Reflect] | 91 # [CustomElementCallbacks], [Reflect] |
92 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s | 92 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s |
93 is_reflect = 'Reflect' in extended_attributes | 93 is_reflect = 'Reflect' in extended_attributes |
94 if is_custom_element_callbacks or is_reflect: | 94 if is_custom_element_callbacks or is_reflect: |
95 includes.add('core/dom/custom/V0CustomElementProcessingStack.h') | 95 includes.add('core/dom/custom/V0CustomElementProcessingStack.h') |
96 # [ImplementedInPrivateScript] | |
97 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_
attributes | |
98 if is_implemented_in_private_script: | |
99 includes.add('bindings/core/v8/PrivateScriptRunner.h') | |
100 includes.add('core/frame/LocalFrame.h') | |
101 includes.add('platform/ScriptForbiddenScope.h') | |
102 # [OnlyExposedToPrivateScript] | |
103 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended
_attributes | |
104 # [PerWorldBindings] | 96 # [PerWorldBindings] |
105 if 'PerWorldBindings' in extended_attributes: | 97 if 'PerWorldBindings' in extended_attributes: |
106 assert idl_type.is_wrapper_type or 'LogActivity' in extended_attributes,
'[PerWorldBindings] should only be used with wrapper types: %s.%s' % (interface
.name, attribute.name) | 98 assert idl_type.is_wrapper_type or 'LogActivity' in extended_attributes,
'[PerWorldBindings] should only be used with wrapper types: %s.%s' % (interface
.name, attribute.name) |
107 # [SaveSameObject] | 99 # [SaveSameObject] |
108 is_save_same_object = ( | 100 is_save_same_object = ( |
109 'SameObject' in attribute.extended_attributes and | 101 'SameObject' in attribute.extended_attributes and |
110 'SaveSameObject' in attribute.extended_attributes) | 102 'SaveSameObject' in attribute.extended_attributes) |
111 if is_save_same_object: | 103 if is_save_same_object: |
112 includes.add('bindings/core/v8/V8PrivateProperty.h') | 104 includes.add('bindings/core/v8/V8PrivateProperty.h') |
113 | 105 |
(...skipping 10 matching lines...) Expand all Loading... |
124 # [CachedAccessor] | 116 # [CachedAccessor] |
125 is_cached_accessor = 'CachedAccessor' in extended_attributes | 117 is_cached_accessor = 'CachedAccessor' in extended_attributes |
126 if is_cached_accessor: | 118 if is_cached_accessor: |
127 includes.add('bindings/core/v8/V8PrivateProperty.h') | 119 includes.add('bindings/core/v8/V8PrivateProperty.h') |
128 | 120 |
129 context = { | 121 context = { |
130 'access_control_list': access_control_list(interface, attribute), | 122 'access_control_list': access_control_list(interface, attribute), |
131 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] | 123 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] |
132 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] | 124 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] |
133 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] | 125 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] |
134 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), | |
135 'cached_attribute_validation_method': cached_attribute_validation_method
, | 126 'cached_attribute_validation_method': cached_attribute_validation_method
, |
136 'constructor_type': constructor_type, | 127 'constructor_type': constructor_type, |
137 'cpp_name': cpp_name(attribute), | 128 'cpp_name': cpp_name(attribute), |
138 'cpp_type': idl_type.cpp_type, | 129 'cpp_type': idl_type.cpp_type, |
139 'cpp_type_initializer': idl_type.cpp_type_initializer, | 130 'cpp_type_initializer': idl_type.cpp_type_initializer, |
140 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] | 131 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] |
141 'enum_type': idl_type.enum_type, | 132 'enum_type': idl_type.enum_type, |
142 'enum_values': idl_type.enum_values, | 133 'enum_values': idl_type.enum_values, |
143 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] | 134 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] |
144 'has_cross_origin_getter': | 135 'has_cross_origin_getter': |
145 has_extended_attribute_value(attribute, 'CrossOrigin', None) or | 136 has_extended_attribute_value(attribute, 'CrossOrigin', None) or |
146 has_extended_attribute_value(attribute, 'CrossOrigin', 'Getter'), | 137 has_extended_attribute_value(attribute, 'CrossOrigin', 'Getter'), |
147 'has_cross_origin_setter': has_extended_attribute_value(attribute, 'Cros
sOrigin', 'Setter'), | 138 'has_cross_origin_setter': has_extended_attribute_value(attribute, 'Cros
sOrigin', 'Setter'), |
148 'has_custom_getter': has_custom_getter(attribute), | 139 'has_custom_getter': has_custom_getter(attribute), |
149 'has_custom_setter': has_custom_setter(attribute), | 140 'has_custom_setter': has_custom_setter(attribute), |
150 'has_setter': has_setter(interface, attribute), | 141 'has_setter': has_setter(interface, attribute), |
151 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType | 142 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType |
152 'is_cached_accessor': is_cached_accessor, | 143 'is_cached_accessor': is_cached_accessor, |
153 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), | 144 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), |
154 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), | 145 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), |
155 'is_ce_reactions': is_ce_reactions, | 146 'is_ce_reactions': is_ce_reactions, |
156 'is_check_security_for_receiver': is_check_security_for_receiver, | 147 'is_check_security_for_receiver': is_check_security_for_receiver, |
157 'is_check_security_for_return_value': is_check_security_for_return_value
, | 148 'is_check_security_for_return_value': is_check_security_for_return_value
, |
158 'is_custom_element_callbacks': is_custom_element_callbacks, | 149 'is_custom_element_callbacks': is_custom_element_callbacks, |
159 # TODO(yukishiino): Make all DOM attributes accessor-type properties. | 150 # TODO(yukishiino): Make all DOM attributes accessor-type properties. |
160 'is_data_type_property': is_data_type_property(interface, attribute), | 151 'is_data_type_property': is_data_type_property(interface, attribute), |
161 'is_getter_raises_exception': # [RaisesException] | 152 'is_getter_raises_exception': # [RaisesException] |
162 'RaisesException' in extended_attributes and | 153 'RaisesException' in extended_attributes and |
163 extended_attributes['RaisesException'] in (None, 'Getter'), | 154 extended_attributes['RaisesException'] in (None, 'Getter'), |
164 'is_implemented_in_private_script': is_implemented_in_private_script, | |
165 'is_keep_alive_for_gc': keep_alive_for_gc, | 155 'is_keep_alive_for_gc': keep_alive_for_gc, |
166 'is_lenient_this': 'LenientThis' in extended_attributes, | 156 'is_lenient_this': 'LenientThis' in extended_attributes, |
167 'is_nullable': idl_type.is_nullable, | 157 'is_nullable': idl_type.is_nullable, |
168 'is_explicit_nullable': idl_type.is_explicit_nullable, | 158 'is_explicit_nullable': idl_type.is_explicit_nullable, |
169 'is_partial_interface_member': | 159 'is_partial_interface_member': |
170 'PartialInterfaceImplementedAs' in extended_attributes, | 160 'PartialInterfaceImplementedAs' in extended_attributes, |
171 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | 161 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, |
172 'is_put_forwards': 'PutForwards' in extended_attributes, | 162 'is_put_forwards': 'PutForwards' in extended_attributes, |
173 'is_read_only': attribute.is_read_only, | 163 'is_read_only': attribute.is_read_only, |
174 'is_reflect': is_reflect, | 164 'is_reflect': is_reflect, |
175 'is_replaceable': 'Replaceable' in attribute.extended_attributes, | 165 'is_replaceable': 'Replaceable' in attribute.extended_attributes, |
176 'is_save_same_object': is_save_same_object, | 166 'is_save_same_object': is_save_same_object, |
177 'is_static': attribute.is_static, | 167 'is_static': attribute.is_static, |
178 'is_url': 'URL' in extended_attributes, | 168 'is_url': 'URL' in extended_attributes, |
179 'is_unforgeable': is_unforgeable(interface, attribute), | 169 'is_unforgeable': is_unforgeable(interface, attribute), |
180 'on_instance': v8_utilities.on_instance(interface, attribute), | 170 'on_instance': v8_utilities.on_instance(interface, attribute), |
181 'on_interface': v8_utilities.on_interface(interface, attribute), | 171 'on_interface': v8_utilities.on_interface(interface, attribute), |
182 'on_prototype': v8_utilities.on_prototype(interface, attribute), | 172 'on_prototype': v8_utilities.on_prototype(interface, attribute), |
183 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct
ion_name(attribute), # [OriginTrialEnabled] | 173 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct
ion_name(attribute), # [OriginTrialEnabled] |
184 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attr
ibute), # [OriginTrialEnabled] | 174 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attr
ibute), # [OriginTrialEnabled] |
185 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res
ult, | 175 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res
ult, |
186 'measure_as': v8_utilities.measure_as(attribute, interface), # [Measure
As] | 176 'measure_as': v8_utilities.measure_as(attribute, interface), # [Measure
As] |
187 'name': attribute.name, | 177 'name': attribute.name, |
188 'only_exposed_to_private_script': is_only_exposed_to_private_script, | |
189 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( | |
190 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa
lse', isolate='scriptState->isolate()'), | |
191 'property_attributes': property_attributes(interface, attribute), | 178 'property_attributes': property_attributes(interface, attribute), |
192 'reflect_empty': extended_attributes.get('ReflectEmpty'), | 179 'reflect_empty': extended_attributes.get('ReflectEmpty'), |
193 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), | 180 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), |
194 'reflect_missing': extended_attributes.get('ReflectMissing'), | 181 'reflect_missing': extended_attributes.get('ReflectMissing'), |
195 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly
'), | 182 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly
'), |
196 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a
ttribute), # [RuntimeEnabled] | 183 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a
ttribute), # [RuntimeEnabled] |
197 'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), #
[RuntimeEnabled] | 184 'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), #
[RuntimeEnabled] |
198 'secure_context_test': v8_utilities.secure_context(attribute, interface)
, # [SecureContext] | 185 'secure_context_test': v8_utilities.secure_context(attribute, interface)
, # [SecureContext] |
199 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), | |
200 'cached_accessor_name': '%s%sCachedAccessor' % (interface.name, attribut
e.name.capitalize()), | 186 'cached_accessor_name': '%s%sCachedAccessor' % (interface.name, attribut
e.name.capitalize()), |
201 'world_suffixes': ( | 187 'world_suffixes': ( |
202 ['', 'ForMainWorld'] | 188 ['', 'ForMainWorld'] |
203 if 'PerWorldBindings' in extended_attributes | 189 if 'PerWorldBindings' in extended_attributes |
204 else ['']), # [PerWorldBindings] | 190 else ['']), # [PerWorldBindings] |
205 } | 191 } |
206 | 192 |
207 if is_constructor_attribute(attribute): | 193 if is_constructor_attribute(attribute): |
208 update_constructor_attribute_context(interface, attribute, context) | 194 update_constructor_attribute_context(interface, attribute, context) |
209 if not has_custom_getter(attribute): | 195 if not has_custom_getter(attribute): |
210 getter_context(interface, attribute, context) | 196 getter_context(interface, attribute, context) |
211 if not has_custom_setter(attribute) and has_setter(interface, attribute): | 197 if not has_custom_setter(attribute) and has_setter(interface, attribute): |
212 setter_context(interface, attribute, interfaces, context) | 198 setter_context(interface, attribute, interfaces, context) |
213 | 199 |
214 # [CrossOrigin] is incompatible with a number of other attributes, so check | 200 # [CrossOrigin] is incompatible with a number of other attributes, so check |
215 # for them here. | 201 # for them here. |
216 if is_cross_origin: | 202 if is_cross_origin: |
217 if context['has_cross_origin_getter'] and context['has_custom_getter']: | 203 if context['has_cross_origin_getter'] and context['has_custom_getter']: |
218 raise Exception('[CrossOrigin] and [Custom] are incompatible on the
same getter: %s.%s', interface.name, attribute.name) | 204 raise Exception('[CrossOrigin] and [Custom] are incompatible on the
same getter: %s.%s', interface.name, attribute.name) |
219 if context['has_cross_origin_setter'] and context['has_custom_setter']: | 205 if context['has_cross_origin_setter'] and context['has_custom_setter']: |
220 raise Exception('[CrossOrigin] and [Custom] are incompatible on the
same setter: %s.%s', interface.name, attribute.name) | 206 raise Exception('[CrossOrigin] and [Custom] are incompatible on the
same setter: %s.%s', interface.name, attribute.name) |
221 if context['is_per_world_bindings']: | 207 if context['is_per_world_bindings']: |
222 raise Exception('[CrossOrigin] and [PerWorldBindings] are incompatib
le: %s.%s', interface.name, attribute.name) | 208 raise Exception('[CrossOrigin] and [PerWorldBindings] are incompatib
le: %s.%s', interface.name, attribute.name) |
223 if context['constructor_type']: | 209 if context['constructor_type']: |
224 raise Exception('[CrossOrigin] cannot be used for constructors: %s.%
s', interface.name, attribute.name) | 210 raise Exception('[CrossOrigin] cannot be used for constructors: %s.%
s', interface.name, attribute.name) |
225 if not context['should_be_exposed_to_script']: | |
226 raise Exception('[CrossOrigin] attributes must be exposed to script:
%s.%s', interface.name, attribute.name) | |
227 | 211 |
228 return context | 212 return context |
229 | 213 |
230 | 214 |
231 def filter_accessors(attributes): | 215 def filter_accessors(attributes): |
232 return [attribute for attribute in attributes if | 216 return [attribute for attribute in attributes if |
233 not (attribute['exposed_test'] or | 217 not (attribute['exposed_test'] or |
234 attribute['secure_context_test'] or | 218 attribute['secure_context_test'] or |
235 attribute['origin_trial_enabled_function'] or | 219 attribute['origin_trial_enabled_function'] or |
236 attribute['runtime_enabled_function']) and | 220 attribute['runtime_enabled_function']) and |
237 not attribute['is_data_type_property'] and | 221 not attribute['is_data_type_property']] |
238 attribute['should_be_exposed_to_script']] | |
239 | 222 |
240 | 223 |
241 def is_data_attribute(attribute): | 224 def is_data_attribute(attribute): |
242 return (not (attribute['exposed_test'] or | 225 return (not (attribute['exposed_test'] or |
243 attribute['secure_context_test'] or | 226 attribute['secure_context_test'] or |
244 attribute['origin_trial_enabled_function'] or | 227 attribute['origin_trial_enabled_function'] or |
245 attribute['runtime_enabled_function']) and | 228 attribute['runtime_enabled_function']) and |
246 attribute['is_data_type_property'] and | 229 attribute['is_data_type_property']) |
247 attribute['should_be_exposed_to_script']) | |
248 | 230 |
249 | 231 |
250 def is_lazy_data_attribute(attribute): | 232 def is_lazy_data_attribute(attribute): |
251 return attribute['constructor_type'] and not attribute['needs_constructor_ge
tter_callback'] | 233 return attribute['constructor_type'] and not attribute['needs_constructor_ge
tter_callback'] |
252 | 234 |
253 | 235 |
254 def filter_data_attributes(attributes): | 236 def filter_data_attributes(attributes): |
255 return [attribute for attribute in attributes if is_data_attribute(attribute
) and not is_lazy_data_attribute(attribute)] | 237 return [attribute for attribute in attributes if is_data_attribute(attribute
) and not is_lazy_data_attribute(attribute)] |
256 | 238 |
257 | 239 |
(...skipping 23 matching lines...) Expand all Loading... |
281 base_idl_type = idl_type.base_type | 263 base_idl_type = idl_type.base_type |
282 extended_attributes = attribute.extended_attributes | 264 extended_attributes = attribute.extended_attributes |
283 | 265 |
284 cpp_value = getter_expression(interface, attribute, context) | 266 cpp_value = getter_expression(interface, attribute, context) |
285 # Normally we can inline the function call into the return statement to | 267 # Normally we can inline the function call into the return statement to |
286 # avoid the overhead of using a Ref<> temporary, but for some cases | 268 # avoid the overhead of using a Ref<> temporary, but for some cases |
287 # (nullable types, EventHandler, [CachedAttribute], or if there are | 269 # (nullable types, EventHandler, [CachedAttribute], or if there are |
288 # exceptions), we need to use a local variable. | 270 # exceptions), we need to use a local variable. |
289 # FIXME: check if compilers are smart enough to inline this, and if so, | 271 # FIXME: check if compilers are smart enough to inline this, and if so, |
290 # always use a local variable (for readability and CG simplicity). | 272 # always use a local variable (for readability and CG simplicity). |
291 if 'ImplementedInPrivateScript' in extended_attributes: | 273 if (idl_type.is_explicit_nullable or |
292 if (not idl_type.is_wrapper_type and | |
293 not idl_type.is_basic_type and | |
294 not idl_type.is_enum): | |
295 raise Exception('Private scripts supports only primitive types and D
OM wrappers.') | |
296 | |
297 context['cpp_value_original'] = cpp_value | |
298 cpp_value = 'result' | |
299 elif (idl_type.is_explicit_nullable or | |
300 base_idl_type == 'EventHandler' or | 274 base_idl_type == 'EventHandler' or |
301 'CachedAttribute' in extended_attributes or | 275 'CachedAttribute' in extended_attributes or |
302 'ReflectOnly' in extended_attributes or | 276 'ReflectOnly' in extended_attributes or |
303 context['is_keep_alive_for_gc'] or | 277 context['is_keep_alive_for_gc'] or |
304 context['is_getter_raises_exception']): | 278 context['is_getter_raises_exception']): |
305 context['cpp_value_original'] = cpp_value | 279 context['cpp_value_original'] = cpp_value |
306 cpp_value = 'cppValue' | 280 cpp_value = 'cppValue' |
307 | 281 |
308 def v8_set_return_value_statement(for_main_world=False): | 282 def v8_set_return_value_statement(for_main_world=False): |
309 if context['is_keep_alive_for_gc'] or 'CachedAttribute' in extended_attr
ibutes: | 283 if context['is_keep_alive_for_gc'] or 'CachedAttribute' in extended_attr
ibutes: |
310 return 'v8SetReturnValue(info, v8Value)' | 284 return 'v8SetReturnValue(info, v8Value)' |
311 return idl_type.v8_set_return_value( | 285 return idl_type.v8_set_return_value( |
312 cpp_value, extended_attributes=extended_attributes, script_wrappable
='impl', | 286 cpp_value, extended_attributes=extended_attributes, script_wrappable
='impl', |
313 for_main_world=for_main_world, is_static=attribute.is_static) | 287 for_main_world=for_main_world, is_static=attribute.is_static) |
314 | 288 |
315 context.update({ | 289 context.update({ |
316 'cpp_value': cpp_value, | 290 'cpp_value': cpp_value, |
317 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( | 291 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
318 cpp_value=cpp_value, creation_context='holder', | 292 cpp_value=cpp_value, creation_context='holder', |
319 extended_attributes=extended_attributes), | 293 extended_attributes=extended_attributes), |
320 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_
main_world=True), | 294 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_
main_world=True), |
321 'v8_set_return_value': v8_set_return_value_statement(), | 295 'v8_set_return_value': v8_set_return_value_statement(), |
322 }) | 296 }) |
323 | 297 |
324 def getter_expression(interface, attribute, context): | 298 def getter_expression(interface, attribute, context): |
325 arguments = [] | 299 arguments = [] |
326 this_getter_base_name = getter_base_name(interface, attribute, arguments) | 300 this_getter_base_name = getter_base_name(interface, attribute, arguments) |
327 getter_name = scoped_name(interface, attribute, this_getter_base_name) | 301 getter_name = scoped_name(interface, attribute, this_getter_base_name) |
328 | 302 |
329 if 'ImplementedInPrivateScript' in attribute.extended_attributes: | |
330 arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->G
etCurrentContext()))') | |
331 arguments.append('impl') | |
332 arguments.append('&result') | |
333 arguments.extend(v8_utilities.call_with_arguments( | 303 arguments.extend(v8_utilities.call_with_arguments( |
334 attribute.extended_attributes.get('CallWith'))) | 304 attribute.extended_attributes.get('CallWith'))) |
335 # Members of IDL partial interface definitions are implemented in C++ as | 305 # Members of IDL partial interface definitions are implemented in C++ as |
336 # static member functions, which for instance members (non-static members) | 306 # static member functions, which for instance members (non-static members) |
337 # take *impl as their first argument | 307 # take *impl as their first argument |
338 if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and | 308 if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and |
339 'ImplementedInPrivateScript' not in attribute.extended_attributes an
d | |
340 not attribute.is_static): | 309 not attribute.is_static): |
341 arguments.append('*impl') | 310 arguments.append('*impl') |
342 if attribute.idl_type.is_explicit_nullable: | 311 if attribute.idl_type.is_explicit_nullable: |
343 arguments.append('isNull') | 312 arguments.append('isNull') |
344 if context['is_getter_raises_exception']: | 313 if context['is_getter_raises_exception']: |
345 arguments.append('exceptionState') | 314 arguments.append('exceptionState') |
346 if attribute.idl_type.use_output_parameter_for_result: | 315 if attribute.idl_type.use_output_parameter_for_result: |
347 arguments.append('result') | 316 arguments.append('result') |
348 | 317 |
349 expression = '%s(%s)' % (getter_name, ', '.join(arguments)) | 318 expression = '%s(%s)' % (getter_name, ', '.join(arguments)) |
350 # Needed to handle getter expressions returning Type& as the | 319 # Needed to handle getter expressions returning Type& as the |
351 # use site for |expression| expects Type*. | 320 # use site for |expression| expects Type*. |
352 if attribute.idl_type.is_interface_type and len(arguments) == 0: | 321 if attribute.idl_type.is_interface_type and len(arguments) == 0: |
353 return 'WTF::getPtr(%s)' % expression | 322 return 'WTF::getPtr(%s)' % expression |
354 return expression | 323 return expression |
355 | 324 |
356 | 325 |
357 CONTENT_ATTRIBUTE_GETTER_NAMES = { | 326 CONTENT_ATTRIBUTE_GETTER_NAMES = { |
358 'boolean': 'fastHasAttribute', | 327 'boolean': 'fastHasAttribute', |
359 'long': 'getIntegralAttribute', | 328 'long': 'getIntegralAttribute', |
360 'unsigned long': 'getUnsignedIntegralAttribute', | 329 'unsigned long': 'getUnsignedIntegralAttribute', |
361 } | 330 } |
362 | 331 |
363 | 332 |
364 def getter_base_name(interface, attribute, arguments): | 333 def getter_base_name(interface, attribute, arguments): |
365 extended_attributes = attribute.extended_attributes | 334 extended_attributes = attribute.extended_attributes |
366 | 335 |
367 if 'ImplementedInPrivateScript' in extended_attributes: | |
368 return '%sAttributeGetter' % uncapitalize(cpp_name(attribute)) | |
369 | |
370 if 'Reflect' not in extended_attributes: | 336 if 'Reflect' not in extended_attributes: |
371 return uncapitalize(cpp_name(attribute)) | 337 return uncapitalize(cpp_name(attribute)) |
372 | 338 |
373 content_attribute_name = extended_attributes['Reflect'] or attribute.name.lo
wer() | 339 content_attribute_name = extended_attributes['Reflect'] or attribute.name.lo
wer() |
374 if content_attribute_name in ['class', 'id', 'name']: | 340 if content_attribute_name in ['class', 'id', 'name']: |
375 # Special-case for performance optimization. | 341 # Special-case for performance optimization. |
376 return 'get%sAttribute' % content_attribute_name.capitalize() | 342 return 'get%sAttribute' % content_attribute_name.capitalize() |
377 | 343 |
378 arguments.append(scoped_content_attribute_name(interface, attribute)) | 344 arguments.append(scoped_content_attribute_name(interface, attribute)) |
379 | 345 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 idl_type.is_wrapper_type) | 410 idl_type.is_wrapper_type) |
445 | 411 |
446 context.update({ | 412 context.update({ |
447 'has_setter_exception_state': | 413 'has_setter_exception_state': |
448 is_setter_raises_exception or has_type_checking_interface or | 414 is_setter_raises_exception or has_type_checking_interface or |
449 idl_type.v8_conversion_needs_exception_state, | 415 idl_type.v8_conversion_needs_exception_state, |
450 'has_type_checking_interface': has_type_checking_interface, | 416 'has_type_checking_interface': has_type_checking_interface, |
451 'is_setter_call_with_execution_context': has_extended_attribute_value( | 417 'is_setter_call_with_execution_context': has_extended_attribute_value( |
452 attribute, 'SetterCallWith', 'ExecutionContext'), | 418 attribute, 'SetterCallWith', 'ExecutionContext'), |
453 'is_setter_raises_exception': is_setter_raises_exception, | 419 'is_setter_raises_exception': is_setter_raises_exception, |
454 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( | |
455 'cppValue', isolate='scriptState->isolate()', | |
456 creation_context='scriptState->context()->Global()'), | |
457 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( | 420 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( |
458 extended_attributes, 'v8Value', 'cppValue'), | 421 extended_attributes, 'v8Value', 'cppValue'), |
459 }) | 422 }) |
460 | 423 |
461 # setter_expression() depends on context values we set above. | 424 # setter_expression() depends on context values we set above. |
462 context['cpp_setter'] = setter_expression(interface, attribute, context) | 425 context['cpp_setter'] = setter_expression(interface, attribute, context) |
463 | 426 |
464 | 427 |
465 def setter_expression(interface, attribute, context): | 428 def setter_expression(interface, attribute, context): |
466 extended_attributes = attribute.extended_attributes | 429 extended_attributes = attribute.extended_attributes |
467 arguments = v8_utilities.call_with_arguments( | 430 arguments = v8_utilities.call_with_arguments( |
468 extended_attributes.get('SetterCallWith') or | 431 extended_attributes.get('SetterCallWith') or |
469 extended_attributes.get('CallWith')) | 432 extended_attributes.get('CallWith')) |
470 | 433 |
471 this_setter_base_name = setter_base_name(interface, attribute, arguments) | 434 this_setter_base_name = setter_base_name(interface, attribute, arguments) |
472 setter_name = scoped_name(interface, attribute, this_setter_base_name) | 435 setter_name = scoped_name(interface, attribute, this_setter_base_name) |
473 | 436 |
474 # Members of IDL partial interface definitions are implemented in C++ as | 437 # Members of IDL partial interface definitions are implemented in C++ as |
475 # static member functions, which for instance members (non-static members) | 438 # static member functions, which for instance members (non-static members) |
476 # take *impl as their first argument | 439 # take *impl as their first argument |
477 if ('PartialInterfaceImplementedAs' in extended_attributes and | 440 if ('PartialInterfaceImplementedAs' in extended_attributes and |
478 'ImplementedInPrivateScript' not in extended_attributes and | |
479 not attribute.is_static): | 441 not attribute.is_static): |
480 arguments.append('*impl') | 442 arguments.append('*impl') |
481 idl_type = attribute.idl_type | 443 idl_type = attribute.idl_type |
482 if 'ImplementedInPrivateScript' in extended_attributes: | 444 if idl_type.base_type == 'EventHandler': |
483 arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->G
etCurrentContext()))') | |
484 arguments.append('impl') | |
485 arguments.append('cppValue') | |
486 elif idl_type.base_type == 'EventHandler': | |
487 getter_name = scoped_name(interface, attribute, cpp_name(attribute)) | 445 getter_name = scoped_name(interface, attribute, cpp_name(attribute)) |
488 context['event_handler_getter_expression'] = '%s(%s)' % ( | 446 context['event_handler_getter_expression'] = '%s(%s)' % ( |
489 getter_name, ', '.join(arguments)) | 447 getter_name, ', '.join(arguments)) |
490 if (interface.name in ['Window', 'WorkerGlobalScope'] and | 448 if (interface.name in ['Window', 'WorkerGlobalScope'] and |
491 attribute.name == 'onerror'): | 449 attribute.name == 'onerror'): |
492 includes.add('bindings/core/v8/V8ErrorHandler.h') | 450 includes.add('bindings/core/v8/V8ErrorHandler.h') |
493 arguments.append( | 451 arguments.append( |
494 'V8EventListenerHelper::ensureEventListener<V8ErrorHandler>(' + | 452 'V8EventListenerHelper::ensureEventListener<V8ErrorHandler>(' + |
495 'v8Value, true, ScriptState::forReceiverObject(info))') | 453 'v8Value, true, ScriptState::forReceiverObject(info))') |
496 else: | 454 else: |
(...skipping 10 matching lines...) Expand all Loading... |
507 | 465 |
508 | 466 |
509 CONTENT_ATTRIBUTE_SETTER_NAMES = { | 467 CONTENT_ATTRIBUTE_SETTER_NAMES = { |
510 'boolean': 'setBooleanAttribute', | 468 'boolean': 'setBooleanAttribute', |
511 'long': 'setIntegralAttribute', | 469 'long': 'setIntegralAttribute', |
512 'unsigned long': 'setUnsignedIntegralAttribute', | 470 'unsigned long': 'setUnsignedIntegralAttribute', |
513 } | 471 } |
514 | 472 |
515 | 473 |
516 def setter_base_name(interface, attribute, arguments): | 474 def setter_base_name(interface, attribute, arguments): |
517 if 'ImplementedInPrivateScript' in attribute.extended_attributes: | |
518 return '%sAttributeSetter' % uncapitalize(cpp_name(attribute)) | |
519 | |
520 if 'Reflect' not in attribute.extended_attributes: | 475 if 'Reflect' not in attribute.extended_attributes: |
521 return 'set%s' % capitalize(cpp_name(attribute)) | 476 return 'set%s' % capitalize(cpp_name(attribute)) |
522 arguments.append(scoped_content_attribute_name(interface, attribute)) | 477 arguments.append(scoped_content_attribute_name(interface, attribute)) |
523 | 478 |
524 base_idl_type = attribute.idl_type.base_type | 479 base_idl_type = attribute.idl_type.base_type |
525 if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: | 480 if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: |
526 return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type] | 481 return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type] |
527 return 'setAttribute' | 482 return 'setAttribute' |
528 | 483 |
529 | 484 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 lambda self: strip_suffix(self.base_type, 'Constructor')) | 567 lambda self: strip_suffix(self.base_type, 'Constructor')) |
613 | 568 |
614 | 569 |
615 def is_constructor_attribute(attribute): | 570 def is_constructor_attribute(attribute): |
616 # FIXME: replace this with [ConstructorAttribute] extended attribute | 571 # FIXME: replace this with [ConstructorAttribute] extended attribute |
617 return attribute.idl_type.name.endswith('Constructor') | 572 return attribute.idl_type.name.endswith('Constructor') |
618 | 573 |
619 | 574 |
620 def update_constructor_attribute_context(interface, attribute, context): | 575 def update_constructor_attribute_context(interface, attribute, context): |
621 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 576 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
OLD | NEW |