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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return lambda suffix: extended_attributes['MeasureAs'] | 359 return lambda suffix: extended_attributes['MeasureAs'] |
360 if 'Measure' in extended_attributes: | 360 if 'Measure' in extended_attributes: |
361 includes.add('core/frame/UseCounter.h') | 361 includes.add('core/frame/UseCounter.h') |
362 measure_as_name = capitalize(definition_or_member.name) | 362 measure_as_name = capitalize(definition_or_member.name) |
363 if interface is not None: | 363 if interface is not None: |
364 measure_as_name = '%s_%s' % (capitalize(interface.name), measure_as_
name) | 364 measure_as_name = '%s_%s' % (capitalize(interface.name), measure_as_
name) |
365 return lambda suffix: 'V8%s_%s' % (measure_as_name, suffix) | 365 return lambda suffix: 'V8%s_%s' % (measure_as_name, suffix) |
366 return None | 366 return None |
367 | 367 |
368 | 368 |
| 369 # [OriginTrialEnabled] |
| 370 def origin_trial_enabled_function_name(definition_or_member, interface): |
| 371 """Returns the name of the OriginTrials enabled function. |
| 372 |
| 373 An exception is raised if both the OriginTrialEnabled and RuntimeEnabled |
| 374 extended attributes are applied to the same IDL member. Only one of the |
| 375 two attributes can be applied to any member - they are mutually exclusive. |
| 376 |
| 377 The returned function checks if the IDL member should be enabled. |
| 378 Given extended attribute OriginTrialEnabled=FeatureName, return: |
| 379 OriginTrials::{featureName}Enabled |
| 380 |
| 381 If the OriginTrialEnabled extended attribute is found, the includes are |
| 382 also updated as a side-effect. |
| 383 """ |
| 384 extended_attributes = definition_or_member.extended_attributes |
| 385 is_origin_trial_enabled = 'OriginTrialEnabled' in extended_attributes |
| 386 |
| 387 if (is_origin_trial_enabled and 'RuntimeEnabled' in extended_attributes): |
| 388 raise Exception('[OriginTrialEnabled] and [RuntimeEnabled] must ' |
| 389 'not be specified on the same definition: ' |
| 390 '%s.%s' % (definition_or_member.idl_name, definition_or_
member.name)) |
| 391 |
| 392 if is_origin_trial_enabled: |
| 393 includes.add('core/inspector/ConsoleMessage.h') |
| 394 includes.add('core/origin_trials/OriginTrials.h') |
| 395 |
| 396 trial_name = extended_attributes['OriginTrialEnabled'] |
| 397 return 'OriginTrials::%sEnabled' % uncapitalize(trial_name) |
| 398 |
| 399 return None |
| 400 |
| 401 |
369 def runtime_feature_name(definition_or_member): | 402 def runtime_feature_name(definition_or_member): |
370 extended_attributes = definition_or_member.extended_attributes | 403 extended_attributes = definition_or_member.extended_attributes |
371 if 'RuntimeEnabled' not in extended_attributes: | 404 if 'RuntimeEnabled' not in extended_attributes: |
372 return None | 405 return None |
373 return extended_attributes['RuntimeEnabled'] | 406 return extended_attributes['RuntimeEnabled'] |
374 | 407 |
375 | 408 |
376 def is_origin_trial_enabled(definition_or_member): | |
377 return 'OriginTrialEnabled' in definition_or_member.extended_attributes | |
378 | |
379 | |
380 def origin_trial_name(definition_or_member): | |
381 return definition_or_member.extended_attributes['OriginTrialEnabled'] if is_
origin_trial_enabled(definition_or_member) else None | |
382 | |
383 | |
384 def origin_trial_enabled_function(definition_or_member): | |
385 trial_name = origin_trial_name(definition_or_member) | |
386 feature_name = runtime_feature_name(definition_or_member) | |
387 if not feature_name or not trial_name: | |
388 return | |
389 return 'OriginTrials::%sEnabled' % uncapitalize(feature_name) | |
390 | |
391 | |
392 # [RuntimeEnabled] | 409 # [RuntimeEnabled] |
393 def runtime_enabled_function_name(definition_or_member): | 410 def runtime_enabled_function_name(definition_or_member): |
394 """Returns the name of the RuntimeEnabledFeatures function. | 411 """Returns the name of the RuntimeEnabledFeatures function. |
395 | 412 |
396 The returned function checks if a method/attribute is enabled. | 413 The returned function checks if a method/attribute is enabled. |
397 Given extended attribute RuntimeEnabled=FeatureName, return: | 414 Given extended attribute RuntimeEnabled=FeatureName, return: |
398 RuntimeEnabledFeatures::{featureName}Enabled | 415 RuntimeEnabledFeatures::{featureName}Enabled |
| 416 |
| 417 If the RuntimeEnabled extended attribute is found, the includes |
| 418 are also updated as a side-effect. |
399 """ | 419 """ |
400 feature_name = runtime_feature_name(definition_or_member) | 420 feature_name = runtime_feature_name(definition_or_member) |
401 | 421 |
402 # If an origin trial is on the method/attribute, it overrides the runtime | 422 if not feature_name: |
403 # enabled status. For now, we are unconditionally installing these | |
404 # attributes/methods, so we are acting as though the runtime enabled | |
405 # function doesn't exist. (It is checked in the generated OriginTrials | |
406 # function, instead) | |
407 trial_name = origin_trial_name(definition_or_member) | |
408 if not feature_name or trial_name: | |
409 return | 423 return |
| 424 |
| 425 includes.add('platform/RuntimeEnabledFeatures.h') |
410 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) | 426 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) |
411 | 427 |
412 | 428 |
413 # [Unforgeable] | 429 # [Unforgeable] |
414 def is_unforgeable(interface, member): | 430 def is_unforgeable(interface, member): |
415 return (('Unforgeable' in interface.extended_attributes or | 431 return (('Unforgeable' in interface.extended_attributes or |
416 'Unforgeable' in member.extended_attributes) and | 432 'Unforgeable' in member.extended_attributes) and |
417 not member.is_static) | 433 not member.is_static) |
418 | 434 |
419 | 435 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 except StopIteration: | 609 except StopIteration: |
594 return None | 610 return None |
595 | 611 |
596 | 612 |
597 IdlInterface.indexed_property_getter = property(indexed_property_getter) | 613 IdlInterface.indexed_property_getter = property(indexed_property_getter) |
598 IdlInterface.indexed_property_setter = property(indexed_property_setter) | 614 IdlInterface.indexed_property_setter = property(indexed_property_setter) |
599 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) | 615 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) |
600 IdlInterface.named_property_getter = property(named_property_getter) | 616 IdlInterface.named_property_getter = property(named_property_getter) |
601 IdlInterface.named_property_setter = property(named_property_setter) | 617 IdlInterface.named_property_setter = property(named_property_setter) |
602 IdlInterface.named_property_deleter = property(named_property_deleter) | 618 IdlInterface.named_property_deleter = property(named_property_deleter) |
OLD | NEW |