Commit 0b7c36ff authored by jochen@chromium.org's avatar jochen@chromium.org

Revert 243896 "Android: moves jni_generator samples to use long ..."

> Android: moves jni_generator samples to use long for JNI.
> 
> BUG=317523
> 
> Review URL: https://codereview.chromium.org/131543003

TBR=bulach@chromium.org

Review URL: https://codereview.chromium.org/131913002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243905 0039d316-1c4b-4281-b951-d872f2087c98
parent 7bbc7e63
...@@ -39,7 +39,7 @@ import java.util.List; ...@@ -39,7 +39,7 @@ import java.util.List;
// functions across boundaries, call only one (and then, internally in the other side, // functions across boundaries, call only one (and then, internally in the other side,
// call as many little functions as required). // call as many little functions as required).
// //
// - If a Java object "owns" a native object, stash the pointer in a "long mNativeClassName". // - If a Java object "owns" a native object, stash the pointer in a "int mNativeClassName".
// Note that it needs to have a "destruction path", i.e., it must eventually call a method // 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 // 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 // in turn deletes the native object). Avoid relying on finalizers: those run in a different
...@@ -78,7 +78,7 @@ import java.util.List; ...@@ -78,7 +78,7 @@ import java.util.List;
class SampleForTests { class SampleForTests {
// Classes can store their C++ pointer counter part as an int that is normally initialized by // Classes can store their C++ pointer counter part as an int that is normally initialized by
// calling out a nativeInit() function. // calling out a nativeInit() function.
long mNativeCPPObject; int mNativeCPPObject;
// You can define methods and attributes on the java class just like any other. // 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. // Methods without the @CalledByNative annotation won't be exposed to JNI.
...@@ -168,14 +168,14 @@ class SampleForTests { ...@@ -168,14 +168,14 @@ class SampleForTests {
// The caller of this method should store it, and supply it as a the nativeCPPClass param to // 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 // subsequent native method calls (see the methods below that take an "int native..." as first
// param). // param).
private native long nativeInit(String param); private native int nativeInit(String param);
// This defines a function binding to the associated C++ class member function. The name is // 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 // derived from |nativeDestroy| and |nativeCPPClass| to arrive at CPPClass::Destroy() (i.e. native
// prefixes stripped). // prefixes stripped).
// The |nativeCPPClass| is automatically cast to type CPPClass* in order to obtain the object on // The |nativeCPPClass| is automatically cast to type CPPClass* in order to obtain the object on
// which to invoke the member function. // which to invoke the member function.
private native void nativeDestroy(long nativeCPPClass); private native void nativeDestroy(int nativeCPPClass);
// This declares a C++ function which the application code must implement: // This declares a C++ function which the application code must implement:
// static jdouble GetDoubleFunction(JNIEnv* env, jobject obj); // static jdouble GetDoubleFunction(JNIEnv* env, jobject obj);
...@@ -200,12 +200,12 @@ class SampleForTests { ...@@ -200,12 +200,12 @@ class SampleForTests {
// Similar to nativeDestroy above, this will cast nativeCPPClass into pointer of CPPClass type and // Similar to nativeDestroy above, this will cast nativeCPPClass into pointer of CPPClass type and
// call its Method member function. // call its Method member function.
private native int nativeMethod(long nativeCPPClass); private native int nativeMethod(int nativeCPPClass);
// Similar to nativeMethod above, but here the C++ fully qualified class name is taken from the // 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. // annotation rather than parameter name, which can thus be chosen freely.
@NativeClassQualifiedName("CPPClass::InnerClass") @NativeClassQualifiedName("CPPClass::InnerClass")
private native double nativeMethodOtherP0(long nativePtr); private native double nativeMethodOtherP0(int nativePtr);
// This "struct" will be created by the native side using |createInnerStructA|, // This "struct" will be created by the native side using |createInnerStructA|,
// and used by the java-side somehow. // and used by the java-side somehow.
...@@ -281,7 +281,7 @@ class SampleForTests { ...@@ -281,7 +281,7 @@ class SampleForTests {
nativeIterateAndDoSomethingWithStructB(mNativeCPPObject); nativeIterateAndDoSomethingWithStructB(mNativeCPPObject);
} }
native void nativeAddStructB(long nativeCPPClass, InnerStructB b); native void nativeAddStructB(int nativeCPPClass, InnerStructB b);
native void nativeIterateAndDoSomethingWithStructB(long nativeCPPClass); native void nativeIterateAndDoSomethingWithStructB(int nativeCPPClass);
native String nativeReturnAString(long nativeCPPClass); native String nativeReturnAString(int nativeCPPClass);
} }
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
], ],
'variables': { 'variables': {
'jni_gen_package': 'example', 'jni_gen_package': 'example',
'jni_generator_ptr_type': 'long',
}, },
'includes': [ '../../../build/jni_generator.gypi' ], 'includes': [ '../../../build/jni_generator.gypi' ],
}, },
......
...@@ -59,7 +59,7 @@ base::android::ScopedJavaLocalRef<jstring> CPPClass::ReturnAString( ...@@ -59,7 +59,7 @@ base::android::ScopedJavaLocalRef<jstring> CPPClass::ReturnAString(
} }
// Static free functions declared and called directly from java. // Static free functions declared and called directly from java.
static jlong Init(JNIEnv* env, jobject obj, jstring param) { static jint Init(JNIEnv* env, jobject obj, jstring param) {
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment