| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/android/jni_android.h" | 5 #include "base/android/jni_android.h" |
| 6 #include "base/android/scoped_java_ref.h" | 6 #include "base/android/scoped_java_ref.h" |
| 7 | 7 |
| 8 // The main purpose of this is to ensure sample_for_tests_jni.h | 8 // The main purpose of this is to ensure sample_for_tests_jni.h |
| 9 // compiles and the functions declared in it as expected. | 9 // compiles and the functions declared in it as expected. |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 jint Method(JNIEnv* env, jobject obj) { | 30 jint Method(JNIEnv* env, jobject obj) { |
| 31 return 0; | 31 return 0; |
| 32 } | 32 } |
| 33 | 33 |
| 34 ScopedJavaLocalRef<jstring> InnerMethod(JNIEnv* env, jobject obj) { | 34 ScopedJavaLocalRef<jstring> InnerMethod(JNIEnv* env, jobject obj) { |
| 35 return ScopedJavaLocalRef<jstring>(); | 35 return ScopedJavaLocalRef<jstring>(); |
| 36 } | 36 } |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 static jint Init(JNIEnv* env, jobject obj) { |
| 40 return 0; |
| 41 } |
| 42 |
| 43 static jdouble GetDoubleFunction(JNIEnv*, jobject) { |
| 44 return 0; |
| 45 } |
| 46 |
| 47 static jfloat GetFloatFunction(JNIEnv*, jclass) { |
| 48 return 0; |
| 49 } |
| 50 |
| 51 static void SetNonPODDatatype(JNIEnv*, jobject, jobject) {} |
| 52 |
| 53 static jobject GetNonPODDatatype(JNIEnv*, jobject) { |
| 54 return NULL; |
| 55 } |
| 56 |
| 57 static jint InnerFunction(JNIEnv*, jclass) { |
| 58 return 0; |
| 59 } |
| 60 |
| 39 } // namespace android | 61 } // namespace android |
| 40 } // namespace base | 62 } // namespace base |
| 41 | 63 |
| 42 #include "jni/SampleForTests_jni.h" | 64 #include "jni/SampleForTests_jni.h" |
| 43 | 65 |
| 44 int main() { | 66 int main() { |
| 45 // On a regular application, you'd call AttachCurrentThread(). This sample is | 67 // On a regular application, you'd call AttachCurrentThread(). This sample is |
| 46 // not yet linking with all the libraries. | 68 // not yet linking with all the libraries. |
| 47 JNIEnv* env = /* AttachCurrentThread() */ NULL; | 69 JNIEnv* env = /* AttachCurrentThread() */ NULL; |
| 48 | 70 |
| 49 // This is how you call a java static method from C++. | 71 // This is how you call a java static method from C++. |
| 50 bool foo = base::android::Java_SampleForTests_staticJavaMethod(env); | 72 bool foo = base::android::Java_SampleForTests_staticJavaMethod(env); |
| 51 | 73 |
| 52 // This is how you call a java method from C++. Note that you must have | 74 // This is how you call a java method from C++. Note that you must have |
| 53 // obtained the jobject somehow. | 75 // obtained the jobject somehow. |
| 54 jobject my_java_object = NULL; | 76 jobject my_java_object = NULL; |
| 55 int bar = base::android::Java_SampleForTests_javaMethod( | 77 int bar = base::android::Java_SampleForTests_javaMethod( |
| 56 env, my_java_object, 1, 2); | 78 env, my_java_object, 1, 2); |
| 57 | 79 |
| 58 return 0; | 80 return 0; |
| 59 } | 81 } |
| OLD | NEW |