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

Unified Diff: base/android/jni_generator/sample_for_tests.cc

Issue 1476403003: jni: Pass method parameters as JavaParamRef in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary namespace qualifiers Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/android/jni_generator/sample_for_tests.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_generator/sample_for_tests.cc
diff --git a/base/android/jni_generator/sample_for_tests.cc b/base/android/jni_generator/sample_for_tests.cc
index a38377cc2f78a34fe4e6bfd66c565b6167789e98..3fca39a55f522164f21ade6cf91cf7a26adb6614 100644
--- a/base/android/jni_generator/sample_for_tests.cc
+++ b/base/android/jni_generator/sample_for_tests.cc
@@ -13,12 +13,16 @@
#include "jni/SampleForTests_jni.h" // Generated by JNI.
using base::android::AttachCurrentThread;
+using base::android::ConvertJavaStringToUTF8;
+using base::android::ConvertUTF8ToJavaString;
using base::android::ScopedJavaLocalRef;
namespace base {
namespace android {
-jdouble CPPClass::InnerClass::MethodOtherP0(JNIEnv* env, jobject caller) {
+jdouble CPPClass::InnerClass::MethodOtherP0(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& caller) {
return 0.0;
}
@@ -33,22 +37,26 @@ bool CPPClass::RegisterJNI(JNIEnv* env) {
return RegisterNativesImpl(env); // Generated in SampleForTests_jni.h
}
-void CPPClass::Destroy(JNIEnv* env, jobject caller) {
+void CPPClass::Destroy(JNIEnv* env, const JavaParamRef<jobject>& caller) {
delete this;
}
-jint CPPClass::Method(JNIEnv* env, jobject caller) {
+jint CPPClass::Method(JNIEnv* env, const JavaParamRef<jobject>& caller) {
return 0;
}
-void CPPClass::AddStructB(JNIEnv* env, jobject caller, jobject structb) {
+void CPPClass::AddStructB(JNIEnv* env,
+ const JavaParamRef<jobject>& caller,
+ const JavaParamRef<jobject>& structb) {
long key = Java_InnerStructB_getKey(env, structb);
std::string value = ConvertJavaStringToUTF8(
env, Java_InnerStructB_getValue(env, structb).obj());
map_[key] = value;
}
-void CPPClass::IterateAndDoSomethingWithStructB(JNIEnv* env, jobject caller) {
+void CPPClass::IterateAndDoSomethingWithStructB(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& caller) {
// Iterate over the elements and do something with them.
for (std::map<long, std::string>::const_iterator it = map_.begin();
it != map_.end(); ++it) {
@@ -58,11 +66,10 @@ void CPPClass::IterateAndDoSomethingWithStructB(JNIEnv* env, jobject caller) {
map_.clear();
}
-base::android::ScopedJavaLocalRef<jstring> CPPClass::ReturnAString(
- JNIEnv* env, jobject caller) {
- base::android::ScopedJavaLocalRef<jstring> ret = ConvertUTF8ToJavaString(
- env, "test");
- return ret;
+ScopedJavaLocalRef<jstring> CPPClass::ReturnAString(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& caller) {
+ return ConvertUTF8ToJavaString(env, "test");
}
// Static free functions declared and called directly from java.
@@ -115,8 +122,7 @@ int main() {
// Creates a "struct" that will then be used by the java side.
ScopedJavaLocalRef<jobject> struct_a =
base::android::Java_InnerStructA_create(
- env, 0, 1,
- base::android::ConvertUTF8ToJavaString(env, "test").obj());
+ env, 0, 1, ConvertUTF8ToJavaString(env, "test").obj());
base::android::Java_SampleForTests_addStructA(
env, my_java_object, struct_a.obj());
}
« no previous file with comments | « base/android/jni_generator/sample_for_tests.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698