| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/python |
| 2 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 # |
| 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are |
| 6 # met: |
| 7 # |
| 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above |
| 11 # copyright notice, this list of conditions and the following disclaimer |
| 12 # in the documentation and/or other materials provided with the |
| 13 # distribution. |
| 14 # * Neither the name of Google Inc. nor the names of its |
| 15 # contributors may be used to endorse or promote products derived from |
| 16 # this software without specific prior written permission. |
| 17 # |
| 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 |
| 30 import optparse |
| 31 import os.path |
| 32 import pprint |
| 33 import sys |
| 34 |
| 35 import json_import_export |
| 36 import code_generator_v8 |
| 37 |
| 38 |
| 39 def parse_options(): |
| 40 parser = optparse.OptionParser() |
| 41 parser.add_option('--output-directory') |
| 42 |
| 43 options, args = parser.parse_args() |
| 44 if options.output_directory is None: |
| 45 parser.error('Must specify output directory using --output-directory.') |
| 46 if len(args) != 1: |
| 47 parser.error('Must specify exactly 1 input file as argument, but %d give
n.' % len(args)) |
| 48 options.target_json_file = args[0] |
| 49 return options |
| 50 |
| 51 |
| 52 def main(): |
| 53 options = parse_options() |
| 54 target_json_file = os.path.realpath(options.target_json_file) |
| 55 |
| 56 target_document = json_import_export.read_json(target_json_file) |
| 57 pprint.pprint(target_document) |
| 58 |
| 59 code_generator = code_generator_v8.CodeGenerator(target_document) |
| 60 code_generator.write_interfaces(options.output_directory) |
| 61 |
| 62 |
| 63 if __name__ == '__main__': |
| 64 sys.exit(main()) |
| OLD | NEW |