Home | History | Annotate | Download | only in jni_generator
      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
      3 // found in the LICENSE file.
      4 
      5 #include <jni.h>
      6 #include <map>
      7 #include <string>
      8 
      9 #include "base/android/jni_android.h"
     10 #include "base/basictypes.h"
     11 
     12 namespace base {
     13 namespace android {
     14 
     15 // This file is used to:
     16 // - document the best practices and guidelines on JNI usage.
     17 // - ensure sample_for_tests_jni.h compiles and the functions declared in it
     18 // as expected.
     19 //
     20 // All methods are called directly from Java. See more documentation in
     21 // SampleForTests.java.
     22 class CPPClass {
     23  public:
     24   CPPClass();
     25   ~CPPClass();
     26 
     27   class InnerClass {
     28    public:
     29     jdouble MethodOtherP0(JNIEnv* env, jobject obj);
     30   };
     31 
     32   void Destroy(JNIEnv* env, jobject obj);
     33 
     34   jint Method(JNIEnv* env, jobject obj);
     35 
     36   void AddStructB(JNIEnv* env, jobject obj, jobject structb);
     37 
     38   void IterateAndDoSomethingWithStructB(JNIEnv* env, jobject obj);
     39 
     40   base::android::ScopedJavaLocalRef<jstring> ReturnAString(
     41       JNIEnv* env, jobject obj);
     42 
     43  private:
     44   std::map<long, std::string> map_;
     45 
     46   DISALLOW_COPY_AND_ASSIGN(CPPClass);
     47 };
     48 
     49 }  // namespace android
     50 }  // namespace base
     51