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 def write_global_constructors_partial_interface(interface_name, destination_file
name, constructor_attributes_list, only_if_changed): | 96 def write_global_constructors_partial_interface(interface_name, destination_file
name, constructor_attributes_list, only_if_changed): |
97 # FIXME: replace this with a simple Jinja template | 97 # FIXME: replace this with a simple Jinja template |
98 lines = (['[\n'] + | 98 lines = (['[\n'] + |
99 [' NoHeader,\n'] + | 99 [' NoHeader,\n'] + |
100 [']\n'] + | 100 [']\n'] + |
101 ['partial interface %s {\n' % interface_name] + | 101 ['partial interface %s {\n' % interface_name] + |
102 [' %s;\n' % constructor_attribute | 102 [' %s;\n' % constructor_attribute |
103 # FIXME: sort by interface name (not first by extended attributes) | 103 # FIXME: sort by interface name (not first by extended attributes) |
104 for constructor_attribute in sorted(constructor_attributes_list)]
+ | 104 for constructor_attribute in sorted(constructor_attributes_list)]
+ |
105 ['};\n']) | 105 ['};\n']) |
106 write_file(lines, destination_filename, only_if_changed) | 106 write_file(''.join(lines), destination_filename, only_if_changed) |
107 | 107 |
108 | 108 |
109 ################################################################################ | 109 ################################################################################ |
110 | 110 |
111 def main(): | 111 def main(): |
112 options, args = parse_options() | 112 options, args = parse_options() |
113 | 113 |
114 # Input IDL files are passed in a file, due to OS command line length | 114 # Input IDL files are passed in a file, due to OS command line length |
115 # limits. This is generated at GYP time, which is ok b/c files are static. | 115 # limits. This is generated at GYP time, which is ok b/c files are static. |
116 with open(options.idl_files_list) as idl_files_list: | 116 with open(options.idl_files_list) as idl_files_list: |
(...skipping 14 matching lines...) Expand all Loading... |
131 | 131 |
132 for idl_filename in idl_files: | 132 for idl_filename in idl_files: |
133 record_global_constructors(idl_filename) | 133 record_global_constructors(idl_filename) |
134 | 134 |
135 for interface_name, global_object in global_objects.iteritems(): | 135 for interface_name, global_object in global_objects.iteritems(): |
136 write_global_constructors_partial_interface(interface_name, global_objec
t['filename'], global_object['constructors'], options.write_file_only_if_changed
) | 136 write_global_constructors_partial_interface(interface_name, global_objec
t['filename'], global_object['constructors'], options.write_file_only_if_changed
) |
137 | 137 |
138 | 138 |
139 if __name__ == '__main__': | 139 if __name__ == '__main__': |
140 sys.exit(main()) | 140 sys.exit(main()) |
OLD | NEW |