Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2589)

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/v8_utilities.py

Issue 1531443003: [bindings] Implement an ExperimentEnabled IDL extended attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 return lambda suffix: extended_attributes['MeasureAs'] 373 return lambda suffix: extended_attributes['MeasureAs']
374 if 'Measure' in extended_attributes: 374 if 'Measure' in extended_attributes:
375 includes.add('core/frame/UseCounter.h') 375 includes.add('core/frame/UseCounter.h')
376 measure_as_name = capitalize(definition_or_member.name) 376 measure_as_name = capitalize(definition_or_member.name)
377 if interface is not None: 377 if interface is not None:
378 measure_as_name = '%s_%s' % (capitalize(interface.name), measure_as_ name) 378 measure_as_name = '%s_%s' % (capitalize(interface.name), measure_as_ name)
379 return lambda suffix: 'V8%s_%s' % (measure_as_name, suffix) 379 return lambda suffix: 'V8%s_%s' % (measure_as_name, suffix)
380 return None 380 return None
381 381
382 382
383 def runtime_feature_name(definition_or_member):
384 extended_attributes = definition_or_member.extended_attributes
385 if 'RuntimeEnabled' not in extended_attributes:
386 return None
387 return extended_attributes['RuntimeEnabled']
388
389
390 def is_api_experiment_enabled(definition_or_member):
391 return 'APIExperimentEnabled' in definition_or_member.extended_attributes
392
393
394 def api_experiment_name(definition_or_member):
395 return definition_or_member.extended_attributes['APIExperimentEnabled'] if i s_api_experiment_enabled(definition_or_member) else None
396
397
398 def api_experiment_enabled_function(definition_or_member):
399 experiment_name = api_experiment_name(definition_or_member)
400 feature_name = runtime_feature_name(definition_or_member)
401 if not feature_name or not experiment_name:
402 return
403 return 'ExperimentalFeatures::%sEnabled' % uncapitalize(feature_name)
404
405
383 # [RuntimeEnabled] 406 # [RuntimeEnabled]
384 def runtime_enabled_function_name(definition_or_member): 407 def runtime_enabled_function_name(definition_or_member):
385 """Returns the name of the RuntimeEnabledFeatures function. 408 """Returns the name of the RuntimeEnabledFeatures function.
386 409
387 The returned function checks if a method/attribute is enabled. 410 The returned function checks if a method/attribute is enabled.
388 Given extended attribute RuntimeEnabled=FeatureName, return: 411 Given extended attribute RuntimeEnabled=FeatureName, return:
389 RuntimeEnabledFeatures::{featureName}Enabled 412 RuntimeEnabledFeatures::{featureName}Enabled
390 """ 413 """
391 extended_attributes = definition_or_member.extended_attributes 414 feature_name = runtime_feature_name(definition_or_member)
392 if 'RuntimeEnabled' not in extended_attributes: 415
393 return None 416 # If an API experiment is on the method/attribute, it overrides the runtime
394 feature_name = extended_attributes['RuntimeEnabled'] 417 # enabled status. For now, we are unconditionally installing experimental
418 # attributes/methods, so we are acting as though the runtime enabled
419 # function doesn't exist. (It is checked in the generated
420 # ExperimentalFeatures function, instead)
421 experiment_name = api_experiment_name(definition_or_member)
422 if not feature_name or experiment_name:
423 return
395 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) 424 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name)
396 425
397 426
398 # [Unforgeable] 427 # [Unforgeable]
399 def is_unforgeable(interface, member): 428 def is_unforgeable(interface, member):
400 return (('Unforgeable' in interface.extended_attributes or 429 return (('Unforgeable' in interface.extended_attributes or
401 'Unforgeable' in member.extended_attributes) and 430 'Unforgeable' in member.extended_attributes) and
402 not member.is_static) 431 not member.is_static)
403 432
404 433
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 except StopIteration: 607 except StopIteration:
579 return None 608 return None
580 609
581 610
582 IdlInterface.indexed_property_getter = property(indexed_property_getter) 611 IdlInterface.indexed_property_getter = property(indexed_property_getter)
583 IdlInterface.indexed_property_setter = property(indexed_property_setter) 612 IdlInterface.indexed_property_setter = property(indexed_property_setter)
584 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) 613 IdlInterface.indexed_property_deleter = property(indexed_property_deleter)
585 IdlInterface.named_property_getter = property(named_property_getter) 614 IdlInterface.named_property_getter = property(named_property_getter)
586 IdlInterface.named_property_setter = property(named_property_setter) 615 IdlInterface.named_property_setter = property(named_property_setter)
587 IdlInterface.named_property_deleter = property(named_property_deleter) 616 IdlInterface.named_property_deleter = property(named_property_deleter)
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/v8_methods.py ('k') | third_party/WebKit/Source/bindings/templates/attributes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698