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

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: tot-merge 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 from v8_utilities import EXPOSED_EXECUTION_CONTEXT_METHOD
28
27 from collections import defaultdict 29 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 30 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 31
30 interface_name_to_global_names = {} 32 interface_name_to_global_names = {}
31 global_name_to_constructors = defaultdict(list) 33 global_name_to_constructors = defaultdict(list)
32 34
33 35
34 HEADER_FORMAT = """// Stub header file for {{idl_basename}} 36 HEADER_FORMAT = """// Stub header file for {{idl_basename}}
35 // Required because the IDL compiler assumes that a corresponding header file 37 // Required because the IDL compiler assumes that a corresponding header file
36 // exists for each IDL file. 38 // 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]) 161 interface_name_idl_filename = [(args[i], args[i + 1])
160 for i in range(0, len(args), 2)] 162 for i in range(0, len(args), 2)]
161 163
162 with open(options.global_objects_file) as global_objects_file: 164 with open(options.global_objects_file) as global_objects_file:
163 interface_name_to_global_names.update(pickle.load(global_objects_file)) 165 interface_name_to_global_names.update(pickle.load(global_objects_file))
164 166
165 for idl_filename in idl_files: 167 for idl_filename in idl_files:
166 record_global_constructors(idl_filename) 168 record_global_constructors(idl_filename)
167 169
168 # Check for [Exposed] / [Global] mismatch. 170 # Check for [Exposed] / [Global] mismatch.
169 known_global_names = frozenset(itertools.chain.from_iterable(interface_name_ to_global_names.values())) 171 known_global_names = EXPOSED_EXECUTION_CONTEXT_METHOD.keys()
170 exposed_global_names = frozenset(global_name_to_constructors) 172 exposed_global_names = frozenset(global_name_to_constructors)
171 if not exposed_global_names.issubset(known_global_names): 173 if not exposed_global_names.issubset(known_global_names):
172 unknown_global_names = exposed_global_names.difference(known_global_name s) 174 unknown_global_names = exposed_global_names.difference(known_global_name s)
173 raise ValueError('The following global names were used in ' 175 raise ValueError('The following global names were used in '
174 '[Exposed=xxx] but do not match any [Global] / ' 176 '[Exposed=xxx] but do not match any [Global] / '
175 '[PrimaryGlobal] interface: %s' 177 '[PrimaryGlobal] interface: %s'
176 % list(unknown_global_names)) 178 % list(unknown_global_names))
177 179
178 # Write partial interfaces containing constructor attributes for each 180 # Write partial interfaces containing constructor attributes for each
179 # global interface. 181 # global interface.
180 for interface_name, idl_filename in interface_name_idl_filename: 182 for interface_name, idl_filename in interface_name_idl_filename:
181 constructors = interface_name_to_constructors(interface_name) 183 constructors = interface_name_to_constructors(interface_name)
182 write_global_constructors_partial_interface( 184 write_global_constructors_partial_interface(
183 interface_name, 185 interface_name,
184 idl_filename, 186 idl_filename,
185 constructors, 187 constructors,
186 options.write_file_only_if_changed) 188 options.write_file_only_if_changed)
187 189
188 190
189 if __name__ == '__main__': 191 if __name__ == '__main__':
190 sys.exit(main()) 192 sys.exit(main())
OLDNEW
« no previous file with comments | « LayoutTests/webexposed/global-interface-listing-compositor-worker-expected.txt ('k') | Source/core/dom/CompositorProxy.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698