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

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

Issue 434133002: Support WebIDL's ExtendedAttributeIdentList in the Blink parser (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 years, 4 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 # http://heycam.github.io/webidl/#es-interfaces 79 # http://heycam.github.io/webidl/#es-interfaces
80 if (is_callback_interface_from_idl(idl_file_contents) or 80 if (is_callback_interface_from_idl(idl_file_contents) or
81 'NoInterfaceObject' in extended_attributes): 81 'NoInterfaceObject' in extended_attributes):
82 return 82 return
83 83
84 # The [Exposed] extended attribute MUST take an identifier list. Each 84 # The [Exposed] extended attribute MUST take an identifier list. Each
85 # identifier in the list MUST be a global name. An interface or interface 85 # identifier in the list MUST be a global name. An interface or interface
86 # member the extended attribute applies to will be exposed only on objects 86 # member the extended attribute applies to will be exposed only on objects
87 # associated with ECMAScript global environments whose global object 87 # associated with ECMAScript global environments whose global object
88 # implements an interface that has a matching global name. 88 # implements an interface that has a matching global name.
89 # FIXME: In spec names are comma-separated, but that makes parsing very 89 exposed_global_names = extended_attributes.get('Exposed', 'Window').strip('( )').split(',')
90 # difficult (https://www.w3.org/Bugs/Public/show_bug.cgi?id=24959).
91 exposed_global_names = extended_attributes.get('Exposed', 'Window').split('& ')
92 new_constructors_list = generate_global_constructors_list(interface_name, ex tended_attributes) 90 new_constructors_list = generate_global_constructors_list(interface_name, ex tended_attributes)
93 for exposed_global_name in exposed_global_names: 91 for exposed_global_name in exposed_global_names:
94 global_name_to_constructors[exposed_global_name].extend(new_constructors _list) 92 global_name_to_constructors[exposed_global_name].extend(new_constructors _list)
95 93
96 94
97 def generate_global_constructors_list(interface_name, extended_attributes): 95 def generate_global_constructors_list(interface_name, extended_attributes):
98 extended_attributes_list = [ 96 extended_attributes_list = [
99 name + '=' + extended_attributes[name] 97 name + '=' + extended_attributes[name]
100 for name in 'Conditional', 'PerContextEnabled', 'RuntimeEnabled' 98 for name in 'Conditional', 'PerContextEnabled', 'RuntimeEnabled'
101 if name in extended_attributes] 99 if name in extended_attributes]
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 constructors = interface_name_to_constructors(interface_name) 173 constructors = interface_name_to_constructors(interface_name)
176 write_global_constructors_partial_interface( 174 write_global_constructors_partial_interface(
177 interface_name, 175 interface_name,
178 idl_filename, 176 idl_filename,
179 constructors, 177 constructors,
180 options.write_file_only_if_changed) 178 options.write_file_only_if_changed)
181 179
182 180
183 if __name__ == '__main__': 181 if __name__ == '__main__':
184 sys.exit(main()) 182 sys.exit(main())
OLDNEW
« no previous file with comments | « Source/bindings/scripts/compute_global_objects.py ('k') | Source/bindings/scripts/idl_validator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698