Package org.python.core

Examples of org.python.core.PyType.lookup()


        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");
View Full Code Here


            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();
    }

    public PyUnicode __unicode__() {
View Full Code Here

            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();
    }

    public PyUnicode __unicode__() {
View Full Code Here

        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__();
        }
View Full Code Here

    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 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

        return super.__len__();
    }

    public PyObject __iter__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__iter__");
        if (impl != null)
            return impl.__get__(this, self_type).__call__();
        impl = self_type.lookup("__getitem__");
        if (impl == null)
            return super.__iter__();
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.