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

Side by Side Diff: sky/engine/bindings2/scripts/generate_event_interfaces.py

Issue 914413004: Add a new bindings2/scripts directory for Dart bindings (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Remove idlrenderer.py it's not used Created 5 years, 10 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (C) 2013 Google Inc. All rights reserved. 3 # Copyright (C) 2013 Google Inc. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 30 matching lines...) Expand all
41 """ 41 """
42 42
43 from optparse import OptionParser 43 from optparse import OptionParser
44 import os 44 import os
45 import posixpath 45 import posixpath
46 import sys 46 import sys
47 47
48 from utilities import get_file_contents, read_file_to_list, write_file, get_inte rface_extended_attributes_from_idl 48 from utilities import get_file_contents, read_file_to_list, write_file, get_inte rface_extended_attributes_from_idl
49 49
50 EXPORTED_EXTENDED_ATTRIBUTES = ( 50 EXPORTED_EXTENDED_ATTRIBUTES = (
51 'Conditional',
52 'ImplementedAs', 51 'ImplementedAs',
53 'RuntimeEnabled',
54 ) 52 )
55 module_path = os.path.dirname(os.path.realpath(__file__)) 53 module_path = os.path.dirname(os.path.realpath(__file__))
56 source_dir = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir)) 54 source_dir = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir))
57 55
58 56
59 def parse_options(): 57 def parse_options():
60 parser = OptionParser() 58 parser = OptionParser()
61 parser.add_option('--event-idl-files-list', help='file listing event IDL fil es') 59 parser.add_option('--event-idl-files-list', help='file listing event IDL fil es')
62 parser.add_option('--event-interfaces-file', help='output file') 60 parser.add_option('--event-interfaces-file', help='output file')
63 parser.add_option('--write-file-only-if-changed', type='int', help='if true, do not write an output file if it would be identical to the existing one, which avoids unnecessary rebuilds in ninja') 61 parser.add_option('--write-file-only-if-changed', type='int', help='if true, do not write an output file if it would be identical to the existing one, which avoids unnecessary rebuilds in ninja')
64 parser.add_option('--suffix', help='specify a suffix to the namespace, i.e., "Modules". Default is None.') 62 parser.add_option('--suffix', help='specify a suffix to the namespace, i.e., "Modules". Default is None.')
65 63
66 options, args = parser.parse_args() 64 options, args = parser.parse_args()
67 if options.event_idl_files_list is None: 65 if options.event_idl_files_list is None:
68 parser.error('Must specify a file listing event IDL files using --event- idl-files-list.') 66 parser.error('Must specify a file listing event IDL files using --event- idl-files-list.')
69 if options.event_interfaces_file is None: 67 if options.event_interfaces_file is None:
70 parser.error('Must specify an output file using --event-interfaces-file. ') 68 parser.error('Must specify an output file using --event-interfaces-file. ')
71 if options.write_file_only_if_changed is None: 69 if options.write_file_only_if_changed is None:
72 parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.') 70 parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.')
73 options.write_file_only_if_changed = bool(options.write_file_only_if_changed ) 71 options.write_file_only_if_changed = bool(options.write_file_only_if_changed )
74 if args: 72 if args:
75 parser.error('No arguments allowed, but %d given.' % len(args)) 73 parser.error('No arguments allowed, but %d given.' % len(args))
76 return options 74 return options
77 75
78 76
79 def write_event_interfaces_file(event_idl_files, destination_filename, only_if_c hanged, suffix): 77 def write_event_interfaces_file(event_idl_files, destination_filename, only_if_c hanged, suffix):
80 def extended_attribute_string(name, value): 78 def extended_attribute_string(name, value):
81 if name == 'RuntimeEnabled':
82 value += 'Enabled'
83 return name + '=' + value 79 return name + '=' + value
84 80
85 def interface_line(full_path): 81 def interface_line(full_path):
86 relative_path_local, _ = os.path.splitext(os.path.relpath(full_path, sou rce_dir)) 82 relative_path_local, _ = os.path.splitext(os.path.relpath(full_path, sou rce_dir))
87 relative_path_posix = relative_path_local.replace(os.sep, posixpath.sep) 83 relative_path_posix = relative_path_local.replace(os.sep, posixpath.sep)
88 84
89 idl_file_contents = get_file_contents(full_path) 85 idl_file_contents = get_file_contents(full_path)
90 extended_attributes = get_interface_extended_attributes_from_idl(idl_fil e_contents) 86 extended_attributes = get_interface_extended_attributes_from_idl(idl_fil e_contents)
91 extended_attributes_list = [ 87 extended_attributes_list = [
92 extended_attribute_string(name, extended_attributes[name]) 88 extended_attribute_string(name, extended_attributes[name])
(...skipping 20 matching lines...) Expand all
113 options = parse_options() 109 options = parse_options()
114 event_idl_files = read_file_to_list(options.event_idl_files_list) 110 event_idl_files = read_file_to_list(options.event_idl_files_list)
115 write_event_interfaces_file(event_idl_files, 111 write_event_interfaces_file(event_idl_files,
116 options.event_interfaces_file, 112 options.event_interfaces_file,
117 options.write_file_only_if_changed, 113 options.write_file_only_if_changed,
118 options.suffix) 114 options.suffix)
119 115
120 116
121 if __name__ == '__main__': 117 if __name__ == '__main__':
122 sys.exit(main()) 118 sys.exit(main())
OLDNEW
« no previous file with comments | « sky/engine/bindings2/scripts/dart_utilities.py ('k') | sky/engine/bindings2/scripts/idl_definitions.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698