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

Side by Side Diff: base/android/jni_generator/sample_for_tests.cc

Issue 1123343005: Improve jni_generator sample documentation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge TOT Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « base/android/jni_generator/sample_for_tests.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_generator/sample_for_tests.h" 5 #include "base/android/jni_generator/sample_for_tests.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "jni/SampleForTests_jni.h" 10 // Generated file for JNI bindings from C++ to Java @CalledByNative methods.
11 11 // Only to be included in one .cc file.
12 // Name is based on the java file name: *.java -> jni/*_jni.h
13 #include "jni/SampleForTests_jni.h" // Generated by JNI.
12 14
13 using base::android::AttachCurrentThread; 15 using base::android::AttachCurrentThread;
14 using base::android::ScopedJavaLocalRef; 16 using base::android::ScopedJavaLocalRef;
15 17
16 namespace base { 18 namespace base {
17 namespace android { 19 namespace android {
18 20
19 jdouble CPPClass::InnerClass::MethodOtherP0(JNIEnv* env, jobject obj) { 21 jdouble CPPClass::InnerClass::MethodOtherP0(JNIEnv* env, jobject obj) {
20 return 0.0; 22 return 0.0;
21 } 23 }
22 24
23 CPPClass::CPPClass() { 25 CPPClass::CPPClass() {
24 } 26 }
25 27
26 CPPClass::~CPPClass() { 28 CPPClass::~CPPClass() {
27 } 29 }
28 30
31 // static
32 bool CPPClass::RegisterJNI(JNIEnv* env) {
33 return RegisterNativesImpl(env); // Generated in SampleForTests_jni.h
34 }
35
29 void CPPClass::Destroy(JNIEnv* env, jobject obj) { 36 void CPPClass::Destroy(JNIEnv* env, jobject obj) {
30 delete this; 37 delete this;
31 } 38 }
32 39
33 jint CPPClass::Method(JNIEnv* env, jobject obj) { 40 jint CPPClass::Method(JNIEnv* env, jobject obj) {
34 return 0; 41 return 0;
35 } 42 }
36 43
37 void CPPClass::AddStructB(JNIEnv* env, jobject obj, jobject structb) { 44 void CPPClass::AddStructB(JNIEnv* env, jobject obj, jobject structb) {
38 long key = Java_InnerStructB_getKey(env, structb); 45 long key = Java_InnerStructB_getKey(env, structb);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 ScopedJavaLocalRef<jobject> struct_a = 111 ScopedJavaLocalRef<jobject> struct_a =
105 base::android::Java_InnerStructA_create( 112 base::android::Java_InnerStructA_create(
106 env, 0, 1, 113 env, 0, 1,
107 base::android::ConvertUTF8ToJavaString(env, "test").obj()); 114 base::android::ConvertUTF8ToJavaString(env, "test").obj());
108 base::android::Java_SampleForTests_addStructA( 115 base::android::Java_SampleForTests_addStructA(
109 env, my_java_object, struct_a.obj()); 116 env, my_java_object, struct_a.obj());
110 } 117 }
111 base::android::Java_SampleForTests_iterateAndDoSomething(env, my_java_object); 118 base::android::Java_SampleForTests_iterateAndDoSomething(env, my_java_object);
112 return 0; 119 return 0;
113 } 120 }
OLDNEW
« 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