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/Field.h"
22 #include "java/lang/reflect/Type.h"
39 Class *Field::class$ = NULL;
40 jmethodID *Field::_mids = NULL;
42 jclass Field::initializeClass()
46 jclass cls = env->findClass("java/lang/reflect/Field");
48 _mids = new jmethodID[max_mid];
49 _mids[mid_getModifiers] =
50 env->getMethodID(cls, "getModifiers",
53 env->getMethodID(cls, "getType",
54 "()Ljava/lang/Class;");
56 env->getMethodID(cls, "getName",
57 "()Ljava/lang/String;");
59 _mids[mid_getGenericType] =
60 env->getMethodID(cls, "getGenericType",
61 "()Ljava/lang/reflect/Type;");
64 class$ = (Class *) new JObject(cls);
67 return (jclass) class$->this$;
70 int Field::getModifiers() const
72 return env->callIntMethod(this$, _mids[mid_getModifiers]);
75 Class Field::getType() const
77 return Class(env->callObjectMethod(this$, _mids[mid_getType]));
80 String Field::getName() const
82 return String(env->callObjectMethod(this$, _mids[mid_getName]));
86 Type Field::getGenericType() const
88 return Type(env->callObjectMethod(this$, _mids[mid_getGenericType]));
96 #include "structmember.h"
97 #include "functions.h"
104 static PyObject *t_Field_getModifiers(t_Field *self);
105 static PyObject *t_Field_getType(t_Field *self);
106 static PyObject *t_Field_getName(t_Field *self);
107 #ifdef _java_generics
108 static PyObject *t_Field_getGenericType(t_Field *self);
111 static PyMethodDef t_Field__methods_[] = {
112 DECLARE_METHOD(t_Field, getModifiers, METH_NOARGS),
113 DECLARE_METHOD(t_Field, getType, METH_NOARGS),
114 DECLARE_METHOD(t_Field, getName, METH_NOARGS),
115 #ifdef _java_generics
116 DECLARE_METHOD(t_Field, getGenericType, METH_NOARGS),
118 { NULL, NULL, 0, NULL }
121 DECLARE_TYPE(Field, t_Field, Object, Field,
122 abstract_init, 0, 0, 0, 0, 0);
124 static PyObject *t_Field_getModifiers(t_Field *self)
128 OBJ_CALL(modifiers = self->object.getModifiers());
129 return PyInt_FromLong(modifiers);
132 static PyObject *t_Field_getType(t_Field *self)
134 Class cls((jobject) NULL);
136 OBJ_CALL(cls = self->object.getType());
137 return t_Class::wrap_Object(cls);
140 static PyObject *t_Field_getName(t_Field *self)
142 String name((jobject) NULL);
144 OBJ_CALL(name = self->object.getName());
148 #ifdef _java_generics
149 static PyObject *t_Field_getGenericType(t_Field *self)
151 Type result((jobject) NULL);
152 OBJ_CALL(result = self->object.getGenericType());
154 return t_Type::wrap_Object(result);