From: <pj...@us...> - 2008-07-21 01:38:49
|
Revision: 4976 http://jython.svn.sourceforge.net/jython/?rev=4976&view=rev Author: pjenvey Date: 2008-07-21 01:38:17 +0000 (Mon, 21 Jul 2008) Log Message: ----------- small cleanup Modified Paths: -------------- trunk/jython/src/org/python/core/PySequence.java Modified: trunk/jython/src/org/python/core/PySequence.java =================================================================== --- trunk/jython/src/org/python/core/PySequence.java 2008-07-19 23:23:25 UTC (rev 4975) +++ trunk/jython/src/org/python/core/PySequence.java 2008-07-21 01:38:17 UTC (rev 4976) @@ -256,7 +256,11 @@ } } - public synchronized PyObject __finditem__(int index) { + public PyObject __finditem__(int index) { + return seq___finditem__(index); + } + + final synchronized PyObject seq___finditem__(int index) { index = fixindex(index); if(index == -1) { return null; @@ -271,7 +275,7 @@ final PyObject seq___finditem__(PyObject index) { if(index instanceof PyInteger || index instanceof PyLong) { - return __finditem__(index.asInt()); + return seq___finditem__(index.asInt()); } else if(index instanceof PySlice) { PySlice s = (PySlice)index; return __getslice__(s.start, s.stop, s.step); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-21 19:10:06
|
Revision: 4981 http://jython.svn.sourceforge.net/jython/?rev=4981&view=rev Author: pjenvey Date: 2008-07-21 19:10:02 +0000 (Mon, 21 Jul 2008) Log Message: ----------- we want the final seq___finditem__ here Modified Paths: -------------- trunk/jython/src/org/python/core/PySequence.java Modified: trunk/jython/src/org/python/core/PySequence.java =================================================================== --- trunk/jython/src/org/python/core/PySequence.java 2008-07-21 05:00:49 UTC (rev 4980) +++ trunk/jython/src/org/python/core/PySequence.java 2008-07-21 19:10:02 UTC (rev 4981) @@ -143,7 +143,7 @@ if(i < 0) { return (i == -1) ? Py.True : Py.False; } - return __finditem__(i)._lt(o.__finditem__(i)); + return seq___finditem__(i)._lt(((PySequence)o).seq___finditem__(i)); } final synchronized PyObject seq___lt__(PyObject o) { @@ -158,7 +158,7 @@ if(i < 0) { return (i == -1 || i == -2) ? Py.True : Py.False; } - return __finditem__(i)._le(o.__finditem__(i)); + return seq___finditem__(i)._le(((PySequence)o).seq___finditem__(i)); } final synchronized PyObject seq___le__(PyObject o) { @@ -172,7 +172,7 @@ int i = cmp(this, -1, o, -1); if(i < 0) return (i == -3) ? Py.True : Py.False; - return __finditem__(i)._gt(o.__finditem__(i)); + return seq___finditem__(i)._gt(((PySequence)o).seq___finditem__(i)); } final synchronized PyObject seq___gt__(PyObject o) { @@ -187,7 +187,7 @@ if(i < 0) { return (i == -3 || i == -2) ? Py.True : Py.False; } - return __finditem__(i)._ge(o.__finditem__(i)); + return seq___finditem__(i)._ge(((PySequence)o).seq___finditem__(i)); } final synchronized PyObject seq___ge__(PyObject o) { @@ -289,7 +289,7 @@ } final PyObject seq___getitem__(PyObject index) { - PyObject ret = __finditem__(index); + PyObject ret = seq___finditem__(index); if(ret == null) { throw Py.IndexError("index out of range: " + index); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-11-23 00:18:20
|
Revision: 5604 http://jython.svn.sourceforge.net/jython/?rev=5604&view=rev Author: cgroves Date: 2008-11-23 00:18:15 +0000 (Sun, 23 Nov 2008) Log Message: ----------- Assume any instance of PySequence has an accurate __len__. See http://www.nabble.com/PySequenceList-and-fastSequence-td14977175.html Modified Paths: -------------- trunk/jython/src/org/python/core/PySequence.java Modified: trunk/jython/src/org/python/core/PySequence.java =================================================================== --- trunk/jython/src/org/python/core/PySequence.java 2008-11-22 23:30:45 UTC (rev 5603) +++ trunk/jython/src/org/python/core/PySequence.java 2008-11-23 00:18:15 UTC (rev 5604) @@ -4,12 +4,12 @@ /** * The abstract superclass of PyObjects that implements a Sequence. Minimize the work in creating * such objects. - * + * * Method names are designed to make it possible for subclasses of PySequence to implement * java.util.List. - * + * * Subclasses must also implement get, getslice, and repeat methods. - * + * * Subclasses that are mutable should also implement: set, setslice, del, and delRange. */ public abstract class PySequence extends PyObject { @@ -19,7 +19,7 @@ */ public PySequence() {} public int gListAllocatedStatus = -1; - + protected PySequence(PyType type) { super(type); } @@ -34,7 +34,7 @@ /** * Returns a range of elements from the sequence. - * + * * @param start * the position of the first element. * @param stop @@ -47,7 +47,7 @@ /** * Repeats the given sequence. - * + * * @param count * the number of times to repeat the sequence. * @return this sequence repeated count times. @@ -57,7 +57,7 @@ // These methods only apply to mutable sequences /** * Sets the given element of the sequence. - * + * * @param index * index of the element to set. * @param value @@ -217,9 +217,9 @@ } // Return a copy of a sequence where the __len__() method is - // telling the thruth. + // telling the truth. protected static PyObject fastSequence(PyObject seq, String msg) { - if(seq instanceof PyList || seq instanceof PyTuple) { + if(seq instanceof PySequence) { return seq; } PyList list = new PyList(); @@ -430,7 +430,7 @@ /** * Return sequence-specific error messages suitable for substitution. - * + * * {0} is the op name. {1} is the left operand type. {2} is the right operand type. */ protected String unsupportedopMessage(String op, PyObject o2) { @@ -442,7 +442,7 @@ /** * Return sequence-specific error messages suitable for substitution. - * + * * {0} is the op name. {1} is the left operand type. {2} is the right operand type. */ protected String runsupportedopMessage(String op, PyObject o2) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-02-16 15:41:52
|
Revision: 6036 http://jython.svn.sourceforge.net/jython/?rev=6036&view=rev Author: fwierzbicki Date: 2009-02-16 15:41:50 +0000 (Mon, 16 Feb 2009) Log Message: ----------- Useless double assignment. Modified Paths: -------------- trunk/jython/src/org/python/core/PySequence.java Modified: trunk/jython/src/org/python/core/PySequence.java =================================================================== --- trunk/jython/src/org/python/core/PySequence.java 2009-02-15 23:27:44 UTC (rev 6035) +++ trunk/jython/src/org/python/core/PySequence.java 2009-02-16 15:41:50 UTC (rev 6036) @@ -249,7 +249,7 @@ protected int boundToSequence(int index) { int length = __len__(); if(index < 0) { - index = index += length; + index += length; if(index < 0) { index = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-03 20:56:57
|
Revision: 6289 http://jython.svn.sourceforge.net/jython/?rev=6289&view=rev Author: pjenvey Date: 2009-05-03 20:56:51 +0000 (Sun, 03 May 2009) Log Message: ----------- refactor Modified Paths: -------------- trunk/jython/src/org/python/core/PySequence.java Modified: trunk/jython/src/org/python/core/PySequence.java =================================================================== --- trunk/jython/src/org/python/core/PySequence.java 2009-05-03 07:37:09 UTC (rev 6288) +++ trunk/jython/src/org/python/core/PySequence.java 2009-05-03 20:56:51 UTC (rev 6289) @@ -97,7 +97,7 @@ } final PyObject seq___eq__(PyObject o) { - if (getType() != o.getType() && !getType().isSubType(o.getType())) { + if (!isSubType(o)) { return null; } int tl = __len__(); @@ -115,7 +115,7 @@ } final PyObject seq___ne__(PyObject o) { - if (getType() != o.getType() && !getType().isSubType(o.getType())) { + if (!isSubType(o)) { return null; } int tl = __len__(); @@ -133,7 +133,7 @@ } final PyObject seq___lt__(PyObject o) { - if (getType() != o.getType() && !getType().isSubType(o.getType())) { + if (!isSubType(o)) { return null; } int i = cmp(this, -1, o, -1); @@ -149,7 +149,7 @@ } final PyObject seq___le__(PyObject o) { - if (getType() != o.getType() && !getType().isSubType(o.getType())) { + if (!isSubType(o)) { return null; } int i = cmp(this, -1, o, -1); @@ -165,7 +165,7 @@ } final PyObject seq___gt__(PyObject o) { - if (getType() != o.getType() && !getType().isSubType(o.getType())) { + if (!isSubType(o)) { return null; } int i = cmp(this, -1, o, -1); @@ -181,7 +181,7 @@ } final PyObject seq___ge__(PyObject o) { - if (getType() != o.getType() && !getType().isSubType(o.getType())) { + if (!isSubType(o)) { return null; } int i = cmp(this, -1, o, -1); @@ -192,6 +192,18 @@ } /** + * isSubType tailored for PySequence binops. + * + * @param other PyObject + * @return true if subclass of other + */ + protected boolean isSubType(PyObject other) { + PyType type = getType(); + PyType otherType = other.getType(); + return type == otherType || type.isSubType(otherType); + } + + /** * Compare the specified object/length pairs. * * @return value >= 0 is the index where the sequences differs. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |