lime
Lime is a C++ library implementing Open Whisper System Signal protocol
types.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstddef>
4 #include <cassert>
5 #include <memory>
6 #include <stdexcept>
7 
8 #include <jni.h>
9 
10 namespace jni
11  {
12  // Not using bool because its size is implementation-defined, and a defined size
13  // is necessary for array operations.
14 
15  using ::jboolean;
16 
17  const jboolean jni_false = 0;
18  const jboolean jni_true = 1;
19 
20  using ::jbyte;
21  using ::jchar;
22  using ::jshort;
23  using ::jint;
24  using ::jlong;
25  using ::jfloat;
26  using ::jdouble;
27 
28  using jsize = std::size_t;
29 
30  struct jobject
31  {
32  jobject() = delete;
33  ~jobject() = delete;
34  jobject(const jobject&) = delete;
35  jobject& operator=(const jobject&) = delete;
36  };
37 
38  struct jclass : public jobject {};
39  struct jstring : public jobject {};
40  struct jthrowable : public jobject {};
41 
42  template < class T >
43  struct jarray : public jobject {};
44 
54 
55  using jfieldID = std::pointer_traits< ::jfieldID >::element_type;
56  using jmethodID = std::pointer_traits< ::jmethodID >::element_type;
57 
58  using ::jobjectRefType;
59 
60  using ::JavaVM;
61  using ::JNIEnv;
62 
63  template < class T >
65 
66  template < class R, class... Args >
67  struct JNINativeMethod< R (JNIEnv*, jclass*, Args...) >
68  {
69  const char* name;
70  const char* signature;
71  R (*fnPtr)(JNIEnv*, jclass*, Args...);
72  };
73 
74  template < class R, class... Args >
75  struct JNINativeMethod< R (JNIEnv*, jobject*, Args...) >
76  {
77  const char* name;
78  const char* signature;
79  R (*fnPtr)(JNIEnv*, jobject*, Args...);
80  };
81 
82  enum version : jint
83  {
84  jni_version_1_1 = version(JNI_VERSION_1_1),
85  jni_version_1_2 = version(JNI_VERSION_1_2),
86  jni_version_1_4 = version(JNI_VERSION_1_4),
87  jni_version_1_6 = version(JNI_VERSION_1_6),
88  };
89 
90  enum error : jint
91  {
92  jni_ok = error(JNI_OK),
93  jni_err = error(JNI_ERR),
94  jni_edetached = error(JNI_EDETACHED),
95  jni_eversion = error(JNI_EVERSION),
96  };
97  }
version
Definition: types.hpp:82
const char * signature
Definition: types.hpp:78
const char * name
Definition: types.hpp:77
Definition: types.hpp:84
Definition: types.hpp:43
Definition: types.hpp:87
error
Definition: types.hpp:90
Definition: advanced_ownership.hpp:5
Definition: types.hpp:94
Definition: types.hpp:86
const jboolean jni_false
Definition: types.hpp:17
const jboolean jni_true
Definition: types.hpp:18
std::size_t jsize
Definition: types.hpp:28
Definition: types.hpp:93
Definition: types.hpp:95
~jobject()=delete
std::pointer_traits< ::jmethodID >::element_type jmethodID
Definition: types.hpp:56
Definition: types.hpp:85
const char * name
Definition: types.hpp:69
Definition: types.hpp:64
jobject()=delete
const char * signature
Definition: types.hpp:70
Definition: types.hpp:38
std::pointer_traits< ::jfieldID >::element_type jfieldID
Definition: types.hpp:55
Definition: types.hpp:39
Definition: types.hpp:40
Definition: types.hpp:30
jobject & operator=(const jobject &)=delete
Definition: types.hpp:92