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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 Extends IdlTypeBase type with |enum_validation_expression| property. | 31 Extends IdlTypeBase type with |enum_validation_expression| property. |
32 | 32 |
33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
34 """ | 34 """ |
35 | 35 |
36 import re | 36 import re |
37 | 37 |
38 from idl_types import IdlTypeBase | 38 from idl_types import IdlTypeBase |
39 import idl_types | 39 import idl_types |
40 from idl_definitions import Exposure | 40 from idl_definitions import Exposure, IdlInterface |
41 from v8_globals import includes | 41 from v8_globals import includes |
42 import v8_types | 42 import v8_types |
43 | 43 |
44 ACRONYMS = [ | 44 ACRONYMS = [ |
45 'CSSOM', # must come *before* CSS to match full acronym | 45 'CSSOM', # must come *before* CSS to match full acronym |
46 'CSS', | 46 'CSS', |
47 'HTML', | 47 'HTML', |
48 'IME', | 48 'IME', |
49 'JS', | 49 'JS', |
50 'SVG', | 50 'SVG', |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 390 |
391 The returned function checks if a method/attribute is enabled. | 391 The returned function checks if a method/attribute is enabled. |
392 Given extended attribute RuntimeEnabled=FeatureName, return: | 392 Given extended attribute RuntimeEnabled=FeatureName, return: |
393 RuntimeEnabledFeatures::{featureName}Enabled | 393 RuntimeEnabledFeatures::{featureName}Enabled |
394 """ | 394 """ |
395 extended_attributes = definition_or_member.extended_attributes | 395 extended_attributes = definition_or_member.extended_attributes |
396 if 'RuntimeEnabled' not in extended_attributes: | 396 if 'RuntimeEnabled' not in extended_attributes: |
397 return None | 397 return None |
398 feature_name = extended_attributes['RuntimeEnabled'] | 398 feature_name = extended_attributes['RuntimeEnabled'] |
399 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) | 399 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) |
| 400 |
| 401 |
| 402 ################################################################################ |
| 403 # Indexed properties |
| 404 # http://heycam.github.io/webidl/#idl-indexed-properties |
| 405 ################################################################################ |
| 406 |
| 407 def indexed_property_getter(interface): |
| 408 try: |
| 409 # Find indexed property getter, if present; has form: |
| 410 # getter TYPE [OPTIONAL_IDENTIFIER](unsigned long ARG1) |
| 411 return next( |
| 412 method |
| 413 for method in interface.operations |
| 414 if ('getter' in method.specials and |
| 415 len(method.arguments) == 1 and |
| 416 str(method.arguments[0].idl_type) == 'unsigned long')) |
| 417 except StopIteration: |
| 418 return None |
| 419 |
| 420 |
| 421 def indexed_property_setter(interface): |
| 422 try: |
| 423 # Find indexed property setter, if present; has form: |
| 424 # setter RETURN_TYPE [OPTIONAL_IDENTIFIER](unsigned long ARG1, ARG_TYPE
ARG2) |
| 425 return next( |
| 426 method |
| 427 for method in interface.operations |
| 428 if ('setter' in method.specials and |
| 429 len(method.arguments) == 2 and |
| 430 str(method.arguments[0].idl_type) == 'unsigned long')) |
| 431 except StopIteration: |
| 432 return None |
| 433 |
| 434 |
| 435 def indexed_property_deleter(interface): |
| 436 try: |
| 437 # Find indexed property deleter, if present; has form: |
| 438 # deleter TYPE [OPTIONAL_IDENTIFIER](unsigned long ARG) |
| 439 return next( |
| 440 method |
| 441 for method in interface.operations |
| 442 if ('deleter' in method.specials and |
| 443 len(method.arguments) == 1 and |
| 444 str(method.arguments[0].idl_type) == 'unsigned long')) |
| 445 except StopIteration: |
| 446 return None |
| 447 |
| 448 |
| 449 ################################################################################ |
| 450 # Named properties |
| 451 # http://heycam.github.io/webidl/#idl-named-properties |
| 452 ################################################################################ |
| 453 |
| 454 def named_property_getter(interface): |
| 455 try: |
| 456 # Find named property getter, if present; has form: |
| 457 # getter TYPE [OPTIONAL_IDENTIFIER](DOMString ARG1) |
| 458 getter = next( |
| 459 method |
| 460 for method in interface.operations |
| 461 if ('getter' in method.specials and |
| 462 len(method.arguments) == 1 and |
| 463 str(method.arguments[0].idl_type) == 'DOMString')) |
| 464 getter.name = getter.name or 'anonymousNamedGetter' |
| 465 return getter |
| 466 except StopIteration: |
| 467 return None |
| 468 |
| 469 |
| 470 def named_property_setter(interface): |
| 471 try: |
| 472 # Find named property setter, if present; has form: |
| 473 # setter RETURN_TYPE [OPTIONAL_IDENTIFIER](DOMString ARG1, ARG_TYPE ARG2
) |
| 474 return next( |
| 475 method |
| 476 for method in interface.operations |
| 477 if ('setter' in method.specials and |
| 478 len(method.arguments) == 2 and |
| 479 str(method.arguments[0].idl_type) == 'DOMString')) |
| 480 except StopIteration: |
| 481 return None |
| 482 |
| 483 |
| 484 def named_property_deleter(interface): |
| 485 try: |
| 486 # Find named property deleter, if present; has form: |
| 487 # deleter TYPE [OPTIONAL_IDENTIFIER](DOMString ARG) |
| 488 return next( |
| 489 method |
| 490 for method in interface.operations |
| 491 if ('deleter' in method.specials and |
| 492 len(method.arguments) == 1 and |
| 493 str(method.arguments[0].idl_type) == 'DOMString')) |
| 494 except StopIteration: |
| 495 return None |
| 496 |
| 497 |
| 498 IdlInterface.indexed_property_getter = property(indexed_property_getter) |
| 499 IdlInterface.indexed_property_setter = property(indexed_property_setter) |
| 500 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) |
| 501 IdlInterface.named_property_getter = property(named_property_getter) |
| 502 IdlInterface.named_property_setter = property(named_property_setter) |
| 503 IdlInterface.named_property_deleter = property(named_property_deleter) |
OLD | NEW |