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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 extended_attributes['Custom'] in [None, 'Setter']) | 60 extended_attributes['Custom'] in [None, 'Setter']) |
61 # [CustomElementCallbacks], [Reflect] | 61 # [CustomElementCallbacks], [Reflect] |
62 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s | 62 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s |
63 is_reflect = 'Reflect' in extended_attributes | 63 is_reflect = 'Reflect' in extended_attributes |
64 if is_custom_element_callbacks or is_reflect: | 64 if is_custom_element_callbacks or is_reflect: |
65 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') | 65 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') |
66 # [PerWorldBindings] | 66 # [PerWorldBindings] |
67 if 'PerWorldBindings' in extended_attributes: | 67 if 'PerWorldBindings' in extended_attributes: |
68 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) | 68 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) |
69 # [TypeChecking] | 69 # [TypeChecking] |
70 has_type_checking_nullable = ( | |
71 (has_extended_attribute_value(interface, 'TypeChecking', 'Nullable') or | |
72 has_extended_attribute_value(attribute, 'TypeChecking', 'Nullable')) an
d | |
73 idl_type.is_wrapper_type) | |
74 has_type_checking_unrestricted = ( | 70 has_type_checking_unrestricted = ( |
75 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted')
or | 71 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted')
or |
76 has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')
) and | 72 has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')
) and |
77 idl_type.name in ('Float', 'Double')) | 73 idl_type.name in ('Float', 'Double')) |
78 | 74 |
79 if (base_idl_type == 'EventHandler' and | 75 if (base_idl_type == 'EventHandler' and |
80 interface.name in ['Window', 'WorkerGlobalScope'] and | 76 interface.name in ['Window', 'WorkerGlobalScope'] and |
81 attribute.name == 'onerror'): | 77 attribute.name == 'onerror'): |
82 includes.add('bindings/v8/V8ErrorHandler.h') | 78 includes.add('bindings/v8/V8ErrorHandler.h') |
83 | 79 |
84 context = { | 80 context = { |
85 'access_control_list': access_control_list(attribute), | 81 'access_control_list': access_control_list(attribute), |
86 '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] |
87 '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] |
88 'activity_logging_include_old_value_for_setter': 'LogPreviousValue' in e
xtended_attributes, # [ActivityLogging] | 84 'activity_logging_include_old_value_for_setter': 'LogPreviousValue' in e
xtended_attributes, # [ActivityLogging] |
89 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] | 85 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] |
90 'cached_attribute_validation_method': extended_attributes.get('CachedAtt
ribute'), | 86 'cached_attribute_validation_method': extended_attributes.get('CachedAtt
ribute'), |
91 'conditional_string': v8_utilities.conditional_string(attribute), | 87 'conditional_string': v8_utilities.conditional_string(attribute), |
92 'constructor_type': idl_type.constructor_type_name | 88 'constructor_type': idl_type.constructor_type_name |
93 if is_constructor_attribute(attribute) else None, | 89 if is_constructor_attribute(attribute) else None, |
94 'cpp_name': cpp_name(attribute), | 90 'cpp_name': cpp_name(attribute), |
95 'cpp_type': idl_type.cpp_type, | 91 'cpp_type': idl_type.cpp_type, |
96 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(cpp_value='origi
nal', creation_context='info.Holder()'), | 92 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(cpp_value='origi
nal', creation_context='info.Holder()'), |
97 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] | 93 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] |
98 'enum_validation_expression': idl_type.enum_validation_expression, | 94 'enum_validation_expression': idl_type.enum_validation_expression, |
99 'has_custom_getter': has_custom_getter, | 95 'has_custom_getter': has_custom_getter, |
100 'has_custom_setter': has_custom_setter, | 96 'has_custom_setter': has_custom_setter, |
101 'has_type_checking_nullable': has_type_checking_nullable, | |
102 'has_type_checking_unrestricted': has_type_checking_unrestricted, | 97 'has_type_checking_unrestricted': has_type_checking_unrestricted, |
103 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType | 98 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType |
104 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va
lue(attribute, 'CallWith', 'ExecutionContext'), | 99 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va
lue(attribute, 'CallWith', 'ExecutionContext'), |
105 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a
ttribute, 'CallWith', 'ScriptState'), | 100 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a
ttribute, 'CallWith', 'ScriptState'), |
106 'is_check_security_for_node': is_check_security_for_node, | 101 'is_check_security_for_node': is_check_security_for_node, |
107 'is_custom_element_callbacks': is_custom_element_callbacks, | 102 'is_custom_element_callbacks': is_custom_element_callbacks, |
108 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes, | 103 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes, |
109 'is_getter_raises_exception': # [RaisesException] | 104 'is_getter_raises_exception': # [RaisesException] |
110 'RaisesException' in extended_attributes and | 105 'RaisesException' in extended_attributes and |
111 extended_attributes['RaisesException'] in (None, 'Getter'), | 106 extended_attributes['RaisesException'] in (None, 'Getter'), |
112 'is_initialized_by_event_constructor': | 107 'is_initialized_by_event_constructor': |
113 'InitializedByEventConstructor' in extended_attributes, | 108 'InitializedByEventConstructor' in extended_attributes, |
114 'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute), | 109 'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute), |
115 'is_nullable': attribute.idl_type.is_nullable, | 110 'is_nullable': idl_type.is_nullable, |
| 111 'is_nullable_simple': idl_type.is_nullable and idl_type.is_wrapper_type,
# null value maps to C++ null pointer |
116 'is_partial_interface_member': | 112 'is_partial_interface_member': |
117 'PartialInterfaceImplementedAs' in extended_attributes, | 113 'PartialInterfaceImplementedAs' in extended_attributes, |
118 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | 114 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, |
119 'is_read_only': attribute.is_read_only, | 115 'is_read_only': attribute.is_read_only, |
120 'is_reflect': is_reflect, | 116 'is_reflect': is_reflect, |
121 'is_replaceable': 'Replaceable' in attribute.extended_attributes, | 117 'is_replaceable': 'Replaceable' in attribute.extended_attributes, |
122 'is_static': attribute.is_static, | 118 'is_static': attribute.is_static, |
123 'is_url': 'URL' in extended_attributes, | 119 'is_url': 'URL' in extended_attributes, |
124 'is_unforgeable': 'Unforgeable' in extended_attributes, | 120 'is_unforgeable': 'Unforgeable' in extended_attributes, |
125 'measure_as': v8_utilities.measure_as(attribute), # [MeasureAs] | 121 'measure_as': v8_utilities.measure_as(attribute), # [MeasureAs] |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 getter_name = scoped_name(interface, attribute, this_getter_base_name) | 196 getter_name = scoped_name(interface, attribute, this_getter_base_name) |
201 | 197 |
202 arguments.extend(v8_utilities.call_with_arguments( | 198 arguments.extend(v8_utilities.call_with_arguments( |
203 attribute.extended_attributes.get('CallWith'))) | 199 attribute.extended_attributes.get('CallWith'))) |
204 # Members of IDL partial interface definitions are implemented in C++ as | 200 # Members of IDL partial interface definitions are implemented in C++ as |
205 # static member functions, which for instance members (non-static members) | 201 # static member functions, which for instance members (non-static members) |
206 # take *impl as their first argument | 202 # take *impl as their first argument |
207 if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and | 203 if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and |
208 not attribute.is_static): | 204 not attribute.is_static): |
209 arguments.append('*impl') | 205 arguments.append('*impl') |
210 if attribute.idl_type.is_nullable and not context['has_type_checking_nullabl
e']: | 206 if attribute.idl_type.is_nullable and not context['is_nullable_simple']: |
211 arguments.append('isNull') | 207 arguments.append('isNull') |
212 if context['is_getter_raises_exception']: | 208 if context['is_getter_raises_exception']: |
213 arguments.append('exceptionState') | 209 arguments.append('exceptionState') |
214 return '%s(%s)' % (getter_name, ', '.join(arguments)) | 210 return '%s(%s)' % (getter_name, ', '.join(arguments)) |
215 | 211 |
216 | 212 |
217 CONTENT_ATTRIBUTE_GETTER_NAMES = { | 213 CONTENT_ATTRIBUTE_GETTER_NAMES = { |
218 'boolean': 'fastHasAttribute', | 214 'boolean': 'fastHasAttribute', |
219 'long': 'getIntegralAttribute', | 215 'long': 'getIntegralAttribute', |
220 'unsigned long': 'getUnsignedIntegralAttribute', | 216 'unsigned long': 'getUnsignedIntegralAttribute', |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 extended_attributes['RaisesException'] in [None, 'Setter']) | 288 extended_attributes['RaisesException'] in [None, 'Setter']) |
293 # [TypeChecking=Interface] | 289 # [TypeChecking=Interface] |
294 has_type_checking_interface = ( | 290 has_type_checking_interface = ( |
295 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or | 291 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or |
296 has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) a
nd | 292 has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) a
nd |
297 idl_type.is_wrapper_type) | 293 idl_type.is_wrapper_type) |
298 | 294 |
299 context.update({ | 295 context.update({ |
300 'has_setter_exception_state': | 296 'has_setter_exception_state': |
301 is_setter_raises_exception or has_type_checking_interface or | 297 is_setter_raises_exception or has_type_checking_interface or |
302 context['has_type_checking_nullable'] or | |
303 context['has_type_checking_unrestricted'] or | 298 context['has_type_checking_unrestricted'] or |
304 idl_type.may_raise_exception_on_conversion, | 299 idl_type.may_raise_exception_on_conversion, |
305 'has_type_checking_interface': has_type_checking_interface, | 300 'has_type_checking_interface': has_type_checking_interface, |
306 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri
bute_value( | 301 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri
bute_value( |
307 attribute, 'SetterCallWith', 'ExecutionContext'), | 302 attribute, 'SetterCallWith', 'ExecutionContext'), |
308 'is_setter_raises_exception': is_setter_raises_exception, | 303 'is_setter_raises_exception': is_setter_raises_exception, |
309 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( | 304 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( |
310 extended_attributes, 'v8Value', 'cppValue'), | 305 extended_attributes, 'v8Value', 'cppValue'), |
311 }) | 306 }) |
312 | 307 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 lambda self: strip_suffix(self.base_type, 'Constructor')) | 427 lambda self: strip_suffix(self.base_type, 'Constructor')) |
433 | 428 |
434 | 429 |
435 def is_constructor_attribute(attribute): | 430 def is_constructor_attribute(attribute): |
436 # FIXME: replace this with [ConstructorAttribute] extended attribute | 431 # FIXME: replace this with [ConstructorAttribute] extended attribute |
437 return attribute.idl_type.base_type.endswith('Constructor') | 432 return attribute.idl_type.base_type.endswith('Constructor') |
438 | 433 |
439 | 434 |
440 def constructor_getter_context(interface, attribute, context): | 435 def constructor_getter_context(interface, attribute, context): |
441 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 436 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
OLD | NEW |