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

Unified Diff: base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java

Issue 132013003: Android: moves jni_generator samples to use long for JNI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: With fixes Created 6 years, 11 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/java/src/org/chromium/example/jni_generator/SampleForTests.java
diff --git a/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java b/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java
index 3886355932130ad95ad4c5df80e752b6479ff5b3..885a6c32af59ee16254c6b66cb82fe8517790976 100644
--- a/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java
+++ b/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java
@@ -39,7 +39,7 @@ import java.util.List;
// functions across boundaries, call only one (and then, internally in the other side,
// call as many little functions as required).
//
-// - If a Java object "owns" a native object, stash the pointer in a "int mNativeClassName".
+// - If a Java object "owns" a native object, stash the pointer in a "long mNativeClassName".
// Note that it needs to have a "destruction path", i.e., it must eventually call a method
// to delete the native object (for example, the java object has a "close()" method that
// in turn deletes the native object). Avoid relying on finalizers: those run in a different
@@ -78,7 +78,7 @@ import java.util.List;
class SampleForTests {
// Classes can store their C++ pointer counter part as an int that is normally initialized by
// calling out a nativeInit() function.
- int mNativeCPPObject;
+ long mNativeCPPObject;
// You can define methods and attributes on the java class just like any other.
// Methods without the @CalledByNative annotation won't be exposed to JNI.
@@ -168,14 +168,14 @@ class SampleForTests {
// The caller of this method should store it, and supply it as a the nativeCPPClass param to
// subsequent native method calls (see the methods below that take an "int native..." as first
// param).
- private native int nativeInit(String param);
+ private native long nativeInit(String param);
// This defines a function binding to the associated C++ class member function. The name is
// derived from |nativeDestroy| and |nativeCPPClass| to arrive at CPPClass::Destroy() (i.e. native
// prefixes stripped).
// The |nativeCPPClass| is automatically cast to type CPPClass* in order to obtain the object on
// which to invoke the member function.
- private native void nativeDestroy(int nativeCPPClass);
+ private native void nativeDestroy(long nativeCPPClass);
// This declares a C++ function which the application code must implement:
// static jdouble GetDoubleFunction(JNIEnv* env, jobject obj);
@@ -200,12 +200,12 @@ class SampleForTests {
// Similar to nativeDestroy above, this will cast nativeCPPClass into pointer of CPPClass type and
// call its Method member function.
- private native int nativeMethod(int nativeCPPClass);
+ private native int nativeMethod(long nativeCPPClass);
// Similar to nativeMethod above, but here the C++ fully qualified class name is taken from the
// annotation rather than parameter name, which can thus be chosen freely.
@NativeClassQualifiedName("CPPClass::InnerClass")
- private native double nativeMethodOtherP0(int nativePtr);
+ private native double nativeMethodOtherP0(long nativePtr);
// This "struct" will be created by the native side using |createInnerStructA|,
// and used by the java-side somehow.
@@ -281,7 +281,7 @@ class SampleForTests {
nativeIterateAndDoSomethingWithStructB(mNativeCPPObject);
}
- native void nativeAddStructB(int nativeCPPClass, InnerStructB b);
- native void nativeIterateAndDoSomethingWithStructB(int nativeCPPClass);
- native String nativeReturnAString(int nativeCPPClass);
+ native void nativeAddStructB(long nativeCPPClass, InnerStructB b);
+ native void nativeIterateAndDoSomethingWithStructB(long nativeCPPClass);
+ native String nativeReturnAString(long nativeCPPClass);
}
« no previous file with comments | « base/android/jni_generator/golden_sample_for_tests_jni.h ('k') | base/android/jni_generator/jni_generator.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698