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

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

Issue 2531273002: android: Realign stack pointer on JNI entry. (Closed)
Patch Set: Rename golden test file to satisfy presubmit Created 4 years 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
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 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 if is_method: 1024 if is_method:
1025 optional_error_return = JavaReturnValueToC(native.return_type) 1025 optional_error_return = JavaReturnValueToC(native.return_type)
1026 if optional_error_return: 1026 if optional_error_return:
1027 optional_error_return = ', ' + optional_error_return 1027 optional_error_return = ', ' + optional_error_return
1028 values.update({ 1028 values.update({
1029 'OPTIONAL_ERROR_RETURN': optional_error_return, 1029 'OPTIONAL_ERROR_RETURN': optional_error_return,
1030 'PARAM0_NAME': native.params[0].name, 1030 'PARAM0_NAME': native.params[0].name,
1031 'P0_TYPE': native.p0_type, 1031 'P0_TYPE': native.p0_type,
1032 }) 1032 })
1033 template = Template("""\ 1033 template = Template("""\
1034 extern "C" __attribute__((visibility("default"))) 1034 JNI_GENERATOR_EXPORT ${RETURN} ${STUB_NAME}(JNIEnv* env, ${PARAMS_IN_STUB}) {
1035 ${RETURN} ${STUB_NAME}(JNIEnv* env,
1036 ${PARAMS_IN_STUB}) {
1037 ${PROFILING_ENTERED_NATIVE} 1035 ${PROFILING_ENTERED_NATIVE}
1038 ${P0_TYPE}* native = reinterpret_cast<${P0_TYPE}*>(${PARAM0_NAME}); 1036 ${P0_TYPE}* native = reinterpret_cast<${P0_TYPE}*>(${PARAM0_NAME});
1039 CHECK_NATIVE_PTR(env, jcaller, native, "${NAME}"${OPTIONAL_ERROR_RETURN}); 1037 CHECK_NATIVE_PTR(env, jcaller, native, "${NAME}"${OPTIONAL_ERROR_RETURN});
1040 return native->${NAME}(${PARAMS_IN_CALL})${POST_CALL}; 1038 return native->${NAME}(${PARAMS_IN_CALL})${POST_CALL};
1041 } 1039 }
1042 """) 1040 """)
1043 else: 1041 else:
1044 template = Template(""" 1042 template = Template("""
1045 static ${RETURN_DECLARATION} ${NAME}(JNIEnv* env, ${PARAMS}); 1043 static ${RETURN_DECLARATION} ${NAME}(JNIEnv* env, ${PARAMS});
1046 1044
1047 extern "C" __attribute__((visibility("default"))) 1045 JNI_GENERATOR_EXPORT ${RETURN} ${STUB_NAME}(JNIEnv* env, ${PARAMS_IN_STUB}) {
1048 ${RETURN} ${STUB_NAME}(JNIEnv* env, ${PARAMS_IN_STUB}) {
1049 ${PROFILING_ENTERED_NATIVE} 1046 ${PROFILING_ENTERED_NATIVE}
1050 return ${NAME}(${PARAMS_IN_CALL})${POST_CALL}; 1047 return ${NAME}(${PARAMS_IN_CALL})${POST_CALL};
1051 } 1048 }
1052 """) 1049 """)
1053 1050
1054 return RemoveIndentedEmptyLines(template.substitute(values)) 1051 return RemoveIndentedEmptyLines(template.substitute(values))
1055 1052
1056 def GetArgument(self, param): 1053 def GetArgument(self, param):
1057 if param.datatype == 'int': 1054 if param.datatype == 'int':
1058 return 'as_jint(' + param.name + ')' 1055 return 'as_jint(' + param.name + ')'
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 root_name = os.path.splitext(os.path.basename(input_file))[0] 1393 root_name = os.path.splitext(os.path.basename(input_file))[0]
1397 output_file = os.path.join(options.output_dir, root_name) + '_jni.h' 1394 output_file = os.path.join(options.output_dir, root_name) + '_jni.h'
1398 GenerateJNIHeader(input_file, output_file, options) 1395 GenerateJNIHeader(input_file, output_file, options)
1399 1396
1400 if options.depfile: 1397 if options.depfile:
1401 build_utils.WriteDepfile(options.depfile, output_file) 1398 build_utils.WriteDepfile(options.depfile, output_file)
1402 1399
1403 1400
1404 if __name__ == '__main__': 1401 if __name__ == '__main__':
1405 sys.exit(main(sys.argv)) 1402 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « base/android/jni_generator/golden_sample_for_tests_jni.h ('k') | base/android/jni_generator/jni_generator_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698