示例#1
0
    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);
        }
    }
示例#2
0
文件: Field.cpp 项目: ahua/java
        namespace reflect {

            static PyObject *t_Field_getModifiers(t_Field *self);
            static PyObject *t_Field_getType(t_Field *self);
            static PyObject *t_Field_getName(t_Field *self);
#ifdef _java_generics
            static PyObject *t_Field_getGenericType(t_Field *self);
#endif

            static PyMethodDef t_Field__methods_[] = {
                DECLARE_METHOD(t_Field, getModifiers, METH_NOARGS),
                DECLARE_METHOD(t_Field, getType, METH_NOARGS),
                DECLARE_METHOD(t_Field, getName, METH_NOARGS),
#ifdef _java_generics
                DECLARE_METHOD(t_Field, getGenericType, METH_NOARGS),
#endif
                { NULL, NULL, 0, NULL }
            };

            DECLARE_TYPE(Field, t_Field, Object, Field,
                         abstract_init, 0, 0, 0, 0, 0);

            static PyObject *t_Field_getModifiers(t_Field *self)
            {
                jint modifiers;

                OBJ_CALL(modifiers = self->object.getModifiers());
                return PyInt_FromLong(modifiers);
            }

            static PyObject *t_Field_getType(t_Field *self)
            {
                Class cls((jobject) NULL);

                OBJ_CALL(cls = self->object.getType());
                return t_Class::wrap_Object(cls);
            }

            static PyObject *t_Field_getName(t_Field *self)
            {
                String name((jobject) NULL);

                OBJ_CALL(name = self->object.getName());
                return j2p(name);
            }

#ifdef _java_generics
            static PyObject *t_Field_getGenericType(t_Field *self)
            {
                Type result((jobject) NULL);
                OBJ_CALL(result = self->object.getGenericType());

                return t_Type::wrap_Object(result);
            }
#endif
        }
示例#3
0
    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);

#ifdef _java_generics
        PyObject *t_Iterator::wrap_Object(const Iterator& object,
                                          PyTypeObject *T)
        {
            PyObject *obj = t_Iterator::wrap_Object(object);
            if (obj != Py_None)
            {
                t_Iterator *self = (t_Iterator *) obj;
                self->parameters[0] = T;
            }
            return obj;
        }

        PyObject *t_Iterator::wrap_jobject(const jobject& object,
                                           PyTypeObject *T)
        {
            PyObject *obj = t_Iterator::wrap_jobject(object);
            if (obj != Py_None)
            {
                t_Iterator *self = (t_Iterator *) obj;
                self->parameters[0] = T;
            }
            return obj;
        }
#endif
        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);
        }
    }
示例#4
0
文件: String.cpp 项目: ahua/java
    namespace lang {

        static int t_String_init(t_String *self,
                                 PyObject *args, PyObject *kwds);
        static PyObject *t_String_length(t_String *self);

        static PyMethodDef t_String__methods_[] = {
            DECLARE_METHOD(t_String, length, METH_NOARGS),
            { NULL, NULL, 0, NULL }
        };

        DECLARE_TYPE(String, t_String, Object, java::lang::String,
                     t_String_init, 0, 0, 0, 0, 0);

        static int t_String_init(t_String *self,
                                 PyObject *args, PyObject *kwds)
        {
            char *bytes;

            switch (PyTuple_Size(args)) {
              case 0:
                INT_CALL(self->object = String());
                break;
              case 1:
                if (!PyArg_ParseTuple(args, "s", &bytes))
                    return -1;
                INT_CALL(self->object = String(env->fromUTF(bytes)));
                break;
              default:
                PyErr_SetString(PyExc_ValueError, "invalid args");
                return -1;
            }
        
            return 0;
        }

        static PyObject *t_String_length(t_String *self)
        {
            jint length;

            OBJ_CALL(length = self->object.length());
            return PyInt_FromLong(length);
        }
    }
示例#5
0
文件: search.cpp 项目: ezmiller/pyicu
                                                   PyObject *arg);
static PyObject *t_searchiterator_getText(t_searchiterator *self,
                                          PyObject *args);
static PyObject *t_searchiterator_setText(t_searchiterator *self,
                                          PyObject *arg);
static PyObject *t_searchiterator_first(t_searchiterator *self);
static PyObject *t_searchiterator_last(t_searchiterator *self);
static PyObject *t_searchiterator_nextMatch(t_searchiterator *self);
static PyObject *t_searchiterator_following(t_searchiterator *self,
                                            PyObject *arg);
static PyObject *t_searchiterator_preceding(t_searchiterator *self,
                                            PyObject *arg);
static PyObject *t_searchiterator_reset(t_searchiterator *self);

