Examples of PyInteger


Examples of org.python.core.PyInteger

    assertTrue(fooClass instanceof PyClass);
    PyObject foo = fooClass.__call__();

    PyObject fooVal = foo.__getattr__("val");
    assertTrue(fooVal instanceof PyInteger);
    PyInteger val = (PyInteger) fooVal;
    assertEquals(17, val.getValue());

    PyObject function = interpreter.get("outside_add_squared");
    assertTrue("method class: " + function.getClass(), function instanceof PyFunction);
    function.__call__(foo, new PyInteger(3));

    fooVal = foo.__getattr__("val");
    assertTrue(fooVal instanceof PyInteger);
    val = (PyInteger) fooVal;
    assertEquals(26, val.getValue());

    JythonWritableWrapper wrappedFoo = new JythonWritableWrapper(foo);
    PyObject newOtherMethod = wrappedFoo.__getattr__("new_other");

    assertTrue(newOtherMethod instanceof PyMethod);
    newOtherMethod.__call__();

    function.__call__(wrappedFoo, new PyInteger(2));

    fooVal = foo.__getattr__("val");
    assertTrue(fooVal instanceof PyInteger);
    val = (PyInteger) fooVal;
    assertEquals(30, val.getValue());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    wrappedFoo.write(dos);

    byte[] data = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    DataInputStream dis = new DataInputStream(bais);

    PyObject foo2 = fooClass.__call__();

    PyObject foo2Val = foo2.__getattr__("val");
    assertTrue(foo2Val instanceof PyInteger);
    PyInteger val2 = (PyInteger) foo2Val;
    assertEquals(17, val2.getValue());

    JythonWritableWrapper wrappedFoo2 = new JythonWritableWrapper(foo2);

    foo2Val = wrappedFoo2.getPyObject().__getattr__("val");
    assertTrue(foo2Val instanceof PyInteger);
    val2 = (PyInteger) foo2Val;
    assertEquals(17, val2.getValue());

    wrappedFoo2.readFields(dis);

    foo2Val = wrappedFoo2.getPyObject().__getattr__("val");
    assertTrue(foo2Val instanceof PyInteger);
    val2 = (PyInteger) foo2Val;
    assertEquals(30, val2.getValue());
  }
View Full Code Here

Examples of org.python.core.PyInteger

            push(value ? Py.True : Py.False);
        }

        final private void load_binint() {
            int x = read_binint();
            push(new PyInteger(x));
        }
View Full Code Here

Examples of org.python.core.PyInteger

        }


        final private void load_binint1() {
            int val = file.read(1).charAt(0);
            push(new PyInteger(val));
        }
View Full Code Here

Examples of org.python.core.PyInteger

            push(new PyInteger(val));
        }

        final private void load_binint2() {
            int val = read_binint2();
            push(new PyInteger(val));
        }
View Full Code Here

Examples of org.python.core.PyInteger

            for (; x >= 1.0; x *= 0.5, exponent++);

            x *= sign;
        }
        return new PyTuple(new PyFloat(x), new PyInteger(exponent));
    }
View Full Code Here

Examples of org.python.core.PyInteger

        return arg;
    }

    @ExposedMethod(defaults = "1")
    public PyObject defaultToOne(int arg) {
        return new PyInteger(arg);
    }
View Full Code Here

Examples of org.python.core.PyInteger

     *
     * @param dict
     */
    static public void classDictInit(PyObject dict) {
        dict.__setitem__("__version__", Py.newString("7290"));
        dict.__setitem__("autocommit", new PyInteger(0));
        dict.__setitem__("close", new ConnectionFunc("close", 0, 0, 0, zxJDBC.getString("close")));
        dict.__setitem__("commit", new ConnectionFunc("commit", 1, 0, 0,
                                                      zxJDBC.getString("commit")));
        dict.__setitem__("cursor", new ConnectionFunc("cursor", 2, 0, 4,
                                                      zxJDBC.getString("cursor")));
View Full Code Here

Examples of org.python.core.PyInteger

     *
     * @param dict
     */
    public static void classDictInit(PyObject dict) {
        dict.__setitem__("apilevel", new PyString("2.0"));
        dict.__setitem__("threadsafety", new PyInteger(1));
        dict.__setitem__("paramstyle", new PyString("qmark"));
        dict.__setitem__("__version__", Py.newString("7290"));
        dict.__setitem__("Date", new zxJDBCFunc("Date", 1, 3, 3,
                                                "construct a Date from year, month, day"));
        dict.__setitem__("Time", new zxJDBCFunc("Time", 2, 3, 3,
View Full Code Here

Examples of org.python.core.PyInteger

                case DatabaseMetaData.procedureColumnIn:
                case DatabaseMetaData.procedureColumnInOut:

                    // bindings are Python-indexed
                    PyInteger key = Py.newInteger(binding++);

                    if (bindings.__finditem__(key) == null) {
                        int dataType = column.__getitem__(DATA_TYPE).asInt();
                        bindings.__setitem__(key, Py.newInteger(dataType));
                    }
View Full Code Here

Examples of org.python.core.PyInteger

            new Thread() {
                @Override
                public void run() {
                    PythonInterpreter interp = new PythonInterpreter();
                    interp.exec("import sys");
                    interp.set("a", new PyInteger(41));
                    int set = Py.tojava(interp.get("a"), Integer.class);
                    assertEquals(41, set);
                    interp.exec("x = 'hello ' + 'goodbye'");
                    assertEquals("hello goodbye", Py.tojava(interp.get("x"), String.class));
                    doneSignal.countDown();
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.