-
Notifications
You must be signed in to change notification settings - Fork 13
/
JniJavaClassOtherDefs.h
41 lines (33 loc) · 1.19 KB
/
JniJavaClassOtherDefs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#ifndef JNI_JAVA_CLASS_OTHER_DEFS_H
#define JNI_JAVA_CLASS_OTHER_DEFS_H
#include <JniForwards.h>
#include <JniSignatureBuilder.h>
#include <JniJavaClassClassDef.h>
namespace JNI {
template<typename R, typename ... Args>
struct JavaClass::MethodGetter<R(Args...)> {
jmethodID Get(const JavaClass& self, const char * name) const {
return self.Env().Val()->GetMethodID(self.Val(), name, JniSignatureBuilder<R(Args...)>::Signature().c_str());
}
};
template<typename R, typename ... Args>
struct JavaClass::StaticMethodGetter<R(Args...)> {
jmethodID Get(const JavaClass& self, const char * name) const {
return self.Env().Val()->GetStaticMethodID(self.Val(), name, JniSignatureBuilder<R(Args...)>::Signature().c_str());
}
};
template<typename T>
struct JavaClass::FieldGetter {
jfieldID Get(const JavaClass& self, const char * name) const {
return self.Env().Val()->GetFieldID(self.Val(), name, JniSignatureBuilder<T>::Signature().c_str());
}
};
template<typename T>
struct JavaClass::StaticFieldGetter {
jfieldID Get(const JavaClass& self, const char * name) const {
return self.Env().Val()->GetStaticFieldID(self.Val(), name, JniSignatureBuilder<T>::Signature().c_str());
}
};
}
#endif