Package org.python.core

Examples of org.python.core.PyType


            return impl.__get__(this, self_type).__call__(other);
        return super.__iand__(other);
    }

    public PyObject __ior__(PyObject other) {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__ior__");
        if (impl != null)
            return impl.__get__(this, self_type).__call__(other);
        return super.__ior__(other);
    }
View Full Code Here


            return impl.__get__(this, self_type).__call__(other);
        return super.__ior__(other);
    }

    public PyObject __ixor__(PyObject other) {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__ixor__");
        if (impl != null)
            return impl.__get__(this, self_type).__call__(other);
        return super.__ixor__(other);
    }
View Full Code Here

            return impl.__get__(this, self_type).__call__(other);
        return super.__ixor__(other);
    }

    public PyObject __int__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__int__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyInteger || res instanceof PyLong)
                return (PyObject) res;
            throw Py.TypeError("__int__" + " should return an integer");
View Full Code Here

        }
        return super.__int__();
    }

    public String toString() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__repr__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (!(res instanceof PyString))
                throw Py.TypeError("__repr__ should return a string");
            return ((PyString) res).toString();
View Full Code Here

        }
        return super.toString();
    }

    public int hashCode() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__hash__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyInteger)
                return ((PyInteger) res).getValue();
            throw Py.TypeError("__hash__ should return a int");
        }
        if (self_type.lookup("__eq__") != null || self_type.lookup("__cmp__") != null)
            throw Py.TypeError("unhashable type");
        return super.hashCode();
    }
View Full Code Here

            throw Py.TypeError("unhashable type");
        return super.hashCode();
    }

    public PyUnicode __unicode__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__unicode__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyUnicode)
                return (PyUnicode) res;
            if (res instanceof PyString)
View Full Code Here

        }
        return super.__unicode__();
    }

    public int __cmp__(PyObject other) {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__cmp__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__(other);
            if (res instanceof PyInteger) {
                int v = ((PyInteger) res).getValue();
                return v < 0 ? -1 : v > 0 ? 1 : 0;
View Full Code Here

        }
        return super.__cmp__(other);
    }

    public boolean __nonzero__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__nonzero__");
        if (impl == null) {
            impl = self_type.lookup("__len__");
            if (impl == null)
                return super.__nonzero__();
        }
        return impl.__get__(this, self_type).__call__().__nonzero__();
    }
View Full Code Here

        }
        return impl.__get__(this, self_type).__call__().__nonzero__();
    }

    public boolean __contains__(PyObject o) {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__contains__");
        if (impl == null)
            return super.__contains__(o);
        return impl.__get__(this, self_type).__call__(o).__nonzero__();
    }
View Full Code Here

            return super.__contains__(o);
        return impl.__get__(this, self_type).__call__(o).__nonzero__();
    }

    public int __len__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__len__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyInteger)
                return ((PyInteger) res).getValue();
            throw Py.TypeError("__len__ should return a int");
View Full Code Here

TOP

Related Classes of org.python.core.PyType

Copyright © 2018 www.massapicom. 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.