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

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

Issue 607933002: mojo: Fix java generator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix findbugs and emptu package. Created 6 years, 2 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 | « mojo/public/tools/bindings/generators/mojom_java_generator.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Generate the org.chromium.mojo.bindings.Callbacks interface""" 1 """Generate the org.chromium.mojo.bindings.Callbacks interface"""
2 2
3 import argparse 3 import argparse
4 import sys 4 import sys
5 5
6 CALLBACK_TEMPLATE = (""" 6 CALLBACK_TEMPLATE = ("""
7 /** 7 /**
8 * A generic %d-argument callback. 8 * A generic %d-argument callback.
9 * 9 *
10 * %s 10 * %s
11 */ 11 */
12 interface Callback%d<%s> { 12 interface Callback%d<%s> {
13 /** 13 /**
14 * Call the callback. 14 * Call the callback.
15 */ 15 */
16 public void call(%s); 16 public void call(%s);
17 } 17 }
18 """) 18 """)
19 19
20 INTERFACE_TEMPLATE = ( 20 INTERFACE_TEMPLATE = (
21 """// Copyright 2014 The Chromium Authors. All rights reserved. 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 22 // Use of this source code is governed by a BSD-style license that can be
23 // found in the LICENSE file. 23 // found in the LICENSE file.
24 24
25 // This file was generated using 25 // This file was generated using
26 // mojo/tools/generate_java_callback_interfaces.py 26 // mojo/tools/generate_java_callback_interfaces.py
27 27
28 package org.chromium.mojo.bindings; 28 package org.chromium.mojo.bindings;
29 29
30 /** 30 /**
31 * Contains a generic interface for callbacks. 31 * Contains a generic interface for callbacks.
32 */ 32 */
33 public interface Callbacks { 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 }
34 %s 44 %s
35 }""") 45 }""")
36 46
37 def GenerateCallback(nb_args): 47 def GenerateCallback(nb_args):
38 params = '\n * '.join( 48 params = '\n * '.join(
39 ['@param <T%d> the type of argument %d.' % (i+1, i+1) 49 ['@param <T%d> the type of argument %d.' % (i+1, i+1)
40 for i in xrange(nb_args)]) 50 for i in xrange(nb_args)])
41 template_parameters = ', '.join(['T%d' % (i+1) for i in xrange(nb_args)]) 51 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)) 52 callback_parameters = ', '.join(['T%d arg%d' % ((i+1), (i+1))
43 for i in xrange(nb_args)]) 53 for i in xrange(nb_args)])
44 return CALLBACK_TEMPLATE % (nb_args, params, nb_args, template_parameters, 54 return CALLBACK_TEMPLATE % (nb_args, params, nb_args, template_parameters,
45 callback_parameters) 55 callback_parameters)
46 56
47 def main(): 57 def main():
48 parser = argparse.ArgumentParser( 58 parser = argparse.ArgumentParser(
49 description="Generate org.chromium.mojo.bindings.Callbacks") 59 description="Generate org.chromium.mojo.bindings.Callbacks")
50 parser.add_argument("max_args", nargs=1, type=int, 60 parser.add_argument("max_args", nargs=1, type=int,
51 help="maximal number of arguments to generate callbacks for") 61 help="maximal number of arguments to generate callbacks for")
52 args = parser.parse_args() 62 args = parser.parse_args()
53 max_args = args.max_args[0] 63 max_args = args.max_args[0]
54 print INTERFACE_TEMPLATE % ''.join([GenerateCallback(i+1) 64 print INTERFACE_TEMPLATE % ''.join([GenerateCallback(i+1)
55 for i in xrange(max_args)]) 65 for i in xrange(max_args)])
56 return 0 66 return 0
57 67
58 if __name__ == "__main__": 68 if __name__ == "__main__":
59 sys.exit(main()) 69 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_java_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698