forked from ninia/jep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClass.c
220 lines (196 loc) · 6.92 KB
/
Class.c
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/*
jep - Java Embedded Python
Copyright (c) 2016-2021 JEP AUTHORS.
This file is licensed under the the zlib/libpng License.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "Jep.h"
static jmethodID getComponentType = 0;
static jmethodID getConstructors = 0;
static jmethodID getDeclaredClasses = 0;
static jmethodID getDeclaredFields = 0;
static jmethodID getDeclaredMethods = 0;
static jmethodID getFields = 0;
static jmethodID getMethods = 0;
static jmethodID getModifiers = 0;
static jmethodID getName = 0;
static jmethodID getSimpleName = 0;
static jmethodID isArray = 0;
static jmethodID newInstance = 0;
static jmethodID isInterface = 0;
static jmethodID getInterfaces = 0;
static jmethodID getSuperclass = 0;
jclass java_lang_Class_getComponentType(JNIEnv* env, jclass this)
{
jclass result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getComponentType, env, JCLASS_TYPE, "getComponentType",
"()Ljava/lang/Class;")) {
result = (jclass) (*env)->CallObjectMethod(env, this, getComponentType);
}
Py_END_ALLOW_THREADS
return result;
}
jobjectArray java_lang_Class_getConstructors(JNIEnv* env, jclass this)
{
jobjectArray result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getConstructors, env, JCLASS_TYPE, "getConstructors",
"()[Ljava/lang/reflect/Constructor;")) {
result = (jobjectArray) (*env)->CallObjectMethod(env, this, getConstructors);
}
Py_END_ALLOW_THREADS
return result;
}
jobjectArray java_lang_Class_getDeclaredClasses(JNIEnv* env, jclass this)
{
jobjectArray result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getDeclaredClasses, env, JCLASS_TYPE, "getDeclaredClasses",
"()[Ljava/lang/Class;")) {
result = (jobjectArray) (*env)->CallObjectMethod(env, this, getDeclaredClasses);
}
Py_END_ALLOW_THREADS
return result;
}
jobjectArray java_lang_Class_getDeclaredFields(JNIEnv* env, jclass this)
{
jobjectArray result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getDeclaredFields, env, JCLASS_TYPE, "getDeclaredFields",
"()[Ljava/lang/reflect/Field;")) {
result = (jobjectArray) (*env)->CallObjectMethod(env, this, getDeclaredFields);
}
Py_END_ALLOW_THREADS
return result;
}
jobjectArray java_lang_Class_getDeclaredMethods(JNIEnv* env, jclass this)
{
jobjectArray result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getDeclaredMethods, env, JCLASS_TYPE, "getDeclaredMethods",
"()[Ljava/lang/reflect/Method;")) {
result = (jobjectArray) (*env)->CallObjectMethod(env, this, getDeclaredMethods);
}
Py_END_ALLOW_THREADS
return result;
}
jobjectArray java_lang_Class_getFields(JNIEnv* env, jclass this)
{
jobjectArray result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getFields, env, JCLASS_TYPE, "getFields",
"()[Ljava/lang/reflect/Field;")) {
result = (jobjectArray) (*env)->CallObjectMethod(env, this, getFields);
}
Py_END_ALLOW_THREADS
return result;
}
jobjectArray java_lang_Class_getMethods(JNIEnv* env, jclass this)
{
jobjectArray result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getMethods, env, JCLASS_TYPE, "getMethods",
"()[Ljava/lang/reflect/Method;")) {
result = (jobjectArray) (*env)->CallObjectMethod(env, this, getMethods);
}
Py_END_ALLOW_THREADS
return result;
}
jint java_lang_Class_getModifiers(JNIEnv* env, jclass this)
{
jint result = 0;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getModifiers, env, JCLASS_TYPE, "getModifiers", "()I")) {
result = (*env)->CallIntMethod(env, this, getModifiers);
}
Py_END_ALLOW_THREADS
return result;
}
jstring java_lang_Class_getName(JNIEnv* env, jclass this)
{
jstring result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getName, env, JCLASS_TYPE, "getName", "()Ljava/lang/String;")) {
result = (jstring) (*env)->CallObjectMethod(env, this, getName);
}
Py_END_ALLOW_THREADS
return result;
}
jstring java_lang_Class_getSimpleName(JNIEnv* env, jclass this)
{
jstring result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getSimpleName, env, JCLASS_TYPE, "getSimpleName",
"()Ljava/lang/String;")) {
result = (jstring) (*env)->CallObjectMethod(env, this, getSimpleName);
}
Py_END_ALLOW_THREADS
return result;
}
jboolean java_lang_Class_isArray(JNIEnv* env, jclass this)
{
jboolean result = JNI_FALSE;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(isArray, env, JCLASS_TYPE, "isArray", "()Z")) {
result = (*env)->CallBooleanMethod(env, this, isArray);
}
Py_END_ALLOW_THREADS
return result;
}
jobject java_lang_Class_newInstance(JNIEnv* env, jclass this)
{
jobject result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(newInstance, env, JCLASS_TYPE, "newInstance",
"()Ljava/lang/Object;")) {
result = (*env)->CallObjectMethod(env, this, newInstance);
}
Py_END_ALLOW_THREADS
return result;
}
jboolean java_lang_Class_isInterface(JNIEnv* env, jclass this)
{
jboolean result = JNI_FALSE;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(isInterface, env, JCLASS_TYPE, "isInterface", "()Z")) {
result = (*env)->CallBooleanMethod(env, this, isInterface);
}
Py_END_ALLOW_THREADS
return result;
}
jclass java_lang_Class_getSuperclass(JNIEnv* env, jclass this)
{
jclass result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getSuperclass, env, JCLASS_TYPE, "getSuperclass",
"()Ljava/lang/Class;")) {
result = (jclass) (*env)->CallObjectMethod(env, this, getSuperclass);
}
Py_END_ALLOW_THREADS
return result;
}
jobjectArray java_lang_Class_getInterfaces(JNIEnv* env, jclass this)
{
jobjectArray result = NULL;
Py_BEGIN_ALLOW_THREADS
if (JNI_METHOD(getInterfaces, env, JCLASS_TYPE, "getInterfaces",
"()[Ljava/lang/Class;")) {
result = (jobjectArray) (*env)->CallObjectMethod(env, this, getInterfaces);
}
Py_END_ALLOW_THREADS
return result;
}