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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 379 |
380 def GetStaticCastForReturnType(return_type): | 380 def GetStaticCastForReturnType(return_type): |
381 type_map = { 'String' : 'jstring', | 381 type_map = { 'String' : 'jstring', |
382 'java/lang/String' : 'jstring', | 382 'java/lang/String' : 'jstring', |
383 'boolean[]': 'jbooleanArray', | 383 'boolean[]': 'jbooleanArray', |
384 'byte[]': 'jbyteArray', | 384 'byte[]': 'jbyteArray', |
385 'char[]': 'jcharArray', | 385 'char[]': 'jcharArray', |
386 'short[]': 'jshortArray', | 386 'short[]': 'jshortArray', |
387 'int[]': 'jintArray', | 387 'int[]': 'jintArray', |
388 'long[]': 'jlongArray', | 388 'long[]': 'jlongArray', |
389 'float[]': 'jfloatArray', | |
390 'double[]': 'jdoubleArray' } | 389 'double[]': 'jdoubleArray' } |
391 ret = type_map.get(return_type, None) | 390 ret = type_map.get(return_type, None) |
392 if ret: | 391 if ret: |
393 return ret | 392 return ret |
394 if return_type.endswith('[]'): | 393 if return_type.endswith('[]'): |
395 return 'jobjectArray' | 394 return 'jobjectArray' |
396 return None | 395 return None |
397 | 396 |
398 | 397 |
399 def GetEnvCall(is_constructor, is_static, return_type): | 398 def GetEnvCall(is_constructor, is_static, return_type): |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 root_name = os.path.splitext(os.path.basename(input_file))[0] | 1386 root_name = os.path.splitext(os.path.basename(input_file))[0] |
1388 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' | 1387 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' |
1389 if options.jarjar: | 1388 if options.jarjar: |
1390 with open(options.jarjar) as f: | 1389 with open(options.jarjar) as f: |
1391 JniParams.SetJarJarMappings(f.read()) | 1390 JniParams.SetJarJarMappings(f.read()) |
1392 GenerateJNIHeader(input_file, output_file, options) | 1391 GenerateJNIHeader(input_file, output_file, options) |
1393 | 1392 |
1394 | 1393 |
1395 if __name__ == '__main__': | 1394 if __name__ == '__main__': |
1396 sys.exit(main(sys.argv)) | 1395 sys.exit(main(sys.argv)) |
OLD | NEW |