Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: Source/bindings/scripts/generate_bindings.py

Issue 17572008: WIP IDL compiler rewrite (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: non-callback headers working Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/scripts/generate-bindings.pl ('k') | Source/bindings/scripts/header.template » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 pickle
33 import sys
34
35 # import blink_idl_parser # FIXME: not checked in yet
36 # import json_import_export # FIXME: not using JSON
37 import code_generator_v8
38 # import interface_merger # FIXME: not checked in yet
39 # import semantic_analyzer # FIXME: not checked in yet
40
41
42 def parse_options():
43 parser = optparse.OptionParser()
44 parser.add_option('--include', dest='idl_directories', action='append')
45 parser.add_option('--output-directory')
46 parser.add_option('--output-headers-directory')
47 parser.add_option('--defines')
48 parser.add_option('--filename')
49 parser.add_option('--verbose', type='int') # FIXME: replace with flag: acti on='store_true', default=False
50 parser.add_option('--supplemental-dependency-file')
51 parser.add_option('--additional-idl-files', default='')
52 parser.add_option('--idl-attributes-file')
53 parser.add_option('--write-file-only-if-changed', type='int')
54 parser.add_option('--no_h', default=None)
55 parser.add_option('--no_cpp', default=None)
56 parser.add_option('--perl-parser', action='store_true', default=False)
57 parser.disable_interspersed_args() # ensure output comes last, so command l ine easy to parse via regexes (e.g., sanitize-win-build-log.sed)
58
59 options, args = parser.parse_args()
60 if options.output_directory is None:
61 parser.error('Must specify output directory using --output-directory.')
62 if options.output_headers_directory is None:
63 options.output_headers_directory = options.output_directory
64 if len(args) != 1:
65 parser.error('Must specify exactly 1 input file as argument, but %d give n.' % len(args))
66 options.target_idl_file = args[0]
67 return options
68
69
70 def read_pickled_idl(interface_name):
71 # Assume pickled file in current directory;
72 # feel free to customize as desired
73 pickle_filename = "/mnt/hdd/PKL-GOOD/" + interface_name + '.pkl'
74 with open(pickle_filename, 'rb') as pickle_file:
75 return pickle.load(pickle_file)
76 raise Exception("[read_pickled_idl] %s NOT FOUND" % interface_name)
77 return None
78
79
80 def main():
81 options = parse_options()
82 target_idl_file = os.path.realpath(options.target_idl_file)
83 target_basename = os.path.basename(options.target_idl_file)
84 target_interface_name, _ = os.path.splitext(target_basename)
85 if options.verbose:
86 print target_idl_file
87
88 # Compute dependencies
89 supplementary_idl_files = []
90 # FIXME: turn on
91 #if options.supplemental_dependency_file:
92 # try:
93 # supplementary_idl_files = interface_merger.compute_supplementary_id l_files(target_basename, options.supplemental_dependency_file, options.additiona l_idl_files)
94 # except interface_merger.IdlNotFoundError:
95 # # We generate empty .h and .cpp files just to tell build scripts th at .h and .cpp files are created.
96 # code_generator_v8.generate_empty_header_and_cpp(target_interface_na me, options.output_headers_directory, options.output_directory)
97 # return
98
99 # Parse the target IDL file
100 # target_document = json_import_export.parse_file(target_idl_file) # Actual read JSON
101 target_document = read_pickled_idl(target_interface_name)
102 # FIXME: switch to Python parser
103 # parser = BlinkIDLParser(verbose=options.verbose)
104 # return parser.Parse(target_idl_file, defines)
105
106 # FIXME: turn on
107 # Post-process: check attributes and merge partial interfaces
108 #if options.idl_attributes_file is not None:
109 # attribute_checker = semantic_analyzer.IDLAttributeChecker(options.idl_a ttributes_file)
110 # attribute_checker.check_idl_attributes(target_document, target_basename )
111 #interface_merger.merge_partial_interfaces(target_document, target_interface _name, target_idl_file, supplementary_idl_files, options)
112
113 # Generate desired output for the target IDL file
114 dependent_idl_files = [options.target_idl_file] + supplementary_idl_files
115 code_generator = code_generator_v8.code_generator_v8(target_document, ["../m odules", "../core", "../../../../out/Release/gen/webkit"], dependent_idl_files, options)
116 code_generator.write_interfaces()
117
118
119 if __name__ == '__main__':
120 sys.exit(main())
OLDNEW
« no previous file with comments | « Source/bindings/scripts/generate-bindings.pl ('k') | Source/bindings/scripts/header.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698