| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 self.jinja_env = initialize_jinja_env(cache_dir) | 259 self.jinja_env = initialize_jinja_env(cache_dir) |
| 260 self.output_dir = output_dir | 260 self.output_dir = output_dir |
| 261 self.target_component = target_component | 261 self.target_component = target_component |
| 262 | 262 |
| 263 def generate_code(self, union_types): | 263 def generate_code(self, union_types): |
| 264 if not union_types: | 264 if not union_types: |
| 265 return () | 265 return () |
| 266 header_template = self.jinja_env.get_template('union.h') | 266 header_template = self.jinja_env.get_template('union.h') |
| 267 cpp_template = self.jinja_env.get_template('union.cpp') | 267 cpp_template = self.jinja_env.get_template('union.cpp') |
| 268 template_context = v8_union.union_context( | 268 template_context = v8_union.union_context( |
| 269 sorted(union_types, key=lambda union_type: union_type.name)) | 269 sorted(union_types, key=lambda union_type: union_type.name), |
| 270 self.interfaces_info) |
| 270 template_context['code_generator'] = module_pyname | 271 template_context['code_generator'] = module_pyname |
| 271 capitalized_component = self.target_component.capitalize() | 272 capitalized_component = self.target_component.capitalize() |
| 273 template_context['header_filename'] = 'bindings/%s/v8/UnionTypes%s.h' %
( |
| 274 self.target_component, capitalized_component) |
| 272 template_context['macro_guard'] = 'UnionType%s_h' % capitalized_componen
t | 275 template_context['macro_guard'] = 'UnionType%s_h' % capitalized_componen
t |
| 273 header_text = header_template.render(template_context) | 276 header_text = header_template.render(template_context) |
| 274 cpp_text = cpp_template.render(template_context) | 277 cpp_text = cpp_template.render(template_context) |
| 275 header_path = posixpath.join(self.output_dir, | 278 header_path = posixpath.join(self.output_dir, |
| 276 'UnionTypes%s.h' % capitalized_component) | 279 'UnionTypes%s.h' % capitalized_component) |
| 277 cpp_path = posixpath.join(self.output_dir, | 280 cpp_path = posixpath.join(self.output_dir, |
| 278 'UnionTypes%s.cpp' % capitalized_component) | 281 'UnionTypes%s.cpp' % capitalized_component) |
| 279 return ( | 282 return ( |
| 280 (header_path, header_text), | 283 (header_path, header_text), |
| 281 (cpp_path, cpp_text), | 284 (cpp_path, cpp_text), |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 364 |
| 362 # Create a dummy file as output for the build system, | 365 # Create a dummy file as output for the build system, |
| 363 # since filenames of individual cache files are unpredictable and opaque | 366 # since filenames of individual cache files are unpredictable and opaque |
| 364 # (they are hashes of the template path, which varies based on environment) | 367 # (they are hashes of the template path, which varies based on environment) |
| 365 with open(dummy_filename, 'w') as dummy_file: | 368 with open(dummy_filename, 'w') as dummy_file: |
| 366 pass # |open| creates or touches the file | 369 pass # |open| creates or touches the file |
| 367 | 370 |
| 368 | 371 |
| 369 if __name__ == '__main__': | 372 if __name__ == '__main__': |
| 370 sys.exit(main(sys.argv)) | 373 sys.exit(main(sys.argv)) |
| OLD | NEW |