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

Unified Diff: base/android/jni_generator/jni_generator.py

Issue 2199973003: Android JNI gen: Don't emit code for empty RegisterNatives() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@jnireg1
Patch Set: Android JNI gen: Don't emit code for empty RegisterNatives() Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
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 0cb70bc836b379f4bf333c4219e78ef0a858f95f..f4c6f28319722644e2b79086813e28e47e9aab31 100755
--- a/base/android/jni_generator/jni_generator.py
+++ b/base/android/jni_generator/jni_generator.py
@@ -760,6 +760,8 @@ $CLOSE_NAMESPACE
'HEADER_GUARD': self.header_guard,
'INCLUDES': self.GetIncludesString(),
}
+ assert ((values['JNI_NATIVE_METHODS'] == '') ==
+ (values['REGISTER_NATIVES'] == ''))
return WrapOutput(template.substitute(values))
def GetClassPathDefinitionsString(self):
@@ -829,6 +831,10 @@ ${KMETHODS}
def GetRegisterNativesString(self):
"""Returns the code for RegisterNatives."""
+ natives = self.GetRegisterNativesImplString()
+ if not natives:
+ return ''
+
template = Template("""\
${REGISTER_NATIVES_SIGNATURE} {
${EARLY_EXIT}
@@ -843,19 +849,12 @@ ${NATIVES}
if (base::android::IsManualJniRegistrationDisabled()) return true;
"""
- natives = self.GetRegisterNativesImplString()
values = {'REGISTER_NATIVES_SIGNATURE': signature,
'EARLY_EXIT': early_exit,
'NATIVES': natives,
}
- func_declaration = ''
- if not natives:
- func_declaration = Template("""\
-${REGISTER_NATIVES_SIGNATURE} __attribute__((unused));
-""").substitute(values)
-
- return func_declaration + template.substitute(values)
+ return template.substitute(values)
def GetRegisterNativesImplString(self):
"""Returns the shared implementation for RegisterNatives."""
« no previous file with comments | « android_webview/native/input_stream_unittest.cc ('k') | base/android/jni_generator/testCalledByNatives.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698