OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 def generate_code(self): | 326 def generate_code(self): |
327 union_types = self.info_provider.union_types | 327 union_types = self.info_provider.union_types |
328 if not union_types: | 328 if not union_types: |
329 return () | 329 return () |
330 header_template = self.jinja_env.get_template('union.h') | 330 header_template = self.jinja_env.get_template('union.h') |
331 cpp_template = self.jinja_env.get_template('union.cpp') | 331 cpp_template = self.jinja_env.get_template('union.cpp') |
332 template_context = v8_union.union_context( | 332 template_context = v8_union.union_context( |
333 union_types, self.info_provider.interfaces_info) | 333 union_types, self.info_provider.interfaces_info) |
334 template_context['code_generator'] = module_pyname | 334 template_context['code_generator'] = module_pyname |
335 capitalized_component = self.target_component.capitalize() | 335 capitalized_component = self.target_component.capitalize() |
| 336 template_context['exported'] = self.info_provider.specifier_for_export |
336 template_context['header_filename'] = 'bindings/%s/v8/UnionTypes%s.h' %
( | 337 template_context['header_filename'] = 'bindings/%s/v8/UnionTypes%s.h' %
( |
337 self.target_component, capitalized_component) | 338 self.target_component, capitalized_component) |
338 template_context['macro_guard'] = 'UnionType%s_h' % capitalized_componen
t | 339 template_context['macro_guard'] = 'UnionType%s_h' % capitalized_componen
t |
| 340 additional_header_includes = [self.info_provider.include_path_for_export
] |
339 | 341 |
340 # Add UnionTypesCore.h as a dependency when we generate modules union ty
pes | 342 # Add UnionTypesCore.h as a dependency when we generate modules union ty
pes |
341 # because we only generate union type containers which are used by both | 343 # because we only generate union type containers which are used by both |
342 # core and modules in UnionTypesCore.h. | 344 # core and modules in UnionTypesCore.h. |
343 # FIXME: This is an ad hoc workaround and we need a general way to | 345 # FIXME: This is an ad hoc workaround and we need a general way to |
344 # handle core <-> modules dependency. | 346 # handle core <-> modules dependency. |
345 if self.target_component == 'modules': | 347 if self.target_component == 'modules': |
346 template_context['header_includes'] = sorted( | 348 additional_header_includes.append( |
347 template_context['header_includes'] + | 349 'bindings/core/v8/UnionTypesCore.h') |
348 ['bindings/core/v8/UnionTypesCore.h']) | 350 |
| 351 template_context['header_includes'] = sorted( |
| 352 template_context['header_includes'] + additional_header_includes) |
349 | 353 |
350 header_text = header_template.render(template_context) | 354 header_text = header_template.render(template_context) |
351 cpp_text = cpp_template.render(template_context) | 355 cpp_text = cpp_template.render(template_context) |
352 header_path = posixpath.join(self.output_dir, | 356 header_path = posixpath.join(self.output_dir, |
353 'UnionTypes%s.h' % capitalized_component) | 357 'UnionTypes%s.h' % capitalized_component) |
354 cpp_path = posixpath.join(self.output_dir, | 358 cpp_path = posixpath.join(self.output_dir, |
355 'UnionTypes%s.cpp' % capitalized_component) | 359 'UnionTypes%s.cpp' % capitalized_component) |
356 return ( | 360 return ( |
357 (header_path, header_text), | 361 (header_path, header_text), |
358 (cpp_path, cpp_text), | 362 (cpp_path, cpp_text), |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 442 |
439 # Create a dummy file as output for the build system, | 443 # Create a dummy file as output for the build system, |
440 # since filenames of individual cache files are unpredictable and opaque | 444 # since filenames of individual cache files are unpredictable and opaque |
441 # (they are hashes of the template path, which varies based on environment) | 445 # (they are hashes of the template path, which varies based on environment) |
442 with open(dummy_filename, 'w') as dummy_file: | 446 with open(dummy_filename, 'w') as dummy_file: |
443 pass # |open| creates or touches the file | 447 pass # |open| creates or touches the file |
444 | 448 |
445 | 449 |
446 if __name__ == '__main__': | 450 if __name__ == '__main__': |
447 sys.exit(main(sys.argv)) | 451 sys.exit(main(sys.argv)) |
OLD | NEW |