| Index: base/android/jni_generator/jni_generator.py
|
| diff --git a/base/android/jni_generator/jni_generator.py b/base/android/jni_generator/jni_generator.py
|
| index 6e39c13d4b0631b90cc300fa26f8a324d8085283..b58c09eca414a68296c6880ecafd2cef6020d169 100755
|
| --- a/base/android/jni_generator/jni_generator.py
|
| +++ b/base/android/jni_generator/jni_generator.py
|
| @@ -1035,6 +1035,31 @@ Java_${FULLY_QUALIFIED_CLASS}_${INIT_NATIVE_NAME}(JNIEnv* env, jclass clazz) {
|
| param.name
|
| for param in called_by_native.params])
|
|
|
| + def GetStubName(self, native):
|
| + """Return the name of the stub function for this native method.
|
| +
|
| + Args:
|
| + native: the native dictionary describing the method.
|
| +
|
| + Returns:
|
| + A string with the stub function name. For native exports mode this is the
|
| + Java_* symbol name required by the JVM; otherwise it is just the name of
|
| + the native method itself.
|
| + """
|
| + if self.options.native_exports:
|
| + template = Template("Java_${JAVA_NAME}_native${NAME}")
|
| +
|
| + java_name = JniParams.RemapClassName(self.fully_qualified_class)
|
| + java_name = java_name.replace('_', '_1').replace('/', '_')
|
| + if native.java_class_name:
|
| + java_name += '_00024' + native.java_class_name
|
| +
|
| + values = {'NAME': native.name,
|
| + 'JAVA_NAME': java_name}
|
| + return template.substitute(values)
|
| + else:
|
| + return native.name
|
| +
|
| def GetForwardDeclaration(self, native):
|
| template_str = """
|
| static ${RETURN} ${NAME}(JNIEnv* env, ${PARAMS});
|
| @@ -1042,7 +1067,7 @@ static ${RETURN} ${NAME}(JNIEnv* env, ${PARAMS});
|
| if self.options.native_exports:
|
| template_str += """
|
| __attribute__((visibility("default"), alias("${NAME}")))
|
| -${RETURN} Java_${JAVA_NAME}_native${NAME}(JNIEnv* env, ${PARAMS});
|
| +${RETURN} ${STUB_NAME}(JNIEnv* env, ${PARAMS});
|
| """
|
| template = Template(template_str)
|
| params_in_call = []
|
| @@ -1050,16 +1075,11 @@ ${RETURN} Java_${JAVA_NAME}_native${NAME}(JNIEnv* env, ${PARAMS});
|
| params_in_call = ['env', 'jcaller']
|
| params_in_call = ', '.join(params_in_call + [p.name for p in native.params])
|
|
|
| - java_name = JniParams.RemapClassName(self.fully_qualified_class)
|
| - java_name = java_name.replace('_', '_1').replace('/', '_')
|
| - if native.java_class_name:
|
| - java_name += '_00024' + native.java_class_name
|
| -
|
| values = {'RETURN': JavaDataTypeToC(native.return_type),
|
| 'NAME': native.name,
|
| - 'JAVA_NAME': java_name,
|
| 'PARAMS': self.GetParamsInDeclaration(native),
|
| - 'PARAMS_IN_CALL': params_in_call}
|
| + 'PARAMS_IN_CALL': params_in_call,
|
| + 'STUB_NAME': self.GetStubName(native)}
|
| return template.substitute(values)
|
|
|
| def GetNativeMethodStubString(self, native):
|
| @@ -1067,11 +1087,11 @@ ${RETURN} Java_${JAVA_NAME}_native${NAME}(JNIEnv* env, ${PARAMS});
|
| if self.options.native_exports:
|
| template_str = """\
|
| __attribute__((visibility("default")))
|
| -${RETURN} Java_${JAVA_NAME}_native${NAME}(JNIEnv* env,
|
| +${RETURN} ${STUB_NAME}(JNIEnv* env,
|
| ${PARAMS_IN_DECLARATION}) {"""
|
| else:
|
| template_str = """\
|
| -static ${RETURN} ${NAME}(JNIEnv* env, ${PARAMS_IN_DECLARATION}) {"""
|
| +static ${RETURN} ${STUB_NAME}(JNIEnv* env, ${PARAMS_IN_DECLARATION}) {"""
|
| template_str += """
|
| ${P0_TYPE}* native = reinterpret_cast<${P0_TYPE}*>(${PARAM0_NAME});
|
| CHECK_NATIVE_PTR(env, jcaller, native, "${NAME}"${OPTIONAL_ERROR_RETURN});
|
| @@ -1093,24 +1113,16 @@ static ${RETURN} ${NAME}(JNIEnv* env, ${PARAMS_IN_DECLARATION}) {"""
|
| if re.match(RE_SCOPED_JNI_RETURN_TYPES, return_type):
|
| post_call = '.Release()'
|
|
|
| - if self.options.native_exports:
|
| - java_name = JniParams.RemapClassName(self.fully_qualified_class)
|
| - java_name = java_name.replace('_', '_1').replace('/', '_')
|
| - if native.java_class_name:
|
| - java_name += '_00024' + native.java_class_name
|
| - else:
|
| - java_name = ''
|
| -
|
| values = {
|
| 'RETURN': return_type,
|
| 'OPTIONAL_ERROR_RETURN': optional_error_return,
|
| - 'JAVA_NAME': java_name,
|
| 'NAME': native.name,
|
| 'PARAMS_IN_DECLARATION': self.GetParamsInDeclaration(native),
|
| 'PARAM0_NAME': native.params[0].name,
|
| 'P0_TYPE': native.p0_type,
|
| 'PARAMS_IN_CALL': params_in_call,
|
| - 'POST_CALL': post_call
|
| + 'POST_CALL': post_call,
|
| + 'STUB_NAME': self.GetStubName(native),
|
| }
|
| return template.substitute(values)
|
|
|
| @@ -1225,12 +1237,13 @@ ${FUNCTION_HEADER}
|
| return template.substitute(values)
|
|
|
| def GetKMethodArrayEntry(self, native):
|
| - template = Template("""\
|
| - { "native${NAME}", ${JNI_SIGNATURE}, reinterpret_cast<void*>(${NAME}) },""")
|
| + template = Template(' { "native${NAME}", ${JNI_SIGNATURE}, ' +
|
| + 'reinterpret_cast<void*>(${STUB_NAME}) },')
|
| values = {'NAME': native.name,
|
| 'JNI_SIGNATURE': JniParams.Signature(native.params,
|
| native.return_type,
|
| - True)}
|
| + True),
|
| + 'STUB_NAME': self.GetStubName(native)}
|
| return template.substitute(values)
|
|
|
| def GetUniqueClasses(self, origin):
|
|
|