OLD | NEW |
---|---|
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 Loading... | |
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 exposed_global_names = extended_attributes.get('Exposed', 'Window').strip('( )').split(',') | 89 exposed_global_names = extended_attributes.get('Exposed', 'Window').strip('( )').split(',') |
Jens Widell
2014/12/09 08:25:12
Does this really work now? It doesn't look like ge
yhirano
2014/12/09 08:42:09
Yeah, I fixed this script in another CL(https://co
Jens Widell
2014/12/09 09:20:47
It would make sense to move that fix over from tha
| |
90 # Blink has Exposed(Arguments) form. In the form, each argument type | |
91 # represents the global context. | |
92 exposed_global_names = [name.split(' ')[0] for name in exposed_global_names] | |
93 | |
90 new_constructors_list = generate_global_constructors_list(interface_name, ex tended_attributes) | 94 new_constructors_list = generate_global_constructors_list(interface_name, ex tended_attributes) |
91 for exposed_global_name in exposed_global_names: | 95 for exposed_global_name in exposed_global_names: |
92 global_name_to_constructors[exposed_global_name].extend(new_constructors _list) | 96 global_name_to_constructors[exposed_global_name].extend(new_constructors _list) |
93 | 97 |
94 | 98 |
95 def generate_global_constructors_list(interface_name, extended_attributes): | 99 def generate_global_constructors_list(interface_name, extended_attributes): |
96 extended_attributes_list = [ | 100 extended_attributes_list = [ |
97 name + '=' + extended_attributes[name] | 101 name + '=' + extended_attributes[name] |
98 for name in 'Conditional', 'PerContextEnabled', 'RuntimeEnabled' | 102 for name in 'Conditional', 'PerContextEnabled', 'RuntimeEnabled' |
99 if name in extended_attributes] | 103 if name in extended_attributes] |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 constructors = interface_name_to_constructors(interface_name) | 177 constructors = interface_name_to_constructors(interface_name) |
174 write_global_constructors_partial_interface( | 178 write_global_constructors_partial_interface( |
175 interface_name, | 179 interface_name, |
176 idl_filename, | 180 idl_filename, |
177 constructors, | 181 constructors, |
178 options.write_file_only_if_changed) | 182 options.write_file_only_if_changed) |
179 | 183 |
180 | 184 |
181 if __name__ == '__main__': | 185 if __name__ == '__main__': |
182 sys.exit(main()) | 186 sys.exit(main()) |
OLD | NEW |