⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pyobject.java

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * with the appropriate args.     * The only reason to override this method is for performance.     *     * @param name the name which will be removed -     *             <b> must be an interned string </b>.     * @exception PyAttributeError if the name doesn't exist     *     * @see #__delattr__(PyString)     **/    public void __delattr__(String name) {        throw Py.TypeError("readonly class");    }    // Used by import logic.    protected PyObject impAttr(String name) {        return __findattr__(name);    }    protected void addKeys(PyList ret, String attr) {        PyObject obj = __findattr__(attr);        if (obj == null)            return;        if (obj instanceof PyDictionary) {            ret.setslice(ret.__len__(), ret.__len__(), 1,                         ((PyDictionary)obj).keys());        }        else if (obj instanceof PyStringMap) {            ret.setslice(ret.__len__(), ret.__len__(), 1,                         ((PyStringMap)obj).keys());        }        else if (obj instanceof PyList) {            ret.setslice(ret.__len__(), ret.__len__(), 1, (PyList)obj);        }    }    /**     * Equivalent to the standard Python __dir__ method.     *     * @return a list of names defined by this object.     **/    public PyObject __dir__() {        PyList ret = new PyList();        addKeys(ret, "__dict__");        addKeys(ret, "__methods__");        addKeys(ret, "__members__");        ret.sort();        return ret;    }    public PyObject _doget(PyObject container) {        return this;    }    public PyObject _doget(PyObject container, PyObject wherefound) {        return _doget(container);    }    public boolean _doset(PyObject container, PyObject value) {        return false;    }    public boolean _dodel(PyObject container) {        return false;    }    /* Numeric coercion */    /**     * Implements numeric coercion     *     * @param o the other object involved in the coercion     * @return null if no coercion is possible;     * a single PyObject to use to replace o if this is unchanged;     * or a PyObject[2] consisting of replacements for this and o.     **/    public Object __coerce_ex__(PyObject o) {        return null;    }    /**     * Equivalent to the standard Python __coerce__ method.     *     * This method can not be overridden.     * To implement __coerce__ functionality, override __coerce_ex__ instead.     *     * @param pyo the other object involved in the coercion.     * @return a tuple of this object and pyo coerced to the same type     *         or Py.None if no coercion is possible.     * @see org.python.core.PyObject#__coerce_ex__(org.python.core.PyObject)     **/    public final PyObject __coerce__(PyObject pyo) {        Object o = __coerce_ex__(pyo);        if (o == null)            throw Py.AttributeError("__coerce__");        if (o == Py.None)            return (PyObject)o;        if (o instanceof PyObject[])            return new PyTuple((PyObject[])o);        else            return new PyTuple(new PyObject[] {this, (PyObject)o});    }    /* The basic comparision operations */    /**     * Equivalent to the standard Python __cmp__ method.     *     * @param other the object to compare this with.     * @return -1 if this < 0; 0 if this == o; +1 if this > o; -2 if no     * comparison is implemented     **/    public int __cmp__(PyObject other) {        return -2;    }    /**     * Equivalent to the standard Python __eq__ method.     *     * @param other the object to compare this with.     * @return the result of the comparison.     **/    public PyObject __eq__(PyObject other) { return null; }    /**     * Equivalent to the standard Python __ne__ method.     *     * @param other the object to compare this with.     * @return the result of the comparison.     **/    public PyObject __ne__(PyObject other) { return null; }    /**     * Equivalent to the standard Python __le__ method.     *     * @param other the object to compare this with.     * @return the result of the comparison.     **/    public PyObject __le__(PyObject other) { return null; }    /**     * Equivalent to the standard Python __lt__ method.     *     * @param other the object to compare this with.     * @return the result of the comparison.     **/    public PyObject __lt__(PyObject other) { return null; }    /**     * Equivalent to the standard Python __ge__ method.     *     * @param other the object to compare this with.     * @return the result of the comparison.     **/    public PyObject __ge__(PyObject other) { return null; }    /**     * Equivalent to the standard Python __gt__ method.     *     * @param other the object to compare this with.     * @return the result of the comparison.     **/    public PyObject __gt__(PyObject other) { return null; }    /**     * Implements cmp(this, other)     *     * @param other the object to compare this with.     * @return -1 if this < 0; 0 if this == o; +1 if this > o     **/    public final int _cmp(PyObject o) {        PyObject token = null;        ThreadState ts = Py.getThreadState();        try {            if (++ts.compareStateNesting > 500) {                if ((token = check_recursion(ts, this, o)) == null)                    return 0;            }            PyObject r;            r = __eq__(o);            if (r != null && r.__nonzero__())                return 0;            r = o.__eq__(this);            if (r != null && r.__nonzero__())                return 0;            r = __lt__(o);            if (r != null && r.__nonzero__())                return -1;            r = o.__gt__(this);            if (r != null && r.__nonzero__())                return -1;            r = __gt__(o);            if (r != null && r.__nonzero__())                return 1;            r = o.__lt__(this);            if (r != null && r.__nonzero__())                return 1;            return _cmp_unsafe(o);        } finally {            delete_token(ts, token);            ts.compareStateNesting--;        }    }    private PyObject make_pair(PyObject o) {        if (System.identityHashCode(this) < System.identityHashCode(o))            return new PyIdentityTuple(new PyObject[] { this, o });        else            return new PyIdentityTuple(new PyObject[] { o, this });    }    private final int _cmp_unsafe(PyObject o2_in) {        // Shortcut for equal objects        if (this == o2_in)            return 0;        PyObject o2 = o2_in;        PyObject o1 = this;        int itmp;        Object ctmp;        if (o1.__class__ != o2.__class__) {            ctmp = o1.__coerce_ex__(o2);            if (ctmp != null) {                if (ctmp instanceof PyObject[]) {                    o1 = ((PyObject[])ctmp)[0];                    o2 = ((PyObject[])ctmp)[1];                }                else {                    o2 = (PyObject)ctmp;                }            }        }        else ctmp = null;        if (ctmp != Py.None && (itmp = o1.__cmp__(o2)) != -2)            return itmp;        o1 = this;        o2 = o2_in;        if (o1.__class__ != o2.__class__) {            ctmp = o2.__coerce_ex__(o1);            if (ctmp != null) {                if (ctmp instanceof PyObject[]) {                    o2 = ((PyObject[])ctmp)[0];                    o1 = ((PyObject[])ctmp)[1];                }                else {                    o1 = (PyObject)ctmp;                }            }        }        if (ctmp != Py.None && (itmp = o2.__cmp__(o1)) != -2)            return -itmp;        if (this == o2_in)            return 0;        /* None is smaller than anything */        if (this == Py.None)            return -1;        if (o2_in == Py.None)            return 1;        // No rational way to compare these, so ask their classes to compare        itmp = this.__class__.__cmp__(o2_in.__class__);        if (itmp == 0)            return System.identityHashCode(this) <                    System.identityHashCode(o2_in) ? -1 : 1;        if (itmp != -2)            return itmp;        return System.identityHashCode(this.__class__) <                System.identityHashCode(o2_in.__class__) ? -1 : 1;    }    private final static PyObject check_recursion(ThreadState ts,                                                  PyObject o1, PyObject o2)    {        PyDictionary stateDict = ts.getCompareStateDict();        PyObject pair = o1.make_pair(o2);        if (stateDict.__finditem__(pair) != null)            return null;        stateDict.__setitem__(pair, pair);        return pair;    }    private final static void delete_token(ThreadState ts, PyObject token) {        if (token == null)            return;        PyDictionary stateDict = ts.getCompareStateDict();        stateDict.__delitem__(token);    }    /**     * Implements the Python expression <code>this == other</code>.     *     * @param other the object to compare this with.     * @return the result of the comparison     **/    public final PyObject _eq(PyObject o) {        PyObject token = null;        ThreadState ts = Py.getThreadState();        try {            if (++ts.compareStateNesting > 10) {                if ((token = check_recursion(ts, this, o)) == null)                    return Py.One;            }            PyObject res = __eq__(o);            if (res != null)                return res;            res = o.__eq__(this);            if (res != null)                return res;            return _cmp_unsafe(o) == 0 ? Py.One : Py.Zero;        } finally {            delete_token(ts, token);            ts.compareStateNesting--;        }    }    /**     * Implements the Python expression <code>this != other</code>.     *     * @param other the object to compare this with.     * @return the result of the comparison     **/    public final PyObject _ne(PyObject o) {        PyObject token = null;        ThreadState ts = Py.getThreadState();        try {            if (++ts.compareStateNesting > 10) {                if ((token = check_recursion(ts, this, o)) == null)                    return Py.Zero;            }            PyObject res = __ne__(o);            if (res != null)                return res;            res = o.__ne__(this);            if (res != null)                return res;            return _cmp_unsafe(o) != 0 ? Py.One : Py.Zero;        } finally {            delete_token(ts, token);            ts.compareStateNesting--;        }    }    /**     * Implements the Python expression <code>this &lt;= other</code>.     *     * @param other the object to compare this with.     * @return the result of the comparison     **/    public final PyObject _le(PyObject o) {        PyObject token = null;        ThreadState ts = Py.getThreadState();        try {            if (++ts.compareStateNesting > 10) {                if ((token = check_recursion(ts, this, o)) == null)                    throw Py.ValueError("can't order recursive values");            }            PyObject res = __le__(o);            if (res != null)                return res;            res = o.__ge__(this);            if (res != null)                return res;            return _cmp_unsafe(o) <= 0 ? Py.One : Py.Zero;        } finally {            delete_token(ts, token);            ts.compareStateNesting--;        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -