OLD | NEW |
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 optparse | 10 import optparse |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 return prefix + qualified_name + ';' | 196 return prefix + qualified_name + ';' |
197 | 197 |
198 # Is it an inner class from an outer class import? (e.g. referencing | 198 # Is it an inner class from an outer class import? (e.g. referencing |
199 # Class.Inner from import pkg.Class). | 199 # Class.Inner from import pkg.Class). |
200 if '.' in param: | 200 if '.' in param: |
201 components = param.split('.') | 201 components = param.split('.') |
202 outer = '/'.join(components[:-1]) | 202 outer = '/'.join(components[:-1]) |
203 inner = components[-1] | 203 inner = components[-1] |
204 for qualified_name in JniParams._imports: | 204 for qualified_name in JniParams._imports: |
205 if qualified_name.endswith('/' + outer): | 205 if qualified_name.endswith('/' + outer): |
206 return prefix + qualified_name + '$' + inner | 206 return prefix + qualified_name + '$' + inner + ';' |
207 | 207 |
208 # Type not found, falling back to same package as this class. | 208 # Type not found, falling back to same package as this class. |
209 return prefix + 'L' + JniParams._package + '/' + param + ';' | 209 return prefix + 'L' + JniParams._package + '/' + param + ';' |
210 | 210 |
211 @staticmethod | 211 @staticmethod |
212 def Signature(params, returns, wrap): | 212 def Signature(params, returns, wrap): |
213 """Returns the JNI signature for the given datatypes.""" | 213 """Returns the JNI signature for the given datatypes.""" |
214 items = ['('] | 214 items = ['('] |
215 items += [JniParams.JavaToJni(param.datatype) for param in params] | 215 items += [JniParams.JavaToJni(param.datatype) for param in params] |
216 items += [')'] | 216 items += [')'] |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 input_file = options.input_file | 1008 input_file = options.input_file |
1009 output_file = None | 1009 output_file = None |
1010 if options.output_dir: | 1010 if options.output_dir: |
1011 root_name = os.path.splitext(os.path.basename(input_file))[0] | 1011 root_name = os.path.splitext(os.path.basename(input_file))[0] |
1012 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' | 1012 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' |
1013 GenerateJNIHeader(input_file, output_file, options.namespace) | 1013 GenerateJNIHeader(input_file, output_file, options.namespace) |
1014 | 1014 |
1015 | 1015 |
1016 if __name__ == '__main__': | 1016 if __name__ == '__main__': |
1017 sys.exit(main(sys.argv)) | 1017 sys.exit(main(sys.argv)) |
OLD | NEW |