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

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

Issue 443293003: Mojo: Add PRESUBMIT.py to mojo/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/support/find_files.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
(...skipping 17 matching lines...) Expand all
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 %s 34 %s
35 }""") 35 }""")
36 36
37 def GenerateCallback(nb_args): 37 def GenerateCallback(nb_args):
38 params = '\n * '.join( 38 params = '\n * '.join(
39 ['@param <T%d> the type of argument %d.' % (i+1, i+1) 39 ['@param <T%d> the type of argument %d.' % (i+1, i+1)
40 for i in xrange(nb_args)]) 40 for i in xrange(nb_args)])
41 template_parameters = ', '.join(['T%d' % (i+1) 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)) 42 callback_parameters = ', '.join(['T%d arg%d' % ((i+1), (i+1))
43 for i in xrange(nb_args)]) 43 for i in xrange(nb_args)])
44 return CALLBACK_TEMPLATE % (nb_args, params, nb_args, template_parameters, 44 return CALLBACK_TEMPLATE % (nb_args, params, nb_args, template_parameters,
45 callback_parameters) 45 callback_parameters)
46 46
47 def main(): 47 def main():
48 parser = argparse.ArgumentParser( 48 parser = argparse.ArgumentParser(
49 description="Generate org.chromium.mojo.bindings.Callbacks") 49 description="Generate org.chromium.mojo.bindings.Callbacks")
50 parser.add_argument("max_args", nargs=1, type=int, 50 parser.add_argument("max_args", nargs=1, type=int,
51 help="maximal number of arguments to generate callbacks for") 51 help="maximal number of arguments to generate callbacks for")
52 args = parser.parse_args() 52 args = parser.parse_args()
53 max_args = args.max_args[0] 53 max_args = args.max_args[0]
54 print INTERFACE_TEMPLATE % ''.join([GenerateCallback(i+1) 54 print INTERFACE_TEMPLATE % ''.join([GenerateCallback(i+1)
55 for i in xrange(max_args)]) 55 for i in xrange(max_args)])
56 return 0 56 return 0
57 57
58 if __name__ == "__main__": 58 if __name__ == "__main__":
59 sys.exit(main()) 59 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/support/find_files.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698