| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 from collections import defaultdict | 44 from collections import defaultdict |
| 45 import optparse | 45 import optparse |
| 46 import os | 46 import os |
| 47 import posixpath | 47 import posixpath |
| 48 import sys | 48 import sys |
| 49 | 49 |
| 50 from idl_compiler import idl_filename_to_interface_name | 50 from idl_compiler import idl_filename_to_interface_name |
| 51 from idl_definitions import Visitor | 51 from idl_definitions import Visitor |
| 52 from idl_reader import IdlReader | 52 from idl_reader import IdlReader |
| 53 from utilities import get_file_contents, read_file_to_list, idl_filename_to_inte
rface_name, idl_filename_to_component, write_pickle_file, get_interface_extended
_attributes_from_idl, is_callback_interface_from_idl, merge_dict_recursively | 53 from utilities import get_file_contents, read_file_to_list, idl_filename_to_inte
rface_name, idl_filename_to_component, write_pickle_file, get_interface_extended
_attributes_from_idl, is_callback_interface_from_idl, merge_dict_recursively, sh
orten_union_name |
| 54 | 54 |
| 55 module_path = os.path.dirname(__file__) | 55 module_path = os.path.dirname(__file__) |
| 56 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir)) | 56 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir)) |
| 57 gen_path = os.path.join('gen', 'blink') | 57 gen_path = os.path.join('gen', 'blink') |
| 58 | 58 |
| 59 | 59 |
| 60 class IdlBadFilenameError(Exception): | 60 class IdlBadFilenameError(Exception): |
| 61 """Raised if an IDL filename disagrees with the interface name in the file."
"" | 61 """Raised if an IDL filename disagrees with the interface name in the file."
"" |
| 62 pass | 62 pass |
| 63 | 63 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 extended_attributes = definition.extended_attributes | 259 extended_attributes = definition.extended_attributes |
| 260 implemented_as = extended_attributes.get('ImplementedAs') | 260 implemented_as = extended_attributes.get('ImplementedAs') |
| 261 full_path = os.path.realpath(idl_filename) | 261 full_path = os.path.realpath(idl_filename) |
| 262 this_include_path = None if 'NoImplHeader' in extended_attributes else i
nclude_path(idl_filename, implemented_as) | 262 this_include_path = None if 'NoImplHeader' in extended_attributes else i
nclude_path(idl_filename, implemented_as) |
| 263 if definition.is_partial: | 263 if definition.is_partial: |
| 264 # We don't create interface_info for partial interfaces, but | 264 # We don't create interface_info for partial interfaces, but |
| 265 # adds paths to another dict. | 265 # adds paths to another dict. |
| 266 partial_include_paths = [] | 266 partial_include_paths = [] |
| 267 if this_include_path: | 267 if this_include_path: |
| 268 partial_include_paths.append(this_include_path) | 268 partial_include_paths.append(this_include_path) |
| 269 if this_union_types: | 269 for union_type in this_union_types: |
| 270 name = shorten_union_name(union_type) |
| 270 partial_include_paths.append( | 271 partial_include_paths.append( |
| 271 'bindings/%s/v8/UnionTypes%s.h' % (component, component.capi
talize())) | 272 'bindings/%s/v8/%s.h' % (component, name)) |
| 272 self.add_paths_to_partials_dict(definition.name, full_path, partial_
include_paths) | 273 self.add_paths_to_partials_dict(definition.name, full_path, partial_
include_paths) |
| 273 # Collects C++ header paths which should be included from generated | 274 # Collects C++ header paths which should be included from generated |
| 274 # .cpp files. The resulting structure is as follows. | 275 # .cpp files. The resulting structure is as follows. |
| 275 # interfaces_info[interface_name] = { | 276 # interfaces_info[interface_name] = { |
| 276 # 'cpp_includes': { | 277 # 'cpp_includes': { |
| 277 # 'core': set(['core/foo/Foo.h', ...]), | 278 # 'core': set(['core/foo/Foo.h', ...]), |
| 278 # 'modules': set(['modules/bar/Bar.h', ...]), | 279 # 'modules': set(['modules/bar/Bar.h', ...]), |
| 279 # }, | 280 # }, |
| 280 # ... | 281 # ... |
| 281 # } | 282 # } |
| 282 if this_include_path: | 283 if this_include_path: |
| 283 merge_dict_recursively( | 284 merge_dict_recursively( |
| 284 self.interfaces_info[definition.name], | 285 self.interfaces_info[definition.name], |
| 285 {'cpp_includes': {component: set([this_include_path])}}) | 286 {'cpp_includes': {component: set([this_include_path])}}) |
| 286 return | 287 return |
| 287 | 288 |
| 288 # 'implements' statements can be included in either the file for the | 289 # 'implements' statements can be included in either the file for the |
| 289 # implement*ing* interface (lhs of 'implements') or implement*ed* interf
ace | 290 # implement*ing* interface (lhs of 'implements') or implement*ed* interf
ace |
| 290 # (rhs of 'implements'). Store both for now, then merge to implement*ing
* | 291 # (rhs of 'implements'). Store both for now, then merge to implement*ing
* |
| 291 # interface later. | 292 # interface later. |
| 292 left_interfaces, right_interfaces = get_implements_from_definitions( | 293 left_interfaces, right_interfaces = get_implements_from_definitions( |
| 293 definitions, definition.name) | 294 definitions, definition.name) |
| 294 | 295 |
| 295 interface_info.update({ | 296 interface_info.update({ |
| 296 'extended_attributes': extended_attributes, | 297 'extended_attributes': extended_attributes, |
| 297 'full_path': full_path, | 298 'full_path': full_path, |
| 298 'has_union_types': bool(this_union_types), | 299 'union_types': this_union_types, |
| 299 'implemented_as': implemented_as, | 300 'implemented_as': implemented_as, |
| 300 'implemented_by_interfaces': left_interfaces, | 301 'implemented_by_interfaces': left_interfaces, |
| 301 'implements_interfaces': right_interfaces, | 302 'implements_interfaces': right_interfaces, |
| 302 'include_path': this_include_path, | 303 'include_path': this_include_path, |
| 303 # FIXME: temporary private field, while removing old treatement of | 304 # FIXME: temporary private field, while removing old treatement of |
| 304 # 'implements': http://crbug.com/360435 | 305 # 'implements': http://crbug.com/360435 |
| 305 'is_legacy_treat_as_partial_interface': 'LegacyTreatAsPartialInterfa
ce' in extended_attributes, | 306 'is_legacy_treat_as_partial_interface': 'LegacyTreatAsPartialInterfa
ce' in extended_attributes, |
| 306 'parent': definition.parent, | 307 'parent': definition.parent, |
| 307 'relative_dir': relative_dir_posix(idl_filename, source_path), | 308 'relative_dir': relative_dir_posix(idl_filename, source_path), |
| 308 }) | 309 }) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 350 |
| 350 write_pickle_file(options.interfaces_info_file, | 351 write_pickle_file(options.interfaces_info_file, |
| 351 info_collector.get_info_as_dict(), | 352 info_collector.get_info_as_dict(), |
| 352 options.write_file_only_if_changed) | 353 options.write_file_only_if_changed) |
| 353 write_pickle_file(options.component_info_file, | 354 write_pickle_file(options.component_info_file, |
| 354 info_collector.get_component_info_as_dict(), | 355 info_collector.get_component_info_as_dict(), |
| 355 options.write_file_only_if_changed) | 356 options.write_file_only_if_changed) |
| 356 | 357 |
| 357 if __name__ == '__main__': | 358 if __name__ == '__main__': |
| 358 sys.exit(main()) | 359 sys.exit(main()) |
| OLD | NEW |