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 package org.chromium.example.jni_generator; | 5 package org.chromium.example.jni_generator; |
6 | 6 |
7 // This class serves as a reference test for the bindings generator, and as exam
ple documentation | 7 // This class serves as a reference test for the bindings generator, and as exam
ple documentation |
8 // for how to use the jni generator. | 8 // for how to use the jni generator. |
9 // The C++ counter-part is sample_for_tests.cc. | 9 // The C++ counter-part is sample_for_tests.cc. |
10 // jni_generator.gyp has a jni_generator_tests target that will: | 10 // jni_generator.gyp has a jni_generator_tests target that will: |
11 // * Generate a header file for the JNI bindings based on this file. | 11 // * Generate a header file for the JNI bindings based on this file. |
12 // * Compile sample_for_tests.cc using the generated header file. | 12 // * Compile sample_for_tests.cc using the generated header file. |
13 // * link a native executable to prove the generated header + cc file are self
-contained. | 13 // * link a native executable to prove the generated header + cc file are self
-contained. |
14 // All comments are informational only, and are ignored by the jni generator. | 14 // All comments are informational only, and are ignored by the jni generator. |
15 // | 15 // |
16 // This JNINamespace annotation indicates that all native methods should be | 16 // This JNINamespace annotation indicates that all native methods should be |
17 // generated inside this namespace, including the native class that this | 17 // generated inside this namespace, including the native class that this |
18 // object binds to. | 18 // object binds to. |
19 @JNINamespace("content") | 19 @JNINamespace("base::android") |
20 class SampleForTests { | 20 class SampleForTests { |
21 // Classes can store their C++ pointer counter part as an int that is normally
initialized by | 21 // Classes can store their C++ pointer counter part as an int that is normally
initialized by |
22 // calling out a nativeInit() function. | 22 // calling out a nativeInit() function. |
23 int nativePtr; | 23 int nativePtr; |
24 | 24 |
25 // You can define methods and attributes on the java class just like any other
. | 25 // You can define methods and attributes on the java class just like any other
. |
26 // Methods without the @CalledByNative annotation won't be exposed to JNI. | 26 // Methods without the @CalledByNative annotation won't be exposed to JNI. |
27 public SampleForTests() { | 27 public SampleForTests() { |
28 } | 28 } |
29 | 29 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 | 148 |
149 @NativeCall("InnerClass") | 149 @NativeCall("InnerClass") |
150 private static native int nativeInnerFunction(); | 150 private static native int nativeInnerFunction(); |
151 | 151 |
152 @NativeCall("InnerClass") | 152 @NativeCall("InnerClass") |
153 private static native String nativeInnerMethod(int nativeCPPClass); | 153 private static native String nativeInnerMethod(int nativeCPPClass); |
154 | 154 |
155 } | 155 } |
156 } | 156 } |
OLD | NEW |