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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 """Functions shared by various parts of the code generator. | 29 """Functions shared by various parts of the code generator. |
30 | 30 |
31 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 31 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
32 """ | 32 """ |
33 | 33 |
34 import re | 34 import re |
35 | 35 |
36 from idl_types import IdlTypeBase | 36 from idl_types import IdlTypeBase |
37 import idl_types | 37 import idl_types |
38 from idl_definitions import Exposure, IdlInterface | 38 from idl_definitions import Exposure, IdlInterface, IdlAttribute, IdlOperation |
39 from v8_globals import includes | 39 from v8_globals import includes |
40 | 40 |
41 ACRONYMS = [ | 41 ACRONYMS = [ |
42 'CSSOM', # must come *before* CSS to match full acronym | 42 'CSSOM', # must come *before* CSS to match full acronym |
43 'CSS', | 43 'CSS', |
44 'HTML', | 44 'HTML', |
45 'IME', | 45 'IME', |
46 'JS', | 46 'JS', |
47 'SVG', | 47 'SVG', |
48 'URL', | 48 'URL', |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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] | 228 # [Constructor], [NamedConstructor] |
229 def is_constructor_attribute(member): | 229 def is_constructor_attribute(member): |
230 # TODO(yukishiino): replace this with [Constructor] and [NamedConstructor] e
xtended attribute | 230 # TODO(yukishiino): replace this with [Constructor] and [NamedConstructor] e
xtended attribute |
231 return member.idl_type.name.endswith('Constructor') | 231 return (type(member) == IdlAttribute and |
| 232 member.idl_type.name.endswith('Constructor')) |
232 | 233 |
233 | 234 |
234 # [DeprecateAs] | 235 # [DeprecateAs] |
235 def deprecate_as(member): | 236 def deprecate_as(member): |
236 extended_attributes = member.extended_attributes | 237 extended_attributes = member.extended_attributes |
237 if 'DeprecateAs' not in extended_attributes: | 238 if 'DeprecateAs' not in extended_attributes: |
238 return None | 239 return None |
239 includes.add('core/frame/UseCounter.h') | 240 includes.add('core/frame/UseCounter.h') |
240 return extended_attributes['DeprecateAs'] | 241 return extended_attributes['DeprecateAs'] |
241 | 242 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 443 |
443 # These members must not be placed on prototype chains. | 444 # These members must not be placed on prototype chains. |
444 if (is_constructor_attribute(member) or | 445 if (is_constructor_attribute(member) or |
445 member.is_static or | 446 member.is_static or |
446 is_unforgeable(interface, member)): | 447 is_unforgeable(interface, member)): |
447 return False | 448 return False |
448 | 449 |
449 # TODO(yukishiino): We should handle [Global] and [PrimaryGlobal] instead of | 450 # TODO(yukishiino): We should handle [Global] and [PrimaryGlobal] instead of |
450 # Window. | 451 # Window. |
451 if (interface.name == 'Window'): | 452 if (interface.name == 'Window'): |
452 return member.idl_type.name == 'EventHandler' | 453 return (member.idl_type.name == 'EventHandler' or |
| 454 type(member) == IdlOperation) |
453 | 455 |
454 return True | 456 return True |
455 | 457 |
456 | 458 |
457 # static, const | 459 # static, const |
458 def on_interface(interface, member): | 460 def on_interface(interface, member): |
459 """Returns True if the interface's member needs to be defined on the | 461 """Returns True if the interface's member needs to be defined on the |
460 interface object. | 462 interface object. |
461 | 463 |
462 The following members must be defiend on an interface object. | 464 The following members must be defiend on an interface object. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 except StopIteration: | 566 except StopIteration: |
565 return None | 567 return None |
566 | 568 |
567 | 569 |
568 IdlInterface.indexed_property_getter = property(indexed_property_getter) | 570 IdlInterface.indexed_property_getter = property(indexed_property_getter) |
569 IdlInterface.indexed_property_setter = property(indexed_property_setter) | 571 IdlInterface.indexed_property_setter = property(indexed_property_setter) |
570 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) | 572 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) |
571 IdlInterface.named_property_getter = property(named_property_getter) | 573 IdlInterface.named_property_getter = property(named_property_getter) |
572 IdlInterface.named_property_setter = property(named_property_setter) | 574 IdlInterface.named_property_setter = property(named_property_setter) |
573 IdlInterface.named_property_deleter = property(named_property_deleter) | 575 IdlInterface.named_property_deleter = property(named_property_deleter) |
OLD | NEW |