Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | |
| 2 # | |
| 3 # Redistribution and use in source and binary forms, with or without | |
| 4 # modification, are permitted provided that the following conditions are | |
| 5 # met: | |
| 6 # | |
| 7 # * Redistributions of source code must retain the above copyright | |
| 8 # notice, this list of conditions and the following disclaimer. | |
| 9 # * Redistributions in binary form must reproduce the above | |
| 10 # copyright notice, this list of conditions and the following disclaimer | |
| 11 # in the documentation and/or other materials provided with the | |
| 12 # distribution. | |
| 13 # * Neither the name of Google Inc. nor the names of its | |
| 14 # contributors may be used to endorse or promote products derived from | |
| 15 # this software without specific prior written permission. | |
| 16 # | |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 28 | |
| 29 """Generate Blink V8 bindings (.h and .cpp files). | |
| 30 | |
| 31 Input: An object of class IdlDocument, representing an IDL interface X | |
| 32 Output: V8X.h and V8X.cpp | |
| 33 | |
| 34 FIXME: Currently a stub, as part of landing the parser and code generator | |
| 35 incrementally. Only implements generation of dummy .cpp and .h files. | |
| 36 | |
| 37 The plan is as follows. | |
|
haraken
2013/07/09 11:16:48
Shall we put this comment in idl_compiler.py since
Nils Barth (inactive)
2013/07/10 02:38:32
Good point (overview in main file); done!
| |
| 38 We will temporarily have two build flows (see ../derived_sources.gyp): | |
| 39 [1] Perl: deprecated_generate_bindings.pl, which calls: | |
| 40 deprecated_idl_parser.pm => deprecated_code_generator_v8.pm | |
| 41 [2] Python: idl_compiler.py, which calls: | |
| 42 frontend (lexer => parser => build_ir.py) => code_generator_v8.py | |
| 43 | |
| 44 We will move IDL files from the Perl build flow [1] to the Python build flow [2] | |
| 45 incrementally. | |
| 46 First we will land the build changes and idl_compiler.py (in one CL). | |
| 47 Next we will land the full frontend (in one CL), which parses all IDL files. | |
| 48 Finally we will incrementally land the code generator (in several CLs), | |
| 49 moving IDL files to the Python build flow as the code generator is completed. | |
| 50 """ | |
| 51 | |
| 52 import os.path | |
| 53 | |
| 54 | |
| 55 def generate_dummy_header_and_cpp(target_interface_name, output_directory): | |
| 56 header_basename = 'V8%s.h' % target_interface_name | |
| 57 cpp_basename = 'V8%s.cpp' % target_interface_name | |
| 58 header_fullname = os.path.join(output_directory, header_basename) | |
| 59 cpp_fullname = os.path.join(output_directory, cpp_basename) | |
| 60 contents = """/* | |
| 61 This file is generated just to tell build scripts that {header_basename} and | |
| 62 {cpp_basename} are created for {target_interface_name}.idl, and thus | |
| 63 prevent the build scripts from trying to generate {header_basename} and | |
| 64 {cpp_basename} at every build. This file must not be tried to compile. | |
| 65 */ | |
| 66 """.format(**locals()) | |
| 67 with open(header_fullname, 'w') as header_file: | |
| 68 header_file.write(contents) | |
| 69 with open(cpp_fullname, 'w') as cpp_file: | |
| 70 cpp_file.write(contents) | |
| OLD | NEW |