lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r732916 [4/14] - in /lucene/pylucene/trunk: ./ java/ java/org/ java/org/osafoundation/ java/org/osafoundation/lucene/ java/org/osafoundation/lucene/analysis/ java/org/osafoundation/lucene/queryParser/ java/org/osafoundation/lucene/search/ j...
Date Fri, 09 Jan 2009 03:28:41 GMT
Added: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.cpp?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.cpp (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.cpp Thu Jan  8 19:28:33 2009
@@ -0,0 +1,193 @@
+/*
+ *   Copyright (c) 2007-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <jni.h>
+#include "JCCEnv.h"
+#include "JArray.h"
+
+#include "java/lang/Class.h"
+#include "java/lang/Object.h"
+#include "java/lang/String.h"
+#include "java/lang/reflect/Method.h"
+
+namespace java {
+    namespace lang {
+        namespace reflect {
+
+            enum {
+                mid_getModifiers,
+                mid_getReturnType,
+                mid_getName,
+                mid_getParameterTypes,
+                mid_getExceptionTypes,
+                mid_getDeclaringClass,
+                max_mid
+            };
+
+            Class *Method::class$ = NULL;
+            jmethodID *Method::_mids = NULL;
+
+            jclass Method::initializeClass()
+            {
+                if (!class$)
+                {
+                    jclass cls = env->findClass("java/lang/reflect/Method");
+
+                    _mids = new jmethodID[max_mid];
+                    _mids[mid_getModifiers] =
+                        env->getMethodID(cls, "getModifiers",
+                                         "()I");
+                    _mids[mid_getReturnType] =
+                        env->getMethodID(cls, "getReturnType",
+                                         "()Ljava/lang/Class;");
+                    _mids[mid_getName] =
+                        env->getMethodID(cls, "getName",
+                                         "()Ljava/lang/String;");
+
+                    _mids[mid_getParameterTypes] =
+                        env->getMethodID(cls, "getParameterTypes",
+                                         "()[Ljava/lang/Class;");
+                    _mids[mid_getExceptionTypes] =
+                        env->getMethodID(cls, "getExceptionTypes",
+                                         "()[Ljava/lang/Class;");
+                    _mids[mid_getDeclaringClass] =
+                        env->getMethodID(cls, "getDeclaringClass",
+                                         "()Ljava/lang/Class;");
+
+                    class$ = (Class *) new JObject(cls);
+                }
+                
+                return (jclass) class$->this$;
+            }
+
+            int Method::getModifiers() const
+            {
+                return env->callIntMethod(this$, _mids[mid_getModifiers]);
+            }
+
+            Class Method::getReturnType() const
+            {
+                return Class(env->callObjectMethod(this$, _mids[mid_getReturnType]));
+            }
+
+            String Method::getName() const
+            {
+                return String(env->callObjectMethod(this$, _mids[mid_getName]));
+            }
+
+            JArray<Class> Method::getParameterTypes() const
+            {
+                jobjectArray array = (jobjectArray)
+                    env->callObjectMethod(this$, _mids[mid_getParameterTypes]);
+
+                return JArray<Class>(array);
+            }
+
+            JArray<Class> Method::getExceptionTypes() const
+            {
+                jobjectArray array = (jobjectArray)
+                    env->callObjectMethod(this$, _mids[mid_getExceptionTypes]);
+
+                return JArray<Class>(array);
+            }
+
+            Class Method::getDeclaringClass() const
+            {
+                return Class(env->callObjectMethod(this$, _mids[mid_getDeclaringClass]));
+            }
+        }
+    }
+}
+
+
+#include "structmember.h"
+#include "functions.h"
+#include "macros.h"
+
+namespace java {
+    namespace lang {
+        namespace reflect {
+
+            static PyObject *t_Method_getModifiers(t_Method *self);
+            static PyObject *t_Method_getReturnType(t_Method *self);
+            static PyObject *t_Method_getName(t_Method *self);
+            static PyObject *t_Method_getParameterTypes(t_Method *self);
+            static PyObject *t_Method_getExceptionTypes(t_Method *self);
+            static PyObject *t_Method_getDeclaringClass(t_Method *self);
+
+            static PyMethodDef t_Method__methods_[] = {
+                DECLARE_METHOD(t_Method, getModifiers, METH_NOARGS),
+                DECLARE_METHOD(t_Method, getReturnType, METH_NOARGS),
+                DECLARE_METHOD(t_Method, getName, METH_NOARGS),
+                DECLARE_METHOD(t_Method, getParameterTypes, METH_NOARGS),
+                DECLARE_METHOD(t_Method, getExceptionTypes, METH_NOARGS),
+                DECLARE_METHOD(t_Method, getDeclaringClass, METH_NOARGS),
+                { NULL, NULL, 0, NULL }
+            };
+
+            DECLARE_TYPE(Method, t_Method, Object, Method,
+                         abstract_init, 0, 0, 0, 0, 0);
+
+            static PyObject *t_Method_getModifiers(t_Method *self)
+            {
+                jint modifiers;
+
+                OBJ_CALL(modifiers = self->object.getModifiers());
+                return PyInt_FromLong(modifiers);
+            }
+
+            static PyObject *t_Method_getReturnType(t_Method *self)
+            {
+                Class cls((jobject) NULL);
+
+                OBJ_CALL(cls = self->object.getReturnType());
+                return t_Class::wrap_Object(cls);
+            }
+
+            static PyObject *t_Method_getName(t_Method *self)
+            {
+                String name((jobject) NULL);
+
+                OBJ_CALL(name = self->object.getName());
+                return j2p(name);
+            }
+
+            static PyObject *t_Method_getParameterTypes(t_Method *self)
+            {
+                JArray<Class> types((jobject) NULL);
+
+                OBJ_CALL(types = self->object.getParameterTypes());
+                return types.toSequence(t_Class::wrap_Object);
+            }
+
+            static PyObject *t_Method_getExceptionTypes(t_Method *self)
+            {
+                JArray<Class> types((jobject) NULL);
+
+                OBJ_CALL(types = self->object.getExceptionTypes());
+                return types.toSequence(t_Class::wrap_Object);
+            }
+
+            static PyObject *t_Method_getDeclaringClass(t_Method *self)
+            {
+                Class cls((jobject) NULL);
+
+                OBJ_CALL(cls = self->object.getDeclaringClass());
+                return t_Class::wrap_Object(cls);
+            }
+        }
+    }
+}

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.h?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.h (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.h Thu Jan  8 19:28:33 2009
@@ -0,0 +1,61 @@
+/*
+ *   Copyright (c) 2007-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#ifndef _Method_H
+#define _Method_H
+
+#include <Python.h>
+#include "JArray.h"
+
+namespace java {
+    namespace lang {
+        class Class;
+        class String;
+
+        namespace reflect {
+            class Method : public Object {
+            public:
+                static Class *class$;
+                static jmethodID *_mids;
+                static jclass initializeClass();
+
+                explicit Method(jobject obj) : Object(obj) {
+                    initializeClass();
+                }
+                Method(const Method& obj) : Object(obj) {}
+
+                int getModifiers() const;
+                Class getReturnType() const;
+                String getName() const;
+                JArray<Class> getParameterTypes() const;
+                JArray<Class> getExceptionTypes() const;
+                Class getDeclaringClass() const;
+            };
+
+            extern PyTypeObject MethodType;
+
+            class t_Method {
+            public:
+                PyObject_HEAD
+                Method object;
+                static PyObject *wrap_Object(const Method& object);
+                static PyObject *wrap_jobject(const jobject& object);
+            };
+        }
+    }
+}
+
+#endif /* _Method_H */

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Method.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.cpp?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.cpp (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.cpp Thu Jan  8 19:28:33 2009
@@ -0,0 +1,280 @@
+/*
+ *   Copyright (c) 2007-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <jni.h>
+#include "JCCEnv.h"
+#include "java/lang/Class.h"
+#include "java/lang/Object.h"
+#include "java/lang/String.h"
+#include "java/lang/reflect/Modifier.h"
+
+namespace java {
+    namespace lang {
+        namespace reflect {
+
+            enum {
+                mid_isPublic,
+                mid_isStatic,
+                mid_isNative,
+                mid_isFinal,
+                mid_isAbstract,
+                mid_isPrivate,
+                mid_isProtected,
+                max_mid
+            };
+
+            Class *Modifier::class$ = NULL;
+            jmethodID *Modifier::_mids = NULL;
+
+            jclass Modifier::initializeClass()
+            {
+                if (!class$)
+                {
+                    jclass cls = env->findClass("java/lang/reflect/Modifier");
+
+                    _mids = new jmethodID[max_mid];
+                    _mids[mid_isPublic] =
+                        env->getStaticMethodID(cls, "isPublic",
+                                               "(I)Z");
+                    _mids[mid_isStatic] =
+                        env->getStaticMethodID(cls, "isStatic",
+                                               "(I)Z");
+                    _mids[mid_isNative] =
+                        env->getStaticMethodID(cls, "isNative",
+                                               "(I)Z");
+                    _mids[mid_isFinal] =
+                        env->getStaticMethodID(cls, "isFinal",
+                                               "(I)Z");
+                    _mids[mid_isAbstract] =
+                        env->getStaticMethodID(cls, "isAbstract",
+                                               "(I)Z");
+                    _mids[mid_isPrivate] =
+                        env->getStaticMethodID(cls, "isPrivate",
+                                               "(I)Z");
+                    _mids[mid_isProtected] =
+                        env->getStaticMethodID(cls, "isProtected",
+                                               "(I)Z");
+
+                    class$ = (Class *) new JObject(cls);
+                }
+                
+                return (jclass) class$->this$;
+            }
+
+            int Modifier::isPublic(int mod)
+            {
+                jclass cls = initializeClass();
+                return (int) env->callStaticBooleanMethod(cls, _mids[mid_isPublic], mod);
+            }
+
+            int Modifier::isStatic(int mod)
+            {
+                jclass cls = initializeClass();
+                return (int) env->callStaticBooleanMethod(cls, _mids[mid_isStatic], mod);
+            }
+
+            int Modifier::isNative(int mod)
+            {
+                jclass cls = initializeClass();
+                return (int) env->callStaticBooleanMethod(cls, _mids[mid_isNative], mod);
+            }
+
+            int Modifier::isFinal(int mod)
+            {
+                jclass cls = initializeClass();
+                return (int) env->callStaticBooleanMethod(cls, _mids[mid_isFinal], mod);
+            }
+
+            int Modifier::isAbstract(int mod)
+            {
+                jclass cls = initializeClass();
+                return (int) env->callStaticBooleanMethod(cls, _mids[mid_isAbstract], mod);
+            }
+
+            int Modifier::isPrivate(int mod)
+            {
+                jclass cls = initializeClass();
+                return (int) env->callStaticBooleanMethod(cls, _mids[mid_isPrivate], mod);
+            }
+
+            int Modifier::isProtected(int mod)
+            {
+                jclass cls = initializeClass();
+                return (int) env->callStaticBooleanMethod(cls, _mids[mid_isProtected], mod);
+            }
+        }
+    }
+}
+
+
+#include "structmember.h"
+#include "functions.h"
+#include "macros.h"
+
+namespace java {
+    namespace lang {
+        namespace reflect {
+
+            static PyObject *t_Modifier_isPublic(PyTypeObject *type, PyObject *arg);
+            static PyObject *t_Modifier_isStatic(PyTypeObject *type, PyObject *arg);
+            static PyObject *t_Modifier_isNative(PyTypeObject *type, PyObject *arg);
+            static PyObject *t_Modifier_isFinal(PyTypeObject *type, PyObject *arg);
+            static PyObject *t_Modifier_isAbstract(PyTypeObject *type, PyObject *arg);
+            static PyObject *t_Modifier_isPrivate(PyTypeObject *type, PyObject *arg);
+            static PyObject *t_Modifier_isProtected(PyTypeObject *type, PyObject *arg);
+
+            static PyMethodDef t_Modifier__methods_[] = {
+                DECLARE_METHOD(t_Modifier, isPublic, METH_O | METH_CLASS),
+                DECLARE_METHOD(t_Modifier, isStatic, METH_O | METH_CLASS),
+                DECLARE_METHOD(t_Modifier, isNative, METH_O | METH_CLASS),
+                DECLARE_METHOD(t_Modifier, isFinal, METH_O | METH_CLASS),
+                DECLARE_METHOD(t_Modifier, isAbstract, METH_O | METH_CLASS),
+                DECLARE_METHOD(t_Modifier, isPrivate, METH_O | METH_CLASS),
+                DECLARE_METHOD(t_Modifier, isProtected, METH_O | METH_CLASS),
+                { NULL, NULL, 0, NULL }
+            };
+
+            DECLARE_TYPE(Modifier, t_Modifier, Object, Modifier,
+                         abstract_init, 0, 0, 0, 0, 0);
+
+            static PyObject *t_Modifier_isPublic(PyTypeObject *type, PyObject *arg)
+            {
+                if (!PyInt_Check(arg))
+                {
+                    PyErr_SetObject(PyExc_TypeError, arg);
+                    return NULL;
+                }
+
+                try {
+                    int mod = PyInt_AsLong(arg);
+                    int isPublic = Modifier::isPublic(mod);
+
+                    Py_RETURN_BOOL(isPublic);
+                } catch (JCCEnv::exception e) {
+                    return PyErr_SetJavaError(e.throwable);
+                }
+            }
+
+            static PyObject *t_Modifier_isStatic(PyTypeObject *type, PyObject *arg)
+            {
+                if (!PyInt_Check(arg))
+                {
+                    PyErr_SetObject(PyExc_TypeError, arg);
+                    return NULL;
+                }
+
+                try {
+                    int mod = PyInt_AsLong(arg);
+                    int isStatic = Modifier::isStatic(mod);
+
+                    Py_RETURN_BOOL(isStatic);
+                } catch (JCCEnv::exception e) {
+                    return PyErr_SetJavaError(e.throwable);
+                }
+            }
+
+            static PyObject *t_Modifier_isNative(PyTypeObject *type, PyObject *arg)
+            {
+                if (!PyInt_Check(arg))
+                {
+                    PyErr_SetObject(PyExc_TypeError, arg);
+                    return NULL;
+                }
+
+                try {
+                    int mod = PyInt_AsLong(arg);
+                    int isNative = Modifier::isNative(mod);
+
+                    Py_RETURN_BOOL(isNative);
+                } catch (JCCEnv::exception e) {
+                    return PyErr_SetJavaError(e.throwable);
+                }
+            }
+
+            static PyObject *t_Modifier_isFinal(PyTypeObject *type, PyObject *arg)
+            {
+                if (!PyInt_Check(arg))
+                {
+                    PyErr_SetObject(PyExc_TypeError, arg);
+                    return NULL;
+                }
+
+                try {
+                    int mod = PyInt_AsLong(arg);
+                    int isFinal = Modifier::isFinal(mod);
+
+                    Py_RETURN_BOOL(isFinal);
+                } catch (JCCEnv::exception e) {
+                    return PyErr_SetJavaError(e.throwable);
+                }
+            }
+
+            static PyObject *t_Modifier_isAbstract(PyTypeObject *type, PyObject *arg)
+            {
+                if (!PyInt_Check(arg))
+                {
+                    PyErr_SetObject(PyExc_TypeError, arg);
+                    return NULL;
+                }
+
+                try {
+                    int mod = PyInt_AsLong(arg);
+                    int isAbstract = Modifier::isAbstract(mod);
+
+                    Py_RETURN_BOOL(isAbstract);
+                } catch (JCCEnv::exception e) {
+                    return PyErr_SetJavaError(e.throwable);
+                }
+            }
+
+            static PyObject *t_Modifier_isPrivate(PyTypeObject *type, PyObject *arg)
+            {
+                if (!PyInt_Check(arg))
+                {
+                    PyErr_SetObject(PyExc_TypeError, arg);
+                    return NULL;
+                }
+
+                try {
+                    int mod = PyInt_AsLong(arg);
+                    int isPrivate = Modifier::isPrivate(mod);
+
+                    Py_RETURN_BOOL(isPrivate);
+                } catch (JCCEnv::exception e) {
+                    return PyErr_SetJavaError(e.throwable);
+                }
+            }
+
+            static PyObject *t_Modifier_isProtected(PyTypeObject *type, PyObject *arg)
+            {
+                if (!PyInt_Check(arg))
+                {
+                    PyErr_SetObject(PyExc_TypeError, arg);
+                    return NULL;
+                }
+
+                try {
+                    int mod = PyInt_AsLong(arg);
+                    int isProtected = Modifier::isProtected(mod);
+
+                    Py_RETURN_BOOL(isProtected);
+                } catch (JCCEnv::exception e) {
+                    return PyErr_SetJavaError(e.throwable);
+                }
+            }
+        }
+    }
+}

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.h?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.h (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.h Thu Jan  8 19:28:33 2009
@@ -0,0 +1,62 @@
+/*
+ *   Copyright (c) 2007-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#ifndef _Modifier_H
+#define _Modifier_H
+
+#include <Python.h>
+#include "JArray.h"
+
+namespace java {
+    namespace lang {
+        class Class;
+        class String;
+
+        namespace reflect {
+            class Modifier : public Object {
+            private:
+                explicit Modifier();
+            public:
+                explicit Modifier(jobject obj) : Object(obj) {
+                    initializeClass();
+                }
+                static Class *class$;
+                static jmethodID *_mids;
+                static jclass initializeClass();
+
+                static int isPublic(int mod);
+                static int isStatic(int mod);
+                static int isNative(int mod);
+                static int isFinal(int mod);
+                static int isAbstract(int mod);
+                static int isPrivate(int mod);
+                static int isProtected(int mod);
+            };
+
+            extern PyTypeObject ModifierType;
+
+            class t_Modifier {
+            public:
+                PyObject_HEAD
+                Modifier object;
+                static PyObject *wrap_Object(const Modifier& object);
+                static PyObject *wrap_jobject(const jobject& object);
+            };
+        }
+    }
+}
+
+#endif /* _Modifier_H */

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/Modifier.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/__init__.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/__init__.cpp?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/__init__.cpp (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/__init__.cpp Thu Jan  8 19:28:33 2009
@@ -0,0 +1,38 @@
+/*
+ *   Copyright (c) 2007-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <Python.h>
+#include "macros.h"
+
+namespace java {
+    namespace lang {
+        namespace reflect {
+
+            extern PyTypeObject ConstructorType;
+            extern PyTypeObject MethodType;
+            extern PyTypeObject ModifierType;
+            extern PyTypeObject FieldType;
+
+            void __install__(PyObject *m)
+            {
+                INSTALL_TYPE(Constructor, m);
+                INSTALL_TYPE(Method, m);
+                INSTALL_TYPE(Modifier, m);
+                INSTALL_TYPE(Field, m);
+            }
+        }
+    }
+}

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/__init__.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/lang/reflect/__init__.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.cpp?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.cpp (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.cpp Thu Jan  8 19:28:33 2009
@@ -0,0 +1,99 @@
+/*
+ *   Copyright (c) 2007-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <jni.h>
+#include "JCCEnv.h"
+
+#include "java/lang/Object.h"
+#include "java/lang/Class.h"
+#include "java/util/Enumeration.h"
+
+namespace java {
+    namespace util {
+        enum {
+            mid_hasMoreElements,
+            mid_nextElement,
+            max_mid
+        };
+
+        Class *Enumeration::class$ = NULL;
+        jmethodID *Enumeration::mids$ = NULL;
+
+        jclass Enumeration::initializeClass()
+        {
+            if (!class$)
+            {
+                jclass cls = env->findClass("java/util/Enumeration");
+
+                mids$ = new jmethodID[max_mid];
+                mids$[mid_hasMoreElements] = env->getMethodID(cls, "hasMoreElements", "()Z");
+                mids$[mid_nextElement] = env->getMethodID(cls, "nextElement", "()Ljava/lang/Object;");
+
+                class$ = (Class *) new JObject(cls);
+            }
+
+            return (jclass) class$->this$;
+        }
+
+        jboolean Enumeration::hasMoreElements() const
+        {
+            return env->callBooleanMethod(this$, mids$[mid_hasMoreElements]);
+        }
+
+        Object Enumeration::nextElement() const
+        {
+            return Object(env->callObjectMethod(this$, mids$[mid_nextElement]));
+        }
+    }
+}
+
+
+#include "structmember.h"
+#include "functions.h"
+#include "macros.h"
+
+namespace java {
+    namespace util {
+
+        static PyObject *t_Enumeration_hasMoreElements(t_Enumeration *self);
+        static PyObject *t_Enumeration_nextElement(t_Enumeration *self);
+
+        static PyMethodDef t_Enumeration__methods_[] = {
+            DECLARE_METHOD(t_Enumeration, hasMoreElements, METH_NOARGS),
+            DECLARE_METHOD(t_Enumeration, nextElement, METH_NOARGS),
+            { NULL, NULL, 0, NULL }
+        };
+
+        DECLARE_TYPE(Enumeration, t_Enumeration, JObject,
+                     java::util::Enumeration, abstract_init, 0, 0, 0, 0, 0);
+
+        static PyObject *t_Enumeration_hasMoreElements(t_Enumeration *self)
+        {
+            jboolean b;
+
+            OBJ_CALL(b = self->object.hasMoreElements());
+            Py_RETURN_BOOL(b);
+        }
+
+        static PyObject *t_Enumeration_nextElement(t_Enumeration *self)
+        {
+            Object nextElement((jobject) NULL);
+
+            OBJ_CALL(nextElement = self->object.nextElement());
+            return t_Object::wrap_Object(nextElement);
+        }
+    }
+}

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.h?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.h (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.h Thu Jan  8 19:28:33 2009
@@ -0,0 +1,57 @@
+/*
+ *   Copyright (c) 2007-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#ifndef _Enumeration_H
+#define _Enumeration_H
+
+#include <Python.h>
+#include "JObject.h"
+
+namespace java {
+    namespace lang {
+        class Class;
+        class Object;
+    }        
+    namespace util {
+        using namespace java::lang;
+
+        class Enumeration : public JObject {
+        public:
+            static Class *class$;
+            static jmethodID *mids$;
+            static jclass initializeClass();
+
+            explicit Enumeration(jobject obj) : JObject(obj) {
+                initializeClass();
+            }
+
+            jboolean hasMoreElements() const;
+            Object nextElement() const;
+        };
+
+        extern PyTypeObject EnumerationType;
+
+        class t_Enumeration {
+        public:
+            PyObject_HEAD
+            Enumeration object;
+            static PyObject *wrap_Object(const Enumeration& object);
+            static PyObject *wrap_jobject(const jobject& object);
+        };
+    }
+}
+
+#endif /* _Enumeration_H */

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/util/Enumeration.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.cpp?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.cpp (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.cpp Thu Jan  8 19:28:33 2009
@@ -0,0 +1,101 @@
+/*
+ *   Copyright (c) 2007-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <jni.h>
+#include "JCCEnv.h"
+
+#include "java/lang/Object.h"
+#include "java/lang/Class.h"
+#include "java/util/Iterator.h"
+
+namespace java {
+    namespace util {
+        enum {
+            mid_hasNext,
+            mid_next,
+            max_mid
+        };
+
+        Class *Iterator::class$ = NULL;
+        jmethodID *Iterator::mids$ = NULL;
+
+        jclass Iterator::initializeClass()
+        {
+            if (!class$)
+            {
+                jclass cls = env->findClass("java/util/Iterator");
+
+                mids$ = new jmethodID[max_mid];
+                mids$[mid_hasNext] = env->getMethodID(cls, "hasNext",
+                                                      "()Z");
+                mids$[mid_next] = env->getMethodID(cls, "next",
+                                                   "()Ljava/lang/Object;");
+
+                class$ = (Class *) new JObject(cls);
+            }
+
+            return (jclass) class$->this$;
+        }
+
+        jboolean Iterator::hasNext() const
+        {
+            return env->callBooleanMethod(this$, mids$[mid_hasNext]);
+        }
+
+        Object Iterator::next() const
+        {
+            return Object(env->callObjectMethod(this$, mids$[mid_next]));
+        }
+    }
+}
+
+
+#include "structmember.h"
+#include "functions.h"
+#include "macros.h"
+
+namespace java {
+    namespace util {
+
+        static PyObject *t_Iterator_hasNext(t_Iterator *self);
+        static PyObject *t_Iterator_next(t_Iterator *self);
+
+        static PyMethodDef t_Iterator__methods_[] = {
+            DECLARE_METHOD(t_Iterator, hasNext, METH_NOARGS),
+            DECLARE_METHOD(t_Iterator, next, METH_NOARGS),
+            { NULL, NULL, 0, NULL }
+        };
+
+        DECLARE_TYPE(Iterator, t_Iterator, JObject, java::util::Iterator,
+                     abstract_init, 0, 0, 0, 0, 0);
+
+        static PyObject *t_Iterator_hasNext(t_Iterator *self)
+        {
+            jboolean b;
+
+            OBJ_CALL(b = self->object.hasNext());
+            Py_RETURN_BOOL(b);
+        }
+
+        static PyObject *t_Iterator_next(t_Iterator *self)
+        {
+            Object next((jobject) NULL);
+
+            OBJ_CALL(next = self->object.next());
+            return t_Object::wrap_Object(next);
+        }
+    }
+}

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.h?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.h (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.h Thu Jan  8 19:28:33 2009
@@ -0,0 +1,57 @@
+/*
+ *   Copyright (c) 2007-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#ifndef _Iterator_H
+#define _Iterator_H
+
+#include <Python.h>
+#include "JObject.h"
+
+namespace java {
+    namespace lang {
+        class Class;
+        class Object;
+    }        
+    namespace util {
+        using namespace java::lang;
+
+        class Iterator : public JObject {
+        public:
+            static Class *class$;
+            static jmethodID *mids$;
+            static jclass initializeClass();
+
+            explicit Iterator(jobject obj) : JObject(obj) {
+                initializeClass();
+            }
+
+            jboolean hasNext() const;
+            Object next() const;
+        };
+
+        extern PyTypeObject IteratorType;
+
+        class t_Iterator {
+        public:
+            PyObject_HEAD
+            Iterator object;
+            static PyObject *wrap_Object(const Iterator& object);
+            static PyObject *wrap_jobject(const jobject& object);
+        };
+    }
+}
+
+#endif /* _Iterator_H */

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/util/Iterator.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonException.java
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonException.java?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonException.java (added)
+++ lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonException.java Thu Jan  8 19:28:33 2009
@@ -0,0 +1,58 @@
+/*
+ *   Copyright (c) 2008-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+package org.osafoundation.jcc;
+
+
+public class PythonException extends RuntimeException {
+    public boolean withTrace = true;
+    protected String message, errorName, traceback;
+
+    public PythonException(String message)
+    {
+        super(message);
+        getErrorInfo();  // sets errorName, message and traceback 
+    }
+
+    public String getMessage(boolean trace)
+    {
+        if (message == null)
+            message = super.getMessage();
+
+        if (trace)
+            return message + "\n" + traceback;
+
+        return message;
+    }
+
+    public String getMessage()
+    {
+        return getMessage(withTrace);
+    }
+
+    public String getErrorName()
+    {
+        return errorName;
+    }
+
+    public String getTraceback()
+    {
+        return traceback;
+    }
+
+    protected native void getErrorInfo();
+    public native void clear();
+}

Propchange: lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonVM.java
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonVM.java?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonVM.java (added)
+++ lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonVM.java Thu Jan  8 19:28:33 2009
@@ -0,0 +1,57 @@
+/*
+ *   Copyright (c) 2008-2008 Open Source Applications Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+package org.osafoundation.jcc;
+
+
+public class PythonVM {
+
+    static protected PythonVM vm;
+
+    static {
+        System.loadLibrary("jcc");
+    }
+
+    static public PythonVM start(String programName, String[] args)
+    {
+        if (vm == null)
+        {
+            vm = new PythonVM();
+            vm.init(programName, args);
+        }
+
+        return vm;
+    }
+
+    static public PythonVM start(String programName)
+    {
+        return start(programName, null);
+    }
+
+    static public PythonVM get()
+    {
+        return vm;
+    }
+
+    protected PythonVM()
+    {
+    }
+
+    protected native void init(String programName, String[] args);
+
+    public native Object instantiate(String moduleName, String className)
+        throws PythonException;
+}

Propchange: lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonVM.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/java/org/osafoundation/jcc/PythonVM.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/jcc/__init__.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/__init__.py?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/__init__.py (added)
+++ lucene/pylucene/trunk/jcc/jcc/__init__.py Thu Jan  8 19:28:33 2009
@@ -0,0 +1,33 @@
+#   Copyright (c) 2007-2008 Open Source Applications Foundation
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+# jcc package
+
+import os, sys
+
+if sys.platform == 'win32':
+    from jcc.config import SHARED
+    if SHARED:
+        path = os.environ['Path'].split(os.pathsep)
+        eggpath = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+        if eggpath not in path:
+            path.insert(0, eggpath)
+            os.environ['Path'] = os.pathsep.join(path)
+
+if __name__ == '__main__':
+    import jcc.__main__
+else:
+    from _jcc import initVM
+
+CLASSPATH=os.path.join(os.path.abspath(os.path.dirname(__file__)), "classes")

Propchange: lucene/pylucene/trunk/jcc/jcc/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/jcc/__init__.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/jcc/__main__.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/__main__.py?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/__main__.py (added)
+++ lucene/pylucene/trunk/jcc/jcc/__main__.py Thu Jan  8 19:28:33 2009
@@ -0,0 +1,5 @@
+
+import sys
+
+from jcc import cpp
+cpp.jcc(sys.argv)

Propchange: lucene/pylucene/trunk/jcc/jcc/__main__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/jcc/__main__.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/jcc/cpp.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/cpp.py?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/cpp.py (added)
+++ lucene/pylucene/trunk/jcc/jcc/cpp.py Thu Jan  8 19:28:33 2009
@@ -0,0 +1,927 @@
+#   Copyright (c) 2007-2008 Open Source Applications Foundation
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+import os, sys, zipfile, _jcc
+
+python_ver = '%d.%d.%d' %(sys.version_info[0:3])
+if python_ver < '2.4':
+    from sets import Set as set
+
+    def split_pkg(string, sep):
+        parts = string.split(sep)
+        if len(parts) > 1:
+            return sep.join(parts[:-1]), parts[-1]
+        return parts
+
+    def sort(list, fn=None, key=None):
+        if fn:
+            list.sort(fn)
+        elif key:
+            def fn(x, y):
+                return cmp(key(x), key(y))
+            list.sort(fn)
+        else:
+            list.sort()
+
+else:
+    def split_pkg(string, sep):
+        return string.rsplit(sep, 1)
+
+    def sort(list, fn=None, key=None):
+        if fn:
+            list.sort(cmp=fn)
+        elif key:
+            list.sort(key=key)
+        else:
+            list.sort()
+
+
+class JavaError(Exception):
+    def getJavaException(self):
+        return self.args[0]
+
+class InvalidArgsError(Exception):
+    pass
+
+_jcc._setExceptionTypes(JavaError, InvalidArgsError)
+from _jcc import *
+
+
+INDENT = '    '
+HALF_INDENT = '  '
+
+PRIMITIVES = { 'boolean': 'Z',
+               'byte': 'B',
+               'char': 'C',
+               'double': 'D',
+               'float': 'F',
+               'int': 'I',
+               'long': 'J',
+               'short': 'S',
+               'void': 'V' }
+
+RESERVED = set(['delete', 'and', 'or', 'not', 'xor', 'union', 'NULL',
+                'register', 'const'])
+
+
+def typename(cls, current, const):
+
+    if cls.isArray():
+        componentType = cls.getComponentType()
+        if componentType.isArray():
+            name = 'JArray< %s >' %(typename(componentType, current, False))
+        else:
+            name = 'JArray<%s>' %(typename(componentType, current, False))
+
+    elif cls.isPrimitive():
+        name = cls.getName()
+        if name != 'void':
+            name = 'j' + name
+        const = False
+
+    elif cls == current:
+        name = cls.getName().split('.')[-1]
+
+    else:
+        name = cls.getName().replace('.', '::')
+
+    if const:
+        return "const %s&" %(name)
+
+    return name
+
+
+def argnames(params, cls):
+
+    if not params:
+        return '', ''
+
+    count = len(params)
+    decls = ', '.join(["%s a%d" %(typename(params[i], cls, True), i)
+                       for i in xrange(count)])
+    args = ', '.join(['a%d%s' %(i, not params[i].isPrimitive() and '.this$' or '')
+                      for i in xrange(count)])
+
+    return decls, ', ' + args
+
+
+def line(out, indent=0, string='', *args):
+
+    out.write(INDENT * indent)
+    out.write(string % args)
+    out.write('\n')
+
+
+def known(cls, typeset, declares, packages, excludes):
+
+    while cls.isArray():
+        cls = cls.getComponentType()
+
+    if cls in excludes:
+        return False
+
+    if cls.isPrimitive():
+        return True
+
+    if cls in typeset:
+        declares.add(cls)
+        return True
+
+    if split_pkg(cls.getName(), '.')[0] in packages:
+        typeset.add(cls)
+        declares.add(cls)
+        cls = cls.getSuperclass()
+        while cls and cls not in typeset:
+            typeset.add(cls)
+            cls = cls.getSuperclass()
+        return True
+
+    return False
+
+
+def find_method(cls, name, params):
+
+    declared = False
+    while True:
+        try:
+            if declared:
+                method = cls.getDeclaredMethod(name, params)
+            else:
+                method = cls.getMethod(name, params)
+            break
+        except JavaError, e:
+            if (e.getJavaException().getClass().getName() == 'java.lang.NoSuchMethodException'):
+                if not declared:
+                    declared = True
+                else:
+                    cls = cls.getSuperclass()
+                    if not cls:
+                        return None
+                continue
+            raise
+
+    modifiers = method.getModifiers()
+    if Modifier.isAbstract(modifiers):
+        return None
+    if Modifier.isPrivate(modifiers):
+        return None
+
+    return method
+
+
+def signature(fn, argsOnly=False):
+
+    def typename(cls):
+        array = ''
+        while cls.isArray():
+            array += '['
+            cls = cls.getComponentType()
+        if cls.isPrimitive():
+            return array + PRIMITIVES[cls.getName()]
+        return '%sL%s;' %(array, cls.getName().replace('.', '/'))
+        
+    if isinstance(fn, Constructor):
+        returnType = 'V'
+    elif isinstance(fn, Method):
+        returnType = typename(fn.getReturnType())
+    elif isinstance(fn, Field):
+        return typename(fn.getType())
+
+    if argsOnly:
+        return '(%s)' %(''.join([typename(param)
+                                 for param in fn.getParameterTypes()]))
+
+    return '(%s)%s' %(''.join([typename(param)
+                               for param in fn.getParameterTypes()]),
+                       returnType)
+
+
+def forward(out, namespace, indent):
+
+    for name, entries in namespace.iteritems():
+        if entries is True:
+            line(out, indent, 'class %s;', name)
+        else:
+            line(out, indent, 'namespace %s {', name)
+            forward(out, entries, indent + 1)
+            line(out, indent, '}')
+
+
+def expandjar(path):
+
+    jar = zipfile.ZipFile(path, 'r')
+
+    for member in jar.infolist():
+        f = member.filename
+        if f.endswith('.class'):
+            yield f.split('.')[0].replace('/', '.')
+
+    jar.close()
+
+
+def jcc(args):
+
+    classNames = set()
+    packages = set()
+    jars = []
+    classpath = []
+    moduleName = None
+    modules = []
+    build = False
+    install = False
+    recompile = False
+    output = 'build'
+    debug = False
+    excludes = []
+    version = ''
+    mappings = {}
+    sequences = {}
+    env = None
+    wrapperFiles = 1
+    prefix = None
+    root = None
+    install_dir = None
+    use_distutils = False
+    shared = False
+    dist = False
+    compiler = None
+
+    i = 1
+    while i < len(args):
+        arg = args[i]
+        if arg.startswith('-'):
+            if arg == '--jar':
+                i += 1
+                classpath.append(args[i])
+                classNames.update(expandjar(args[i]))
+                jars.append(args[i])
+            elif arg == '--include':
+                i += 1
+                classpath.append(args[i])
+                jars.append(args[i])
+            elif arg == '--package':
+                i += 1
+                packages.add(args[i])
+            elif arg == '--classpath':
+                i += 1
+                classpath.append(args[i])
+            elif arg == '--python':
+                from python import python, module
+                i += 1
+                moduleName = args[i]
+            elif arg == '--module':
+                i += 1
+                modules.append(args[i])
+            elif arg == '--build':
+                from python import compile
+                build = True
+            elif arg == '--install':
+                from python import compile
+                install = True
+            elif arg == '--compile':
+                from python import compile
+                recompile = True
+            elif arg == '--output':
+                i += 1
+                output = args[i]
+            elif arg == '--debug':
+                debug = True
+            elif arg == '--exclude':
+                i += 1
+                excludes.append(args[i])
+            elif arg == '--version':
+                i += 1
+                version = args[i]
+            elif arg == '--mapping':
+                mappings[args[i + 1]] = args[i + 2]
+                i += 2
+            elif arg == '--sequence':
+                sequences[args[i + 1]] = (args[i + 2], args[i + 3])
+                i += 3
+            elif arg == '--files':
+                i += 1
+                wrapperFiles = args[i]
+                if wrapperFiles != 'separate':
+                    wrapperFiles = int(wrapperFiles)
+            elif arg == '--prefix':
+                i += 1
+                prefix = args[i]
+            elif arg == '--root':
+                i += 1
+                root = args[i]
+            elif arg == '--install-dir':
+                i += 1
+                install_dir = args[i]
+            elif arg == '--use-distutils':
+                use_distutils = True
+            elif arg == '--shared':
+                shared = True
+            elif arg == '--bdist':
+                from python import compile
+                dist = True
+            elif arg == '--compiler':
+                i += 1
+                compiler = args[i]
+            else:
+                raise ValueError, "Invalid argument: %s" %(arg)
+        else:
+            classNames.add(arg)
+        i += 1
+
+    env = initVM(os.pathsep.join(classpath) or None, maxstack='512k',
+                 vmargs='-Djava.awt.headless=true')
+
+    typeset = set()
+    excludes = set([findClass(className.replace('.', '/'))
+                    for className in excludes])
+
+    if recompile or not build and (install or dist):
+        if moduleName is None:
+            raise ValueError, 'module name not specified (use --python)'
+        else:
+            compile(env, os.path.dirname(args[0]), output, moduleName,
+                    install, dist, debug, jars, version,
+                    prefix, root, install_dir, use_distutils,
+                    shared, compiler, modules)
+    else:
+        for className in classNames:
+            cls = findClass(className.replace('.', '/'))
+            if cls is None:
+                raise ValueError, className
+            if cls in excludes:
+                continue
+            if Modifier.isPublic(cls.getModifiers()):
+                typeset.add(cls)
+                cls = cls.getSuperclass()
+                while cls and cls not in typeset:
+                    typeset.add(cls)
+                    cls = cls.getSuperclass()
+        typeset.add(findClass('java/lang/Class'))
+        typeset.add(findClass('java/lang/String'))
+        typeset.add(findClass('java/lang/Throwable'))
+        typeset.add(findClass('java/lang/Exception'))
+        typeset.add(findClass('java/lang/RuntimeException'))
+        if moduleName:
+            typeset.add(findClass('java/lang/Number'))
+            typeset.add(findClass('java/lang/Boolean'))
+            typeset.add(findClass('java/lang/Integer'))
+            typeset.add(findClass('java/lang/Long'))
+            typeset.add(findClass('java/lang/Double'))
+            typeset.add(findClass('java/util/Iterator'))
+            typeset.add(findClass('java/util/Enumeration'))
+
+        if moduleName:
+            cppdir = os.path.join(output, '_%s' %(moduleName))
+        else:
+            cppdir = output
+
+        allInOne = wrapperFiles != 'separate'
+        if allInOne:
+            if not os.path.isdir(cppdir):
+                os.makedirs(cppdir)
+            if wrapperFiles <= 1:
+                out_cpp = file(os.path.join(cppdir, '__wrap__.cpp'), 'w')
+            else:
+                fileCount = 1
+                fileName = '__wrap%02d__.cpp' %(fileCount)
+                out_cpp = file(os.path.join(cppdir, fileName), 'w')
+
+        done = set()
+        todo = typeset - done
+	if allInOne and wrapperFiles > 1:
+            classesPerFile = max(1, len(todo) / wrapperFiles)
+        classCount = 0
+        while todo:
+            for cls in todo:
+                classCount += 1
+                className = cls.getName()
+                names = className.split('.')
+                dir = os.path.join(cppdir, *names[:-1])
+                if not os.path.isdir(dir):
+                    os.makedirs(dir)
+
+                fileName = os.path.join(dir, names[-1])
+                out_h = file(fileName + '.h', "w")
+                line(out_h, 0, '#ifndef %s_H', '_'.join(names))
+                line(out_h, 0, '#define %s_H', '_'.join(names))
+
+                (superCls, constructors, methods, protectedMethods,
+                 fields, instanceFields, declares) = \
+                    header(env, out_h, cls, typeset, packages, excludes)
+
+                if not allInOne:
+                    out_cpp = file(fileName + '.cpp', 'w')
+                names, superNames = code(env, out_cpp,
+                                         cls, superCls, constructors,
+                                         methods, protectedMethods,
+                                         fields, instanceFields, 
+                                         declares, typeset, excludes)
+                if moduleName:
+                    python(env, out_h, out_cpp,
+                           cls, superCls, names, superNames,
+                           constructors, methods, protectedMethods,
+                           fields, instanceFields,
+                           mappings.get(className), sequences.get(className),
+                           declares, typeset, excludes, moduleName)
+
+                line(out_h)
+                line(out_h, 0, '#endif')
+                out_h.close()
+
+                if not allInOne:
+                    out_cpp.close()
+                elif wrapperFiles > 1:
+                    if classCount >= classesPerFile:
+                        out_cpp.close()
+	                fileCount += 1
+	                fileName = '__wrap%02d__.cpp' %(fileCount)
+	                out_cpp = file(os.path.join(cppdir, fileName), 'w')
+                        classCount = 0
+                        
+            done.update(todo)
+            todo = typeset - done
+
+        if allInOne:
+            out_cpp.close()
+
+        if moduleName:
+            out = file(os.path.join(cppdir, moduleName) + '.cpp', 'w')
+            module(out, allInOne, done, cppdir, moduleName, shared)
+            out.close()
+            if build or install or dist:
+                compile(env, os.path.dirname(args[0]), output, moduleName,
+                        install, dist, debug, jars, version,
+                        prefix, root, install_dir, use_distutils,
+                        shared, compiler, modules)
+
+
+def header(env, out, cls, typeset, packages, excludes):
+
+    names = cls.getName().split('.')
+    superCls = cls.getSuperclass()
+    declares = set([cls.getClass()])
+
+    interfaces = []
+    for interface in cls.getInterfaces():
+        if superCls and interface.isAssignableFrom(superCls):
+            continue
+        if known(interface, typeset, declares, packages, excludes):
+            interfaces.append(interface)
+
+    if cls.isInterface():
+        if interfaces:
+            superCls = interfaces.pop(0)
+        else:
+            superCls = findClass('java/lang/Object')
+        superClsName = superCls.getName()
+    elif superCls:
+        superClsName = superCls.getName()
+    else:
+        superClsName = 'JObject'
+
+    constructors = []
+    for constructor in cls.getDeclaredConstructors():
+        if Modifier.isPublic(constructor.getModifiers()):
+            params = constructor.getParameterTypes()
+            if len(params) == 1 and params[0] == cls:
+                continue
+            for param in params:
+                if not known(param, typeset, declares, packages, excludes):
+                    break
+            else:
+                constructors.append(constructor)
+    sort(constructors, key=lambda x: len(x.getParameterTypes()))
+
+    methods = {}
+    protectedMethods = []
+    for method in cls.getDeclaredMethods():
+        modifiers = method.getModifiers()
+        if Modifier.isPublic(modifiers):
+            returnType = method.getReturnType()
+            if not known(returnType, typeset, declares, packages, excludes):
+                continue
+            sig = "%s:%s" %(method.getName(), signature(method, True))
+            if sig in methods and returnType != cls:
+                continue
+            for param in method.getParameterTypes():
+                if not known(param, typeset, declares, packages, excludes):
+                    break
+            else:
+                methods[sig] = method
+        elif Modifier.isProtected(modifiers):
+            protectedMethods.append(method)
+    for interface in interfaces:
+        for method in interface.getMethods():
+            sig = "%s:%s" %(method.getName(), signature(method, True))
+            if sig not in methods:
+                param = method.getReturnType()
+                if not known(param, typeset, declares, packages, excludes):
+                    continue
+                for param in method.getParameterTypes():
+                    if not known(param, typeset, declares, packages, excludes):
+                        break
+                else:
+                    methods[sig] = method
+
+    def _compare(m0, m1):
+        value = cmp(m0.getName(), m1.getName())
+        if value == 0:
+            value = len(m0.getParameterTypes()) - len(m1.getParameterTypes())
+        return value
+
+    methods = methods.values()
+    sort(methods, fn=_compare)
+
+    for constructor in constructors:
+        for exception in constructor.getExceptionTypes():
+            known(exception, typeset, declares, packages, excludes)
+    for method in methods:
+        for exception in method.getExceptionTypes():
+            known(exception, typeset, declares, packages, excludes)
+
+    fields = []
+    instanceFields = []
+    for field in cls.getDeclaredFields():
+        modifiers = field.getModifiers()
+        if Modifier.isPublic(modifiers):
+            if not known(field.getType(),
+                         typeset, declares, packages, excludes):
+                continue
+            if Modifier.isStatic(modifiers):
+                fields.append(field)
+            else:
+                instanceFields.append(field)
+    sort(fields, key=lambda x: x.getName())
+    sort(instanceFields, key=lambda x: x.getName())
+
+    line(out)
+    superNames = superClsName.split('.')
+    line(out, 0, '#include "%s.h"', '/'.join(superNames))
+
+    line(out, 0)
+    namespaces = {}
+    for declare in declares:
+        namespace = namespaces
+        if declare not in (cls, superCls):
+            declareNames = declare.getName().split('.')
+            for declareName in declareNames[:-1]:
+                namespace = namespace.setdefault(declareName, {})
+            namespace[declareNames[-1]] = True
+    forward(out, namespaces, 0)
+    line(out, 0, 'template<class T> class JArray;')
+
+    indent = 0;
+    line(out)
+    for name in names[:-1]:
+        line(out, indent, 'namespace %s {', name)
+        indent += 1
+
+    line(out)
+    if superClsName == 'JObject':
+        line(out, indent, 'class %s : public JObject {', names[-1])
+    else:
+        line(out, indent, 'class %s : public %s {',
+             names[-1], '::'.join(superNames))
+        
+    line(out, indent, 'public:')
+    indent += 1
+
+    if methods or protectedMethods or constructors:
+        line(out, indent, 'enum {')
+        for constructor in constructors:
+            line(out, indent + 1, 'mid_init$_%s,',
+                 env.strhash(signature(constructor)))
+        for method in methods:
+            line(out, indent + 1, 'mid_%s_%s,', method.getName(),
+                 env.strhash(signature(method)))
+        for method in protectedMethods:
+            line(out, indent + 1, 'mid_%s_%s,', method.getName(),
+                 env.strhash(signature(method)))
+        line(out, indent + 1, 'max_mid')
+        line(out, indent, '};')
+
+    if instanceFields:
+        line(out)
+        line(out, indent, 'enum {')
+        for field in instanceFields:
+            line(out, indent + 1, 'fid_%s,', field.getName())
+        line(out, indent + 1, 'max_fid')
+        line(out, indent, '};')
+
+    line(out)
+    line(out, indent, 'static java::lang::Class *class$;');
+    line(out, indent, 'static jmethodID *mids$;');
+    if instanceFields:
+        line(out, indent, 'static jfieldID *fids$;');
+    line(out, indent, 'static jclass initializeClass();');
+    line(out)
+    line(out, indent, 'static inline java::lang::Class *getclass$() {')
+    line(out, indent + 1, 'initializeClass();')
+    line(out, indent + 1, 'return class$;');
+    line(out, indent, '}')
+
+    line(out)
+
+    line(out, indent, 'explicit %s(jobject obj) : %s(obj) {',
+         names[-1], '::'.join(superNames))
+    line(out, indent + 1, 'initializeClass();')
+    line(out, indent, '}')
+    line(out, indent, '%s(const %s& obj) : %s(obj) {}',
+         names[-1], names[-1], '::'.join(superNames))
+
+    if fields:
+        line(out)
+        for field in fields:
+            fieldType = field.getType()
+            fieldName = field.getName()
+            if fieldName in RESERVED:
+                fieldName += '$'
+            if fieldType.isPrimitive():
+                line(out, indent, 'static %s %s;',
+                     typename(fieldType, cls, False), fieldName)
+            else:
+                line(out, indent, 'static %s *%s;',
+                     typename(fieldType, cls, False), fieldName)
+
+    if instanceFields:
+        line(out)
+        for field in instanceFields:
+            fieldType = field.getType()
+            fieldName = field.getName()
+            modifiers = field.getModifiers()
+            line(out, indent, '%s _get_%s() const;',
+                 typename(fieldType, cls, False), fieldName)
+            if not Modifier.isFinal(modifiers):
+                line(out, indent, 'void _set_%s(%s) const;',
+                     fieldName, typename(fieldType, cls, True))
+
+    if constructors:
+        line(out)
+        for constructor in constructors:
+            params = [typename(param, cls, True)
+                      for param in constructor.getParameterTypes()]
+            line(out, indent, '%s(%s);', names[-1], ', '.join(params))
+
+    if methods:
+        line(out)
+        for method in methods:
+            modifiers = method.getModifiers()
+            if Modifier.isStatic(modifiers):
+                prefix = 'static '
+                const = ''
+            else:
+                prefix = ''
+                const = ' const'
+            params = [typename(param, cls, True)
+                      for param in method.getParameterTypes()]
+            methodName = method.getName()
+            if methodName in RESERVED:
+                methodName += '$'
+            line(out, indent, '%s%s %s(%s)%s;',
+                 prefix, typename(method.getReturnType(), cls, False),
+                 methodName, ', '.join(params), const)
+
+    indent -= 1
+    line(out, indent, '};')
+
+    while indent:
+        indent -= 1
+        line(out, indent, '}')
+
+    return (superCls, constructors, methods, protectedMethods,
+            fields, instanceFields, declares)
+
+
+def code(env, out, cls, superCls, constructors, methods, protectedMethods,
+         fields, instanceFields, declares, typeset, excludes):
+
+    className = cls.getName()
+    names = className.split('.')
+
+    if superCls:
+        superClsName = superCls.getName()
+    else:
+        superClsName = 'JObject'
+    superNames = superClsName.split('.')
+
+    line(out, 0, '#include <jni.h>')
+    line(out, 0, '#include "JCCEnv.h"')
+    line(out, 0, '#include "%s.h"', className.replace('.', '/'))
+    for declare in declares:
+        if declare not in (cls, superCls):
+            line(out, 0, '#include "%s.h"', declare.getName().replace('.', '/'))
+    line(out, 0, '#include "JArray.h"')
+
+    indent = 0
+    line(out)
+    for name in names[:-1]:
+        line(out, indent, 'namespace %s {', name)
+        indent += 1
+
+    line(out)
+    line(out, indent, 'java::lang::Class *%s::class$ = NULL;', names[-1])
+    line(out, indent, 'jmethodID *%s::mids$ = NULL;', names[-1])
+    if instanceFields:
+        line(out, indent, 'jfieldID *%s::fids$ = NULL;', names[-1])
+
+    for field in fields:
+        fieldType = field.getType()
+        fieldName = field.getName()
+        if fieldName in RESERVED:
+            fieldName += '$'
+        typeName = typename(fieldType, cls, False)
+        if fieldType.isPrimitive():
+            line(out, indent, '%s %s::%s = (%s) 0;',
+                 typeName, names[-1], fieldName, typeName)
+        else:
+            line(out, indent, '%s *%s::%s = NULL;',
+                 typeName, names[-1], fieldName)
+
+    line(out)
+    line(out, indent, 'jclass %s::initializeClass()', names[-1])
+    line(out, indent, '{')
+    line(out, indent + 1, 'if (!class$)')
+    line(out, indent + 1, '{')
+    line(out)
+    line(out, indent + 2, 'jclass cls = (jclass) env->findClass("%s");',
+         className.replace('.', '/'))
+
+    if methods or protectedMethods or constructors:
+        line(out)
+        line(out, indent + 2, 'mids$ = new jmethodID[max_mid];')
+        for constructor in constructors:
+            sig = signature(constructor)
+            line(out, indent + 2,
+                 'mids$[mid_init$_%s] = env->getMethodID(cls, "<init>", "%s");',
+                 env.strhash(sig), sig)
+        isExtension = False
+        for method in methods:
+            methodName = method.getName()
+            if methodName == 'pythonExtension':
+                isExtension = True
+            sig = signature(method)
+            line(out, indent + 2,
+                 'mids$[mid_%s_%s] = env->get%sMethodID(cls, "%s", "%s");',
+                 methodName, env.strhash(sig),
+                 Modifier.isStatic(method.getModifiers()) and 'Static' or '',
+                 methodName, sig)
+        for method in protectedMethods:
+            methodName = method.getName()
+            sig = signature(method)
+            line(out, indent + 2,
+                 'mids$[mid_%s_%s] = env->get%sMethodID(cls, "%s", "%s");',
+                 methodName, env.strhash(sig),
+                 Modifier.isStatic(method.getModifiers()) and 'Static' or '',
+                 methodName, sig)
+
+    if instanceFields:
+        line(out)
+        line(out, indent + 2, 'fids$ = new jfieldID[max_fid];')
+        for field in instanceFields:
+            fieldName = field.getName()
+            line(out, indent + 2,
+                 'fids$[fid_%s] = env->getFieldID(cls, "%s", "%s");',
+                 fieldName, fieldName, signature(field))
+
+    line(out)
+    line(out, indent + 2, 'class$ = (java::lang::Class *) new JObject(cls);')
+
+    if fields:
+        line(out, indent + 2, 'cls = (jclass) class$->this$;')
+        line(out)
+        for field in fields:
+            fieldType = field.getType()
+            fieldName = field.getName()
+            if fieldType.isPrimitive():
+                line(out, indent + 2,
+                     '%s%s = env->getStatic%sField(cls, "%s");',
+                     fieldName, fieldName in RESERVED and '$' or '',
+                     fieldType.getName().capitalize(), fieldName)
+            else:
+                line(out, indent + 2,
+                     '%s%s = new %s(env->getStaticObjectField(cls, "%s", "%s"));',
+                     fieldName, fieldName in RESERVED and '$' or '',
+                     typename(fieldType, cls, False), fieldName,
+                     signature(field))
+
+    line(out, indent + 1, '}')
+    line(out, indent + 1, 'return (jclass) class$->this$;')
+    line(out, indent, '}')
+
+    for constructor in constructors:
+        line(out)
+        sig = signature(constructor)
+        decls, args = argnames(constructor.getParameterTypes(), cls)
+
+        line(out, indent, "%s::%s(%s) : %s(env->newObject(initializeClass, &mids$, mid_init$_%s%s)) {}",
+             names[-1], names[-1], decls, '::'.join(superNames),
+             env.strhash(sig), args)
+
+    for method in methods:
+        modifiers = method.getModifiers()
+        returnType = method.getReturnType()
+        params = method.getParameterTypes()
+        methodName = method.getName()
+        superMethod = None
+        isStatic = Modifier.isStatic(modifiers)
+
+        if (isExtension and not isStatic and superCls and
+            Modifier.isNative(modifiers)):
+            superMethod = find_method(superCls, methodName, params)
+            if superMethod is None:
+                continue
+
+        if isStatic:
+            qualifier = 'Static'
+            this = 'cls'
+            midns = ''
+            const = ''
+        else:
+            isStatic = False
+            if superMethod is not None:
+                qualifier = 'Nonvirtual'
+                this = 'this$, (jclass) %s::class$->this$' %('::'.join(superNames))
+                declaringClass = superMethod.getDeclaringClass()
+                midns = '%s::' %(declaringClass.getName().replace('.', '::'))
+            else:
+                qualifier = ''
+                this = 'this$'
+                midns = ''
+            const = ' const'
+
+        sig = signature(method)
+        decls, args = argnames(params, cls)
+
+        line(out)
+        line(out, indent, '%s %s::%s%s(%s)%s',
+             typename(returnType, cls, False), names[-1], methodName,
+             methodName in RESERVED and '$' or '', decls, const)
+        line(out, indent, '{')
+        if isStatic:
+            line(out, indent + 1, 'jclass cls = initializeClass();');
+        if returnType.isPrimitive():
+            line(out, indent + 1,
+                 '%senv->call%s%sMethod(%s, %smids$[%smid_%s_%s]%s);',
+                 not returnType.getName() == 'void' and 'return ' or '',
+                 qualifier, returnType.getName().capitalize(), this,
+                 midns, midns, methodName, env.strhash(sig), args)
+        else:
+            line(out, indent + 1,
+                 'return %s(env->call%sObjectMethod(%s, %smids$[%smid_%s_%s]%s));',
+                 typename(returnType, cls, False), qualifier, this,
+                 midns, midns, methodName, env.strhash(sig), args)
+        line(out, indent, '}')
+
+    if instanceFields:
+        for field in instanceFields:
+            fieldType = field.getType()
+            fieldName = field.getName()
+            line(out)
+            line(out, indent, '%s %s::_get_%s() const',
+                 typename(fieldType, cls, False), names[-1], fieldName)
+            line(out, indent, '{')
+            if fieldType.isPrimitive():
+                line(out, indent + 1,
+                     'return env->get%sField(this$, fids$[fid_%s]);',
+                     fieldType.getName().capitalize(), fieldName)
+            else:
+                line(out, indent + 1,
+                     'return %s(env->getObjectField(this$, fids$[fid_%s]));',
+                     typename(fieldType, cls, False), fieldName)
+            line(out, indent, '}')
+
+            if not Modifier.isFinal(field.getModifiers()):
+                line(out)
+                line(out, indent, 'void %s::_set_%s(%s a0) const',
+                     names[-1], fieldName, typename(fieldType, cls, True))
+                line(out, indent, '{')
+                if fieldType.isPrimitive():
+                    line(out, indent + 1,
+                         'env->set%sField(this$, fids$[fid_%s], a0);',
+                         fieldType.getName().capitalize(), fieldName)
+                else:
+                    line(out, indent + 1,
+                         'env->setObjectField(this$, fids$[fid_%s], a0.this$);',
+                         fieldName)
+                line(out, indent, '}')
+
+    while indent:
+        indent -= 1
+        line(out, indent, '}')
+
+    return names, superNames
+
+
+if __name__ == '__main__':
+    jcc(sys.argv)

Propchange: lucene/pylucene/trunk/jcc/jcc/cpp.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/jcc/cpp.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/jcc/patches/patch.4195
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/patches/patch.4195?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/patches/patch.4195 (added)
+++ lucene/pylucene/trunk/jcc/jcc/patches/patch.4195 Thu Jan  8 19:28:33 2009
@@ -0,0 +1,18 @@
+--- runpy.py.old	2008-10-19 16:02:18.000000000 -0700
++++ runpy.py	2008-10-19 16:13:44.000000000 -0700
+@@ -79,10 +79,13 @@
+     loader = get_loader(mod_name)
+     if loader is None:
+         raise ImportError("No module named %s" % mod_name)
+     if loader.is_package(mod_name):
+-        raise ImportError(("%s is a package and cannot " +
+-                          "be directly executed") % mod_name)
++        try:
++            return _get_module_details('.'.join((mod_name, '__main__')))
++        except ImportError, e:
++            raise ImportError(("%s; %s is a package and cannot " +
++                               "be directly executed") %(e, mod_name))
+     code = loader.get_code(mod_name)
+     if code is None:
+         raise ImportError("No code object available for %s" % mod_name)
+     filename = _get_filename(loader, mod_name)

Added: lucene/pylucene/trunk/jcc/jcc/patches/patch.43
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/patches/patch.43?rev=732916&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/patches/patch.43 (added)
+++ lucene/pylucene/trunk/jcc/jcc/patches/patch.43 Thu Jan  8 19:28:33 2009
@@ -0,0 +1,135 @@
+Index: setuptools/extension.py
+===================================================================
+--- setuptools/extension.py	(revision 66382)
++++ setuptools/extension.py	(working copy)
+@@ -28,6 +28,11 @@
+ class Library(Extension):
+     """Just like a regular Extension, but built as a library instead"""
+ 
++    def __init__(self, *args, **kwds):
++        self.force_shared = kwds.pop('force_shared', False)
++        Extension.__init__(self, *args, **kwds)
++
++
+ import sys, distutils.core, distutils.extension
+ distutils.core.Extension = Extension
+ distutils.extension.Extension = Extension
+Index: setuptools/command/build_ext.py
+===================================================================
+--- setuptools/command/build_ext.py	(revision 66382)
++++ setuptools/command/build_ext.py	(working copy)
+@@ -84,8 +84,12 @@
+         filename = _build_ext.get_ext_filename(self,fullname)
+         ext = self.ext_map[fullname]
+         if isinstance(ext,Library):
++            if ext.force_shared and not use_stubs:
++                _libtype = 'shared'
++            else:
++                _libtype = libtype
+             fn, ext = os.path.splitext(filename)
+-            return self.shlib_compiler.library_filename(fn,libtype)
++            return self.shlib_compiler.library_filename(fn,_libtype)
+         elif use_stubs and ext._links_to_dynamic:
+             d,fn = os.path.split(filename)
+             return os.path.join(d,'dl-'+fn)
+@@ -170,14 +174,22 @@
+     def build_extension(self, ext):
+         _compiler = self.compiler
+         try:
++            force_shared = False
+             if isinstance(ext,Library):
+                 self.compiler = self.shlib_compiler
++                force_shared = ext.force_shared and not use_stubs
++                if force_shared:
++                    self.compiler.link_shared_object = \
++                        sh_link_shared_object.__get__(self.compiler)
+             _build_ext.build_extension(self,ext)
+             if ext._needs_stub:
+                 self.write_stub(
+                     self.get_finalized_command('build_py').build_lib, ext
+                 )
+         finally:
++            if force_shared:
++                self.compiler.link_shared_object = \
++                    link_shared_object.__get__(self.compiler)
+             self.compiler = _compiler
+ 
+     def links_to_dynamic(self, ext):
+@@ -244,44 +256,41 @@
+                 os.unlink(stub_file)
+ 
+ 
+-if use_stubs or os.name=='nt':
+-    # Build shared libraries
+-    #
+-    def link_shared_object(self, objects, output_libname, output_dir=None,
+-        libraries=None, library_dirs=None, runtime_library_dirs=None,
+-        export_symbols=None, debug=0, extra_preargs=None,
+-        extra_postargs=None, build_temp=None, target_lang=None
+-    ):  self.link(
+-            self.SHARED_LIBRARY, objects, output_libname,
+-            output_dir, libraries, library_dirs, runtime_library_dirs,
+-            export_symbols, debug, extra_preargs, extra_postargs,
+-            build_temp, target_lang
+-        )
+-else:
+-    # Build static libraries everywhere else
+-    libtype = 'static'
++def sh_link_shared_object(self, objects, output_libname, output_dir=None,
++    libraries=None, library_dirs=None, runtime_library_dirs=None,
++    export_symbols=None, debug=0, extra_preargs=None,
++    extra_postargs=None, build_temp=None, target_lang=None
++):  self.link(self.SHARED_LIBRARY, objects, output_libname,
++              output_dir, libraries, library_dirs, runtime_library_dirs,
++              export_symbols, debug, extra_preargs, extra_postargs,
++              build_temp, target_lang)
+ 
+-    def link_shared_object(self, objects, output_libname, output_dir=None,
+-        libraries=None, library_dirs=None, runtime_library_dirs=None,
+-        export_symbols=None, debug=0, extra_preargs=None,
+-        extra_postargs=None, build_temp=None, target_lang=None
+-    ):
+-        # XXX we need to either disallow these attrs on Library instances,
+-        #     or warn/abort here if set, or something...
+-        #libraries=None, library_dirs=None, runtime_library_dirs=None,
+-        #export_symbols=None, extra_preargs=None, extra_postargs=None,
+-        #build_temp=None
++def st_link_shared_object(self, objects, output_libname, output_dir=None,
++    libraries=None, library_dirs=None, runtime_library_dirs=None,
++    export_symbols=None, debug=0, extra_preargs=None,
++    extra_postargs=None, build_temp=None, target_lang=None
++):
++    # XXX we need to either disallow these attrs on Library instances,
++    #     or warn/abort here if set, or something...
++    #libraries=None, library_dirs=None, runtime_library_dirs=None,
++    #export_symbols=None, extra_preargs=None, extra_postargs=None,
++    #build_temp=None
+ 
+-        assert output_dir is None   # distutils build_ext doesn't pass this
+-        output_dir,filename = os.path.split(output_libname)
+-        basename, ext = os.path.splitext(filename)
+-        if self.library_filename("x").startswith('lib'):
+-            # strip 'lib' prefix; this is kludgy if some platform uses
+-            # a different prefix
+-            basename = basename[3:]
++    assert output_dir is None   # distutils build_ext doesn't pass this
++    output_dir,filename = os.path.split(output_libname)
++    basename, ext = os.path.splitext(filename)
++    if self.library_filename("x").startswith('lib'):
++        # strip 'lib' prefix; this is kludgy if some platform uses
++        # a different prefix
++        basename = basename[3:]
+ 
+-        self.create_static_lib(
+-            objects, basename, output_dir, debug, target_lang
+-        )
++    self.create_static_lib(objects, basename, output_dir, debug, target_lang)
+ 
+ 
++if use_stubs or os.name=='nt':
++    # Build shared libraries
++    link_shared_object = sh_link_shared_object
++else:
++    # Build static libraries everywhere else (unless force_shared)
++    libtype = 'static'
++    link_shared_object = st_link_shared_object



Mime
View raw message