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

Side by Side Diff: base/android/jni_generator/jni_generator.py

Issue 10850030: Do not wrap preprocessor lines in the generated JNI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit test. Created 8 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 | « no previous file | base/android/jni_generator/jni_generator_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # TODO (qinmin): Need to refactor this file as base should not know about 6 # TODO (qinmin): Need to refactor this file as base should not know about
7 # higher level concepts. Currently this file has knowledge about higher level 7 # higher level concepts. Currently this file has knowledge about higher level
8 # java classes. 8 # java classes.
9 9
10 """Extracts native methods from a Java file and generates the JNI bindings. 10 """Extracts native methods from a Java file and generates the JNI bindings.
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 'JNI_SIGNATURE': JniSignature(called_by_native.params, 873 'JNI_SIGNATURE': JniSignature(called_by_native.params,
874 called_by_native.return_type, 874 called_by_native.return_type,
875 True) 875 True)
876 } 876 }
877 return template.substitute(values) 877 return template.substitute(values)
878 878
879 879
880 def WrapOutput(output): 880 def WrapOutput(output):
881 ret = [] 881 ret = []
882 for line in output.splitlines(): 882 for line in output.splitlines():
883 if len(line) < 80: 883 # Do not wrap lines under 80 characters or preprocessor directives.
884 if len(line) < 80 or line.lstrip()[:1] == '#':
884 stripped = line.rstrip() 885 stripped = line.rstrip()
885 if len(ret) == 0 or len(ret[-1]) or len(stripped): 886 if len(ret) == 0 or len(ret[-1]) or len(stripped):
886 ret.append(stripped) 887 ret.append(stripped)
887 else: 888 else:
888 first_line_indent = ' ' * (len(line) - len(line.lstrip())) 889 first_line_indent = ' ' * (len(line) - len(line.lstrip()))
889 subsequent_indent = first_line_indent + ' ' * 4 890 subsequent_indent = first_line_indent + ' ' * 4
890 if line.startswith('//'): 891 if line.startswith('//'):
891 subsequent_indent = '//' + subsequent_indent 892 subsequent_indent = '//' + subsequent_indent
892 wrapper = textwrap.TextWrapper(width=80, 893 wrapper = textwrap.TextWrapper(width=80,
893 subsequent_indent=subsequent_indent, 894 subsequent_indent=subsequent_indent,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 input_file = options.input_file 975 input_file = options.input_file
975 output_file = None 976 output_file = None
976 if options.output_dir: 977 if options.output_dir:
977 root_name = os.path.splitext(os.path.basename(input_file))[0] 978 root_name = os.path.splitext(os.path.basename(input_file))[0]
978 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' 979 output_file = os.path.join(options.output_dir, root_name) + '_jni.h'
979 GenerateJNIHeader(input_file, output_file, options.namespace) 980 GenerateJNIHeader(input_file, output_file, options.namespace)
980 981
981 982
982 if __name__ == '__main__': 983 if __name__ == '__main__':
983 sys.exit(main(sys.argv)) 984 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | base/android/jni_generator/jni_generator_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698