static PyMethodDef t_searchiterator_methods[] = {
    DECLARE_METHOD(t_searchiterator, getOffset, METH_NOARGS),
    DECLARE_METHOD(t_searchiterator, setOffset, METH_O),
    DECLARE_METHOD(t_searchiterator, getAttribute, METH_O),
    DECLARE_METHOD(t_searchiterator, setAttribute, METH_VARARGS),
    DECLARE_METHOD(t_searchiterator, getMatchedStart, METH_NOARGS),
    DECLARE_METHOD(t_searchiterator, getMatchedLength, METH_NOARGS),
    DECLARE_METHOD(t_searchiterator, getMatchedText, METH_VARARGS),
    DECLARE_METHOD(t_searchiterator, getBreakIterator, METH_NOARGS),
    DECLARE_METHOD(t_searchiterator, setBreakIterator, METH_O),
    DECLARE_METHOD(t_searchiterator, getText, METH_VARARGS),
    DECLARE_METHOD(t_searchiterator, setText, METH_O),
    DECLARE_METHOD(t_searchiterator, first, METH_NOARGS),
    DECLARE_METHOD(t_searchiterator, last, METH_NOARGS),
    DECLARE_METHOD(t_searchiterator, nextMatch, METH_NOARGS),
    DECLARE_METHOD(t_searchiterator, following, METH_O),
    DECLARE_METHOD(t_searchiterator, preceding, METH_O),
#include "macros.h"


/* ForwardCharacterIterator */

class t_forwardcharacteriterator : public _wrapper {
public:
    ForwardCharacterIterator *object;
};

static PyObject *t_forwardcharacteriterator_nextPostInc(t_forwardcharacteriterator *self);
static PyObject *t_forwardcharacteriterator_next32PostInc(t_forwardcharacteriterator *self);
static PyObject *t_forwardcharacteriterator_hasNext(t_forwardcharacteriterator *self);

static PyMethodDef t_forwardcharacteriterator_methods[] = {
    DECLARE_METHOD(t_forwardcharacteriterator, nextPostInc, METH_NOARGS),
    DECLARE_METHOD(t_forwardcharacteriterator, next32PostInc, METH_NOARGS),
    DECLARE_METHOD(t_forwardcharacteriterator, hasNext, METH_NOARGS),
    { NULL, NULL, 0, NULL }
};

DECLARE_TYPE(ForwardCharacterIterator, t_forwardcharacteriterator, UObject,
             ForwardCharacterIterator, abstract_init, NULL);

/* CharacterIterator */

class t_characteriterator : public _wrapper {
public:
    CharacterIterator *object;
};
示例#7
0
static int t_regexpattern_init(t_regexpattern *self,
                               PyObject *args, PyObject *kwds);
static PyObject *t_regexpattern_matcher(t_regexpattern *self, PyObject *args);
static PyObject *t_regexpattern_pattern(t_regexpattern *self);
static PyObject *t_regexpattern_flags(t_regexpattern *self);
static PyObject *t_regexpattern_split(t_regexpattern *self, PyObject *args);
static PyObject *t_regexpattern_compile(PyTypeObject *type, PyObject *args);
static PyObject *t_regexpattern_matches(PyTypeObject *type, PyObject *args);

static PyObject *wrap_RegexPattern(RegexPattern *pattern, PyObject *re);
static PyObject *wrap_RegexMatcher(RegexMatcher *matcher, PyObject *pattern,
                                   PyObject *input);

static PyMethodDef t_regexpattern_methods[] = {
    DECLARE_METHOD(t_regexpattern, matcher, METH_VARARGS),
    DECLARE_METHOD(t_regexpattern, pattern, METH_NOARGS),
    DECLARE_METHOD(t_regexpattern, flags, METH_NOARGS),
    DECLARE_METHOD(t_regexpattern, split, METH_VARARGS),
    DECLARE_METHOD(t_regexpattern, compile, METH_VARARGS | METH_CLASS),
    DECLARE_METHOD(t_regexpattern, matches, METH_VARARGS | METH_CLASS),
    { NULL, NULL, 0, NULL }
};

static void t_regexpattern_dealloc(t_regexpattern *self)
{
    if (self->flags & T_OWNED)
        delete self->object;
    self->object = NULL;

    Py_CLEAR(self->re);
示例#8
0
文件: locale.cpp 项目: ezmiller/pyicu
static PyObject *t_locale_getPRC(PyTypeObject *type);
static PyObject *t_locale_getTaiwan(PyTypeObject *type);
static PyObject *t_locale_getUK(PyTypeObject *type);
static PyObject *t_locale_getUS(PyTypeObject *type);
static PyObject *t_locale_getCanada(PyTypeObject *type);
static PyObject *t_locale_getCanadaFrench(PyTypeObject *type);
static PyObject *t_locale_getDefault(PyTypeObject *type);
static PyObject *t_locale_setDefault(PyTypeObject *type, PyObject *args);
static PyObject *t_locale_createFromName(PyTypeObject *type, PyObject *args);
static PyObject *t_locale_createCanonical(PyTypeObject *type, PyObject *arg);
static PyObject *t_locale_getAvailableLocales(PyTypeObject *type);
static PyObject *t_locale_getISOCountries(PyTypeObject *type);
static PyObject *t_locale_getISOLanguages(PyTypeObject *type);

static PyMethodDef t_locale_methods[] = {
    DECLARE_METHOD(t_locale, getLanguage, METH_NOARGS),
    DECLARE_METHOD(t_locale, getScript, METH_NOARGS),
    DECLARE_METHOD(t_locale, getCountry, METH_NOARGS),
    DECLARE_METHOD(t_locale, getVariant, METH_NOARGS),
    DECLARE_METHOD(t_locale, getName, METH_NOARGS),
    DECLARE_METHOD(t_locale, getBaseName, METH_NOARGS),
    DECLARE_METHOD(t_locale, getISO3Language, METH_NOARGS),
    DECLARE_METHOD(t_locale, getISO3Country, METH_NOARGS),
    DECLARE_METHOD(t_locale, getLCID, METH_NOARGS),
    DECLARE_METHOD(t_locale, getDisplayLanguage, METH_VARARGS),
    DECLARE_METHOD(t_locale, getDisplayScript, METH_VARARGS),
    DECLARE_METHOD(t_locale, getDisplayCountry, METH_VARARGS),
    DECLARE_METHOD(t_locale, getDisplayVariant, METH_VARARGS),
    DECLARE_METHOD(t_locale, getDisplayName, METH_VARARGS),
    DECLARE_METHOD(t_locale, createKeywords, METH_NOARGS),
    DECLARE_METHOD(t_locale, getKeywordValue, METH_O),