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

📄 pyinstance.java

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    }    public PyObject __call__(PyObject args[], String keywords[]) {        ThreadState ts = Py.getThreadState();        if (ts.recursion_depth++ > ts.systemState.getrecursionlimit())            throw Py.RuntimeError("maximum __call__ recursion depth exceeded");        try {            return invoke("__call__", args, keywords);        } finally {            --ts.recursion_depth;        }    }    public PyString __repr__() {        PyObject ret = invoke_ex("__repr__");        if (ret == null) {            PyObject mod = __class__.__dict__.__finditem__("__module__");            String smod;            if (mod == Py.None) smod = "";            else {                if (mod == null || !(mod instanceof PyString))                    smod = "<unknown>.";                else                    smod = ((PyString)mod).toString()+'.';            }            return new PyString("<"+smod+__class__.__name__+                                " instance "+Py.idstr(this)+">");        }        if (!(ret instanceof PyString))            throw Py.TypeError("__repr__ method must return a string");        return (PyString)ret;    }    public PyString __str__() {        PyObject ret = null;        try {            ret = invoke_ex("__str__");        } catch (PyException exc) { }        if (ret == null)            return __repr__();        if (!(ret instanceof PyString))            throw Py.TypeError("__str__ method must return a string");        return (PyString)ret;    }    public int hashCode() {        PyObject ret;        ret = invoke_ex("__hash__");        if (ret == null) {            if (__findattr__("__eq__") != null ||                __findattr__("__cmp__") != null)                throw Py.TypeError("unhashable instance");            return super.hashCode();        }        if (ret instanceof PyInteger) {            return ((PyInteger)ret).getValue();        }        throw Py.TypeError("__hash__() must return int");    }    public int __cmp__(PyObject o) {        PyObject ret = invoke_ex("__cmp__", o);        if (ret == null)            return -2;        if (ret instanceof PyInteger) {            int v = ((PyInteger)ret).getValue();            return v < 0 ? -1 : v > 0 ? 1 : 0;        }        throw Py.TypeError("__cmp__() must return int");    }    private PyObject invoke_ex_richcmp(String name, PyObject o) {        PyObject ret = invoke_ex(name, o);        if (ret == Py.NotImplemented)            return null;        return ret;    }    public PyObject __lt__(PyObject o) {        return invoke_ex_richcmp("__lt__", o);    }    public PyObject __le__(PyObject o) {        return invoke_ex_richcmp("__le__", o);    }    public PyObject __gt__(PyObject o) {        return invoke_ex_richcmp("__gt__", o);    }    public PyObject __ge__(PyObject o) {        return invoke_ex_richcmp("__ge__", o);    }    public PyObject __eq__(PyObject o) {        return invoke_ex_richcmp("__eq__", o);    }    public PyObject __ne__(PyObject o) {        return invoke_ex_richcmp("__ne__", o);    }    public boolean __nonzero__() {        PyObject meth = null;        try {            meth = __findattr__("__nonzero__");        } catch (PyException exc) { }        if (meth == null) {            // Copied form __len__()            CollectionProxy proxy = getCollection();            if (proxy != CollectionProxy.NoProxy) {                return proxy.__len__() != 0 ? true : false;            }            try {                meth = __findattr__("__len__");            } catch (PyException exc) { }            if (meth == null)                return true;        }        PyObject ret = meth.__call__();        return ret.__nonzero__();    }    private CollectionProxy collectionProxy=null;    private CollectionProxy getCollection() {        if (collectionProxy == null)            collectionProxy = CollectionProxy.findCollection(javaProxy);        return collectionProxy;    }    public int __len__() {        CollectionProxy proxy = getCollection();        if (proxy != CollectionProxy.NoProxy) {            return proxy.__len__();        }        PyObject ret = invoke("__len__");        if (ret instanceof PyInteger)            return ((PyInteger)ret).getValue();        throw Py.TypeError("__len__() should return an int");    }    public PyObject __finditem__(int key) {        CollectionProxy proxy = getCollection();        if (proxy != CollectionProxy.NoProxy) {            return proxy.__finditem__(key);        }        return __finditem__(new PyInteger(key));    }    private PyObject trySlice(PyObject key, String name, PyObject extraArg) {        if (!(key instanceof PySlice))            return null;        PySlice slice = (PySlice)key;        if (slice.step != Py.None && slice.step != Py.One) {            if (slice.step instanceof PyInteger) {                if (((PyInteger)slice.step).getValue() != 1) {                    return null;                }            } else {                return null;            }        }        PyObject func = __findattr__(name);        if (func == null)            return null;        PyObject start = slice.start;        PyObject stop = slice.stop;        if (start == Py.None)            start = Py.Zero;        if (stop == Py.None)            stop = new PyInteger(PySystemState.maxint);        if (extraArg == null) {            return func.__call__(start, stop);        } else {            return func.__call__(start, stop, extraArg);        }    }    public PyObject __finditem__(PyObject key) {        CollectionProxy proxy = getCollection();        if (proxy != CollectionProxy.NoProxy) {            return proxy.__finditem__(key);        }        try {            PyObject ret = trySlice(key, "__getslice__", null);            if (ret != null)                return ret;            return invoke("__getitem__", key);        } catch (PyException e) {            if (Py.matchException(e, Py.IndexError))                return null;            throw e;        }    }    public PyObject __getitem__(PyObject key) {        CollectionProxy proxy = getCollection();        if (proxy != CollectionProxy.NoProxy) {            PyObject ret = proxy.__finditem__(key);            if (ret == null) {                throw Py.KeyError(key.toString());            }            return ret;        }        PyObject ret = trySlice(key, "__getslice__", null);        if (ret != null)            return ret;        return invoke("__getitem__", key);    }    public void __setitem__(PyObject key, PyObject value) {        CollectionProxy proxy = getCollection();        if (proxy != CollectionProxy.NoProxy) {            proxy.__setitem__(key, value);            return;        }        if (trySlice(key, "__setslice__", value) != null)            return;        invoke("__setitem__", key, value);    }    public void __delitem__(PyObject key) {        CollectionProxy proxy = getCollection();        if (proxy != CollectionProxy.NoProxy) {            proxy.__delitem__(key);            return;        }        if (trySlice(key, "__delslice__", null) != null)            return;        invoke("__delitem__", key);    }    public PyObject __iter__() {        PyObject iter = getCollectionIter();        if (iter != null) {            return iter;        }        PyObject func = __findattr__("__iter__");        if (func != null)            return func.__call__();        func = __findattr__("__getitem__");        if (func == null)            return super.__iter__();        return new PySequenceIter(this);    }    public PyObject __iternext__() {        PyObject func = __findattr__("next");        if (func != null) {            try {                return func.__call__();            } catch (PyException exc) {                if (Py.matchException(exc, Py.StopIteration))                    return null;                throw exc;            }        }        throw Py.TypeError("instance has no next() method");    }    private static CollectionIter[] iterFactories = null;    private PyObject getCollectionIter() {        if (iterFactories == null)            initializeIterators();        for (int i = 0; iterFactories[i] != null; i++) {            PyObject iter = iterFactories[i].findCollection(javaProxy);            if (iter != null)                return iter;        }        return null;    }    private static synchronized void initializeIterators() {        if (iterFactories != null)            return;        String factories = "org.python.core.CollectionIter," +                           "org.python.core.CollectionIter2," +                           Py.getSystemState().registry.getProperty(                                "python.collections", "");        int i = 0;        StringTokenizer st = new StringTokenizer(factories, ",");        iterFactories = new CollectionIter[st.countTokens() + 1];        while (st.hasMoreTokens()) {            String s = st.nextToken();            try {                Class factoryClass = Class.forName(s);                CollectionIter factory =                        (CollectionIter)factoryClass.newInstance();                iterFactories[i++] = factory;            } catch (Throwable t) { }        }    }    public boolean __contains__(PyObject o) {        PyObject func = __findattr__("__contains__");        if (func == null)           return super.__contains__(o);        PyObject ret = func.__call__(o);        return ret.__nonzero__();    }    //Begin the numeric methods here    public Object __coerce_ex__(PyObject o) {        PyObject ret = invoke_ex("__coerce__", o);        if (ret == null || ret == Py.None)            return ret;        if (!(ret instanceof PyTuple))            throw Py.TypeError("coercion should return None or 2-tuple");        return ((PyTuple)ret).list;    }    // Generated by make_binops.py    // Unary ops    /**     * Implements the __hex__ method by looking it up     * in the instance's dictionary and calling it if it is found.     **/    public PyString __hex__() {        PyObject ret = invoke("__hex__");        if (ret instanceof PyString)            return (PyString)ret;        throw Py.TypeError("__hex__() should return a string");    }    /**     * Implements the __oct__ method by looking it up     * in the instance's dictionary and calling it if it is found.     **/    public PyString __oct__() {        PyObject ret = invoke("__oct__");        if (ret instanceof PyString)            return (PyString)ret;        throw Py.TypeError("__oct__() should return a string");    }    /**     * Implements the __int__ method by looking it up     * in the instance's dictionary and calling it if it is found.     **/    public PyInteger __int__() {

⌨️ 快捷键说明

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