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

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

Issue 2386713002: Ignore return type annotations in @CalledByNative methods. (Closed)
Patch Set: Make regex normal Created 4 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 | « 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 """Extracts native methods from a Java file and generates the JNI bindings. 6 """Extracts native methods from a Java file and generates the JNI bindings.
7 If you change this, please run and update the tests.""" 7 If you change this, please run and update the tests."""
8 8
9 import collections 9 import collections
10 import errno 10 import errno
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 511
512 512
513 # Regex to match the JNI types that should be wrapped in a JavaRef. 513 # Regex to match the JNI types that should be wrapped in a JavaRef.
514 RE_SCOPED_JNI_TYPES = re.compile('jobject|jclass|jstring|jthrowable|.*Array') 514 RE_SCOPED_JNI_TYPES = re.compile('jobject|jclass|jstring|jthrowable|.*Array')
515 515
516 516
517 # Regex to match a string like "@CalledByNative public void foo(int bar)". 517 # Regex to match a string like "@CalledByNative public void foo(int bar)".
518 RE_CALLED_BY_NATIVE = re.compile( 518 RE_CALLED_BY_NATIVE = re.compile(
519 '@CalledByNative(?P<Unchecked>(Unchecked)*?)(?:\("(?P<annotation>.*)"\))?' 519 '@CalledByNative(?P<Unchecked>(Unchecked)*?)(?:\("(?P<annotation>.*)"\))?'
520 '\s+(?P<prefix>[\w ]*?)' 520 '\s+(?P<prefix>[\w ]*?)'
521 '(:?\s*@\w+)?' # Ignore annotations in return types.
521 '\s*(?P<return_type>\S+?)' 522 '\s*(?P<return_type>\S+?)'
522 '\s+(?P<name>\w+)' 523 '\s+(?P<name>\w+)'
523 '\s*\((?P<params>[^\)]*)\)') 524 '\s*\((?P<params>[^\)]*)\)')
524 525
525 526
526 def ExtractCalledByNatives(contents): 527 def ExtractCalledByNatives(contents):
527 """Parses all methods annotated with @CalledByNative. 528 """Parses all methods annotated with @CalledByNative.
528 529
529 Args: 530 Args:
530 contents: the contents of the java file. 531 contents: the contents of the java file.
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 root_name = os.path.splitext(os.path.basename(input_file))[0] 1378 root_name = os.path.splitext(os.path.basename(input_file))[0]
1378 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' 1379 output_file = os.path.join(options.output_dir, root_name) + '_jni.h'
1379 GenerateJNIHeader(input_file, output_file, options) 1380 GenerateJNIHeader(input_file, output_file, options)
1380 1381
1381 if options.depfile: 1382 if options.depfile:
1382 build_utils.WriteDepfile(options.depfile, output_file) 1383 build_utils.WriteDepfile(options.depfile, output_file)
1383 1384
1384 1385
1385 if __name__ == '__main__': 1386 if __name__ == '__main__':
1386 sys.exit(main(sys.argv)) 1387 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