Examples of PyBuiltinCallable


Examples of org.python.core.PyBuiltinCallable

                                                                                 new Type[] {PYTYPE}),
                                                        "simpleexposed",
                                                        new String[0],
                                                        new String[0],
                                                        "");
        PyBuiltinCallable bound = createBound(exp);
        assertEquals("a", bound.__call__().toString());
    }
View Full Code Here

Examples of org.python.core.PyBuiltinCallable

                                                                                             PYOBJ}),
                                                        "simpleexposed",
                                                        new String[0],
                                                        new String[] {"null", "Py.None"},
                                                        "");
        PyBuiltinCallable bound = createBound(exp);
        assertEquals(0, bound.__call__().asInt());
        assertEquals(1, bound.__call__(Py.newString("hello")).asInt());
        assertEquals(2, bound.__call__(Py.newString("nothello"), Py.None).asInt());
        assertEquals(3, bound.__call__(Py.newString("nothello"), Py.One).asInt());
    }
View Full Code Here

Examples of org.python.core.PyBuiltinCallable

        assertEquals(2, bound.__call__(Py.newString("nothello"), Py.None).asInt());
        assertEquals(3, bound.__call__(Py.newString("nothello"), Py.One).asInt());
    }

    public void testThreadState() throws Exception {
        PyBuiltinCallable bound = createBound("needsThreadState", STRING, THREAD_STATE, STRING);
        ThreadState ts = Py.getThreadState();
        PyObject expected = Py.newString("foo got state " + ts.hashCode());
        assertEquals(expected, bound.__call__(Py.getThreadState(), Py.newString("foo")));
        assertEquals(expected, bound.__call__(Py.newString("foo")));
        ts = new ThreadState(new Thread(), ts.systemState);
        assertEquals(Py.newString("foo got state " + ts.hashCode()),
                     bound.__call__(ts, Py.newString("foo")));
    }
View Full Code Here

Examples of org.python.core.PyBuiltinCallable

                                                              Type.getMethodDescriptor(Type.INT_TYPE,
                                                                                       new Type[] {THREAD_STATE,
                                                                                                   APYOBJ,
                                                                                                   ASTRING}),
                                                              "simpleexposed");
        PyBuiltinCallable bound = createBound(exp);
        assertEquals(Py.Zero, bound.__call__(Py.getThreadState()));
        assertEquals(Py.Zero, bound.__call__());
        assertEquals(Py.One, bound.__call__(Py.getThreadState(), Py.One));
        assertEquals(Py.One, bound.__call__(Py.One));
    }
View Full Code Here

Examples of org.python.core.PyBuiltinCallable

                                                                                             STRING}),
                                                        "simpleexposed",
                                                        new String[0],
                                                        new String[] {"null"},
                                                        "");
        PyBuiltinCallable bound = createBound(exp);
        ThreadState ts = Py.getThreadState();
        PyObject arg0 = Py.newString("bar");
        PyObject arg1 = Py.newString(" and extra");
        PyObject expected = Py.newString("bar got state " + ts.hashCode() + " got type and extra");
        assertEquals(expected, bound.__call__(Py.getThreadState(), arg0, arg1));
        assertEquals(expected, bound.__call__(arg0, arg1));
    }
View Full Code Here

Examples of org.python.core.PyBuiltinCallable

        ice.getNewExposer().load(loader);
        ice.getTypeExposer().load(loader);
        Class doctoredSimple = loader.loadClassFromBytes("org.python.expose.generate.SimpleExposed",
                                                         ice.getBytecode());
        PyObject simp = (PyObject)doctoredSimple.newInstance();
        PyBuiltinCallable func = MethodExposerTest.instantiate(simple_method, "invisible");
        PyBuiltinCallable bound = func.bind(simp);
        bound.__call__();
        PyDataDescr desc = (PyDataDescr)tostringDesc.newInstance();
        desc.setType(simp.getType());
        assertEquals(doctoredSimple.getField("toStringVal").get(simp),
                     desc.__get__(simp, PyType.fromClass(doctoredSimple)).toString());
        assertEquals(desc.__getattr__("__doc__"), new PyString("tostring docs"));
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.