forked from richardchien/natiflect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.h
115 lines (72 loc) · 3.54 KB
/
class.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// Copyright (c) 2016 Richard Chien
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//
// Created by Richard Chien on 7/5/16.
//
#ifndef NATIFLECT_CLASS_H
#define NATIFLECT_CLASS_H
#include <jni.h>
#include "exception.h"
#include "object.h"
namespace natiflect {
class Class : public Object<jclass> {
public:
Class(JNIEnv *env, jclass clz) : Object(env, clz) { };
Class(JNIEnv *env, const char *name);
jclass GetJClass() { return GetValue(); };
void SetJClass(jclass clz) { SetValue(clz); }
#pragma mark - Static Method
void CallStatic_V(const char *name, const char *sig = "()V", ...);
jboolean CallStatic_Z(const char *name, const char *sig = "()Z", ...);
jbyte CallStatic_B(const char *name, const char *sig = "()B", ...);
jchar CallStatic_C(const char *name, const char *sig = "()C", ...);
jshort CallStatic_S(const char *name, const char *sig = "()S", ...);
jint CallStatic_I(const char *name, const char *sig = "()I", ...);
jlong CallStatic_J(const char *name, const char *sig = "()J", ...);
jfloat CallStatic_F(const char *name, const char *sig = "()F", ...);
jdouble CallStatic_D(const char *name, const char *sig = "()D", ...);
jobject CallStatic_L(const char *name, const char *sig, ...);
#pragma mark - Static Field
jboolean GetStatic_Z(const char *name);
void SetStatic_Z(const char *name, jboolean value);
jbyte GetStatic_B(const char *name);
void SetStatic_B(const char *name, jbyte value);
jchar GetStatic_C(const char *name);
void SetStatic_C(const char *name, jchar value);
jshort GetStatic_S(const char *name);
void SetStatic_S(const char *name, jshort value);
jint GetStatic_I(const char *name);
void SetStatic_I(const char *name, jint value);
jlong GetStatic_J(const char *name);
void SetStatic_J(const char *name, jlong value);
jfloat GetStatic_F(const char *name);
void SetStatic_F(const char *name, jfloat value);
jdouble GetStatic_D(const char *name);
void SetStatic_D(const char *name, jdouble value);
jobject GetStatic_L(const char *name, const char *sig);
void SetStatic_L(const char *name, const char *sig, jobject value);
#pragma mark - Instance Method
Class GetSuperClass();
jobject NewInstance(const char *constructor_sig = "()V", ...);
jobject NewInstanceV(const char *constructor_sig, va_list args);
};
}
#endif //NATIFLECT_CLASS_H