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 errno | 10 import errno |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 334 |
335 def GetStaticCastForReturnType(return_type): | 335 def GetStaticCastForReturnType(return_type): |
336 type_map = { 'String' : 'jstring', | 336 type_map = { 'String' : 'jstring', |
337 'java/lang/String' : 'jstring', | 337 'java/lang/String' : 'jstring', |
338 'boolean[]': 'jbooleanArray', | 338 'boolean[]': 'jbooleanArray', |
339 'byte[]': 'jbyteArray', | 339 'byte[]': 'jbyteArray', |
340 'char[]': 'jcharArray', | 340 'char[]': 'jcharArray', |
341 'short[]': 'jshortArray', | 341 'short[]': 'jshortArray', |
342 'int[]': 'jintArray', | 342 'int[]': 'jintArray', |
343 'long[]': 'jlongArray', | 343 'long[]': 'jlongArray', |
| 344 'float[]': 'jfloatArray', |
344 'double[]': 'jdoubleArray' } | 345 'double[]': 'jdoubleArray' } |
345 ret = type_map.get(return_type, None) | 346 ret = type_map.get(return_type, None) |
346 if ret: | 347 if ret: |
347 return ret | 348 return ret |
348 if return_type.endswith('[]'): | 349 if return_type.endswith('[]'): |
349 return 'jobjectArray' | 350 return 'jobjectArray' |
350 return None | 351 return None |
351 | 352 |
352 | 353 |
353 def GetEnvCall(is_constructor, is_static, return_type): | 354 def GetEnvCall(is_constructor, is_static, return_type): |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 root_name = os.path.splitext(os.path.basename(input_file))[0] | 1290 root_name = os.path.splitext(os.path.basename(input_file))[0] |
1290 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' | 1291 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' |
1291 if options.jarjar: | 1292 if options.jarjar: |
1292 with open(options.jarjar) as f: | 1293 with open(options.jarjar) as f: |
1293 JniParams.SetJarJarMappings(f.read()) | 1294 JniParams.SetJarJarMappings(f.read()) |
1294 GenerateJNIHeader(input_file, output_file, options) | 1295 GenerateJNIHeader(input_file, output_file, options) |
1295 | 1296 |
1296 | 1297 |
1297 if __name__ == '__main__': | 1298 if __name__ == '__main__': |
1298 sys.exit(main(sys.argv)) | 1299 sys.exit(main(sys.argv)) |
OLD | NEW |