From: <pj...@us...> - 2010-03-15 01:37:37
|
Revision: 6986 http://jython.svn.sourceforge.net/jython/?rev=6986&view=rev Author: pjenvey Date: 2010-03-15 01:37:30 +0000 (Mon, 15 Mar 2010) Log Message: ----------- coding standards, rename minLong -> MIN_LONG Modified Paths: -------------- trunk/jython/src/org/python/core/PyInteger.java trunk/jython/src/org/python/core/PyLong.java trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/modules/struct.java Modified: trunk/jython/src/org/python/core/PyInteger.java =================================================================== --- trunk/jython/src/org/python/core/PyInteger.java 2010-03-14 21:39:57 UTC (rev 6985) +++ trunk/jython/src/org/python/core/PyInteger.java 2010-03-15 01:37:30 UTC (rev 6986) @@ -21,11 +21,18 @@ public static final PyType TYPE = PyType.fromClass(PyInteger.class); /** The minimum value of an int represented by a BigInteger */ - public static final BigInteger minInt = BigInteger.valueOf(Integer.MIN_VALUE); + public static final BigInteger MIN_INT = BigInteger.valueOf(Integer.MIN_VALUE); /** The maximum value of an int represented by a BigInteger */ - public static final BigInteger maxInt = BigInteger.valueOf(Integer.MAX_VALUE); + public static final BigInteger MAX_INT = BigInteger.valueOf(Integer.MAX_VALUE); + /** @deprecated Use MIN_INT instead. */ + @Deprecated + public static final BigInteger minInt = MIN_INT; + /** @deprecated Use MAX_INT instead. */ + @Deprecated + public static final BigInteger maxInt = MAX_INT; + private int value; public PyInteger(PyType subType, int v) { Modified: trunk/jython/src/org/python/core/PyLong.java =================================================================== --- trunk/jython/src/org/python/core/PyLong.java 2010-03-14 21:39:57 UTC (rev 6985) +++ trunk/jython/src/org/python/core/PyLong.java 2010-03-15 01:37:30 UTC (rev 6986) @@ -21,11 +21,21 @@ public static final PyType TYPE = PyType.fromClass(PyLong.class); - public static final BigInteger minLong = BigInteger.valueOf(Long.MIN_VALUE); - public static final BigInteger maxLong = BigInteger.valueOf(Long.MAX_VALUE); - public static final BigInteger maxULong = + public static final BigInteger MIN_LONG = BigInteger.valueOf(Long.MIN_VALUE); + public static final BigInteger MAX_LONG = BigInteger.valueOf(Long.MAX_VALUE); + public static final BigInteger MAX_ULONG = BigInteger.valueOf(1).shiftLeft(64).subtract(BigInteger.valueOf(1)); + /** @deprecated Use MIN_INT instead. */ + @Deprecated + public static final BigInteger minLong = MIN_LONG; + /** @deprecated Use MAX_INT instead. */ + @Deprecated + public static final BigInteger maxLong = MAX_LONG; + /** @deprecated Use MAX_ULONG instead. */ + @Deprecated + public static final BigInteger maxULong = MAX_ULONG; + private BigInteger value; public PyLong(PyType subType, BigInteger v) { @@ -194,7 +204,7 @@ } public long getLong(long min, long max, String overflowMsg) { - if (value.compareTo(maxLong) <= 0 && value.compareTo(minLong) >= 0) { + if (value.compareTo(MAX_LONG) <= 0 && value.compareTo(MIN_LONG) >= 0) { long v = value.longValue(); if (v >= min && v <= max) { return v; @@ -853,7 +863,7 @@ @ExposedMethod(doc = BuiltinDocs.long___int___doc) final PyObject long___int__() { - if (value.compareTo(PyInteger.maxInt) <= 0 && value.compareTo(PyInteger.minInt) >= 0) { + if (value.compareTo(PyInteger.MAX_INT) <= 0 && value.compareTo(PyInteger.MIN_INT) >= 0) { return Py.newInteger(value.intValue()); } return long___long__(); @@ -960,8 +970,8 @@ @Override public int asIndex(PyObject err) { - boolean tooLow = value.compareTo(PyInteger.minInt) < 0; - boolean tooHigh = value.compareTo(PyInteger.maxInt) > 0; + boolean tooLow = value.compareTo(PyInteger.MIN_INT) < 0; + boolean tooHigh = value.compareTo(PyInteger.MAX_INT) > 0; if (tooLow || tooHigh) { if (err != null) { throw new PyException(err, "cannot fit 'long' into an index-sized integer"); Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2010-03-14 21:39:57 UTC (rev 6985) +++ trunk/jython/src/org/python/core/PyString.java 2010-03-15 01:37:30 UTC (rev 6986) @@ -1570,7 +1570,7 @@ bi = new BigInteger("-" + s, base); } else bi = new BigInteger(s, base); - if (bi.compareTo(PyInteger.maxInt) > 0 || bi.compareTo(PyInteger.minInt) < 0) { + if (bi.compareTo(PyInteger.MAX_INT) > 0 || bi.compareTo(PyInteger.MIN_INT) < 0) { throw Py.OverflowError("long int too large to convert to int"); } return bi.intValue(); Modified: trunk/jython/src/org/python/modules/struct.java =================================================================== --- trunk/jython/src/org/python/modules/struct.java 2010-03-14 21:39:57 UTC (rev 6985) +++ trunk/jython/src/org/python/modules/struct.java 2010-03-15 01:37:30 UTC (rev 6986) @@ -342,7 +342,7 @@ BigInteger get_ulong(PyObject value) { if (value instanceof PyLong){ BigInteger v = (BigInteger)value.__tojava__(BigInteger.class); - if (v.compareTo(PyLong.maxULong) > 0){ + if (v.compareTo(PyLong.MAX_ULONG) > 0){ throw StructError("unsigned long int too long to convert"); } return v; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |