[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / mojo / tools / generate_java_callback_interfaces.py
blobfdf1f74d8a98f4e2adfbe6079561d0bc5b25bd58
1 """Generate the org.chromium.mojo.bindings.Callbacks interface"""
3 import argparse
4 import sys
6 CALLBACK_TEMPLATE = ("""
7 /**
8 * A generic %d-argument callback.
10 * %s
12 interface Callback%d<%s> {
13 /**
14 * Call the callback.
16 public void call(%s);
18 """)
20 INTERFACE_TEMPLATE = (
21 """// Copyright 2014 The Chromium Authors. All rights reserved.
22 // Use of this source code is governed by a BSD-style license that can be
23 // found in the LICENSE file.
25 // This file was generated using
26 // mojo/tools/generate_java_callback_interfaces.py
28 package org.chromium.mojo.bindings;
30 /**
31 * Contains a generic interface for callbacks.
33 public interface Callbacks {
35 }""")
37 def GenerateCallback(nb_args):
38 params = '\n * '.join(
39 ['@param <T%d> the type of argument %d.' % (i+1, i+1)
40 for i in xrange(nb_args)])
41 template_parameters = ', '.join(['T%d' % (i+1) for i in xrange(nb_args)])
42 callback_parameters = ', '.join(['T%d arg%d' % ((i+1), (i+1))
43 for i in xrange(nb_args)])
44 return CALLBACK_TEMPLATE % (nb_args, params, nb_args, template_parameters,
45 callback_parameters)
47 def main():
48 parser = argparse.ArgumentParser(
49 description="Generate org.chromium.mojo.bindings.Callbacks")
50 parser.add_argument("max_args", nargs=1, type=int,
51 help="maximal number of arguments to generate callbacks for")
52 args = parser.parse_args()
53 max_args = args.max_args[0]
54 print INTERFACE_TEMPLATE % ''.join([GenerateCallback(i+1)
55 for i in xrange(max_args)])
56 return 0
58 if __name__ == "__main__":
59 sys.exit(main())