lime
Lime is a C++ library implementing Open Whisper System Signal protocol
Loading...
Searching...
No Matches
typed_methods.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <jni.h>
4
5namespace jni
6 {
7 template < class R > struct TypedMethods;
8
9 template <> struct TypedMethods< jobject* >
10 {
11 static constexpr auto CallMethod = &JNIEnv::CallObjectMethod;
12 static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualObjectMethod;
13 static constexpr auto GetField = &JNIEnv::GetObjectField;
14 static constexpr auto SetField = &JNIEnv::SetObjectField;
15 static constexpr auto CallStaticMethod = &JNIEnv::CallStaticObjectMethod;
16 static constexpr auto GetStaticField = &JNIEnv::GetStaticObjectField;
17 static constexpr auto SetStaticField = &JNIEnv::SetStaticObjectField;
18 };
19
20 template <> struct TypedMethods< jboolean >
21 {
22 static constexpr auto CallMethod = &JNIEnv::CallBooleanMethod;
23 static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualBooleanMethod;
24 static constexpr auto GetField = &JNIEnv::GetBooleanField;
25 static constexpr auto SetField = &JNIEnv::SetBooleanField;
26 static constexpr auto CallStaticMethod = &JNIEnv::CallStaticBooleanMethod;
27 static constexpr auto GetStaticField = &JNIEnv::GetStaticBooleanField;
28 static constexpr auto SetStaticField = &JNIEnv::SetStaticBooleanField;
29 static constexpr auto NewArray = &JNIEnv::NewBooleanArray;
30 static constexpr auto GetArrayElements = &JNIEnv::GetBooleanArrayElements;
31 static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseBooleanArrayElements;
32 static constexpr auto GetArrayRegion = &JNIEnv::GetBooleanArrayRegion;
33 static constexpr auto SetArrayRegion = &JNIEnv::SetBooleanArrayRegion;
34 };
35
36 template <> struct TypedMethods< jbyte >
37 {
38 static constexpr auto CallMethod = &JNIEnv::CallByteMethod;
39 static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualByteMethod;
40 static constexpr auto GetField = &JNIEnv::GetByteField;
41 static constexpr auto SetField = &JNIEnv::SetByteField;
42 static constexpr auto CallStaticMethod = &JNIEnv::CallStaticByteMethod;
43 static constexpr auto GetStaticField = &JNIEnv::GetStaticByteField;
44 static constexpr auto SetStaticField = &JNIEnv::SetStaticByteField;
45 static constexpr auto NewArray = &JNIEnv::NewByteArray;
46 static constexpr auto GetArrayElements = &JNIEnv::GetByteArrayElements;
47 static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseByteArrayElements;
48 static constexpr auto GetArrayRegion = &JNIEnv::GetByteArrayRegion;
49 static constexpr auto SetArrayRegion = &JNIEnv::SetByteArrayRegion;
50 };
51
52 template <> struct TypedMethods< jchar >
53 {
54 static constexpr auto CallMethod = &JNIEnv::CallCharMethod;
55 static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualCharMethod;
56 static constexpr auto GetField = &JNIEnv::GetCharField;
57 static constexpr auto SetField = &JNIEnv::SetCharField;
58 static constexpr auto CallStaticMethod = &JNIEnv::CallStaticCharMethod;
59 static constexpr auto GetStaticField = &JNIEnv::GetStaticCharField;
60 static constexpr auto SetStaticField = &JNIEnv::SetStaticCharField;
61 static constexpr auto NewArray = &JNIEnv::NewCharArray;
62 static constexpr auto GetArrayElements = &JNIEnv::GetCharArrayElements;
63 static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseCharArrayElements;
64 static constexpr auto GetArrayRegion = &JNIEnv::GetCharArrayRegion;
65 static constexpr auto SetArrayRegion = &JNIEnv::SetCharArrayRegion;
66 };
67
68 template <> struct TypedMethods< jshort >
69 {
70 static constexpr auto CallMethod = &JNIEnv::CallShortMethod;
71 static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualShortMethod;
72 static constexpr auto GetField = &JNIEnv::GetShortField;
73 static constexpr auto SetField = &JNIEnv::SetShortField;
74 static constexpr auto CallStaticMethod = &JNIEnv::CallStaticShortMethod;
75 static constexpr auto GetStaticField = &JNIEnv::GetStaticShortField;
76 static constexpr auto SetStaticField = &JNIEnv::SetStaticShortField;
77 static constexpr auto NewArray = &JNIEnv::NewShortArray;
78 static constexpr auto GetArrayElements = &JNIEnv::GetShortArrayElements;
79 static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseShortArrayElements;
80 static constexpr auto GetArrayRegion = &JNIEnv::GetShortArrayRegion;
81 static constexpr auto SetArrayRegion = &JNIEnv::SetShortArrayRegion;
82 };
83
84 template <> struct TypedMethods< jint >
85 {
86 static constexpr auto CallMethod = &JNIEnv::CallIntMethod;
87 static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualIntMethod;
88 static constexpr auto GetField = &JNIEnv::GetIntField;
89 static constexpr auto SetField = &JNIEnv::SetIntField;
90 static constexpr auto CallStaticMethod = &JNIEnv::CallStaticIntMethod;
91 static constexpr auto GetStaticField = &JNIEnv::GetStaticIntField;
92 static constexpr auto SetStaticField = &JNIEnv::SetStaticIntField;
93 static constexpr auto NewArray = &JNIEnv::NewIntArray;
94 static constexpr auto GetArrayElements = &JNIEnv::GetIntArrayElements;
95 static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseIntArrayElements;
96 static constexpr auto GetArrayRegion = &JNIEnv::GetIntArrayRegion;
97 static constexpr auto SetArrayRegion = &JNIEnv::SetIntArrayRegion;
98 };
99
100 template <> struct TypedMethods< jlong >
101 {
102 static constexpr auto CallMethod = &JNIEnv::CallLongMethod;
103 static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualLongMethod;
104 static constexpr auto GetField = &JNIEnv::GetLongField;
105 static constexpr auto SetField = &JNIEnv::SetLongField;
106 static constexpr auto CallStaticMethod = &JNIEnv::CallStaticLongMethod;
107 static constexpr auto GetStaticField = &JNIEnv::GetStaticLongField;
108 static constexpr auto SetStaticField = &JNIEnv::SetStaticLongField;
109 static constexpr auto NewArray = &JNIEnv::NewLongArray;
110 static constexpr auto GetArrayElements = &JNIEnv::GetLongArrayElements;
111 static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseLongArrayElements;
112 static constexpr auto GetArrayRegion = &JNIEnv::GetLongArrayRegion;
113 static constexpr auto SetArrayRegion = &JNIEnv::SetLongArrayRegion;
114 };
115
116 template <> struct TypedMethods< jfloat >
117 {
118 static constexpr auto CallMethod = &JNIEnv::CallFloatMethod;
119 static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualFloatMethod;
120 static constexpr auto GetField = &JNIEnv::GetFloatField;
121 static constexpr auto SetField = &JNIEnv::SetFloatField;
122 static constexpr auto CallStaticMethod = &JNIEnv::CallStaticFloatMethod;
123 static constexpr auto GetStaticField = &JNIEnv::GetStaticFloatField;
124 static constexpr auto SetStaticField = &JNIEnv::SetStaticFloatField;
125 static constexpr auto NewArray = &JNIEnv::NewFloatArray;
126 static constexpr auto GetArrayElements = &JNIEnv::GetFloatArrayElements;
127 static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseFloatArrayElements;
128 static constexpr auto GetArrayRegion = &JNIEnv::GetFloatArrayRegion;
129 static constexpr auto SetArrayRegion = &JNIEnv::SetFloatArrayRegion;
130 };
131
132 template <> struct TypedMethods< jdouble >
133 {
134 static constexpr auto CallMethod = &JNIEnv::CallDoubleMethod;
135 static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualDoubleMethod;
136 static constexpr auto GetField = &JNIEnv::GetDoubleField;
137 static constexpr auto SetField = &JNIEnv::SetDoubleField;
138 static constexpr auto CallStaticMethod = &JNIEnv::CallStaticDoubleMethod;
139 static constexpr auto GetStaticField = &JNIEnv::GetStaticDoubleField;
140 static constexpr auto SetStaticField = &JNIEnv::SetStaticDoubleField;
141 static constexpr auto NewArray = &JNIEnv::NewDoubleArray;
142 static constexpr auto GetArrayElements = &JNIEnv::GetDoubleArrayElements;
143 static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseDoubleArrayElements;
144 static constexpr auto GetArrayRegion = &JNIEnv::GetDoubleArrayRegion;
145 static constexpr auto SetArrayRegion = &JNIEnv::SetDoubleArrayRegion;
146 };
147 }
Definition advanced_ownership.hpp:6
std::enable_if_t<!std::is_void< R >::value, R > CallStaticMethod(JNIEnv &env, jclass &clazz, jmethodID &method, Args &&... args)
Definition functions.hpp:328
void SetField(JNIEnv &env, jobject *obj, jfieldID &field, T value)
Definition functions.hpp:313
void SetArrayRegion(JNIEnv &env, jarray< T > &array, jsize start, jsize len, const T *buf)
Definition functions.hpp:539
std::tuple< UniqueArrayElements< E >, bool > GetArrayElements(JNIEnv &env, jarray< E > &array)
Definition functions.hpp:479
jarray< E > & NewArray(JNIEnv &env, jsize length)
Definition functions.hpp:472
std::enable_if_t<!std::is_void< R >::value, R > CallNonvirtualMethod(JNIEnv &env, jobject *obj, jclass &clazz, jmethodID &method, Args &&... args)
Definition functions.hpp:284
void SetStaticField(JNIEnv &env, jclass &clazz, jfieldID &field, T value)
Definition functions.hpp:357
std::enable_if_t<!std::is_void< R >::value, R > CallMethod(JNIEnv &env, jobject *obj, jmethodID &method, Args &&... args)
Definition functions.hpp:268
void ReleaseArrayElements(JNIEnv &env, jarray< E > &array, E *elems)
Definition functions.hpp:488
T GetStaticField(JNIEnv &env, jclass &clazz, jfieldID &field)
Definition functions.hpp:350
void GetArrayRegion(JNIEnv &env, jarray< T > &array, jsize start, jsize len, T *buf)
Definition functions.hpp:525
T GetField(JNIEnv &env, jobject *obj, jfieldID &field)
Definition functions.hpp:306
Definition typed_methods.hpp:7
Definition types.hpp:31