| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_unrestricted = ( | 70 has_type_checking_unrestricted = ( |
| 71 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted')
or | 71 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted')
or |
| 72 has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')
) and | 72 has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')
) and |
| 73 idl_type.name in ('Float', 'Double')) | 73 idl_type.name in ('Float', 'Double')) |
| 74 # [ImplementedInPrivateScript] |
| 75 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_
attributes |
| 76 if is_implemented_in_private_script: |
| 77 includes.add('bindings/core/v8/PrivateScriptRunner.h') |
| 78 includes.add('core/frame/LocalFrame.h') |
| 74 | 79 |
| 75 if (base_idl_type == 'EventHandler' and | 80 if (base_idl_type == 'EventHandler' and |
| 76 interface.name in ['Window', 'WorkerGlobalScope'] and | 81 interface.name in ['Window', 'WorkerGlobalScope'] and |
| 77 attribute.name == 'onerror'): | 82 attribute.name == 'onerror'): |
| 78 includes.add('bindings/core/v8/V8ErrorHandler.h') | 83 includes.add('bindings/core/v8/V8ErrorHandler.h') |
| 79 | 84 |
| 80 # Nullable type where the corresponding C++ type supports a null value. | 85 # Nullable type where the corresponding C++ type supports a null value. |
| 81 is_nullable_simple = idl_type.is_nullable and ( | 86 is_nullable_simple = idl_type.is_nullable and ( |
| 82 (idl_type.is_string_type or idl_type.is_wrapper_type) and | 87 (idl_type.is_string_type or idl_type.is_wrapper_type) and |
| 83 not idl_type.array_or_sequence_type) | 88 not idl_type.array_or_sequence_type) |
| 84 | 89 |
| 85 context = { | 90 context = { |
| 86 'access_control_list': access_control_list(attribute), | 91 'access_control_list': access_control_list(attribute), |
| 87 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] | 92 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] |
| 88 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] | 93 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] |
| 89 'activity_logging_include_old_value_for_setter': 'LogPreviousValue' in e
xtended_attributes, # [ActivityLogging] | 94 'activity_logging_include_old_value_for_setter': 'LogPreviousValue' in e
xtended_attributes, # [ActivityLogging] |
| 90 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] | 95 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] |
| 96 'argument_cpp_type': idl_type.cpp_type_args(used_as_argument=True), |
| 91 'cached_attribute_validation_method': extended_attributes.get('CachedAtt
ribute'), | 97 'cached_attribute_validation_method': extended_attributes.get('CachedAtt
ribute'), |
| 92 'conditional_string': v8_utilities.conditional_string(attribute), | 98 'conditional_string': v8_utilities.conditional_string(attribute), |
| 93 'constructor_type': idl_type.constructor_type_name | 99 'constructor_type': idl_type.constructor_type_name |
| 94 if is_constructor_attribute(attribute) else None, | 100 if is_constructor_attribute(attribute) else None, |
| 95 'cpp_name': cpp_name(attribute), | 101 'cpp_name': cpp_name(attribute), |
| 96 'cpp_type': idl_type.cpp_type, | 102 'cpp_type': idl_type.cpp_type, |
| 97 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] | 103 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] |
| 98 'enum_validation_expression': idl_type.enum_validation_expression, | 104 'enum_validation_expression': idl_type.enum_validation_expression, |
| 99 'has_custom_getter': has_custom_getter, | 105 'has_custom_getter': has_custom_getter, |
| 100 'has_custom_setter': has_custom_setter, | 106 'has_custom_setter': has_custom_setter, |
| 101 'has_type_checking_unrestricted': has_type_checking_unrestricted, | 107 'has_type_checking_unrestricted': has_type_checking_unrestricted, |
| 102 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType | 108 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType |
| 103 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va
lue(attribute, 'CallWith', 'ExecutionContext'), | 109 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va
lue(attribute, 'CallWith', 'ExecutionContext'), |
| 104 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a
ttribute, 'CallWith', 'ScriptState'), | 110 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a
ttribute, 'CallWith', 'ScriptState'), |
| 105 'is_check_security_for_node': is_check_security_for_node, | 111 'is_check_security_for_node': is_check_security_for_node, |
| 106 'is_custom_element_callbacks': is_custom_element_callbacks, | 112 'is_custom_element_callbacks': is_custom_element_callbacks, |
| 107 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes, | 113 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes, |
| 108 'is_getter_raises_exception': # [RaisesException] | 114 'is_getter_raises_exception': # [RaisesException] |
| 109 'RaisesException' in extended_attributes and | 115 'RaisesException' in extended_attributes and |
| 110 extended_attributes['RaisesException'] in (None, 'Getter'), | 116 extended_attributes['RaisesException'] in (None, 'Getter'), |
| 117 'is_implemented_in_private_script': is_implemented_in_private_script, |
| 111 'is_initialized_by_event_constructor': | 118 'is_initialized_by_event_constructor': |
| 112 'InitializedByEventConstructor' in extended_attributes, | 119 'InitializedByEventConstructor' in extended_attributes, |
| 113 'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute), | 120 'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute), |
| 114 'is_nullable': idl_type.is_nullable, | 121 'is_nullable': idl_type.is_nullable, |
| 115 'is_nullable_simple': is_nullable_simple, | 122 'is_nullable_simple': is_nullable_simple, |
| 116 'is_partial_interface_member': | 123 'is_partial_interface_member': |
| 117 'PartialInterfaceImplementedAs' in extended_attributes, | 124 'PartialInterfaceImplementedAs' in extended_attributes, |
| 118 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | 125 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, |
| 119 'is_read_only': attribute.is_read_only, | 126 'is_read_only': attribute.is_read_only, |
| 120 'is_reflect': is_reflect, | 127 'is_reflect': is_reflect, |
| 121 'is_replaceable': 'Replaceable' in attribute.extended_attributes, | 128 'is_replaceable': 'Replaceable' in attribute.extended_attributes, |
| 122 'is_static': attribute.is_static, | 129 'is_static': attribute.is_static, |
| 123 'is_url': 'URL' in extended_attributes, | 130 'is_url': 'URL' in extended_attributes, |
| 124 'is_unforgeable': 'Unforgeable' in extended_attributes, | 131 'is_unforgeable': 'Unforgeable' in extended_attributes, |
| 125 'measure_as': v8_utilities.measure_as(attribute), # [MeasureAs] | 132 'measure_as': v8_utilities.measure_as(attribute), # [MeasureAs] |
| 126 'name': attribute.name, | 133 'name': attribute.name, |
| 127 'per_context_enabled_function': v8_utilities.per_context_enabled_functio
n_name(attribute), # [PerContextEnabled] | 134 'per_context_enabled_function': v8_utilities.per_context_enabled_functio
n_name(attribute), # [PerContextEnabled] |
| 135 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( |
| 136 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is
olate()', used_in_private_script=True), |
| 128 'property_attributes': property_attributes(attribute), | 137 'property_attributes': property_attributes(attribute), |
| 129 'put_forwards': 'PutForwards' in extended_attributes, | 138 'put_forwards': 'PutForwards' in extended_attributes, |
| 130 'reflect_empty': extended_attributes.get('ReflectEmpty'), | 139 'reflect_empty': extended_attributes.get('ReflectEmpty'), |
| 131 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), | 140 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), |
| 132 'reflect_missing': extended_attributes.get('ReflectMissing'), | 141 'reflect_missing': extended_attributes.get('ReflectMissing'), |
| 133 'reflect_only': extended_attributes['ReflectOnly'].split('|') | 142 'reflect_only': extended_attributes['ReflectOnly'].split('|') |
| 134 if 'ReflectOnly' in extended_attributes else None, | 143 if 'ReflectOnly' in extended_attributes else None, |
| 144 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a
ttribute), # [RuntimeEnabled] |
| 135 'setter_callback': setter_callback_name(interface, attribute), | 145 'setter_callback': setter_callback_name(interface, attribute), |
| 136 'v8_type': v8_types.v8_type(base_idl_type), | 146 'v8_type': v8_types.v8_type(base_idl_type), |
| 137 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a
ttribute), # [RuntimeEnabled] | |
| 138 'world_suffixes': ['', 'ForMainWorld'] | 147 'world_suffixes': ['', 'ForMainWorld'] |
| 139 if 'PerWorldBindings' in extended_attributes | 148 if 'PerWorldBindings' in extended_attributes |
| 140 else [''], # [PerWorldBindings] | 149 else [''], # [PerWorldBindings] |
| 141 } | 150 } |
| 142 | 151 |
| 143 if is_constructor_attribute(attribute): | 152 if is_constructor_attribute(attribute): |
| 144 constructor_getter_context(interface, attribute, context) | 153 constructor_getter_context(interface, attribute, context) |
| 145 return context | 154 return context |
| 146 if not has_custom_getter: | 155 if not has_custom_getter: |
| 147 getter_context(interface, attribute, context) | 156 getter_context(interface, attribute, context) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 162 extended_attributes = attribute.extended_attributes | 171 extended_attributes = attribute.extended_attributes |
| 163 | 172 |
| 164 cpp_value = getter_expression(interface, attribute, context) | 173 cpp_value = getter_expression(interface, attribute, context) |
| 165 # Normally we can inline the function call into the return statement to | 174 # Normally we can inline the function call into the return statement to |
| 166 # avoid the overhead of using a Ref<> temporary, but for some cases | 175 # avoid the overhead of using a Ref<> temporary, but for some cases |
| 167 # (nullable types, EventHandler, [CachedAttribute], or if there are | 176 # (nullable types, EventHandler, [CachedAttribute], or if there are |
| 168 # exceptions), we need to use a local variable. | 177 # exceptions), we need to use a local variable. |
| 169 # FIXME: check if compilers are smart enough to inline this, and if so, | 178 # FIXME: check if compilers are smart enough to inline this, and if so, |
| 170 # always use a local variable (for readability and CG simplicity). | 179 # always use a local variable (for readability and CG simplicity). |
| 171 release = False | 180 release = False |
| 172 if ((idl_type.is_nullable and not context['is_nullable_simple']) or | 181 if 'ImplementedInPrivateScript' in extended_attributes: |
| 182 if (not idl_type.is_wrapper_type and |
| 183 not idl_type.is_basic_type): |
| 184 raise Exception('Private scripts supports only primitive types and D
OM wrappers.') |
| 185 |
| 186 context['cpp_value_original'] = cpp_value |
| 187 cpp_value = 'result' |
| 188 # EventHandler has special handling |
| 189 if base_idl_type != 'EventHandler': |
| 190 release = idl_type.release |
| 191 elif ((idl_type.is_nullable and not context['is_nullable_simple']) or |
| 173 base_idl_type == 'EventHandler' or | 192 base_idl_type == 'EventHandler' or |
| 174 'CachedAttribute' in extended_attributes or | 193 'CachedAttribute' in extended_attributes or |
| 175 'LogPreviousValue' in extended_attributes or | 194 'LogPreviousValue' in extended_attributes or |
| 176 'ReflectOnly' in extended_attributes or | 195 'ReflectOnly' in extended_attributes or |
| 177 context['is_keep_alive_for_gc'] or | 196 context['is_keep_alive_for_gc'] or |
| 178 context['is_getter_raises_exception']): | 197 context['is_getter_raises_exception']): |
| 179 context['cpp_value_original'] = cpp_value | 198 context['cpp_value_original'] = cpp_value |
| 180 cpp_value = 'cppValue' | 199 cpp_value = 'cppValue' |
| 181 # EventHandler has special handling | 200 # EventHandler has special handling |
| 182 if base_idl_type != 'EventHandler' and idl_type.is_interface_type: | 201 if base_idl_type != 'EventHandler': |
| 183 release = True | 202 release = idl_type.release |
| 184 | 203 |
| 185 def v8_set_return_value_statement(for_main_world=False): | 204 def v8_set_return_value_statement(for_main_world=False): |
| 186 if context['is_keep_alive_for_gc']: | 205 if context['is_keep_alive_for_gc']: |
| 187 return 'v8SetReturnValue(info, wrapper)' | 206 return 'v8SetReturnValue(info, wrapper)' |
| 188 return idl_type.v8_set_return_value(cpp_value, extended_attributes=exten
ded_attributes, script_wrappable='impl', release=release, for_main_world=for_mai
n_world) | 207 return idl_type.v8_set_return_value(cpp_value, extended_attributes=exten
ded_attributes, script_wrappable='impl', release=release, for_main_world=for_mai
n_world) |
| 189 | 208 |
| 190 context.update({ | 209 context.update({ |
| 191 'cpp_value': cpp_value, | 210 'cpp_value': cpp_value, |
| 192 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( | 211 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
| 193 cpp_value=cpp_value, creation_context='info.Holder()', | 212 cpp_value=cpp_value, creation_context='info.Holder()', |
| 194 extended_attributes=extended_attributes), | 213 extended_attributes=extended_attributes), |
| 195 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_
main_world=True), | 214 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_
main_world=True), |
| 196 'v8_set_return_value': v8_set_return_value_statement(), | 215 'v8_set_return_value': v8_set_return_value_statement(), |
| 197 }) | 216 }) |
| 198 | 217 |
| 199 | 218 |
| 200 def getter_expression(interface, attribute, context): | 219 def getter_expression(interface, attribute, context): |
| 201 arguments = [] | 220 arguments = [] |
| 202 this_getter_base_name = getter_base_name(interface, attribute, arguments) | 221 this_getter_base_name = getter_base_name(interface, attribute, arguments) |
| 203 getter_name = scoped_name(interface, attribute, this_getter_base_name) | 222 getter_name = scoped_name(interface, attribute, this_getter_base_name) |
| 204 | 223 |
| 224 if 'ImplementedInPrivateScript' in attribute.extended_attributes: |
| 225 arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentCont
ext())') |
| 226 arguments.append('impl') |
| 227 arguments.append('&result') |
| 205 arguments.extend(v8_utilities.call_with_arguments( | 228 arguments.extend(v8_utilities.call_with_arguments( |
| 206 attribute.extended_attributes.get('CallWith'))) | 229 attribute.extended_attributes.get('CallWith'))) |
| 207 # Members of IDL partial interface definitions are implemented in C++ as | 230 # Members of IDL partial interface definitions are implemented in C++ as |
| 208 # static member functions, which for instance members (non-static members) | 231 # static member functions, which for instance members (non-static members) |
| 209 # take *impl as their first argument | 232 # take *impl as their first argument |
| 210 if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and | 233 if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and |
| 211 not attribute.is_static): | 234 not attribute.is_static): |
| 212 arguments.append('*impl') | 235 arguments.append('*impl') |
| 213 if attribute.idl_type.is_nullable and not context['is_nullable_simple']: | 236 if attribute.idl_type.is_nullable and not context['is_nullable_simple']: |
| 214 arguments.append('isNull') | 237 arguments.append('isNull') |
| 215 if context['is_getter_raises_exception']: | 238 if context['is_getter_raises_exception']: |
| 216 arguments.append('exceptionState') | 239 arguments.append('exceptionState') |
| 217 return '%s(%s)' % (getter_name, ', '.join(arguments)) | 240 return '%s(%s)' % (getter_name, ', '.join(arguments)) |
| 218 | 241 |
| 219 | 242 |
| 220 CONTENT_ATTRIBUTE_GETTER_NAMES = { | 243 CONTENT_ATTRIBUTE_GETTER_NAMES = { |
| 221 'boolean': 'fastHasAttribute', | 244 'boolean': 'fastHasAttribute', |
| 222 'long': 'getIntegralAttribute', | 245 'long': 'getIntegralAttribute', |
| 223 'unsigned long': 'getUnsignedIntegralAttribute', | 246 'unsigned long': 'getUnsignedIntegralAttribute', |
| 224 } | 247 } |
| 225 | 248 |
| 226 | 249 |
| 227 def getter_base_name(interface, attribute, arguments): | 250 def getter_base_name(interface, attribute, arguments): |
| 228 extended_attributes = attribute.extended_attributes | 251 extended_attributes = attribute.extended_attributes |
| 252 |
| 253 if 'ImplementedInPrivateScript' in extended_attributes: |
| 254 return '%sAttributeGetterImplementedInPrivateScript' % uncapitalize(cpp_
name(attribute)) |
| 255 |
| 229 if 'Reflect' not in extended_attributes: | 256 if 'Reflect' not in extended_attributes: |
| 230 return uncapitalize(cpp_name(attribute)) | 257 return uncapitalize(cpp_name(attribute)) |
| 231 | 258 |
| 232 content_attribute_name = extended_attributes['Reflect'] or attribute.name.lo
wer() | 259 content_attribute_name = extended_attributes['Reflect'] or attribute.name.lo
wer() |
| 233 if content_attribute_name in ['class', 'id', 'name']: | 260 if content_attribute_name in ['class', 'id', 'name']: |
| 234 # Special-case for performance optimization. | 261 # Special-case for performance optimization. |
| 235 return 'get%sAttribute' % content_attribute_name.capitalize() | 262 return 'get%sAttribute' % content_attribute_name.capitalize() |
| 236 | 263 |
| 237 arguments.append(scoped_content_attribute_name(interface, attribute)) | 264 arguments.append(scoped_content_attribute_name(interface, attribute)) |
| 238 | 265 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 328 |
| 302 context.update({ | 329 context.update({ |
| 303 'has_setter_exception_state': | 330 'has_setter_exception_state': |
| 304 is_setter_raises_exception or has_type_checking_interface or | 331 is_setter_raises_exception or has_type_checking_interface or |
| 305 context['has_type_checking_unrestricted'] or | 332 context['has_type_checking_unrestricted'] or |
| 306 idl_type.may_raise_exception_on_conversion, | 333 idl_type.may_raise_exception_on_conversion, |
| 307 'has_type_checking_interface': has_type_checking_interface, | 334 'has_type_checking_interface': has_type_checking_interface, |
| 308 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri
bute_value( | 335 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri
bute_value( |
| 309 attribute, 'SetterCallWith', 'ExecutionContext'), | 336 attribute, 'SetterCallWith', 'ExecutionContext'), |
| 310 'is_setter_raises_exception': is_setter_raises_exception, | 337 'is_setter_raises_exception': is_setter_raises_exception, |
| 338 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
| 339 'cppValue', isolate='scriptState->isolate()', |
| 340 creation_context='scriptState->context()->Global()'), |
| 311 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( | 341 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( |
| 312 extended_attributes, 'v8Value', 'cppValue'), | 342 extended_attributes, 'v8Value', 'cppValue'), |
| 313 }) | 343 }) |
| 314 | 344 |
| 315 # setter_expression() depends on context values we set above. | 345 # setter_expression() depends on context values we set above. |
| 316 context['cpp_setter'] = setter_expression(interface, attribute, context) | 346 context['cpp_setter'] = setter_expression(interface, attribute, context) |
| 317 | 347 |
| 318 | 348 |
| 319 def setter_expression(interface, attribute, context): | 349 def setter_expression(interface, attribute, context): |
| 320 extended_attributes = attribute.extended_attributes | 350 extended_attributes = attribute.extended_attributes |
| 321 arguments = v8_utilities.call_with_arguments( | 351 arguments = v8_utilities.call_with_arguments( |
| 322 extended_attributes.get('SetterCallWith') or | 352 extended_attributes.get('SetterCallWith') or |
| 323 extended_attributes.get('CallWith')) | 353 extended_attributes.get('CallWith')) |
| 324 | 354 |
| 325 this_setter_base_name = setter_base_name(interface, attribute, arguments) | 355 this_setter_base_name = setter_base_name(interface, attribute, arguments) |
| 326 setter_name = scoped_name(interface, attribute, this_setter_base_name) | 356 setter_name = scoped_name(interface, attribute, this_setter_base_name) |
| 327 | 357 |
| 328 # Members of IDL partial interface definitions are implemented in C++ as | 358 # Members of IDL partial interface definitions are implemented in C++ as |
| 329 # static member functions, which for instance members (non-static members) | 359 # static member functions, which for instance members (non-static members) |
| 330 # take *impl as their first argument | 360 # take *impl as their first argument |
| 331 if ('PartialInterfaceImplementedAs' in extended_attributes and | 361 if ('PartialInterfaceImplementedAs' in extended_attributes and |
| 332 not attribute.is_static): | 362 not attribute.is_static): |
| 333 arguments.append('*impl') | 363 arguments.append('*impl') |
| 334 idl_type = attribute.idl_type | 364 idl_type = attribute.idl_type |
| 335 if idl_type.base_type == 'EventHandler': | 365 if 'ImplementedInPrivateScript' in extended_attributes: |
| 366 arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentCont
ext())') |
| 367 arguments.append('impl') |
| 368 arguments.append('cppValue') |
| 369 elif idl_type.base_type == 'EventHandler': |
| 336 getter_name = scoped_name(interface, attribute, cpp_name(attribute)) | 370 getter_name = scoped_name(interface, attribute, cpp_name(attribute)) |
| 337 context['event_handler_getter_expression'] = '%s(%s)' % ( | 371 context['event_handler_getter_expression'] = '%s(%s)' % ( |
| 338 getter_name, ', '.join(arguments)) | 372 getter_name, ', '.join(arguments)) |
| 339 if (interface.name in ['Window', 'WorkerGlobalScope'] and | 373 if (interface.name in ['Window', 'WorkerGlobalScope'] and |
| 340 attribute.name == 'onerror'): | 374 attribute.name == 'onerror'): |
| 341 includes.add('bindings/core/v8/V8ErrorHandler.h') | 375 includes.add('bindings/core/v8/V8ErrorHandler.h') |
| 342 arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHa
ndler>(v8Value, true, ScriptState::current(info.GetIsolate()))') | 376 arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHa
ndler>(v8Value, true, ScriptState::current(info.GetIsolate()))') |
| 343 else: | 377 else: |
| 344 arguments.append('V8EventListenerList::getEventListener(ScriptState:
:current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate)') | 378 arguments.append('V8EventListenerList::getEventListener(ScriptState:
:current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate)') |
| 345 elif idl_type.is_interface_type and not idl_type.array_type: | 379 elif idl_type.is_interface_type and not idl_type.array_type: |
| 346 # FIXME: should be able to eliminate WTF::getPtr in most or all cases | 380 # FIXME: should be able to eliminate WTF::getPtr in most or all cases |
| 347 arguments.append('WTF::getPtr(cppValue)') | 381 arguments.append('WTF::getPtr(cppValue)') |
| 348 else: | 382 else: |
| 349 arguments.append('cppValue') | 383 arguments.append('cppValue') |
| 350 if context['is_setter_raises_exception']: | 384 if context['is_setter_raises_exception']: |
| 351 arguments.append('exceptionState') | 385 arguments.append('exceptionState') |
| 352 | 386 |
| 353 return '%s(%s)' % (setter_name, ', '.join(arguments)) | 387 return '%s(%s)' % (setter_name, ', '.join(arguments)) |
| 354 | 388 |
| 355 | 389 |
| 356 CONTENT_ATTRIBUTE_SETTER_NAMES = { | 390 CONTENT_ATTRIBUTE_SETTER_NAMES = { |
| 357 'boolean': 'setBooleanAttribute', | 391 'boolean': 'setBooleanAttribute', |
| 358 'long': 'setIntegralAttribute', | 392 'long': 'setIntegralAttribute', |
| 359 'unsigned long': 'setUnsignedIntegralAttribute', | 393 'unsigned long': 'setUnsignedIntegralAttribute', |
| 360 } | 394 } |
| 361 | 395 |
| 362 | 396 |
| 363 def setter_base_name(interface, attribute, arguments): | 397 def setter_base_name(interface, attribute, arguments): |
| 398 if 'ImplementedInPrivateScript' in attribute.extended_attributes: |
| 399 return '%sAttributeSetterImplementedInPrivateScript' % uncapitalize(cpp_
name(attribute)) |
| 400 |
| 364 if 'Reflect' not in attribute.extended_attributes: | 401 if 'Reflect' not in attribute.extended_attributes: |
| 365 return 'set%s' % capitalize(cpp_name(attribute)) | 402 return 'set%s' % capitalize(cpp_name(attribute)) |
| 366 arguments.append(scoped_content_attribute_name(interface, attribute)) | 403 arguments.append(scoped_content_attribute_name(interface, attribute)) |
| 367 | 404 |
| 368 base_idl_type = attribute.idl_type.base_type | 405 base_idl_type = attribute.idl_type.base_type |
| 369 if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: | 406 if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: |
| 370 return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type] | 407 return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type] |
| 371 return 'setAttribute' | 408 return 'setAttribute' |
| 372 | 409 |
| 373 | 410 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 lambda self: strip_suffix(self.base_type, 'Constructor')) | 471 lambda self: strip_suffix(self.base_type, 'Constructor')) |
| 435 | 472 |
| 436 | 473 |
| 437 def is_constructor_attribute(attribute): | 474 def is_constructor_attribute(attribute): |
| 438 # FIXME: replace this with [ConstructorAttribute] extended attribute | 475 # FIXME: replace this with [ConstructorAttribute] extended attribute |
| 439 return attribute.idl_type.base_type.endswith('Constructor') | 476 return attribute.idl_type.base_type.endswith('Constructor') |
| 440 | 477 |
| 441 | 478 |
| 442 def constructor_getter_context(interface, attribute, context): | 479 def constructor_getter_context(interface, attribute, context): |
| 443 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 480 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
| OLD | NEW |