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