| 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 # Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 5 | 6 |
| 6 """Extracts native methods from a Java file and generates the JNI bindings. | 7 """Extracts native methods from a Java file and generates the JNI bindings. |
| 7 If you change this, please run and update the tests.""" | 8 If you change this, please run and update the tests.""" |
| 8 | 9 |
| 9 import collections | 10 import collections |
| 10 import errno | 11 import errno |
| 11 import optparse | 12 import optparse |
| 12 import os | 13 import os |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 335 |
| 335 def GetStaticCastForReturnType(return_type): | 336 def GetStaticCastForReturnType(return_type): |
| 336 type_map = { 'String' : 'jstring', | 337 type_map = { 'String' : 'jstring', |
| 337 'java/lang/String' : 'jstring', | 338 'java/lang/String' : 'jstring', |
| 338 'boolean[]': 'jbooleanArray', | 339 'boolean[]': 'jbooleanArray', |
| 339 'byte[]': 'jbyteArray', | 340 'byte[]': 'jbyteArray', |
| 340 'char[]': 'jcharArray', | 341 'char[]': 'jcharArray', |
| 341 'short[]': 'jshortArray', | 342 'short[]': 'jshortArray', |
| 342 'int[]': 'jintArray', | 343 'int[]': 'jintArray', |
| 343 'long[]': 'jlongArray', | 344 'long[]': 'jlongArray', |
| 345 'float[]': 'jfloatArray', |
| 344 'double[]': 'jdoubleArray' } | 346 'double[]': 'jdoubleArray' } |
| 345 ret = type_map.get(return_type, None) | 347 ret = type_map.get(return_type, None) |
| 346 if ret: | 348 if ret: |
| 347 return ret | 349 return ret |
| 348 if return_type.endswith('[]'): | 350 if return_type.endswith('[]'): |
| 349 return 'jobjectArray' | 351 return 'jobjectArray' |
| 350 return None | 352 return None |
| 351 | 353 |
| 352 | 354 |
| 353 def GetEnvCall(is_constructor, is_static, return_type): | 355 def GetEnvCall(is_constructor, is_static, return_type): |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 root_name = os.path.splitext(os.path.basename(input_file))[0] | 1287 root_name = os.path.splitext(os.path.basename(input_file))[0] |
| 1286 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' | 1288 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' |
| 1287 if options.jarjar: | 1289 if options.jarjar: |
| 1288 with open(options.jarjar) as f: | 1290 with open(options.jarjar) as f: |
| 1289 JniParams.SetJarJarMappings(f.read()) | 1291 JniParams.SetJarJarMappings(f.read()) |
| 1290 GenerateJNIHeader(input_file, output_file, options) | 1292 GenerateJNIHeader(input_file, output_file, options) |
| 1291 | 1293 |
| 1292 | 1294 |
| 1293 if __name__ == '__main__': | 1295 if __name__ == '__main__': |
| 1294 sys.exit(main(sys.argv)) | 1296 sys.exit(main(sys.argv)) |
| OLD | NEW |