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

Side by Side Diff: mojo/tools/generate_java_callback_interfaces.py

Issue 705703002: Remove mojo/tools/, not needed in chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove gyp Created 6 years, 1 month 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 | « mojo/tools/data/unittests ('k') | mojo/tools/message_generator.cc » ('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 """Generate the org.chromium.mojo.bindings.Callbacks interface"""
2
3 import argparse
4 import sys
5
6 CALLBACK_TEMPLATE = ("""
7 /**
8 * A generic %d-argument callback.
9 *
10 * %s
11 */
12 interface Callback%d<%s> {
13 /**
14 * Call the callback.
15 */
16 public void call(%s);
17 }
18 """)
19
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.
24
25 // This file was generated using
26 // mojo/tools/generate_java_callback_interfaces.py
27
28 package org.chromium.mojo.bindings;
29
30 /**
31 * Contains a generic interface for callbacks.
32 */
33 public interface Callbacks {
34
35 /**
36 * A generic callback.
37 */
38 interface Callback0 {
39 /**
40 * Call the callback.
41 */
42 public void call();
43 }
44 %s
45 }""")
46
47 def GenerateCallback(nb_args):
48 params = '\n * '.join(
49 ['@param <T%d> the type of argument %d.' % (i+1, i+1)
50 for i in xrange(nb_args)])
51 template_parameters = ', '.join(['T%d' % (i+1) for i in xrange(nb_args)])
52 callback_parameters = ', '.join(['T%d arg%d' % ((i+1), (i+1))
53 for i in xrange(nb_args)])
54 return CALLBACK_TEMPLATE % (nb_args, params, nb_args, template_parameters,
55 callback_parameters)
56
57 def main():
58 parser = argparse.ArgumentParser(
59 description="Generate org.chromium.mojo.bindings.Callbacks")
60 parser.add_argument("max_args", nargs=1, type=int,
61 help="maximal number of arguments to generate callbacks for")
62 args = parser.parse_args()
63 max_args = args.max_args[0]
64 print INTERFACE_TEMPLATE % ''.join([GenerateCallback(i+1)
65 for i in xrange(max_args)])
66 return 0
67
68 if __name__ == "__main__":
69 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/tools/data/unittests ('k') | mojo/tools/message_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698