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

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

Issue 23587011: Fix building with Java 7 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Linewrap test case Created 7 years, 3 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 class JNIFromJavaP(object): 449 class JNIFromJavaP(object):
450 """Uses 'javap' to parse a .class file and generate the JNI header file.""" 450 """Uses 'javap' to parse a .class file and generate the JNI header file."""
451 451
452 def __init__(self, contents, namespace): 452 def __init__(self, contents, namespace):
453 self.contents = contents 453 self.contents = contents
454 self.namespace = namespace 454 self.namespace = namespace
455 self.fully_qualified_class = re.match( 455 self.fully_qualified_class = re.match(
456 '.*?(class|interface) (?P<class_name>.*?)( |{)', 456 '.*?(class|interface) (?P<class_name>.*?)( |{)',
457 contents[1]).group('class_name') 457 contents[1]).group('class_name')
458 self.fully_qualified_class = self.fully_qualified_class.replace('.', '/') 458 self.fully_qualified_class = self.fully_qualified_class.replace('.', '/')
459 # Java 7's javap includes type parameters in output, like HashSet<T>. Strip
460 # away the <...> and use the raw class name that Java 6 would've given us.
461 self.fully_qualified_class = self.fully_qualified_class.split('<', 1)[0]
459 JniParams.SetFullyQualifiedClass(self.fully_qualified_class) 462 JniParams.SetFullyQualifiedClass(self.fully_qualified_class)
460 self.java_class_name = self.fully_qualified_class.split('/')[-1] 463 self.java_class_name = self.fully_qualified_class.split('/')[-1]
461 if not self.namespace: 464 if not self.namespace:
462 self.namespace = 'JNI_' + self.java_class_name 465 self.namespace = 'JNI_' + self.java_class_name
463 re_method = re.compile('(?P<prefix>.*?)(?P<return_type>\S+?) (?P<name>\w+?)' 466 re_method = re.compile('(?P<prefix>.*?)(?P<return_type>\S+?) (?P<name>\w+?)'
464 '\((?P<params>.*?)\)') 467 '\((?P<params>.*?)\)')
465 self.called_by_natives = [] 468 self.called_by_natives = []
466 for content in contents[2:]: 469 for content in contents[2:]:
467 match = re.match(re_method, content) 470 match = re.match(re_method, content)
468 if not match: 471 if not match:
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' 1059 output_file = os.path.join(options.output_dir, root_name) + '_jni.h'
1057 if options.jarjar: 1060 if options.jarjar:
1058 with open(options.jarjar) as f: 1061 with open(options.jarjar) as f:
1059 JniParams.SetJarJarMappings(f.read()) 1062 JniParams.SetJarJarMappings(f.read())
1060 GenerateJNIHeader(input_file, output_file, options.namespace, 1063 GenerateJNIHeader(input_file, output_file, options.namespace,
1061 options.optimize_generation) 1064 options.optimize_generation)
1062 1065
1063 1066
1064 if __name__ == '__main__': 1067 if __name__ == '__main__':
1065 sys.exit(main(sys.argv)) 1068 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