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

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

Issue 301743008: Update run-bindings-tests per compute_interfaces_info split (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Cleaner Created 6 years, 6 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 (C) 2013 Google Inc. All rights reserved. 3 # Copyright (C) 2013 Google Inc. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 Needed for merging partial_interface_files across components. 125 Needed for merging partial_interface_files across components.
126 """ 126 """
127 for key, value in other.iteritems(): 127 for key, value in other.iteritems():
128 if key not in existing: 128 if key not in existing:
129 existing[key] = value 129 existing[key] = value
130 continue 130 continue
131 existing_value = existing[key] 131 existing_value = existing[key]
132 for inner_key, inner_value in value.iteritems(): 132 for inner_key, inner_value in value.iteritems():
133 existing_value[inner_key].extend(inner_value) 133 existing_value[inner_key].extend(inner_value)
134 134
135
135 ################################################################################ 136 ################################################################################
136 # Computations 137 # Computations
137 ################################################################################ 138 ################################################################################
138 139
140 def read_interfaces_info(interfaces_info_individual_filenames):
141 # Read in individual info from files
142 for interfaces_info_individual_filename in interfaces_info_individual_filena mes:
143 with open(interfaces_info_individual_filename) as interfaces_info_indivi dual_file:
144 yield pickle.load(interfaces_info_individual_file)
145
139 146
140 def compute_inheritance_info(interface_name): 147 def compute_inheritance_info(interface_name):
141 """Compute inheritance information, namely ancestors and inherited extended attributes.""" 148 """Compute inheritance information, namely ancestors and inherited extended attributes."""
142 def generate_ancestors(interface_name): 149 def generate_ancestors(interface_name):
143 while interface_name in parent_interfaces: 150 while interface_name in parent_interfaces:
144 interface_name = parent_interfaces[interface_name] 151 interface_name = parent_interfaces[interface_name]
145 yield interface_name 152 yield interface_name
146 153
147 ancestors = list(generate_ancestors(interface_name)) 154 ancestors = list(generate_ancestors(interface_name))
148 inherited_extended_attributes = inherited_extended_attributes_by_interface[i nterface_name] 155 inherited_extended_attributes = inherited_extended_attributes_by_interface[i nterface_name]
149 for ancestor in ancestors: 156 for ancestor in ancestors:
150 # Ancestors may not be present, notably if an ancestor is a generated 157 # Ancestors may not be present, notably if an ancestor is a generated
151 # IDL file and we are running this script from run-bindings-tests, 158 # IDL file and we are running this script from run-bindings-tests,
152 # where we don't generate these files. 159 # where we don't generate these files.
153 ancestor_extended_attributes = inherited_extended_attributes_by_interfac e.get(ancestor, {}) 160 ancestor_extended_attributes = inherited_extended_attributes_by_interfac e.get(ancestor, {})
154 inherited_extended_attributes.update(ancestor_extended_attributes) 161 inherited_extended_attributes.update(ancestor_extended_attributes)
155 162
156 interfaces_info[interface_name].update({ 163 interfaces_info[interface_name].update({
157 'ancestors': ancestors, 164 'ancestors': ancestors,
158 'inherited_extended_attributes': inherited_extended_attributes, 165 'inherited_extended_attributes': inherited_extended_attributes,
159 }) 166 })
160 167
161 168
162 def compute_interfaces_info_overall(interfaces_info_individual_filenames): 169 def compute_interfaces_info_overall(info_individuals):
163 """Compute information about IDL files. 170 """Compute information about IDL files.
164 171
165 Information is stored in global interfaces_info. 172 Information is stored in global interfaces_info.
166 """ 173 """
167 # Read in individual info from files 174 for info in info_individuals:
168 for interfaces_info_individual_filename in interfaces_info_individual_filena mes: 175 # No overlap between interface names, so ok to use dict.update
169 with open(interfaces_info_individual_filename) as interfaces_info_indivi dual_file: 176 interfaces_info.update(info['interfaces_info'])
170 info = pickle.load(interfaces_info_individual_file) 177 # Interfaces in one component may have partial interfaces in
171 # No overlap between interface names, so ok to use dict.update 178 # another component. This is ok (not a layering violation), since
172 interfaces_info.update(info['interfaces_info']) 179 # partial interfaces are used to *extend* interfaces.
173 # Interfaces in one component may have partial interfaces in 180 # We thus need to update or append if already present
174 # another component. This is ok (not a layering violation), since 181 dict_of_dicts_of_lists_update_or_append(
175 # partial interfaces are used to *extend* interfaces. 182 partial_interface_files, info['partial_interface_files'])
176 # We thus need to update or append if already present
177 dict_of_dicts_of_lists_update_or_append(
178 partial_interface_files, info['partial_interface_files'])
179 183
180 # Record inheritance information individually 184 # Record inheritance information individually
181 for interface_name, interface_info in interfaces_info.iteritems(): 185 for interface_name, interface_info in interfaces_info.iteritems():
182 extended_attributes = interface_info['extended_attributes'] 186 extended_attributes = interface_info['extended_attributes']
183 inherited_extended_attributes_by_interface[interface_name] = dict( 187 inherited_extended_attributes_by_interface[interface_name] = dict(
184 (key, value) 188 (key, value)
185 for key, value in extended_attributes.iteritems() 189 for key, value in extended_attributes.iteritems()
186 if key in INHERITED_EXTENDED_ATTRIBUTES) 190 if key in INHERITED_EXTENDED_ATTRIBUTES)
187 parent = interface_info['parent'] 191 parent = interface_info['parent']
188 if parent: 192 if parent:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 del interface_info['is_legacy_treat_as_partial_interface'] 252 del interface_info['is_legacy_treat_as_partial_interface']
249 del interface_info['parent'] 253 del interface_info['parent']
250 254
251 255
252 ################################################################################ 256 ################################################################################
253 257
254 def main(): 258 def main():
255 options, args = parse_options() 259 options, args = parse_options()
256 # args = Input1, Input2, ..., Output 260 # args = Input1, Input2, ..., Output
257 interfaces_info_filename = args.pop() 261 interfaces_info_filename = args.pop()
262 info_individuals = read_interfaces_info(args)
258 263
259 compute_interfaces_info_overall(args) 264 compute_interfaces_info_overall(info_individuals)
260 write_pickle_file(interfaces_info_filename, 265 write_pickle_file(interfaces_info_filename,
261 interfaces_info, 266 interfaces_info,
262 options.write_file_only_if_changed) 267 options.write_file_only_if_changed)
263 268
264 269
265 if __name__ == '__main__': 270 if __name__ == '__main__':
266 sys.exit(main()) 271 sys.exit(main())
OLDNEW
« no previous file with comments | « Source/bindings/scripts/compute_interfaces_info_individual.py ('k') | Tools/Scripts/webkitpy/bindings/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698