PyLucene 3.4.0-1 import
[pylucene.git] / jcc / _jcc / java / lang / Class.h
1 /*
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
5  *
6  *       http://www.apache.org/licenses/LICENSE-2.0
7  *
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.
13  */
14
15 #ifndef _Class_H
16 #define _Class_H
17
18 #include <Python.h>
19 #include "JArray.h"
20 #include "java/lang/Object.h"
21
22 namespace java {
23     namespace lang {
24         namespace reflect {
25             class Method;
26             class Constructor;
27             class Field;
28 #ifdef _java_generics
29             class Type;
30             class TypeVariable;
31 #endif
32         }
33
34         using namespace reflect;
35
36         class Class : public Object {
37         public:
38             static Class *class$;
39             static jmethodID *_mids;
40             static jclass initializeClass();
41
42             explicit Class(jobject obj) : Object(obj) {
43                 initializeClass();
44             }
45             Class(const Class& obj) : Object(obj) {}
46
47             static Class forName(const String& className);
48             JArray<Method> getDeclaredMethods() const;
49             JArray<Method> getMethods() const;
50             Method getMethod(const String &name, const JArray<Class>& params) const;
51             Method getDeclaredMethod(const String &name, const JArray<Class>& params) const;
52             JArray<Constructor> getDeclaredConstructors() const;
53             JArray<Field> getDeclaredFields() const;
54             JArray<Class> getDeclaredClasses() const;
55             int isArray() const;
56             int isPrimitive() const;
57             int isInterface() const;
58             int isAssignableFrom(const Class& obj) const;
59             Class getComponentType() const;
60             Class getSuperclass() const;
61             Class getDeclaringClass() const;
62             Class getEnclosingClass() const;
63             JArray<Class> getInterfaces() const;
64             String getName() const;
65             int getModifiers() const;
66             int isInstance(const Object &obj) const;
67 #ifdef _java_generics
68             JArray<TypeVariable> getTypeParameters() const;
69             JArray<Type> getGenericInterfaces() const;
70             Type getGenericSuperclass() const;
71 #endif
72         };
73
74         extern PyTypeObject PY_TYPE(Class);
75
76         class t_Class {
77         public:
78             PyObject_HEAD
79             Class object;
80 #ifdef _java_generics
81             PyTypeObject *parameters[1];
82             static PyTypeObject **parameters_(t_Class *self)
83             {
84                 return (PyTypeObject **) &(self->parameters);
85             }
86 #endif
87             static PyObject *wrap_Object(const Class& object);
88 #ifdef _java_generics
89             static PyObject *wrap_Object(const Class& object, PyTypeObject *T);
90 #endif
91             static PyObject *wrap_jobject(const jobject& object);
92         };
93     }
94 }
95
96 #endif /* _Class_H */