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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 # Exposed=env or Exposed=(env1,...) case | 96 # Exposed=env or Exposed=(env1,...) case |
97 exposed_global_names = extended_attributes.get('Exposed', 'Window').stri
p('()').split(',') | 97 exposed_global_names = extended_attributes.get('Exposed', 'Window').stri
p('()').split(',') |
98 new_constructors_list = generate_global_constructors_list(interface_name
, extended_attributes) | 98 new_constructors_list = generate_global_constructors_list(interface_name
, extended_attributes) |
99 for name in exposed_global_names: | 99 for name in exposed_global_names: |
100 global_name_to_constructors[name].extend(new_constructors_list) | 100 global_name_to_constructors[name].extend(new_constructors_list) |
101 | 101 |
102 | 102 |
103 def generate_global_constructors_list(interface_name, extended_attributes): | 103 def generate_global_constructors_list(interface_name, extended_attributes): |
104 extended_attributes_list = [ | 104 extended_attributes_list = [ |
105 name + '=' + extended_attributes[name] | 105 name + '=' + extended_attributes[name] |
106 for name in 'Conditional', 'PerContextEnabled', 'RuntimeEnabled' | 106 for name in 'Conditional', 'RuntimeEnabled' |
107 if name in extended_attributes] | 107 if name in extended_attributes] |
108 if extended_attributes_list: | 108 if extended_attributes_list: |
109 extended_string = '[%s] ' % ', '.join(extended_attributes_list) | 109 extended_string = '[%s] ' % ', '.join(extended_attributes_list) |
110 else: | 110 else: |
111 extended_string = '' | 111 extended_string = '' |
112 | 112 |
113 attribute_string = 'attribute {interface_name}Constructor {interface_name}'.
format(interface_name=interface_name) | 113 attribute_string = 'attribute {interface_name}Constructor {interface_name}'.
format(interface_name=interface_name) |
114 attributes_list = [extended_string + attribute_string] | 114 attributes_list = [extended_string + attribute_string] |
115 | 115 |
116 # In addition to the usual interface property, for every [NamedConstructor] | 116 # In addition to the usual interface property, for every [NamedConstructor] |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 constructors = interface_name_to_constructors(interface_name) | 181 constructors = interface_name_to_constructors(interface_name) |
182 write_global_constructors_partial_interface( | 182 write_global_constructors_partial_interface( |
183 interface_name, | 183 interface_name, |
184 idl_filename, | 184 idl_filename, |
185 constructors, | 185 constructors, |
186 options.write_file_only_if_changed) | 186 options.write_file_only_if_changed) |
187 | 187 |
188 | 188 |
189 if __name__ == '__main__': | 189 if __name__ == '__main__': |
190 sys.exit(main()) | 190 sys.exit(main()) |
OLD | NEW |