Chromium Code Reviews| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 def conditional_string(definition_or_member): | 221 def conditional_string(definition_or_member): |
| 222 extended_attributes = definition_or_member.extended_attributes | 222 extended_attributes = definition_or_member.extended_attributes |
| 223 if 'Conditional' not in extended_attributes: | 223 if 'Conditional' not in extended_attributes: |
| 224 return None | 224 return None |
| 225 return 'ENABLE(%s)' % extended_attributes['Conditional'] | 225 return 'ENABLE(%s)' % extended_attributes['Conditional'] |
| 226 | 226 |
| 227 | 227 |
| 228 # [Constructor], [NamedConstructor] | |
| 229 def is_constructor_attribute(member): | |
| 230 # TODO: replace this with [Constructor] and [NamedConstructor] extended attr ibute | |
|
haraken
2015/06/17 16:31:21
TODO(yukishiino)
Yuki
2015/06/18 07:44:41
Done.
| |
| 231 return member.idl_type.name.endswith('Constructor') | |
| 232 | |
| 233 | |
| 228 # [DeprecateAs] | 234 # [DeprecateAs] |
| 229 def deprecate_as(member): | 235 def deprecate_as(member): |
| 230 extended_attributes = member.extended_attributes | 236 extended_attributes = member.extended_attributes |
| 231 if 'DeprecateAs' not in extended_attributes: | 237 if 'DeprecateAs' not in extended_attributes: |
| 232 return None | 238 return None |
| 233 includes.add('core/frame/UseCounter.h') | 239 includes.add('core/frame/UseCounter.h') |
| 234 return extended_attributes['DeprecateAs'] | 240 return extended_attributes['DeprecateAs'] |
| 235 | 241 |
| 236 | 242 |
| 237 # [Exposed] | 243 # [Exposed] |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 | 403 |
| 398 # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking] | 404 # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking] |
| 399 def is_legacy_interface_type_checking(interface, member): | 405 def is_legacy_interface_type_checking(interface, member): |
| 400 if not ('TypeChecking' in interface.extended_attributes or | 406 if not ('TypeChecking' in interface.extended_attributes or |
| 401 'TypeChecking' in member.extended_attributes): | 407 'TypeChecking' in member.extended_attributes): |
| 402 return True | 408 return True |
| 403 if 'LegacyInterfaceTypeChecking' in member.extended_attributes: | 409 if 'LegacyInterfaceTypeChecking' in member.extended_attributes: |
| 404 return True | 410 return True |
| 405 return False | 411 return False |
| 406 | 412 |
| 413 | |
| 414 # [Unforgeable], [OverrideBuiltins], [Global], [PrimaryGlobal] and [ExposeJSAcce ssors] / [DoNotExposeJSAccessors] | |
|
haraken
2015/06/17 16:31:21
This comment is a bit confusing.
- You have the s
bashi
2015/06/18 02:16:27
I'd recommend to have docstring to describe how th
Yuki
2015/06/18 07:44:40
Done.
Yuki
2015/06/18 07:44:40
Done.
| |
| 415 def on_instance(interface, member): | |
| 416 return not on_prototype(interface, member) | |
| 417 | |
| 418 | |
| 419 # [Unforgeable], [OverrideBuiltins], [Global], [PrimaryGlobal] and [ExposeJSAcce ssors] / [DoNotExposeJSAccessors] | |
| 420 def on_prototype(interface, member): | |
| 421 if ('ExposeJSAccessors' in interface.extended_attributes and | |
| 422 'DoNotExposeJSAccessors' in interface.extended_attributes): | |
| 423 raise Exception('Both of ExposeJSAccessors and DoNotExposeJSAccessors ar e specified at a time in an interface: ' + interface.name) | |
| 424 if ('ExposeJSAccessors' in member.extended_attributes and | |
| 425 'DoNotExposeJSAccessors' in member.extended_attributes): | |
| 426 raise Exception('Both of ExposeJSAccessors and DoNotExposeJSAccessors ar e specified at a time on a member: ' + member.name + ' in an interface: ' + inte rface.name) | |
| 427 | |
| 428 # Note that ExposeJSAccessors and DoNotExposeJSAccessors are more powerful | |
| 429 # than 'static', [Unforgeable] and [OverrideBuiltins]. | |
| 430 if 'ExposeJSAccessors' in member.extended_attributes: | |
| 431 return True | |
| 432 if 'DoNotExposeJSAccessors' in member.extended_attributes: | |
| 433 return False | |
| 434 | |
| 435 # These members must not be placed on prototype chains. | |
| 436 if (is_constructor_attribute(member) or | |
| 437 member.is_static or | |
| 438 is_unforgeable(interface, member) or | |
| 439 'OverrideBuiltins' in interface.extended_attributes): | |
| 440 return False | |
| 441 | |
| 442 # TODO(yukishiino): We should handle [Global] and [PrimaryGlobal] instead of | |
| 443 # Window. | |
| 444 if (interface.name == 'Window'): | |
| 445 return member.idl_type.name == 'EventHandler' | |
| 446 | |
| 447 # TODO(yukishiino): We should move all of the following members to prototype | |
| 448 # chains. | |
| 449 if ('Custom' in member.extended_attributes): | |
|
bashi
2015/06/18 02:16:27
nit: drop parenthesis.
Yuki
2015/06/18 07:44:40
Done.
| |
| 450 return False | |
| 451 | |
| 452 if 'ExposeJSAccessors' in interface.extended_attributes: | |
| 453 return True | |
| 454 if 'DoNotExposeJSAccessors' in interface.extended_attributes: | |
| 455 return False | |
|
haraken
2015/06/17 16:31:21
It's a bit confusing that the priority of [ExposeJ
Yuki
2015/06/18 07:44:41
Well, however, we should not place static members
| |
| 456 | |
| 457 return True | |
| 458 | |
| 459 | |
| 460 # [Unforgeable], [OverrideBuiltins], [Global], [PrimaryGlobal] and [ExposeJSAcce ssors] / [DoNotExposeJSAccessors] | |
| 461 def on_interface(interface, member): | |
| 462 return False | |
|
haraken
2015/06/17 16:31:21
Just help me understand: When should on_interface
Yuki
2015/06/18 07:44:41
constants and static members must be defined on th
| |
| 463 | |
| 464 | |
| 407 ################################################################################ | 465 ################################################################################ |
| 408 # Indexed properties | 466 # Indexed properties |
| 409 # http://heycam.github.io/webidl/#idl-indexed-properties | 467 # http://heycam.github.io/webidl/#idl-indexed-properties |
| 410 ################################################################################ | 468 ################################################################################ |
| 411 | 469 |
| 412 def indexed_property_getter(interface): | 470 def indexed_property_getter(interface): |
| 413 try: | 471 try: |
| 414 # Find indexed property getter, if present; has form: | 472 # Find indexed property getter, if present; has form: |
| 415 # getter TYPE [OPTIONAL_IDENTIFIER](unsigned long ARG1) | 473 # getter TYPE [OPTIONAL_IDENTIFIER](unsigned long ARG1) |
| 416 return next( | 474 return next( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 except StopIteration: | 557 except StopIteration: |
| 500 return None | 558 return None |
| 501 | 559 |
| 502 | 560 |
| 503 IdlInterface.indexed_property_getter = property(indexed_property_getter) | 561 IdlInterface.indexed_property_getter = property(indexed_property_getter) |
| 504 IdlInterface.indexed_property_setter = property(indexed_property_setter) | 562 IdlInterface.indexed_property_setter = property(indexed_property_setter) |
| 505 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) | 563 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) |
| 506 IdlInterface.named_property_getter = property(named_property_getter) | 564 IdlInterface.named_property_getter = property(named_property_getter) |
| 507 IdlInterface.named_property_setter = property(named_property_setter) | 565 IdlInterface.named_property_setter = property(named_property_setter) |
| 508 IdlInterface.named_property_deleter = property(named_property_deleter) | 566 IdlInterface.named_property_deleter = property(named_property_deleter) |
| OLD | NEW |