OLD | NEW |
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 def __init__(self, cache_directory=None): | 161 def __init__(self, cache_directory=None): |
162 self.reader = IdlReader(interfaces_info=None, outputdir=cache_directory) | 162 self.reader = IdlReader(interfaces_info=None, outputdir=cache_directory) |
163 self.interfaces_info = {} | 163 self.interfaces_info = {} |
164 self.partial_interface_files = defaultdict(lambda: { | 164 self.partial_interface_files = defaultdict(lambda: { |
165 'full_paths': [], | 165 'full_paths': [], |
166 'include_paths': [], | 166 'include_paths': [], |
167 }) | 167 }) |
168 self.union_types = set() | 168 self.union_types = set() |
169 | 169 |
170 def add_paths_to_partials_dict(self, partial_interface_name, full_path, | 170 def add_paths_to_partials_dict(self, partial_interface_name, full_path, |
171 this_include_path=None): | 171 include_paths): |
172 paths_dict = self.partial_interface_files[partial_interface_name] | 172 paths_dict = self.partial_interface_files[partial_interface_name] |
173 paths_dict['full_paths'].append(full_path) | 173 paths_dict['full_paths'].append(full_path) |
174 if this_include_path: | 174 paths_dict['include_paths'].extend(include_paths) |
175 paths_dict['include_paths'].append(this_include_path) | |
176 | 175 |
177 def collect_info(self, idl_filename): | 176 def collect_info(self, idl_filename): |
178 """Reads an idl file and collects information which is required by the | 177 """Reads an idl file and collects information which is required by the |
179 binding code generation.""" | 178 binding code generation.""" |
180 definitions = self.reader.read_idl_file(idl_filename) | 179 definitions = self.reader.read_idl_file(idl_filename) |
181 if definitions.interfaces: | 180 if definitions.interfaces: |
182 definition = next(definitions.interfaces.itervalues()) | 181 definition = next(definitions.interfaces.itervalues()) |
183 interface_info = { | 182 interface_info = { |
184 'is_callback_interface': definition.is_callback, | 183 'is_callback_interface': definition.is_callback, |
185 'is_dictionary': False, | 184 'is_dictionary': False, |
(...skipping 19 matching lines...) Expand all Loading... |
205 this_union_types = collect_union_types_from_definitions(definitions) | 204 this_union_types = collect_union_types_from_definitions(definitions) |
206 self.union_types.update(this_union_types) | 205 self.union_types.update(this_union_types) |
207 | 206 |
208 extended_attributes = definition.extended_attributes | 207 extended_attributes = definition.extended_attributes |
209 implemented_as = extended_attributes.get('ImplementedAs') | 208 implemented_as = extended_attributes.get('ImplementedAs') |
210 full_path = os.path.realpath(idl_filename) | 209 full_path = os.path.realpath(idl_filename) |
211 this_include_path = None if 'NoImplHeader' in extended_attributes else i
nclude_path(idl_filename, implemented_as) | 210 this_include_path = None if 'NoImplHeader' in extended_attributes else i
nclude_path(idl_filename, implemented_as) |
212 if definition.is_partial: | 211 if definition.is_partial: |
213 # We don't create interface_info for partial interfaces, but | 212 # We don't create interface_info for partial interfaces, but |
214 # adds paths to another dict. | 213 # adds paths to another dict. |
215 self.add_paths_to_partials_dict(definition.name, full_path, this_inc
lude_path) | 214 partial_include_paths = [] |
| 215 if this_include_path: |
| 216 partial_include_paths.append(this_include_path) |
| 217 if this_union_types: |
| 218 component = idl_filename_to_component(idl_filename) |
| 219 partial_include_paths.append( |
| 220 'bindings/%s/v8/UnionTypes%s.h' % (component, component.capi
talize())) |
| 221 self.add_paths_to_partials_dict(definition.name, full_path, partial_
include_paths) |
216 return | 222 return |
217 | 223 |
218 # 'implements' statements can be included in either the file for the | 224 # 'implements' statements can be included in either the file for the |
219 # implement*ing* interface (lhs of 'implements') or implement*ed* interf
ace | 225 # implement*ing* interface (lhs of 'implements') or implement*ed* interf
ace |
220 # (rhs of 'implements'). Store both for now, then merge to implement*ing
* | 226 # (rhs of 'implements'). Store both for now, then merge to implement*ing
* |
221 # interface later. | 227 # interface later. |
222 left_interfaces, right_interfaces = get_implements_from_definitions( | 228 left_interfaces, right_interfaces = get_implements_from_definitions( |
223 definitions, definition.name) | 229 definitions, definition.name) |
224 | 230 |
225 interface_info.update({ | 231 interface_info.update({ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 282 |
277 write_pickle_file(options.interfaces_info_file, | 283 write_pickle_file(options.interfaces_info_file, |
278 info_collector.get_info_as_dict(), | 284 info_collector.get_info_as_dict(), |
279 options.write_file_only_if_changed) | 285 options.write_file_only_if_changed) |
280 write_pickle_file(options.component_info_file, | 286 write_pickle_file(options.component_info_file, |
281 info_collector.get_component_info_as_dict(), | 287 info_collector.get_component_info_as_dict(), |
282 options.write_file_only_if_changed) | 288 options.write_file_only_if_changed) |
283 | 289 |
284 if __name__ == '__main__': | 290 if __name__ == '__main__': |
285 sys.exit(main()) | 291 sys.exit(main()) |
OLD | NEW |