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

Side by Side Diff: Source/bindings/scripts/generate_global_constructors.py

Issue 1101583003: compositor-worker: Restrict the global interface in CompositorWorker. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Generates interface properties on global objects. 7 """Generates interface properties on global objects.
8 8
9 Concretely these are implemented as "constructor attributes", meaning 9 Concretely these are implemented as "constructor attributes", meaning
10 "attributes whose name ends with Constructor" (special-cased by code generator), 10 "attributes whose name ends with Constructor" (special-cased by code generator),
(...skipping 18 matching lines...) Expand all
29 29
30 interface_name_to_global_names = {} 30 interface_name_to_global_names = {}
31 global_name_to_constructors = defaultdict(list) 31 global_name_to_constructors = defaultdict(list)
32 32
33 33
34 HEADER_FORMAT = """// Stub header file for {{idl_basename}} 34 HEADER_FORMAT = """// Stub header file for {{idl_basename}}
35 // Required because the IDL compiler assumes that a corresponding header file 35 // Required because the IDL compiler assumes that a corresponding header file
36 // exists for each IDL file. 36 // exists for each IDL file.
37 """ 37 """
38 38
39 EXTRA_GLOBAL_NAME_FROM_MODULES = frozenset([
40 'CompositorWorker',
haraken 2015/04/22 11:07:28 Can we avoid adding this here by tweaking Exposure
sadrul 2015/04/22 22:17:19 The error I get without the change in this file is
41 ])
42
39 def parse_options(): 43 def parse_options():
40 parser = optparse.OptionParser() 44 parser = optparse.OptionParser()
41 parser.add_option('--idl-files-list', help='file listing IDL files') 45 parser.add_option('--idl-files-list', help='file listing IDL files')
42 parser.add_option('--global-objects-file', help='pickle file of global objec ts') 46 parser.add_option('--global-objects-file', help='pickle file of global objec ts')
43 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') 47 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')
44 48
45 options, args = parser.parse_args() 49 options, args = parser.parse_args()
46 50
47 if options.idl_files_list is None: 51 if options.idl_files_list is None:
48 parser.error('Must specify a file listing IDL files using --idl-files-li st.') 52 parser.error('Must specify a file listing IDL files using --idl-files-li st.')
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 interface_name_idl_filename = [(args[i], args[i + 1]) 163 interface_name_idl_filename = [(args[i], args[i + 1])
160 for i in range(0, len(args), 2)] 164 for i in range(0, len(args), 2)]
161 165
162 with open(options.global_objects_file) as global_objects_file: 166 with open(options.global_objects_file) as global_objects_file:
163 interface_name_to_global_names.update(pickle.load(global_objects_file)) 167 interface_name_to_global_names.update(pickle.load(global_objects_file))
164 168
165 for idl_filename in idl_files: 169 for idl_filename in idl_files:
166 record_global_constructors(idl_filename) 170 record_global_constructors(idl_filename)
167 171
168 # Check for [Exposed] / [Global] mismatch. 172 # Check for [Exposed] / [Global] mismatch.
169 known_global_names = frozenset(itertools.chain.from_iterable(interface_name_ to_global_names.values())) 173 known_global_names = set(itertools.chain.from_iterable(interface_name_to_glo bal_names.values()))
174 known_global_names.update(EXTRA_GLOBAL_NAME_FROM_MODULES)
170 exposed_global_names = frozenset(global_name_to_constructors) 175 exposed_global_names = frozenset(global_name_to_constructors)
171 if not exposed_global_names.issubset(known_global_names): 176 if not exposed_global_names.issubset(known_global_names):
172 unknown_global_names = exposed_global_names.difference(known_global_name s) 177 unknown_global_names = exposed_global_names.difference(known_global_name s)
173 raise ValueError('The following global names were used in ' 178 raise ValueError('The following global names were used in '
174 '[Exposed=xxx] but do not match any [Global] / ' 179 '[Exposed=xxx] but do not match any [Global] / '
175 '[PrimaryGlobal] interface: %s' 180 '[PrimaryGlobal] interface: %s'
176 % list(unknown_global_names)) 181 % list(unknown_global_names))
177 182
178 # Write partial interfaces containing constructor attributes for each 183 # Write partial interfaces containing constructor attributes for each
179 # global interface. 184 # global interface.
180 for interface_name, idl_filename in interface_name_idl_filename: 185 for interface_name, idl_filename in interface_name_idl_filename:
181 constructors = interface_name_to_constructors(interface_name) 186 constructors = interface_name_to_constructors(interface_name)
182 write_global_constructors_partial_interface( 187 write_global_constructors_partial_interface(
183 interface_name, 188 interface_name,
184 idl_filename, 189 idl_filename,
185 constructors, 190 constructors,
186 options.write_file_only_if_changed) 191 options.write_file_only_if_changed)
187 192
188 193
189 if __name__ == '__main__': 194 if __name__ == '__main__':
190 sys.exit(main()) 195 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698