OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef BASE_ANDROID_JNI_GENERATOR_SAMPLE_FOR_TESTS_H_ | 5 #ifndef BASE_ANDROID_JNI_GENERATOR_SAMPLE_FOR_TESTS_H_ |
6 #define BASE_ANDROID_JNI_GENERATOR_SAMPLE_FOR_TESTS_H_ | 6 #define BASE_ANDROID_JNI_GENERATOR_SAMPLE_FOR_TESTS_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 namespace android { | 15 namespace android { |
16 | 16 |
17 // This file is used to: | 17 // This file is used to: |
18 // - document the best practices and guidelines on JNI usage. | 18 // - document the best practices and guidelines on JNI usage. |
19 // - ensure sample_for_tests_jni.h compiles and the functions declared in it | 19 // - ensure sample_for_tests_jni.h compiles and the functions declared in it |
20 // as expected. | 20 // as expected. |
21 // | 21 // |
22 // Methods are called directly from Java (except RegisterJNI). More | 22 // Methods are called directly from Java (except RegisterJNI). More |
23 // documentation in SampleForTests.java | 23 // documentation in SampleForTests.java |
24 // | 24 // |
25 // For C++ to access Java methods: | 25 // For C++ to access Java methods: |
26 // - GYP Build must be configured to generate bindings: | |
27 // # ... | |
28 // 'targets': [ | |
29 // { | |
30 // # An example target that will rely on JNI: | |
31 // 'target_name': 'foo', | |
32 // 'type': '<(component)', | |
33 // # ... normal sources, defines, deps. | |
34 // # For each jni generated .java -> .h header file in foo_jni_headers | |
35 // # target there will be a single .cc file here that includes it. | |
36 // # | |
37 // # Add deps for JNI: | |
38 // 'conditions': [ | |
39 // ['OS == "android"', { | |
40 // 'dependencies': [ | |
41 // 'foo_java', | |
42 // 'foo_jni_headers', | |
43 // ], | |
44 // }], | |
45 // ], | |
46 // }, | |
47 // ], | |
48 // # ... | |
49 // # Create targets for JNI: | |
50 // 'conditions': [ | |
51 // ['OS == "android"', { | |
52 // 'targets': [ | |
53 // { | |
54 // 'target_name': 'foo_jni_headers', | |
55 // 'type': 'none', | |
56 // 'sources': [ | |
57 // 'java/src/org/chromium/example/jni_generator/SampleForTests.java', | |
58 // ], | |
59 // 'variables': { | |
60 // 'jni_gen_package': 'foo', | |
61 // }, | |
62 // 'includes': [ '../../../build/jni_generator.gypi' ], | |
63 // }, | |
64 // { | |
65 // 'target_name': 'foo_java', | |
66 // 'type': 'none', | |
67 // 'dependencies': [ | |
68 // '../../../base/base.gyp:base', | |
69 // ], | |
70 // 'variables': { | |
71 // 'java_in_dir': 'java', | |
72 // }, | |
73 // 'includes': [ '../../../build/java.gypi' ], | |
74 // }, | |
75 // ], | |
76 // }], | |
77 // ], | |
78 // | |
79 // - GN Build must be configured to generate bindings: | 26 // - GN Build must be configured to generate bindings: |
80 // # Add import at top of file: | 27 // # Add import at top of file: |
81 // if (is_android) { | 28 // if (is_android) { |
82 // import("//build/config/android/rules.gni") # For generate_jni(). | 29 // import("//build/config/android/rules.gni") # For generate_jni(). |
83 // } | 30 // } |
84 // # ... | 31 // # ... |
85 // # An example target that will rely on JNI: | 32 // # An example target that will rely on JNI: |
86 // component("foo") { | 33 // component("foo") { |
87 // # ... normal sources, defines, deps. | 34 // # ... normal sources, defines, deps. |
88 // # For each jni generated .java -> .h header file in jni_headers | 35 // # For each jni generated .java -> .h header file in jni_headers |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 private: | 117 private: |
171 std::map<long, std::string> map_; | 118 std::map<long, std::string> map_; |
172 | 119 |
173 DISALLOW_COPY_AND_ASSIGN(CPPClass); | 120 DISALLOW_COPY_AND_ASSIGN(CPPClass); |
174 }; | 121 }; |
175 | 122 |
176 } // namespace android | 123 } // namespace android |
177 } // namespace base | 124 } // namespace base |
178 | 125 |
179 #endif // BASE_ANDROID_JNI_GENERATOR_SAMPLE_FOR_TESTS_H_ | 126 #endif // BASE_ANDROID_JNI_GENERATOR_SAMPLE_FOR_TESTS_H_ |
OLD | NEW |