2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
17 #include "java/lang/Class.h"
18 #include "java/lang/Object.h"
19 #include "java/lang/String.h"
20 #include "java/lang/reflect/Modifier.h"
37 Class *Modifier::class$ = NULL;
38 jmethodID *Modifier::_mids = NULL;
40 jclass Modifier::initializeClass()
44 jclass cls = env->findClass("java/lang/reflect/Modifier");
46 _mids = new jmethodID[max_mid];
48 env->getStaticMethodID(cls, "isPublic",
51 env->getStaticMethodID(cls, "isStatic",
54 env->getStaticMethodID(cls, "isNative",
57 env->getStaticMethodID(cls, "isFinal",
59 _mids[mid_isAbstract] =
60 env->getStaticMethodID(cls, "isAbstract",
62 _mids[mid_isPrivate] =
63 env->getStaticMethodID(cls, "isPrivate",
65 _mids[mid_isProtected] =
66 env->getStaticMethodID(cls, "isProtected",
69 class$ = (Class *) new JObject(cls);
72 return (jclass) class$->this$;
75 int Modifier::isPublic(int mod)
77 jclass cls = initializeClass();
78 return (int) env->callStaticBooleanMethod(cls, _mids[mid_isPublic], mod);
81 int Modifier::isStatic(int mod)
83 jclass cls = initializeClass();
84 return (int) env->callStaticBooleanMethod(cls, _mids[mid_isStatic], mod);
87 int Modifier::isNative(int mod)
89 jclass cls = initializeClass();
90 return (int) env->callStaticBooleanMethod(cls, _mids[mid_isNative], mod);
93 int Modifier::isFinal(int mod)
95 jclass cls = initializeClass();
96 return (int) env->callStaticBooleanMethod(cls, _mids[mid_isFinal], mod);
99 int Modifier::isAbstract(int mod)
101 jclass cls = initializeClass();
102 return (int) env->callStaticBooleanMethod(cls, _mids[mid_isAbstract], mod);
105 int Modifier::isPrivate(int mod)
107 jclass cls = initializeClass();
108 return (int) env->callStaticBooleanMethod(cls, _mids[mid_isPrivate], mod);
111 int Modifier::isProtected(int mod)
113 jclass cls = initializeClass();
114 return (int) env->callStaticBooleanMethod(cls, _mids[mid_isProtected], mod);
121 #include "structmember.h"
122 #include "functions.h"
129 static PyObject *t_Modifier_isPublic(PyTypeObject *type, PyObject *arg);
130 static PyObject *t_Modifier_isStatic(PyTypeObject *type, PyObject *arg);
131 static PyObject *t_Modifier_isNative(PyTypeObject *type, PyObject *arg);
132 static PyObject *t_Modifier_isFinal(PyTypeObject *type, PyObject *arg);
133 static PyObject *t_Modifier_isAbstract(PyTypeObject *type, PyObject *arg);
134 static PyObject *t_Modifier_isPrivate(PyTypeObject *type, PyObject *arg);
135 static PyObject *t_Modifier_isProtected(PyTypeObject *type, PyObject *arg);
137 static PyMethodDef t_Modifier__methods_[] = {
138 DECLARE_METHOD(t_Modifier, isPublic, METH_O | METH_CLASS),
139 DECLARE_METHOD(t_Modifier, isStatic, METH_O | METH_CLASS),
140 DECLARE_METHOD(t_Modifier, isNative, METH_O | METH_CLASS),
141 DECLARE_METHOD(t_Modifier, isFinal, METH_O | METH_CLASS),
142 DECLARE_METHOD(t_Modifier, isAbstract, METH_O | METH_CLASS),
143 DECLARE_METHOD(t_Modifier, isPrivate, METH_O | METH_CLASS),
144 DECLARE_METHOD(t_Modifier, isProtected, METH_O | METH_CLASS),
145 { NULL, NULL, 0, NULL }
148 DECLARE_TYPE(Modifier, t_Modifier, Object, Modifier,
149 abstract_init, 0, 0, 0, 0, 0);
151 static PyObject *t_Modifier_isPublic(PyTypeObject *type, PyObject *arg)
153 if (!PyInt_Check(arg))
155 PyErr_SetObject(PyExc_TypeError, arg);
159 int mod = PyInt_AsLong(arg);
162 OBJ_CALL(isPublic = Modifier::isPublic(mod));
163 Py_RETURN_BOOL(isPublic);
166 static PyObject *t_Modifier_isStatic(PyTypeObject *type, PyObject *arg)
168 if (!PyInt_Check(arg))
170 PyErr_SetObject(PyExc_TypeError, arg);
174 int mod = PyInt_AsLong(arg);
177 OBJ_CALL(isStatic = Modifier::isStatic(mod));
178 Py_RETURN_BOOL(isStatic);
181 static PyObject *t_Modifier_isNative(PyTypeObject *type, PyObject *arg)
183 if (!PyInt_Check(arg))
185 PyErr_SetObject(PyExc_TypeError, arg);
189 int mod = PyInt_AsLong(arg);
192 OBJ_CALL(isNative = Modifier::isNative(mod));
193 Py_RETURN_BOOL(isNative);
196 static PyObject *t_Modifier_isFinal(PyTypeObject *type, PyObject *arg)
198 if (!PyInt_Check(arg))
200 PyErr_SetObject(PyExc_TypeError, arg);
204 int mod = PyInt_AsLong(arg);
207 OBJ_CALL(isFinal = Modifier::isFinal(mod));
208 Py_RETURN_BOOL(isFinal);
211 static PyObject *t_Modifier_isAbstract(PyTypeObject *type, PyObject *arg)
213 if (!PyInt_Check(arg))
215 PyErr_SetObject(PyExc_TypeError, arg);
219 int mod = PyInt_AsLong(arg);
222 OBJ_CALL(isAbstract = Modifier::isAbstract(mod));
223 Py_RETURN_BOOL(isAbstract);
226 static PyObject *t_Modifier_isPrivate(PyTypeObject *type, PyObject *arg)
228 if (!PyInt_Check(arg))
230 PyErr_SetObject(PyExc_TypeError, arg);
234 int mod = PyInt_AsLong(arg);
237 OBJ_CALL(isPrivate = Modifier::isPrivate(mod));
238 Py_RETURN_BOOL(isPrivate);
241 static PyObject *t_Modifier_isProtected(PyTypeObject *type, PyObject *arg)
243 if (!PyInt_Check(arg))
245 PyErr_SetObject(PyExc_TypeError, arg);
249 int mod = PyInt_AsLong(arg);
252 OBJ_CALL(isProtected = Modifier::isProtected(mod));
253 Py_RETURN_BOOL(isProtected);