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.
19 #include "java/lang/Class.h"
20 #include "java/lang/Object.h"
21 #include "java/lang/String.h"
22 #include "java/lang/reflect/Constructor.h"
24 #include "java/lang/reflect/Type.h"
25 #include "java/lang/reflect/TypeVariable.h"
35 mid_getParameterTypes,
36 mid_getExceptionTypes,
38 mid_getTypeParameters,
39 mid_getGenericExceptionTypes,
40 mid_getGenericParameterTypes,
45 Class *Constructor::class$ = NULL;
46 jmethodID *Constructor::_mids = NULL;
48 jclass Constructor::initializeClass()
52 jclass cls = env->findClass("java/lang/reflect/Constructor");
54 _mids = new jmethodID[max_mid];
55 _mids[mid_getModifiers] =
56 env->getMethodID(cls, "getModifiers",
58 _mids[mid_getParameterTypes] =
59 env->getMethodID(cls, "getParameterTypes",
60 "()[Ljava/lang/Class;");
61 _mids[mid_getExceptionTypes] =
62 env->getMethodID(cls, "getExceptionTypes",
63 "()[Ljava/lang/Class;");
66 _mids[mid_getTypeParameters] =
67 env->getMethodID(cls, "getTypeParameters",
68 "()[Ljava/lang/reflect/TypeVariable;");
69 _mids[mid_getGenericExceptionTypes] =
70 env->getMethodID(cls, "getGenericExceptionTypes",
71 "()[Ljava/lang/reflect/Type;");
72 _mids[mid_getGenericParameterTypes] =
73 env->getMethodID(cls, "getGenericParameterTypes",
74 "()[Ljava/lang/reflect/Type;");
77 class$ = (Class *) new JObject(cls);
80 return (jclass) class$->this$;
83 int Constructor::getModifiers() const
85 return env->callIntMethod(this$, _mids[mid_getModifiers]);
88 JArray<Class> Constructor::getParameterTypes() const
90 jobjectArray array = (jobjectArray)
91 env->callObjectMethod(this$, _mids[mid_getParameterTypes]);
93 return JArray<Class>(array);
96 JArray<Class> Constructor::getExceptionTypes() const
98 jobjectArray array = (jobjectArray)
99 env->callObjectMethod(this$, _mids[mid_getExceptionTypes]);
101 return JArray<Class>(array);
104 #ifdef _java_generics
105 JArray<TypeVariable> Constructor::getTypeParameters() const
107 return JArray<TypeVariable>(env->callObjectMethod(this$, _mids[mid_getTypeParameters]));
110 JArray<Type> Constructor::getGenericExceptionTypes() const
112 return JArray<Type>(env->callObjectMethod(this$, _mids[mid_getGenericExceptionTypes]));
115 JArray<Type> Constructor::getGenericParameterTypes() const
117 return JArray<Type>(env->callObjectMethod(this$, _mids[mid_getGenericParameterTypes]));
125 #include "structmember.h"
126 #include "functions.h"
133 static PyObject *t_Constructor_getModifiers(t_Constructor *self);
134 static PyObject *t_Constructor_getParameterTypes(t_Constructor *self);
135 static PyObject *t_Constructor_getExceptionTypes(t_Constructor *self);
136 #ifdef _java_generics
137 static PyObject *t_Constructor_getTypeParameters(t_Constructor *self);
138 static PyObject *t_Constructor_getGenericExceptionTypes(t_Constructor *self);
139 static PyObject *t_Constructor_getGenericParameterTypes(t_Constructor *self);
142 static PyMethodDef t_Constructor__methods_[] = {
143 DECLARE_METHOD(t_Constructor, getModifiers, METH_NOARGS),
144 DECLARE_METHOD(t_Constructor, getParameterTypes, METH_NOARGS),
145 DECLARE_METHOD(t_Constructor, getExceptionTypes, METH_NOARGS),
146 #ifdef _java_generics
147 DECLARE_METHOD(t_Constructor, getTypeParameters, METH_NOARGS),
148 DECLARE_METHOD(t_Constructor, getGenericExceptionTypes, METH_NOARGS),
149 DECLARE_METHOD(t_Constructor, getGenericParameterTypes, METH_NOARGS),
151 { NULL, NULL, 0, NULL }
154 DECLARE_TYPE(Constructor, t_Constructor, Object, Constructor,
155 abstract_init, 0, 0, 0, 0, 0);
157 static PyObject *t_Constructor_getModifiers(t_Constructor *self)
161 OBJ_CALL(modifiers = self->object.getModifiers());
162 return PyInt_FromLong(modifiers);
165 static PyObject *t_Constructor_getParameterTypes(t_Constructor *self)
167 JArray<Class> types((jobject) NULL);
168 OBJ_CALL(types = self->object.getParameterTypes());
169 return types.toSequence(t_Class::wrap_Object);
172 static PyObject *t_Constructor_getExceptionTypes(t_Constructor *self)
174 JArray<Class> types((jobject) NULL);
175 OBJ_CALL(types = self->object.getExceptionTypes());
176 return types.toSequence(t_Class::wrap_Object);
179 #ifdef _java_generics
180 static PyObject *t_Constructor_getTypeParameters(t_Constructor *self)
182 JArray<TypeVariable> result((jobject) NULL);
183 OBJ_CALL(result = self->object.getTypeParameters());
185 return result.toSequence(t_TypeVariable::wrap_Object);
188 static PyObject *t_Constructor_getGenericExceptionTypes(t_Constructor *self)
190 JArray<Type> result((jobject) NULL);
191 OBJ_CALL(result = self->object.getGenericExceptionTypes());
193 return result.toSequence(t_Type::wrap_Object);
196 static PyObject *t_Constructor_getGenericParameterTypes(t_Constructor *self)
198 JArray<Type> result((jobject) NULL);
199 OBJ_CALL(result = self->object.getGenericParameterTypes());
201 return result.toSequence(t_Type::wrap_Object);