From: <pj...@us...> - 2008-07-23 01:18:55
|
Revision: 4985 http://jython.svn.sourceforge.net/jython/?rev=4985&view=rev Author: pjenvey Date: 2008-07-23 01:18:53 +0000 (Wed, 23 Jul 2008) Log Message: ----------- o make Py.makeCharacter consisitent in never returning unicode unless it was asked for o move calculateIndex into PySequence for PyArray o allow PyLong.getLong access for PyArray Modified Paths: -------------- branches/asm/src/org/python/core/Py.java branches/asm/src/org/python/core/PyList.java branches/asm/src/org/python/core/PyLong.java branches/asm/src/org/python/core/PySequence.java Modified: branches/asm/src/org/python/core/Py.java =================================================================== --- branches/asm/src/org/python/core/Py.java 2008-07-21 19:48:17 UTC (rev 4984) +++ branches/asm/src/org/python/core/Py.java 2008-07-23 01:18:53 UTC (rev 4985) @@ -1441,8 +1441,8 @@ return makeCharacter(c, false); } - static final PyString makeCharacter(int codepoint, boolean explicitUnicode) { - if (explicitUnicode || codepoint > 255) { + static final PyString makeCharacter(int codepoint, boolean toUnicode) { + if (toUnicode) { return new PyUnicode(codepoint); } Modified: branches/asm/src/org/python/core/PyList.java =================================================================== --- branches/asm/src/org/python/core/PyList.java 2008-07-21 19:48:17 UTC (rev 4984) +++ branches/asm/src/org/python/core/PyList.java 2008-07-23 01:18:53 UTC (rev 4985) @@ -528,25 +528,6 @@ throw Py.ValueError(message); } - // This is closely related to fixindex in PySequence, but less strict - // fixindex returns -1 if index += length < 0 or if index >= length - // where this function returns 0 in former case and length in the latter. - // I think both are needed in different cases, but if this method turns - // out to be needed in other sequence subclasses, it should be moved to - // PySequence. - private int calculateIndex(int index) { - int length = size(); - if(index < 0) { - index = index += length; - if(index < 0) { - index = 0; - } - } else if(index > length) { - index = length; - } - return index; - } - /** * Insert the argument element into the list at the specified index. <br> * Same as <code>s[index:index] = [o] if index >= 0</code>. Modified: branches/asm/src/org/python/core/PyLong.java =================================================================== --- branches/asm/src/org/python/core/PyLong.java 2008-07-21 19:48:17 UTC (rev 4984) +++ branches/asm/src/org/python/core/PyLong.java 2008-07-23 01:18:53 UTC (rev 4985) @@ -182,11 +182,11 @@ } - private long getLong(long min, long max) { + public long getLong(long min, long max) { return getLong(min, max, "long int too large to convert"); } - private long getLong(long min, long max, String overflowMsg) { + public long getLong(long min, long max, String overflowMsg) { if (value.compareTo(maxLong) <= 0 && value.compareTo(minLong) >= 0) { long v = value.longValue(); if (v >= min && v <= max) Modified: branches/asm/src/org/python/core/PySequence.java =================================================================== --- branches/asm/src/org/python/core/PySequence.java 2008-07-21 19:48:17 UTC (rev 4984) +++ branches/asm/src/org/python/core/PySequence.java 2008-07-23 01:18:53 UTC (rev 4985) @@ -256,6 +256,20 @@ } } + // XXX: more appropriate naming of this vs fixindex + protected int calculateIndex(int index) { + int length = __len__(); + if(index < 0) { + index = index += length; + if(index < 0) { + index = 0; + } + } else if(index > length) { + index = length; + } + return index; + } + public PyObject __finditem__(int index) { return seq___finditem__(index); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |