Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 """Generate Blink V8 bindings (.h and .cpp files). | 29 """Generate Blink V8 bindings (.h and .cpp files). |
| 30 | 30 |
| 31 UNSTABLE: Not currently used in build. | |
|
haraken
2013/09/18 09:45:36
UNSTABLE => FIXME ?
Nils Barth (inactive)
2013/09/18 09:53:30
Done!
| |
| 32 This is a rewrite of the Perl IDL compiler in Python, but is not complete. | |
| 33 Once it is complete, we will switch all IDL files over to Python at once. | |
| 34 Until then, please work on the Perl IDL compiler. | |
| 35 For details, see bug http://crbug.com/239771 | |
| 36 | |
| 31 Input: An object of class IdlDefinitions, containing an IDL interface X | 37 Input: An object of class IdlDefinitions, containing an IDL interface X |
| 32 Output: V8X.h and V8X.cpp | 38 Output: V8X.h and V8X.cpp |
| 33 """ | 39 """ |
| 34 | 40 |
| 35 import os | 41 import os |
| 36 import posixpath | 42 import posixpath |
| 37 import sys | 43 import sys |
| 38 | 44 |
| 39 # jinja2 is in chromium's third_party directory. | 45 # jinja2 is in chromium's third_party directory. |
| 40 module_path, module_name = os.path.split(__file__) | 46 module_path, module_name = os.path.split(__file__) |
| 41 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pard ir) | 47 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pard ir, os.pardir) |
| 42 sys.path.append(third_party) | 48 sys.path.append(third_party) |
| 43 import jinja2 | 49 import jinja2 |
| 44 | 50 |
| 45 templates_dir = os.path.join(module_path, os.pardir, 'templates') | 51 templates_dir = os.path.join(module_path, os.pardir, os.pardir, 'templates') |
| 46 | 52 |
| 47 import v8_callback_interface | 53 import v8_callback_interface |
| 48 import v8_interface | 54 import v8_interface |
| 49 from v8_utilities import cpp_class_name, generate_conditional_string, v8_class_n ame | 55 from v8_utilities import cpp_class_name, generate_conditional_string, v8_class_n ame |
| 50 | 56 |
| 51 | 57 |
| 52 class CodeGeneratorV8: | 58 class CodeGeneratorV8: |
| 53 def __init__(self, definitions, interface_name, output_directory, relative_d ir_posix, idl_directories, verbose=False): | 59 def __init__(self, definitions, interface_name, output_directory, relative_d ir_posix, idl_directories, verbose=False): |
| 54 self.idl_definitions = definitions | 60 self.idl_definitions = definitions |
| 55 self.interface_name = interface_name | 61 self.interface_name = interface_name |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 self.write_file(header_basename, header_file_text) | 117 self.write_file(header_basename, header_file_text) |
| 112 | 118 |
| 113 cpp_basename = v8_class_name(interface) + '.cpp' | 119 cpp_basename = v8_class_name(interface) + '.cpp' |
| 114 cpp_file_text = self.cpp_template.render(template_contents) | 120 cpp_file_text = self.cpp_template.render(template_contents) |
| 115 self.write_file(cpp_basename, cpp_file_text) | 121 self.write_file(cpp_basename, cpp_file_text) |
| 116 | 122 |
| 117 def write_file(self, basename, file_text): | 123 def write_file(self, basename, file_text): |
| 118 filename = os.path.join(self.output_directory, basename) | 124 filename = os.path.join(self.output_directory, basename) |
| 119 with open(filename, 'w') as output_file: | 125 with open(filename, 'w') as output_file: |
| 120 output_file.write(file_text) | 126 output_file.write(file_text) |
| OLD | NEW |