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