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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/code_generator_v8.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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 # [Conditional] 416 # [Conditional]
417 def conditional_if_endif(code, conditional_string): 417 def conditional_if_endif(code, conditional_string):
418 # Jinja2 filter to generate if/endif directive blocks 418 # Jinja2 filter to generate if/endif directive blocks
419 if not conditional_string: 419 if not conditional_string:
420 return code 420 return code
421 return ('#if %s\n' % conditional_string + 421 return ('#if %s\n' % conditional_string +
422 code + 422 code +
423 '#endif // %s\n' % conditional_string) 423 '#endif // %s\n' % conditional_string)
424 424
425 425
426 def maybe_add_conditional(code, test, conditional):
427 if not test:
428 return code
429 return generate_indented_conditional(code, conditional)
430
426 # [Exposed] 431 # [Exposed]
427 def exposed_if(code, exposed_test): 432 def exposed_if(code, exposed_test):
428 if not exposed_test: 433 return maybe_add_conditional(code, exposed_test, 'executionContext && (%s)' % exposed_test)
429 return code
430 return generate_indented_conditional(code, 'executionContext && (%s)' % expo sed_test)
431 434
432 435
433 # [RuntimeEnabled] 436 # [RuntimeEnabled]
434 def runtime_enabled_if(code, runtime_enabled_function_name): 437 def runtime_enabled_if(code, runtime_enabled_function_name):
435 if not runtime_enabled_function_name: 438 return maybe_add_conditional(code, runtime_enabled_function_name, '%s()' % r untime_enabled_function_name)
436 return code
437 return generate_indented_conditional(code, '%s()' % runtime_enabled_function _name)
438 439
439 440
440 ################################################################################ 441 ################################################################################
441 442
442 def main(argv): 443 def main(argv):
443 # If file itself executed, cache templates 444 # If file itself executed, cache templates
444 try: 445 try:
445 cache_dir = argv[1] 446 cache_dir = argv[1]
446 dummy_filename = argv[2] 447 dummy_filename = argv[2]
447 except IndexError as err: 448 except IndexError as err:
(...skipping 10 matching lines...) Expand all
458 459
459 # Create a dummy file as output for the build system, 460 # Create a dummy file as output for the build system,
460 # since filenames of individual cache files are unpredictable and opaque 461 # since filenames of individual cache files are unpredictable and opaque
461 # (they are hashes of the template path, which varies based on environment) 462 # (they are hashes of the template path, which varies based on environment)
462 with open(dummy_filename, 'w') as dummy_file: 463 with open(dummy_filename, 'w') as dummy_file:
463 pass # |open| creates or touches the file 464 pass # |open| creates or touches the file
464 465
465 466
466 if __name__ == '__main__': 467 if __name__ == '__main__':
467 sys.exit(main(sys.argv)) 468 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698