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

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

Issue 189543008: Factor abstract base class IDLCompiler, concrete class IDLComplierV8 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: get_file_contents() Created 6 years, 9 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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())
OLDNEW
« no previous file with comments | « Source/bindings/scripts/generate_event_interfaces.py ('k') | Source/bindings/scripts/idl_compiler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698