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

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, 7 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),
11 hence "global constructors" for short. 11 hence "global constructors" for short.
12 12
13 For reference on global objects, see: 13 For reference on global objects, see:
14 http://heycam.github.io/webidl/#Global 14 http://heycam.github.io/webidl/#Global
15 http://heycam.github.io/webidl/#Exposed 15 http://heycam.github.io/webidl/#Exposed
16 16
17 Design document: http://www.chromium.org/developers/design-documents/idl-build 17 Design document: http://www.chromium.org/developers/design-documents/idl-build
18 """ 18 """
19 19
20 import itertools 20 import itertools
21 import optparse 21 import optparse
22 import os 22 import os
23 import cPickle as pickle 23 import cPickle as pickle
24 import re 24 import re
25 import sys 25 import sys
26 26
27 import v8_types
28 from v8_utilities import EXPOSED_EXECUTION_CONTEXT_METHOD
29
27 from collections import defaultdict 30 from collections import defaultdict
28 from utilities import should_generate_impl_file_from_idl, get_file_contents, idl _filename_to_interface_name, read_file_to_list, write_file, get_interface_extend ed_attributes_from_idl, get_interface_exposed_arguments, is_callback_interface_f rom_idl 31 from utilities import should_generate_impl_file_from_idl, get_file_contents, idl _filename_to_interface_name, read_file_to_list, write_file, get_interface_extend ed_attributes_from_idl, get_interface_exposed_arguments, is_callback_interface_f rom_idl
29 32
30 interface_name_to_global_names = {} 33 interface_name_to_global_names = {}
31 global_name_to_constructors = defaultdict(list) 34 global_name_to_constructors = defaultdict(list)
32 35
33 36
34 HEADER_FORMAT = """// Stub header file for {{idl_basename}} 37 HEADER_FORMAT = """// Stub header file for {{idl_basename}}
35 // Required because the IDL compiler assumes that a corresponding header file 38 // Required because the IDL compiler assumes that a corresponding header file
36 // exists for each IDL file. 39 // exists for each IDL file.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 interface_name_idl_filename = [(args[i], args[i + 1]) 162 interface_name_idl_filename = [(args[i], args[i + 1])
160 for i in range(0, len(args), 2)] 163 for i in range(0, len(args), 2)]
161 164
162 with open(options.global_objects_file) as global_objects_file: 165 with open(options.global_objects_file) as global_objects_file:
163 interface_name_to_global_names.update(pickle.load(global_objects_file)) 166 interface_name_to_global_names.update(pickle.load(global_objects_file))
164 167
165 for idl_filename in idl_files: 168 for idl_filename in idl_files:
166 record_global_constructors(idl_filename) 169 record_global_constructors(idl_filename)
167 170
168 # Check for [Exposed] / [Global] mismatch. 171 # Check for [Exposed] / [Global] mismatch.
169 known_global_names = frozenset(itertools.chain.from_iterable(interface_name_ to_global_names.values())) 172 known_global_names = EXPOSED_EXECUTION_CONTEXT_METHOD.keys()
170 exposed_global_names = frozenset(global_name_to_constructors) 173 exposed_global_names = frozenset(global_name_to_constructors)
171 if not exposed_global_names.issubset(known_global_names): 174 if not exposed_global_names.issubset(known_global_names):
172 unknown_global_names = exposed_global_names.difference(known_global_name s) 175 unknown_global_names = exposed_global_names.difference(known_global_name s)
173 raise ValueError('The following global names were used in ' 176 raise ValueError('The following global names were used in '
174 '[Exposed=xxx] but do not match any [Global] / ' 177 '[Exposed=xxx] but do not match any [Global] / '
175 '[PrimaryGlobal] interface: %s' 178 '[PrimaryGlobal] interface: %s'
176 % list(unknown_global_names)) 179 % list(unknown_global_names))
177 180
178 # Write partial interfaces containing constructor attributes for each 181 # Write partial interfaces containing constructor attributes for each
179 # global interface. 182 # global interface.
180 for interface_name, idl_filename in interface_name_idl_filename: 183 for interface_name, idl_filename in interface_name_idl_filename:
181 constructors = interface_name_to_constructors(interface_name) 184 constructors = interface_name_to_constructors(interface_name)
182 write_global_constructors_partial_interface( 185 write_global_constructors_partial_interface(
183 interface_name, 186 interface_name,
184 idl_filename, 187 idl_filename,
185 constructors, 188 constructors,
186 options.write_file_only_if_changed) 189 options.write_file_only_if_changed)
187 190
188 191
189 if __name__ == '__main__': 192 if __name__ == '__main__':
190 sys.exit(main()) 193 sys.exit(main())
OLDNEW
« no previous file with comments | « LayoutTests/webexposed/global-interface-listing-shared-worker.html ('k') | Source/core/dom/CompositorProxy.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698