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