Examples of PyInteger


Examples of org.python.core.PyInteger

                    "    def incval(self):\n" +
                    "        self.val += 1\n" +
                    "        return self.val");
        PyObject blahClass = interp.get("Blah");
        int base = 42;
        PyObject blahInstance = blahClass.__call__(new PyInteger(base));
        for (int i = 0; i < 4; i++) {
            assertEquals(++base, blahInstance.invoke("incval").__tojava__(Integer.class));
        }
    }
View Full Code Here

Examples of org.python.core.PyInteger

            PyObject file_size = new PyLong(zipEntry.getSize());
            // file_offset is a CPython optimization; it's used to seek directly to the
            // file when reading it later. Jython doesn't do this nor is the offset
            // available
            PyObject file_offset = Py.newInteger(-1);
            PyObject time = new PyInteger(epochToDosTime(zipEntry.getTime()));
            PyObject date = new PyInteger(epochToDosDate(zipEntry.getTime()));
            PyObject crc = new PyLong(zipEntry.getCrc());

            PyTuple entry = new PyTuple(__file__, compress, data_size, file_size, file_offset,
                                        time, date, crc);
            files.__setitem__(new PyString(name), entry);
View Full Code Here

Examples of org.python.core.PyInteger

    public static void exit() {
        exit_thread();
    }

    public static void exit_thread() {
        throw new PyException(Py.SystemExit, new PyInteger(0));
    }
View Full Code Here

Examples of org.python.core.PyInteger

        if (o instanceof Num) {
            Num num = (Num)o;
            if (num.getInternalN() instanceof PyInteger) {
                int v = ((PyInteger)num.getInternalN()).getValue();
                if (v >= 0) {
                    num.setN(new PyInteger(-v));
                    return num;
                }
            } else if (num.getInternalN() instanceof PyLong) {
                BigInteger v = ((PyLong)num.getInternalN()).getValue();
                if (v.compareTo(BigInteger.ZERO) == 1) {
View Full Code Here

Examples of org.python.core.PyInteger

    public static PyIterator count(final int init) {
        return new PyIterator() {
            int counter = init;

            public PyObject __iternext__() {
                return new PyInteger(counter++);
            }
           
            public PyString __repr__() {
                return (PyString)(Py.newString("count(%d)").__mod__(Py.newInteger(counter)));
            }
View Full Code Here

Examples of org.python.core.PyInteger

    /**
     * @see #islice(PyObject, PyObject, PyObject, PyObject) startObj defaults to 0 and stepObj to 1
     */
    public static PyIterator islice(PyObject iterable, PyObject stopObj) {
        return islice(iterable, new PyInteger(0), stopObj, new PyInteger(1));
    }
View Full Code Here

Examples of org.python.core.PyInteger

    /**
     * @see #islice(PyObject, PyObject, PyObject, PyObject) stepObj defaults to 1
     */
    public static PyIterator islice(PyObject iterable, PyObject start,
            PyObject stopObj) {
        return islice(iterable, start, stopObj, new PyInteger(1));
    }
View Full Code Here

Examples of org.python.core.PyInteger

            write.__call__(new PyString(buff.toString()));
            buff.setLength(0);
        }

        public String read(int len) {
            return read.__call__(new PyInteger(len)).toString();
        }
View Full Code Here

Examples of org.python.core.PyInteger

        try {
            ByteArrayOutputStream bout=new ByteArrayOutputStream();
            ObjectOutputStream oout=new ObjectOutputStream(bout);
            oout.writeObject(this.javaRandom);
            byte b[]=bout.toByteArray();
            PyInteger retarr[]=new PyInteger[b.length];
            for (int i=0;i<b.length;i++) {
                retarr[i]=new PyInteger(b[i]);
            }
            PyTuple ret=new PyTuple(retarr);
            return ret;
        } catch (IOException e) {
            throw Py.SystemError("creation of state vector failed: "+
View Full Code Here

Examples of org.python.core.PyInteger

    private static PyTimeTuple toTimeTuple(Calendar cal, int isdst) {
        int dow = cal.get(Calendar.DAY_OF_WEEK) - 2;
        if (dow < 0) {
            dow += 7;
        }
        return new PyTimeTuple(new PyInteger(cal.get(Calendar.YEAR)),
                new PyInteger(cal.get(Calendar.MONTH) + 1),
                new PyInteger(cal.get(Calendar.DAY_OF_MONTH)),
                new PyInteger(cal.get(Calendar.HOUR)
                + 12 * cal.get(Calendar.AM_PM)),
                new PyInteger(cal.get(Calendar.MINUTE)),
                new PyInteger(cal.get(Calendar.SECOND)),
                new PyInteger(dow),
                new PyInteger(cal.get(Calendar.DAY_OF_YEAR)),
                new PyInteger(isdst));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.