| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 Input: An object of class IdlDefinitions, containing an IDL interface X | 42 Input: An object of class IdlDefinitions, containing an IDL interface X |
| 43 Output: V8X.h and V8X.cpp | 43 Output: V8X.h and V8X.cpp |
| 44 | 44 |
| 45 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 45 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
| 46 """ | 46 """ |
| 47 | 47 |
| 48 import os | 48 import os |
| 49 import posixpath | 49 import posixpath |
| 50 | 50 |
| 51 from code_generator import CodeGeneratorBase, normalize_and_sort_includes | 51 from code_generator import CodeGeneratorBase, render_template, normalize_and_sor
t_includes |
| 52 from idl_definitions import Visitor | 52 from idl_definitions import Visitor |
| 53 from idl_types import IdlType | 53 from idl_types import IdlType |
| 54 import v8_callback_function | 54 import v8_callback_function |
| 55 import v8_callback_interface | 55 import v8_callback_interface |
| 56 import v8_dictionary | 56 import v8_dictionary |
| 57 from v8_globals import includes | 57 from v8_globals import includes |
| 58 import v8_interface | 58 import v8_interface |
| 59 import v8_types | 59 import v8_types |
| 60 import v8_union | 60 import v8_union |
| 61 from v8_utilities import cpp_name | 61 from v8_utilities import cpp_name |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 template_context = v8_union.container_context( | 295 template_context = v8_union.container_context( |
| 296 union_type, self.info_provider.interfaces_info) | 296 union_type, self.info_provider.interfaces_info) |
| 297 template_context['header_includes'].append( | 297 template_context['header_includes'].append( |
| 298 self.info_provider.include_path_for_export) | 298 self.info_provider.include_path_for_export) |
| 299 template_context['header_includes'] = normalize_and_sort_includes( | 299 template_context['header_includes'] = normalize_and_sort_includes( |
| 300 template_context['header_includes']) | 300 template_context['header_includes']) |
| 301 template_context['code_generator'] = self.generator_name | 301 template_context['code_generator'] = self.generator_name |
| 302 template_context['exported'] = self.info_provider.specifier_for_export | 302 template_context['exported'] = self.info_provider.specifier_for_export |
| 303 name = shorten_union_name(union_type) | 303 name = shorten_union_name(union_type) |
| 304 template_context['this_include_header_name'] = name | 304 template_context['this_include_header_name'] = name |
| 305 header_text = header_template.render(template_context) | 305 header_text = render_template(header_template, template_context) |
| 306 cpp_text = cpp_template.render(template_context) | 306 cpp_text = render_template(cpp_template, template_context) |
| 307 header_path = posixpath.join(self.output_dir, '%s.h' % name) | 307 header_path = posixpath.join(self.output_dir, '%s.h' % name) |
| 308 cpp_path = posixpath.join(self.output_dir, '%s.cpp' % name) | 308 cpp_path = posixpath.join(self.output_dir, '%s.cpp' % name) |
| 309 return ( | 309 return ( |
| 310 (header_path, header_text), | 310 (header_path, header_text), |
| 311 (cpp_path, cpp_text), | 311 (cpp_path, cpp_text), |
| 312 ) | 312 ) |
| 313 | 313 |
| 314 def _get_union_types_for_containers(self): | 314 def _get_union_types_for_containers(self): |
| 315 union_types = self.info_provider.union_types | 315 union_types = self.info_provider.union_types |
| 316 if not union_types: | 316 if not union_types: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 cpp_template = self.jinja_env.get_template('callback_function.cpp.tmpl') | 350 cpp_template = self.jinja_env.get_template('callback_function.cpp.tmpl') |
| 351 template_context = v8_callback_function.callback_function_context( | 351 template_context = v8_callback_function.callback_function_context( |
| 352 callback_function) | 352 callback_function) |
| 353 if not is_testing_target(path): | 353 if not is_testing_target(path): |
| 354 template_context['exported'] = self.info_provider.specifier_for_expo
rt | 354 template_context['exported'] = self.info_provider.specifier_for_expo
rt |
| 355 template_context['header_includes'].append( | 355 template_context['header_includes'].append( |
| 356 self.info_provider.include_path_for_export) | 356 self.info_provider.include_path_for_export) |
| 357 template_context['header_includes'] = normalize_and_sort_includes( | 357 template_context['header_includes'] = normalize_and_sort_includes( |
| 358 template_context['header_includes']) | 358 template_context['header_includes']) |
| 359 template_context['code_generator'] = MODULE_PYNAME | 359 template_context['code_generator'] = MODULE_PYNAME |
| 360 header_text = header_template.render(template_context) | 360 header_text = render_template(header_template, template_context) |
| 361 cpp_text = cpp_template.render(template_context) | 361 cpp_text = render_template(cpp_template, template_context) |
| 362 header_path = posixpath.join(self.output_dir, '%s.h' % callback_function
.name) | 362 header_path = posixpath.join(self.output_dir, '%s.h' % callback_function
.name) |
| 363 cpp_path = posixpath.join(self.output_dir, '%s.cpp' % callback_function.
name) | 363 cpp_path = posixpath.join(self.output_dir, '%s.cpp' % callback_function.
name) |
| 364 return ( | 364 return ( |
| 365 (header_path, header_text), | 365 (header_path, header_text), |
| 366 (cpp_path, cpp_text), | 366 (cpp_path, cpp_text), |
| 367 ) | 367 ) |
| 368 | 368 |
| 369 # pylint: disable=W0221 | 369 # pylint: disable=W0221 |
| 370 def generate_code(self): | 370 def generate_code(self): |
| 371 callback_functions = self.info_provider.callback_functions | 371 callback_functions = self.info_provider.callback_functions |
| 372 if not callback_functions: | 372 if not callback_functions: |
| 373 return () | 373 return () |
| 374 outputs = set() | 374 outputs = set() |
| 375 for callback_function_dict in callback_functions.itervalues(): | 375 for callback_function_dict in callback_functions.itervalues(): |
| 376 if callback_function_dict['component_dir'] != self.target_component: | 376 if callback_function_dict['component_dir'] != self.target_component: |
| 377 continue | 377 continue |
| 378 callback_function = callback_function_dict['callback_function'] | 378 callback_function = callback_function_dict['callback_function'] |
| 379 if 'Custom' in callback_function.extended_attributes: | 379 if 'Custom' in callback_function.extended_attributes: |
| 380 continue | 380 continue |
| 381 path = callback_function_dict['full_path'] | 381 path = callback_function_dict['full_path'] |
| 382 outputs.update(self.generate_code_internal(callback_function, path)) | 382 outputs.update(self.generate_code_internal(callback_function, path)) |
| 383 return outputs | 383 return outputs |
| OLD | NEW |