| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 base_idl_type == 'EventHandler' or | 274 base_idl_type == 'EventHandler' or |
| 275 'CachedAttribute' in extended_attributes or | 275 'CachedAttribute' in extended_attributes or |
| 276 'ReflectOnly' in extended_attributes or | 276 'ReflectOnly' in extended_attributes or |
| 277 context['is_keep_alive_for_gc'] or | 277 context['is_keep_alive_for_gc'] or |
| 278 context['is_getter_raises_exception']): | 278 context['is_getter_raises_exception']): |
| 279 context['cpp_value_original'] = cpp_value | 279 context['cpp_value_original'] = cpp_value |
| 280 cpp_value = 'cppValue' | 280 cpp_value = 'cppValue' |
| 281 | 281 |
| 282 def v8_set_return_value_statement(for_main_world=False): | 282 def v8_set_return_value_statement(for_main_world=False): |
| 283 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: |
| 284 return 'v8SetReturnValue(info, v8Value)' | 284 return 'V8SetReturnValue(info, v8Value)' |
| 285 return idl_type.v8_set_return_value( | 285 return idl_type.v8_set_return_value( |
| 286 cpp_value, extended_attributes=extended_attributes, script_wrappable
='impl', | 286 cpp_value, extended_attributes=extended_attributes, script_wrappable
='impl', |
| 287 for_main_world=for_main_world, is_static=attribute.is_static) | 287 for_main_world=for_main_world, is_static=attribute.is_static) |
| 288 | 288 |
| 289 context.update({ | 289 context.update({ |
| 290 'cpp_value': cpp_value, | 290 'cpp_value': cpp_value, |
| 291 '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( |
| 292 cpp_value=cpp_value, creation_context='holder', | 292 cpp_value=cpp_value, creation_context='holder', |
| 293 extended_attributes=extended_attributes), | 293 extended_attributes=extended_attributes), |
| 294 '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), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 312 arguments.append('isNull') | 312 arguments.append('isNull') |
| 313 if context['is_getter_raises_exception']: | 313 if context['is_getter_raises_exception']: |
| 314 arguments.append('exceptionState') | 314 arguments.append('exceptionState') |
| 315 if attribute.idl_type.use_output_parameter_for_result: | 315 if attribute.idl_type.use_output_parameter_for_result: |
| 316 arguments.append('result') | 316 arguments.append('result') |
| 317 | 317 |
| 318 expression = '%s(%s)' % (getter_name, ', '.join(arguments)) | 318 expression = '%s(%s)' % (getter_name, ', '.join(arguments)) |
| 319 # Needed to handle getter expressions returning Type& as the | 319 # Needed to handle getter expressions returning Type& as the |
| 320 # use site for |expression| expects Type*. | 320 # use site for |expression| expects Type*. |
| 321 if attribute.idl_type.is_interface_type and len(arguments) == 0: | 321 if attribute.idl_type.is_interface_type and len(arguments) == 0: |
| 322 return 'WTF::getPtr(%s)' % expression | 322 return 'WTF::GetPtr(%s)' % expression |
| 323 return expression | 323 return expression |
| 324 | 324 |
| 325 | 325 |
| 326 CONTENT_ATTRIBUTE_GETTER_NAMES = { | 326 CONTENT_ATTRIBUTE_GETTER_NAMES = { |
| 327 'boolean': 'fastHasAttribute', | 327 'boolean': 'FastHasAttribute', |
| 328 'long': 'getIntegralAttribute', | 328 'long': 'GetIntegralAttribute', |
| 329 'unsigned long': 'getUnsignedIntegralAttribute', | 329 'unsigned long': 'GetUnsignedIntegralAttribute', |
| 330 } | 330 } |
| 331 | 331 |
| 332 | 332 |
| 333 def getter_base_name(interface, attribute, arguments): | 333 def getter_base_name(interface, attribute, arguments): |
| 334 extended_attributes = attribute.extended_attributes | 334 extended_attributes = attribute.extended_attributes |
| 335 | 335 |
| 336 if 'Reflect' not in extended_attributes: | 336 if 'Reflect' not in extended_attributes: |
| 337 return uncapitalize(cpp_name(attribute)) | 337 return uncapitalize(cpp_name(attribute)) |
| 338 | 338 |
| 339 content_attribute_name = extended_attributes['Reflect'] or attribute.name.lo
wer() | 339 content_attribute_name = extended_attributes['Reflect'] or attribute.name.lo
wer() |
| 340 if content_attribute_name in ['class', 'id', 'name']: | 340 if content_attribute_name in ['class', 'id', 'name']: |
| 341 # Special-case for performance optimization. | 341 # Special-case for performance optimization. |
| 342 return 'get%sAttribute' % content_attribute_name.capitalize() | 342 return 'Get%sAttribute' % content_attribute_name.capitalize() |
| 343 | 343 |
| 344 arguments.append(scoped_content_attribute_name(interface, attribute)) | 344 arguments.append(scoped_content_attribute_name(interface, attribute)) |
| 345 | 345 |
| 346 base_idl_type = attribute.idl_type.base_type | 346 base_idl_type = attribute.idl_type.base_type |
| 347 if base_idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES: | 347 if base_idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES: |
| 348 return CONTENT_ATTRIBUTE_GETTER_NAMES[base_idl_type] | 348 return CONTENT_ATTRIBUTE_GETTER_NAMES[base_idl_type] |
| 349 if 'URL' in attribute.extended_attributes: | 349 if 'URL' in attribute.extended_attributes: |
| 350 return 'getURLAttribute' | 350 return 'GetURLAttribute' |
| 351 return 'fastGetAttribute' | 351 return 'FastGetAttribute' |
| 352 | 352 |
| 353 | 353 |
| 354 def is_keep_alive_for_gc(interface, attribute): | 354 def is_keep_alive_for_gc(interface, attribute): |
| 355 idl_type = attribute.idl_type | 355 idl_type = attribute.idl_type |
| 356 base_idl_type = idl_type.base_type | 356 base_idl_type = idl_type.base_type |
| 357 extended_attributes = attribute.extended_attributes | 357 extended_attributes = attribute.extended_attributes |
| 358 return ( | 358 return ( |
| 359 # For readonly attributes, for performance reasons we keep the attribute | 359 # For readonly attributes, for performance reasons we keep the attribute |
| 360 # wrapper alive while the owner wrapper is alive, because the attribute | 360 # wrapper alive while the owner wrapper is alive, because the attribute |
| 361 # never changes. | 361 # never changes. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 387 try: | 387 try: |
| 388 attribute = next(candidate | 388 attribute = next(candidate |
| 389 for candidate in interface.attributes | 389 for candidate in interface.attributes |
| 390 if candidate.name == target_attribute_name) | 390 if candidate.name == target_attribute_name) |
| 391 except StopIteration: | 391 except StopIteration: |
| 392 raise Exception('[PutForward] target not found:\n' | 392 raise Exception('[PutForward] target not found:\n' |
| 393 'Attribute "%s" is not present in interface "%s"' % | 393 'Attribute "%s" is not present in interface "%s"' % |
| 394 (target_attribute_name, target_interface_name)) | 394 (target_attribute_name, target_interface_name)) |
| 395 | 395 |
| 396 if ('Replaceable' in attribute.extended_attributes): | 396 if ('Replaceable' in attribute.extended_attributes): |
| 397 context['cpp_setter'] = 'v8CallBoolean(info.Holder()->CreateDataProperty
(info.GetIsolate()->GetCurrentContext(), propertyName, v8Value))' | 397 context['cpp_setter'] = ( |
| 398 'V8CallBoolean(info.Holder()->CreateDataProperty(' + |
| 399 'info.GetIsolate()->GetCurrentContext(), propertyName, v8Value))') |
| 398 return | 400 return |
| 399 | 401 |
| 400 extended_attributes = attribute.extended_attributes | 402 extended_attributes = attribute.extended_attributes |
| 401 idl_type = attribute.idl_type | 403 idl_type = attribute.idl_type |
| 402 | 404 |
| 403 # [RaisesException], [RaisesException=Setter] | 405 # [RaisesException], [RaisesException=Setter] |
| 404 is_setter_raises_exception = ( | 406 is_setter_raises_exception = ( |
| 405 'RaisesException' in extended_attributes and | 407 'RaisesException' in extended_attributes and |
| 406 extended_attributes['RaisesException'] in [None, 'Setter']) | 408 extended_attributes['RaisesException'] in [None, 'Setter']) |
| 407 # [LegacyInterfaceTypeChecking] | 409 # [LegacyInterfaceTypeChecking] |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 arguments.append('*impl') | 444 arguments.append('*impl') |
| 443 idl_type = attribute.idl_type | 445 idl_type = attribute.idl_type |
| 444 if idl_type.base_type == 'EventHandler': | 446 if idl_type.base_type == 'EventHandler': |
| 445 getter_name = scoped_name(interface, attribute, cpp_name(attribute)) | 447 getter_name = scoped_name(interface, attribute, cpp_name(attribute)) |
| 446 context['event_handler_getter_expression'] = '%s(%s)' % ( | 448 context['event_handler_getter_expression'] = '%s(%s)' % ( |
| 447 getter_name, ', '.join(arguments)) | 449 getter_name, ', '.join(arguments)) |
| 448 if (interface.name in ['Window', 'WorkerGlobalScope'] and | 450 if (interface.name in ['Window', 'WorkerGlobalScope'] and |
| 449 attribute.name == 'onerror'): | 451 attribute.name == 'onerror'): |
| 450 includes.add('bindings/core/v8/V8ErrorHandler.h') | 452 includes.add('bindings/core/v8/V8ErrorHandler.h') |
| 451 arguments.append( | 453 arguments.append( |
| 452 'V8EventListenerHelper::ensureEventListener<V8ErrorHandler>(' + | 454 'V8EventListenerHelper::EnsureEventListener<V8ErrorHandler>(' + |
| 453 'v8Value, true, ScriptState::forReceiverObject(info))') | 455 'v8Value, true, ScriptState::ForReceiverObject(info))') |
| 454 else: | 456 else: |
| 455 arguments.append( | 457 arguments.append( |
| 456 'V8EventListenerHelper::getEventListener(' + | 458 'V8EventListenerHelper::GetEventListener(' + |
| 457 'ScriptState::forReceiverObject(info), v8Value, true, ' + | 459 'ScriptState::ForReceiverObject(info), v8Value, true, ' + |
| 458 'ListenerFindOrCreate)') | 460 'kListenerFindOrCreate)') |
| 459 else: | 461 else: |
| 460 arguments.append('cppValue') | 462 arguments.append('cppValue') |
| 461 if context['is_setter_raises_exception']: | 463 if context['is_setter_raises_exception']: |
| 462 arguments.append('exceptionState') | 464 arguments.append('exceptionState') |
| 463 | 465 |
| 464 return '%s(%s)' % (setter_name, ', '.join(arguments)) | 466 return '%s(%s)' % (setter_name, ', '.join(arguments)) |
| 465 | 467 |
| 466 | 468 |
| 467 CONTENT_ATTRIBUTE_SETTER_NAMES = { | 469 CONTENT_ATTRIBUTE_SETTER_NAMES = { |
| 468 'boolean': 'setBooleanAttribute', | 470 'boolean': 'SetBooleanAttribute', |
| 469 'long': 'setIntegralAttribute', | 471 'long': 'SetIntegralAttribute', |
| 470 'unsigned long': 'setUnsignedIntegralAttribute', | 472 'unsigned long': 'SetUnsignedIntegralAttribute', |
| 471 } | 473 } |
| 472 | 474 |
| 473 | 475 |
| 474 def setter_base_name(interface, attribute, arguments): | 476 def setter_base_name(interface, attribute, arguments): |
| 475 if 'Reflect' not in attribute.extended_attributes: | 477 if 'Reflect' not in attribute.extended_attributes: |
| 476 return 'set%s' % capitalize(cpp_name(attribute)) | 478 return 'set%s' % capitalize(cpp_name(attribute)) |
| 477 arguments.append(scoped_content_attribute_name(interface, attribute)) | 479 arguments.append(scoped_content_attribute_name(interface, attribute)) |
| 478 | 480 |
| 479 base_idl_type = attribute.idl_type.base_type | 481 base_idl_type = attribute.idl_type.base_type |
| 480 if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: | 482 if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 def is_constructor_attribute(attribute): | 562 def is_constructor_attribute(attribute): |
| 561 return attribute.idl_type.name.endswith('Constructor') | 563 return attribute.idl_type.name.endswith('Constructor') |
| 562 | 564 |
| 563 | 565 |
| 564 def is_named_constructor_attribute(attribute): | 566 def is_named_constructor_attribute(attribute): |
| 565 return attribute.idl_type.name.endswith('ConstructorConstructor') | 567 return attribute.idl_type.name.endswith('ConstructorConstructor') |
| 566 | 568 |
| 567 | 569 |
| 568 def update_constructor_attribute_context(interface, attribute, context): | 570 def update_constructor_attribute_context(interface, attribute, context): |
| 569 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 571 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
| OLD | NEW |