You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Samuele P. <ped...@us...> - 2001-02-01 01:52:21
|
Update of /cvsroot/jython/jython/Demo/jreload/src In directory usw-pr-cvs1:/tmp/cvs-serv21472/src Log Message: Directory /cvsroot/jython/jython/Demo/jreload/src added to the repository |
From: Samuele P. <ped...@us...> - 2001-02-01 01:52:21
|
Update of /cvsroot/jython/jython/Demo/jreload/_xample In directory usw-pr-cvs1:/tmp/cvs-serv21472/_xample Log Message: Directory /cvsroot/jython/jython/Demo/jreload/_xample added to the repository |
From: Samuele P. <ped...@us...> - 2001-02-01 01:50:17
|
Update of /cvsroot/jython/jython/Demo/jreload In directory usw-pr-cvs1:/tmp/cvs-serv20832/jreload Log Message: Directory /cvsroot/jython/jython/Demo/jreload added to the repository |
From: Samuele P. <ped...@us...> - 2001-02-01 01:49:13
|
Update of /cvsroot/jython/jython/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20504 Modified Files: jreload.py Log Message: jreload typ fix Index: jreload.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/jreload.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** jreload.py 2001/01/17 02:24:00 1.2 --- jreload.py 2001/02/01 01:49:13 1.3 *************** *** 85,89 **** def makeLoadSet(name,path): ! if sys.modules.has_key('name'): return sys.modules[name] sys.modules[name] = ls = LoadSet(name,path) return ls --- 85,89 ---- def makeLoadSet(name,path): ! if sys.modules.has_key(name): return sys.modules[name] sys.modules[name] = ls = LoadSet(name,path) return ls |
From: Finn B. <bc...@us...> - 2001-01-31 13:39:22
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv15073 Modified Files: PyInstance.java PyObject.java PySequence.java PyString.java Log Message: Support for Rich Comparisons (pep-0207). Index: PyInstance.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyInstance.java,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** PyInstance.java 2001/01/31 13:34:35 2.14 --- PyInstance.java 2001/01/31 13:39:20 2.15 *************** *** 431,434 **** --- 431,458 ---- } + public PyObject __lt__(PyObject o) { + return invoke_ex("__lt__", o); + } + + public PyObject __le__(PyObject o) { + return invoke_ex("__le__", o); + } + + public PyObject __gt__(PyObject o) { + return invoke_ex("__gt__", o); + } + + public PyObject __ge__(PyObject o) { + return invoke_ex("__ge__", o); + } + + public PyObject __eq__(PyObject o) { + return invoke_ex("__eq__", o); + } + + public PyObject __ne__(PyObject o) { + return invoke_ex("__ne__", o); + } + public boolean __nonzero__() { PyObject ret = invoke_ex("__nonzero__"); Index: PyObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyObject.java,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** PyObject.java 2001/01/31 13:34:35 2.17 --- PyObject.java 2001/01/31 13:39:20 2.18 *************** *** 175,179 **** public boolean equals(Object ob_other) { return (ob_other instanceof PyObject) && ! _cmp((PyObject)ob_other) == 0; } --- 175,179 ---- public boolean equals(Object ob_other) { return (ob_other instanceof PyObject) && ! _eq((PyObject)ob_other).__nonzero__(); } *************** *** 825,828 **** --- 825,841 ---- + public PyObject __eq__(PyObject other) { return null; } + + public PyObject __ne__(PyObject other) { return null; } + + public PyObject __le__(PyObject other) { return null; } + + public PyObject __lt__(PyObject other) { return null; } + + public PyObject __ge__(PyObject other) { return null; } + + public PyObject __gt__(PyObject other) { return null; } + + /** Implements cmp(this, other) *************** *** 920,940 **** } public final PyObject _eq(PyObject o) { ! return _cmp(o) == 0 ? Py.One : Py.Zero; } public final PyObject _ne(PyObject o) { ! return _cmp(o) != 0 ? Py.One : Py.Zero; } public final PyObject _le(PyObject o) { ! return _cmp(o) <= 0 ? Py.One : Py.Zero; } public final PyObject _lt(PyObject o) { ! return _cmp(o) < 0 ? Py.One : Py.Zero; } public final PyObject _ge(PyObject o) { ! return _cmp(o) >= 0 ? Py.One : Py.Zero; } public final PyObject _gt(PyObject o) { ! return _cmp(o) > 0 ? Py.One : Py.Zero; } --- 933,1090 ---- } + + private final static PyObject check_recursion(ThreadState ts, PyObject o1, PyObject o2) { + PyDictionary stateDict = ts.getCompareStateDict(); + + PyObject pair = o1.make_pair(o2); + + if (stateDict.__finditem__(pair) != null) + return null; + + stateDict.__setitem__(pair, pair); + return pair; + } + + private final static void delete_token(ThreadState ts, PyObject token) { + if (token == null) + return; + PyDictionary stateDict = ts.getCompareStateDict(); + + stateDict.__delitem__(token); + } + + public final PyObject _eq(PyObject o) { ! PyObject token = null; ! ! ThreadState ts = Py.getThreadState(); ! try { ! if (++ts.compareStateNesting > 10) { ! if ((token = check_recursion(ts, this, o)) == null) ! return Py.One; ! } ! PyObject res = __eq__(o); ! if (res != null) ! return res; ! res = o.__eq__(this); ! if (res != null) ! return res; ! return _cmp_unsafe(o) == 0 ? Py.One : Py.Zero; ! } finally { ! delete_token(ts, token); ! ts.compareStateNesting--; ! } } + + public final PyObject _ne(PyObject o) { ! PyObject token = null; ! ! ThreadState ts = Py.getThreadState(); ! try { ! if (++ts.compareStateNesting > 10) { ! if ((token = check_recursion(ts, this, o)) == null) ! return Py.Zero; ! } ! PyObject res = __ne__(o); ! if (res != null) ! return res; ! res = o.__ne__(this); ! if (res != null) ! return res; ! return _cmp_unsafe(o) != 0 ? Py.One : Py.Zero; ! } finally { ! delete_token(ts, token); ! ts.compareStateNesting--; ! } } + public final PyObject _le(PyObject o) { ! PyObject token = null; ! ! ThreadState ts = Py.getThreadState(); ! try { ! if (++ts.compareStateNesting > 10) { ! if ((token = check_recursion(ts, this, o)) == null) ! throw Py.ValueError("can't order recursive values"); ! } ! PyObject res = __le__(o); ! if (res != null) ! return res; ! res = o.__ge__(this); ! if (res != null) ! return res; ! return _cmp_unsafe(o) <= 0 ? Py.One : Py.Zero; ! } finally { ! delete_token(ts, token); ! ts.compareStateNesting--; ! } } + public final PyObject _lt(PyObject o) { ! PyObject token = null; ! ! ThreadState ts = Py.getThreadState(); ! try { ! if (++ts.compareStateNesting > 10) { ! if ((token = check_recursion(ts, this, o)) == null) ! throw Py.ValueError("can't order recursive values"); ! } ! PyObject res = __lt__(o); ! if (res != null) ! return res; ! res = o.__gt__(this); ! if (res != null) ! return res; ! return _cmp_unsafe(o) < 0 ? Py.One : Py.Zero; ! } finally { ! delete_token(ts, token); ! ts.compareStateNesting--; ! } } + public final PyObject _ge(PyObject o) { ! PyObject token = null; ! ! ThreadState ts = Py.getThreadState(); ! try { ! if (++ts.compareStateNesting > 10) { ! if ((token = check_recursion(ts, this, o)) == null) ! throw Py.ValueError("can't order recursive values"); ! } ! PyObject res = __ge__(o); ! if (res != null) ! return res; ! res = o.__le__(this); ! if (res != null) ! return res; ! return _cmp_unsafe(o) >= 0 ? Py.One : Py.Zero; ! } finally { ! delete_token(ts, token); ! ts.compareStateNesting--; ! } } + public final PyObject _gt(PyObject o) { ! PyObject token = null; ! ! ThreadState ts = Py.getThreadState(); ! try { ! if (++ts.compareStateNesting > 10) { ! if ((token = check_recursion(ts, this, o)) == null) ! throw Py.ValueError("can't order recursive values"); ! } ! PyObject res = __gt__(o); ! if (res != null) ! return res; ! res = o.__lt__(this); ! if (res != null) ! return res; ! return _cmp_unsafe(o) > 0 ? Py.One : Py.Zero; ! } finally { ! delete_token(ts, token); ! ts.compareStateNesting--; ! } ! } *************** *** 942,945 **** --- 1092,1096 ---- return this == o ? Py.One : Py.Zero; } + public PyObject _isnot(PyObject o) { return this != o ? Py.One : Py.Zero; Index: PySequence.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PySequence.java,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -r2.13 -r2.14 *** PySequence.java 2001/01/31 13:34:35 2.13 --- PySequence.java 2001/01/31 13:39:20 2.14 *************** *** 185,204 **** } ! public synchronized int __cmp__(PyObject ob_other) { ! if (ob_other.__class__ != __class__) ! return -2; ! ! PySequence other = (PySequence)ob_other; ! int s1 = __len__(); ! int s2 = other.__len__(); ! int len = (s1 > s2) ? s2 : s1; ! ! for (int i=0; i<len; i++) { ! int c = get(i)._cmp(other.get(i)); ! if (c != 0) ! return c; } ! return s1 < s2 ? -1 : (s1 > s2 ? 1: 0); } // Return a copy of a sequence where the __len__() method is --- 185,265 ---- } ! public synchronized PyObject __eq__(PyObject o) { ! if (o.__class__ != __class__) ! return null; ! int tl = __len__(); ! int ol = o.__len__(); ! if (tl != ol) ! return Py.Zero; ! int i = cmp(this, tl, o, ol); ! return (i < 0) ? Py.One : Py.Zero; ! } ! ! public synchronized PyObject __ne__(PyObject o) { ! if (o.__class__ != __class__) ! return null; ! int tl = __len__(); ! int ol = o.__len__(); ! if (tl != ol) ! return Py.One; ! int i = cmp(this, tl, o, ol); ! return (i < 0) ? Py.Zero : Py.One; ! } ! ! public synchronized PyObject __lt__(PyObject o) { ! if (o.__class__ != __class__) ! return null; ! int i = cmp(this, -1, o, -1); ! if (i < 0) ! return (i == -1) ? Py.One : Py.Zero; ! return __finditem__(i)._lt(o.__finditem__(i)); ! } ! ! public synchronized PyObject __le__(PyObject o) { ! if (o.__class__ != __class__) ! return null; ! int i = cmp(this, -1, o, -1); ! if (i < 0) ! return (i == -1 || i == -2) ? Py.One : Py.Zero; ! return __finditem__(i)._le(o.__finditem__(i)); ! } ! ! public synchronized PyObject __gt__(PyObject o) { ! if (o.__class__ != __class__) ! return null; ! int i = cmp(this, -1, o, -1); ! if (i < 0) ! return (i == -3) ? Py.One : Py.Zero; ! return __finditem__(i)._gt(o.__finditem__(i)); ! } ! ! public synchronized PyObject __ge__(PyObject o) { ! if (o.__class__ != __class__) ! return null; ! int i = cmp(this, -1, o, -1); ! if (i < 0) ! return (i == -3 || i == -2) ? Py.One : Py.Zero; ! return __finditem__(i)._ge(o.__finditem__(i)); ! } ! ! // Return value >= 0 is the index where the sequences differs. ! // -1: reached the end of o1 without a difference ! // -2: reached the end of both seqeunces without a difference ! // -3: reached the end of o2 without a difference ! private static int cmp(PyObject o1, int ol1, PyObject o2, int ol2) { ! if (ol1 < 0) ! ol1 = o1.__len__(); ! if (ol2 < 0) ! ol2 = o2.__len__(); ! int i = 0; ! for ( ; i < ol1 && i < ol2; i++) { ! if (!o1.__getitem__(i)._eq(o2.__getitem__(i)).__nonzero__()) ! return i; } ! if (ol1 == ol2) ! return -2; ! return (ol1 < ol2) ? -1 : -3; } + // Return a copy of a sequence where the __len__() method is Index: PyString.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyString.java,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -r2.34 -r2.35 *** PyString.java 2001/01/21 16:21:36 2.34 --- PyString.java 2001/01/31 13:39:20 2.35 *************** *** 558,561 **** --- 558,609 ---- } + public PyObject __eq__(PyObject other) { + String s = coerce(other); + if (s == null) + return null; + return string.equals(s) ? Py.One : Py.Zero; + } + + public PyObject __ne__(PyObject other) { + String s = coerce(other); + if (s == null) + return null; + return string.equals(s) ? Py.Zero : Py.One; + } + + public PyObject __lt__(PyObject other) { + String s = coerce(other); + if (s == null) + return null; + return string.compareTo(s) < 0 ? Py.One : Py.Zero; + } + + public PyObject __le__(PyObject other) { + String s = coerce(other); + if (s == null) + return null; + return string.compareTo(s) <= 0 ? Py.One : Py.Zero; + } + + public PyObject __gt__(PyObject other) { + String s = coerce(other); + if (s == null) + return null; + return string.compareTo(s) > 0 ? Py.One : Py.Zero; + } + + public PyObject __ge__(PyObject other) { + String s = coerce(other); + if (s == null) + return null; + return string.compareTo(s) >= 0 ? Py.One : Py.Zero; + } + + private static String coerce(PyObject o) { + if (o instanceof PyString) + return o.toString(); + return null; + } + public int hashCode() { if (cached_hashcode == 0) |
From: Finn B. <bc...@us...> - 2001-01-31 13:34:37
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv14267 Modified Files: PyComplex.java PyFloat.java PyInteger.java PyLong.java PyInstance.java PyNone.java PyObject.java PyList.java PySequence.java Log Message: Support for the reworked Coercion Model (pep-0208). Index: PyComplex.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyComplex.java,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** PyComplex.java 1999/05/17 19:59:38 2.1 --- PyComplex.java 2001/01/31 13:34:34 2.2 *************** *** 7,14 **** static PyComplex J = new PyComplex(0, 1.); - public static PyClass __class__; - public PyComplex(double r, double i) { - super(__class__); real = r; imag = i; --- 7,11 ---- *************** *** 89,143 **** } ! public PyObject __add__(PyObject o) { ! PyComplex c = (PyComplex)o; return new PyComplex(real+c.real, imag+c.imag); } ! public PyObject __sub__(PyObject o) { ! PyComplex c = (PyComplex)o; ! return new PyComplex(real-c.real, imag-c.imag); } ! public PyObject __mul__(PyObject o) { ! PyComplex c = (PyComplex)o; ! return new PyComplex(real*c.real-imag*c.imag, real*c.imag+imag*c.real); } ! public PyObject __div__(PyObject o) { ! PyComplex c = (PyComplex)o; ! double denom = c.real*c.real+c.imag*c.imag; if (denom == 0) throw Py.ZeroDivisionError("complex division"); ! return new PyComplex((real*c.real + imag*c.imag)/denom, ! (imag*c.real - real*c.imag)/denom); } ! public PyObject __mod__(PyObject o) { ! PyComplex z = (PyComplex)__div__(o); z.real = Math.floor(z.real); z.imag = 0.0; ! return __sub__(z.__mul__(o)); } ! public PyObject __divmod__(PyObject o) { ! PyComplex z = (PyComplex)__div__(o); z.real = Math.floor(z.real); z.imag = 0.0; ! return new PyTuple(new PyObject[] {z, __sub__(z.__mul__(o))}); } ! private PyObject ipow(int iexp) { int pow = iexp; if (pow < 0) pow = -pow; ! double xr = real; ! double xi = imag; double zr = 1; --- 86,222 ---- } + private final boolean canCoerce(PyObject other) { + return other instanceof PyComplex || + other instanceof PyFloat || + other instanceof PyInteger || + other instanceof PyLong; + } + + private final PyComplex coerce(PyObject other) { + if (other instanceof PyComplex) + return (PyComplex) other; + if (other instanceof PyFloat) + return new PyComplex(((PyFloat)other).getValue(), 0); + if (other instanceof PyInteger) + return new PyComplex((double)((PyInteger)other).getValue(), 0); + if (other instanceof PyLong) + return new PyComplex(((PyLong)other).doubleValue(), 0); + throw Py.TypeError("xxx"); + } ! public PyObject __add__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! PyComplex c = coerce(right); return new PyComplex(real+c.real, imag+c.imag); } + + public PyObject __radd__(PyObject left) { + return __add__(left); + } + + private final static PyObject _sub(PyComplex o1, PyComplex o2) { + return new PyComplex(o1.real-o2.real, o1.imag-o2.imag); + } + + public PyObject __sub__(PyObject right) { + if (!canCoerce(right)) + return null; + return _sub(this, coerce(right)); + } + + public PyObject __rsub__(PyObject left) { + if (!canCoerce(left)) + return null; + return _sub(coerce(left), this); + } ! private final static PyObject _mul(PyComplex o1, PyComplex o2) { ! return new PyComplex(o1.real*o2.real-o1.imag*o2.imag, ! o1.real*o2.imag+o1.imag*o2.real); } ! public PyObject __mul__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return _mul(this, coerce(right)); } ! public PyObject __rmul__(PyObject left) { ! if (!canCoerce(left)) ! return null; ! return _mul(coerce(left), this); ! } ! ! private final static PyObject _div(PyComplex o1, PyComplex o2) { ! double denom = o2.real*o2.real+o2.imag*o2.imag; if (denom == 0) throw Py.ZeroDivisionError("complex division"); ! return new PyComplex((o1.real*o2.real + o1.imag*o2.imag)/denom, ! (o1.imag*o2.real - o1.real*o2.imag)/denom); ! } ! ! public PyObject __div__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return _div(this, coerce(right)); ! } ! ! public PyObject __rdiv__(PyObject left) { ! if (!canCoerce(left)) ! return null; ! return _div(coerce(left), this); } + + public PyObject __mod__(PyObject right) { + if (!canCoerce(right)) + return null; + return _mod(this, coerce(right)); + } + + public PyObject __rmod__(PyObject left) { + if (!canCoerce(left)) + return null; + return _mod(coerce(left), this); + } ! private static PyObject _mod(PyComplex value, PyComplex right) { ! PyComplex z = (PyComplex)value.__div__(right); z.real = Math.floor(z.real); z.imag = 0.0; ! return value.__sub__(z.__mul__(right)); } ! public PyObject __divmod__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return _divmod(this, coerce(right)); ! } ! ! public PyObject __rdivmod__(PyObject left) { ! if (!canCoerce(left)) ! return null; ! return _divmod(coerce(left), this); ! } + private static PyObject _divmod(PyComplex value, PyComplex right) { + PyComplex z = (PyComplex)value.__div__(right); + z.real = Math.floor(z.real); z.imag = 0.0; ! return new PyTuple(new PyObject[] {z, value.__sub__(z.__mul__(right))}); } ! private static PyObject ipow(PyComplex value, int iexp) { int pow = iexp; if (pow < 0) pow = -pow; ! double xr = value.real; ! double xi = value.imag; double zr = 1; *************** *** 171,179 **** throw Py.ValueError("complex modulo"); } ! ! double xr = real; ! double xi = imag; ! double yr = ((PyComplex)right).real; ! double yi = ((PyComplex)right).imag; if (yr == 0 && yi == 0) { --- 250,269 ---- throw Py.ValueError("complex modulo"); } ! if (!canCoerce(right)) ! return null; ! return _pow(this, coerce(right)); ! } ! ! public PyObject __rpow__(PyObject left) { ! if (!canCoerce(left)) ! return null; ! return _pow(coerce(left), this); ! } ! ! public static PyObject _pow(PyComplex value, PyComplex right) { ! double xr = value.real; ! double xi = value.imag; ! double yr = right.real; ! double yi = right.imag; if (yr == 0 && yi == 0) { *************** *** 190,194 **** int iexp = (int)yr; if (yi == 0 && yr == (double)iexp && iexp >= -128 && iexp <= 128) { ! return ipow(iexp); } --- 280,284 ---- int iexp = (int)yr; if (yi == 0 && yr == (double)iexp && iexp >= -128 && iexp <= 128) { ! return ipow(value, iexp); } *************** *** 236,239 **** --- 326,339 ---- public PyComplex conjugate() { return new PyComplex(real, -imag); + } + + public boolean isMappingType() { return false; } + public boolean isSequenceType() { return false; } + + // __class__ boilerplate -- see PyObject for details + public static PyClass __class__; + + protected PyClass getPyClass() { + return __class__; } } Index: PyFloat.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyFloat.java,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** PyFloat.java 2000/12/11 18:39:45 2.3 --- PyFloat.java 2001/01/31 13:34:35 2.4 *************** *** 90,113 **** } public PyObject __add__(PyObject right) { ! return new PyFloat(value+((PyFloat)right).value); } public PyObject __sub__(PyObject right) { ! return new PyFloat(value-((PyFloat)right).value); } public PyObject __mul__(PyObject right) { ! return new PyFloat(value*((PyFloat)right).value); } public PyObject __div__(PyObject right) { ! double y = ((PyFloat)right).value; ! if (y == 0) throw Py.ZeroDivisionError("float division"); ! return new PyFloat(value/y); } ! private double modulo(double x, double y) { if (y == 0) throw Py.ZeroDivisionError("float modulo"); --- 90,166 ---- } + private static final boolean canCoerce(PyObject other) { + return other instanceof PyFloat || other instanceof PyInteger || + other instanceof PyLong; + } + + private static final double coerce(PyObject other) { + if (other instanceof PyFloat) + return ((PyFloat) other).value; + else if (other instanceof PyInteger) + return ((PyInteger) other).getValue(); + else if (other instanceof PyLong) + return ((PyLong) other).doubleValue(); + else + throw Py.TypeError("xxx"); + } + + + public PyObject __add__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! double rightv = coerce(right); ! return new PyFloat(value + rightv); } + public PyObject __radd__(PyObject left) { + return __add__(left); + } + public PyObject __sub__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! double rightv = coerce(right); ! return new PyFloat(value - rightv); } + public PyObject __rsub__(PyObject left) { + if (!canCoerce(left)) + return null; + double leftv = coerce(left); + return new PyFloat(leftv - value); + } + public PyObject __mul__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! double rightv = coerce(right); ! return new PyFloat(value * rightv); ! } ! ! public PyObject __rmul__(PyObject left) { ! return __mul__(left); } public PyObject __div__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! double rightv = coerce(right); ! if (rightv == 0) ! throw Py.ZeroDivisionError("float division"); ! return new PyFloat(value / rightv); ! } ! ! public PyObject __rdiv__(PyObject left) { ! if (!canCoerce(left)) ! return null; ! double leftv = coerce(left); ! if (value == 0) throw Py.ZeroDivisionError("float division"); ! return new PyFloat(leftv / value); } ! private static double modulo(double x, double y) { if (y == 0) throw Py.ZeroDivisionError("float modulo"); *************** *** 119,143 **** public PyObject __mod__(PyObject right) { ! return new PyFloat(modulo(value, ((PyFloat)right).value)); } public PyObject __divmod__(PyObject right) { ! double y = ((PyFloat)right).value; ! if (y == 0) throw Py.ZeroDivisionError("float division"); ! double z = Math.floor(value/y); return new PyTuple( ! new PyObject[] {new PyFloat(z), new PyFloat(value-z*y)} ); } public PyObject __pow__(PyObject right, PyObject modulo) { ! // Rely completely on Java's pow function ! double iw = ((PyFloat)right).value; if (iw == 0) { if (modulo != null) ! return new PyFloat(modulo(1.0, ((PyFloat)modulo).value)); return new PyFloat(1.0); } --- 172,239 ---- public PyObject __mod__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! double rightv = coerce(right); ! return new PyFloat(modulo(value, rightv)); } + public PyObject __rmod__(PyObject left) { + if (!canCoerce(left)) + return null; + double leftv = coerce(left); + return new PyFloat(modulo(leftv, value)); + } + public PyObject __divmod__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! double rightv = coerce(right); ! ! if (rightv == 0) throw Py.ZeroDivisionError("float division"); ! double z = Math.floor(value / rightv); return new PyTuple( ! new PyObject[] {new PyFloat(z), new PyFloat(value-z*rightv)} ); } + public PyObject __rdivmod__(PyObject left) { + if (!canCoerce(left)) + return null; + double leftv = coerce(left); + + if (value == 0) + throw Py.ZeroDivisionError("float division"); + double z = Math.floor(leftv / value); + + return new PyTuple( + new PyObject[] {new PyFloat(z), new PyFloat(leftv-z*value)} + ); + } + + public PyObject __pow__(PyObject right, PyObject modulo) { ! if (!canCoerce(right)) ! return null; ! if (modulo != null && !canCoerce(modulo)) ! return null; ! ! return _pow(value, coerce(right), modulo); ! } ! ! public PyObject __rpow__(PyObject left) { ! if (!canCoerce(left)) ! return null; ! ! return _pow(coerce(left), value, null); ! } ! ! private static PyFloat _pow(double value, double iw, PyObject modulo) { ! // Rely completely on Java's pow function if (iw == 0) { if (modulo != null) ! return new PyFloat(modulo(1.0, coerce(modulo))); return new PyFloat(1.0); } *************** *** 152,156 **** return new PyFloat(ret); } else { ! return new PyFloat(modulo(ret, ((PyFloat)modulo).value)); } } --- 248,252 ---- return new PyFloat(ret); } else { ! return new PyFloat(modulo(ret, coerce(modulo))); } } *************** *** 188,191 **** --- 284,297 ---- public PyComplex __complex__() { return new PyComplex(value, 0.); + } + + public boolean isMappingType() { return false; } + public boolean isSequenceType() { return false; } + + // __class__ boilerplate -- see PyObject for details + public static PyClass __class__; + + protected PyClass getPyClass() { + return __class__; } } Index: PyInteger.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyInteger.java,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** PyInteger.java 2000/12/11 18:39:45 2.5 --- PyInteger.java 2001/01/31 13:34:35 2.6 *************** *** 65,89 **** } public PyObject __add__(PyObject right) { int a = value; ! int b = ((PyInteger)right).value; int x = a + b; if ((x^a) < 0 && (x^b) < 0) throw Py.OverflowError("integer addition: "+this+" + "+right); ! return Py.newInteger(x); //new PyInteger(x); } ! public PyObject __sub__(PyObject right) { ! int a = value; ! int b = ((PyInteger)right).value; int x = a - b; if ((x^a) < 0 && (x^~b) < 0) ! throw Py.OverflowError("integer subtraction: "+this+" - "+right); return Py.newInteger(x); } public PyObject __mul__(PyObject right) { double x = (double)value; ! x *= ((PyInteger)right).value; //long x = ((long)value)*((PyInteger)right).value; //System.out.println("mul: "+this+" * "+right+" = "+x); --- 65,124 ---- } + private static final boolean canCoerce(PyObject other) { + return other instanceof PyInteger; + } + + private static final int coerce(PyObject other) { + if (other instanceof PyInteger) + return ((PyInteger) other).value; + else + throw Py.TypeError("xxx"); + } + + public PyObject __add__(PyObject right) { + if (!canCoerce(right)) + return null; + int rightv = coerce(right); int a = value; ! int b = rightv; int x = a + b; if ((x^a) < 0 && (x^b) < 0) throw Py.OverflowError("integer addition: "+this+" + "+right); ! return Py.newInteger(x); ! } ! public PyObject __radd__(PyObject left) { ! return __add__(left); } ! private static PyInteger _sub(int a, int b) { int x = a - b; if ((x^a) < 0 && (x^~b) < 0) ! throw Py.OverflowError("integer subtraction: "+a+" - "+b); return Py.newInteger(x); } + public PyObject __sub__(PyObject right) { + if (!canCoerce(right)) + return null; + return _sub(value, coerce(right)); + } + + public PyObject __rsub__(PyObject left) { + if (!canCoerce(left)) + return null; + return _sub(coerce(left), value); + } + public PyObject __mul__(PyObject right) { + if (right instanceof PySequence) + return ((PySequence) right).repeat(value); + + if (!canCoerce(right)) + return null; + int rightv = coerce(right); + double x = (double)value; ! x *= rightv; //long x = ((long)value)*((PyInteger)right).value; //System.out.println("mul: "+this+" * "+right+" = "+x); *************** *** 95,101 **** } // Getting signs correct for integer division // This convention makes sense when you consider it in tandem with modulo ! private int divide(int x, int y) { if (y == 0) throw Py.ZeroDivisionError("integer division or modulo"); --- 130,140 ---- } + public PyObject __rmul__(PyObject left) { + return __mul__(left); + } + // Getting signs correct for integer division // This convention makes sense when you consider it in tandem with modulo ! private static int divide(int x, int y) { if (y == 0) throw Py.ZeroDivisionError("integer division or modulo"); *************** *** 112,139 **** public PyObject __div__(PyObject right) { ! return Py.newInteger(divide(value, ((PyInteger)right).value)); } ! private int modulo(int x, int y, int xdivy) { return x - xdivy*y; } public PyObject __mod__(PyObject right) { ! int x = ((PyInteger)right).value; ! return Py.newInteger(modulo(value, x, divide(value, x))); } public PyObject __divmod__(PyObject right) { ! int x = ((PyInteger)right).value; ! int xdivy = divide(value, x); return new PyTuple(new PyObject[] { new PyInteger(xdivy), ! new PyInteger(modulo(value, x, xdivy)) }); } public PyObject __pow__(PyObject right, PyObject modulo) { int mod = 0; - int pow = ((PyInteger)right).value; long tmp = value; boolean neg = false; --- 151,217 ---- public PyObject __div__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return Py.newInteger(divide(value, coerce(right))); } ! public PyObject __rdiv__(PyObject left) { ! if (!canCoerce(left)) ! return null; ! return Py.newInteger(divide(coerce(left), value)); ! } ! ! private static int modulo(int x, int y, int xdivy) { return x - xdivy*y; } public PyObject __mod__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! int rightv = coerce(right); ! return Py.newInteger(modulo(value, rightv, divide(value, rightv))); } + public PyObject __rmod__(PyObject left) { + if (!canCoerce(left)) + return null; + int leftv = coerce(left); + return Py.newInteger(modulo(leftv, value, divide(leftv, value))); + } + public PyObject __divmod__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! int rightv = coerce(right); ! ! int xdivy = divide(value, rightv); return new PyTuple(new PyObject[] { new PyInteger(xdivy), ! new PyInteger(modulo(value, rightv, xdivy)) }); } public PyObject __pow__(PyObject right, PyObject modulo) { + if (!canCoerce(right)) + return null; + + if (modulo != null && !canCoerce(modulo)) + return null; + + return _pow(value, coerce(right), modulo); + } + + public PyObject __rpow__(PyObject left, PyObject modulo) { + if (!canCoerce(left)) + return null; + + if (modulo != null && !canCoerce(modulo)) + return null; + + return _pow(coerce(left), value, modulo); + } + + private static PyInteger _pow(int value, int pow, PyObject modulo) { int mod = 0; long tmp = value; boolean neg = false; *************** *** 152,156 **** if (modulo != null) { ! mod = ((PyInteger)modulo).value; if (mod == 0) { throw Py.ValueError("pow(x, y, z) with z==0"); --- 230,234 ---- if (modulo != null) { ! mod = coerce(modulo); if (mod == 0) { throw Py.ValueError("pow(x, y, z) with z==0"); *************** *** 196,219 **** public PyObject __lshift__(PyObject right) { ! int shift = ((PyInteger)right).value; ! if (shift > 31) return new PyInteger(0); ! return Py.newInteger(value << shift); } public PyObject __rshift__(PyObject right) { ! return Py.newInteger(value >>> ((PyInteger)right).value); } public PyObject __and__(PyObject right) { ! return Py.newInteger(value & ((PyInteger)right).value); } public PyObject __xor__(PyObject right) { ! return Py.newInteger(value ^ ((PyInteger)right).value); } public PyObject __or__(PyObject right) { ! return Py.newInteger(value | ((PyInteger)right).value); } --- 274,326 ---- public PyObject __lshift__(PyObject right) { ! int rightv; ! if (right instanceof PyInteger) ! rightv = ((PyInteger)right).value; ! else ! return null; ! ! if (rightv > 31) return new PyInteger(0); ! return Py.newInteger(value << rightv); } public PyObject __rshift__(PyObject right) { ! int rightv; ! if (right instanceof PyInteger) ! rightv = ((PyInteger)right).value; ! else ! return null; ! ! return Py.newInteger(value >>> rightv); } public PyObject __and__(PyObject right) { ! int rightv; ! if (right instanceof PyInteger) ! rightv = ((PyInteger)right).value; ! else ! return null; ! ! return Py.newInteger(value & rightv); } public PyObject __xor__(PyObject right) { ! int rightv; ! if (right instanceof PyInteger) ! rightv = ((PyInteger)right).value; ! else ! return null; ! ! return Py.newInteger(value ^ rightv); } public PyObject __or__(PyObject right) { ! int rightv; ! if (right instanceof PyInteger) ! rightv = ((PyInteger)right).value; ! else ! return null; ! ! return Py.newInteger(value | rightv); } Index: PyLong.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyLong.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** PyLong.java 2000/12/20 13:44:43 2.6 --- PyLong.java 2001/01/31 13:34:35 2.7 *************** *** 109,122 **** } public PyObject __add__(PyObject right) { ! return new PyLong(value.add(((PyLong)right).value)); } public PyObject __sub__(PyObject right) { ! return new PyLong(value.subtract(((PyLong)right).value)); } public PyObject __mul__(PyObject right) { ! return new PyLong(value.multiply(((PyLong)right).value)); } --- 109,161 ---- } + private static final boolean canCoerce(PyObject other) { + return other instanceof PyLong || other instanceof PyInteger; + } + + private static final BigInteger coerce(PyObject other) { + if (other instanceof PyLong) + return ((PyLong) other).value; + else if (other instanceof PyInteger) + return java.math.BigInteger.valueOf(((PyInteger) other).getValue()); + else + throw Py.TypeError("xxx"); + } + + public PyObject __add__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return new PyLong(value.add(coerce(right))); } + public PyObject __radd__(PyObject left) { + return __add__(left); + } + public PyObject __sub__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return new PyLong(value.subtract(coerce(right))); ! } ! ! public PyObject __rsub__(PyObject left) { ! return new PyLong(coerce(left).subtract(value)); } public PyObject __mul__(PyObject right) { ! if (right instanceof PySequence) ! return ((PySequence) right).repeat(coerceInt(this)); ! ! if (!canCoerce(right)) ! return null; ! return new PyLong(value.multiply(coerce(right))); ! } ! ! public PyObject __rmul__(PyObject left) { ! if (left instanceof PySequence) ! return ((PySequence) left).repeat(coerceInt(this)); ! if (!canCoerce(left)) ! return null; ! return new PyLong(coerce(left).multiply(value)); } *************** *** 139,143 **** public PyObject __div__(PyObject right) { ! return new PyLong(divide(value, ((PyLong)right).value)); } --- 178,190 ---- public PyObject __div__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return new PyLong(divide(value, coerce(right))); ! } ! ! public PyObject __rdiv__(PyObject left) { ! if (!canCoerce(left)) ! return null; ! return new PyLong(divide(coerce(left), value)); } *************** *** 147,165 **** public PyObject __mod__(PyObject right) { ! BigInteger y = ((PyLong)right).value; ! return new PyLong(modulo(value, y, divide(value, y))); } public PyObject __divmod__(PyObject right) { ! BigInteger y = ((PyLong)right).value; ! BigInteger xdivy = divide(value, y); return new PyTuple(new PyObject[] { new PyLong(xdivy), ! new PyLong(modulo(value, y, xdivy)) }); } public PyObject __pow__(PyObject right, PyObject modulo) { ! BigInteger y = ((PyLong)right).value; if (y.compareTo(BigInteger.valueOf(0)) < 0) { if (value.compareTo(BigInteger.valueOf(0)) != 0) --- 194,250 ---- public PyObject __mod__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! BigInteger rightv = coerce(right); ! return new PyLong(modulo(value, rightv, divide(value, rightv))); } + public PyObject __rmod__(PyObject left) { + if (!canCoerce(left)) + return null; + BigInteger leftv = coerce(left); + return new PyLong(modulo(leftv, value, divide(leftv, value))); + } + public PyObject __divmod__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! BigInteger rightv = coerce(right); ! ! BigInteger xdivy = divide(value, rightv); return new PyTuple(new PyObject[] { new PyLong(xdivy), ! new PyLong(modulo(value, rightv, xdivy)) }); } + public PyObject __rdivmod__(PyObject left) { + if (!canCoerce(left)) + return null; + BigInteger leftv = coerce(left); + + BigInteger xdivy = divide(leftv, value); + return new PyTuple(new PyObject[] { + new PyLong(xdivy), + new PyLong(modulo(leftv, value, xdivy)) + }); + } + public PyObject __pow__(PyObject right, PyObject modulo) { ! if (!canCoerce(right)) ! return null; ! ! if (modulo != null && !canCoerce(right)) ! return null; ! return _pow(value, coerce(right), modulo); ! } ! ! public PyObject __rpow__(PyObject left) { ! if (!canCoerce(left)) ! return null; ! return _pow(coerce(left), value, null); ! } ! ! public static PyLong _pow(BigInteger value, BigInteger y, PyObject modulo) { if (y.compareTo(BigInteger.valueOf(0)) < 0) { if (value.compareTo(BigInteger.valueOf(0)) != 0) *************** *** 174,178 **** // are fixed by SUN ! BigInteger z = ((PyLong)modulo).value; int zi = z.intValue(); // Clear up some special cases right away --- 259,263 ---- // are fixed by SUN ! BigInteger z = coerce(modulo); int zi = z.intValue(); // Clear up some special cases right away *************** *** 203,224 **** } public PyObject __lshift__(PyObject right) { ! return new PyLong(value.shiftLeft(((PyLong)right).value.intValue())); } public PyObject __rshift__(PyObject right) { ! return new PyLong(value.shiftRight(((PyLong)right).value.intValue())); } public PyObject __and__(PyObject right) { ! return new PyLong(value.and(((PyLong)right).value)); } public PyObject __xor__(PyObject right) { ! return new PyLong(value.xor(((PyLong)right).value)); } public PyObject __or__(PyObject right) { ! return new PyLong(value.or(((PyLong)right).value)); } --- 288,328 ---- } + private static final int coerceInt(PyObject other) { + if (other instanceof PyLong) + return (int) ((PyLong) other).getLong(Integer.MIN_VALUE, Integer.MAX_VALUE); + else if (other instanceof PyInteger) + return ((PyInteger) other).getValue(); + else + throw Py.TypeError("xxx"); + } + public PyObject __lshift__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return new PyLong(value.shiftLeft(coerceInt(right))); } public PyObject __rshift__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return new PyLong(value.shiftRight(coerceInt(right))); } public PyObject __and__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return new PyLong(value.and(coerce(right))); } public PyObject __xor__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return new PyLong(value.xor(coerce(right))); } public PyObject __or__(PyObject right) { ! if (!canCoerce(right)) ! return null; ! return new PyLong(value.or(coerce(right))); } *************** *** 275,278 **** --- 379,392 ---- public PyString __str__() { return Py.newString(value.toString()); + } + + public boolean isMappingType() { return false; } + public boolean isSequenceType() { return false; } + + // __class__ boilerplate -- see PyObject for details + public static PyClass __class__; + + protected PyClass getPyClass() { + return __class__; } } Index: PyInstance.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyInstance.java,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -r2.13 -r2.14 *** PyInstance.java 2000/10/08 18:20:09 2.13 --- PyInstance.java 2001/01/31 13:34:35 2.14 *************** *** 679,683 **** **/ public PyObject __add__(PyObject o) { ! return invoke_ex("__add__", o); } --- 679,693 ---- **/ public PyObject __add__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__add__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__add__", o2); ! else ! return o1._add(o2); ! } } *************** *** 687,691 **** **/ public PyObject __radd__(PyObject o) { ! return invoke_ex("__radd__", o); } --- 697,711 ---- **/ public PyObject __radd__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__radd__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__radd__", o2); ! else ! return o2._add(o1); ! } } *************** *** 706,710 **** **/ public PyObject __sub__(PyObject o) { ! return invoke_ex("__sub__", o); } --- 726,740 ---- **/ public PyObject __sub__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__sub__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__sub__", o2); ! else ! return o1._sub(o2); ! } } *************** *** 714,718 **** **/ public PyObject __rsub__(PyObject o) { ! return invoke_ex("__rsub__", o); } --- 744,758 ---- **/ public PyObject __rsub__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rsub__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rsub__", o2); ! else ! return o2._sub(o1); ! } } *************** *** 733,737 **** **/ public PyObject __mul__(PyObject o) { ! return invoke_ex("__mul__", o); } --- 773,787 ---- **/ public PyObject __mul__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__mul__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__mul__", o2); ! else ! return o1._mul(o2); ! } } *************** *** 741,745 **** **/ public PyObject __rmul__(PyObject o) { ! return invoke_ex("__rmul__", o); } --- 791,805 ---- **/ public PyObject __rmul__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rmul__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rmul__", o2); ! else ! return o2._mul(o1); ! } } *************** *** 760,764 **** **/ public PyObject __div__(PyObject o) { ! return invoke_ex("__div__", o); } --- 820,834 ---- **/ public PyObject __div__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__div__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__div__", o2); ! else ! return o1._div(o2); ! } } *************** *** 768,772 **** **/ public PyObject __rdiv__(PyObject o) { ! return invoke_ex("__rdiv__", o); } --- 838,852 ---- **/ public PyObject __rdiv__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rdiv__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rdiv__", o2); ! else ! return o2._div(o1); ! } } *************** *** 787,791 **** **/ public PyObject __mod__(PyObject o) { ! return invoke_ex("__mod__", o); } --- 867,881 ---- **/ public PyObject __mod__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__mod__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__mod__", o2); ! else ! return o1._mod(o2); ! } } *************** *** 795,799 **** **/ public PyObject __rmod__(PyObject o) { ! return invoke_ex("__rmod__", o); } --- 885,899 ---- **/ public PyObject __rmod__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rmod__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rmod__", o2); ! else ! return o2._mod(o1); ! } } *************** *** 814,818 **** **/ public PyObject __divmod__(PyObject o) { ! return invoke_ex("__divmod__", o); } --- 914,928 ---- **/ public PyObject __divmod__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__divmod__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__divmod__", o2); ! else ! return o1._divmod(o2); ! } } *************** *** 822,826 **** **/ public PyObject __rdivmod__(PyObject o) { ! return invoke_ex("__rdivmod__", o); } --- 932,946 ---- **/ public PyObject __rdivmod__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rdivmod__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rdivmod__", o2); ! else ! return o2._divmod(o1); ! } } *************** *** 830,834 **** **/ public PyObject __pow__(PyObject o) { ! return invoke_ex("__pow__", o); } --- 950,964 ---- **/ public PyObject __pow__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__pow__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__pow__", o2); ! else ! return o1._pow(o2); ! } } *************** *** 838,842 **** **/ public PyObject __rpow__(PyObject o) { ! return invoke_ex("__rpow__", o); } --- 968,982 ---- **/ public PyObject __rpow__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rpow__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rpow__", o2); ! else ! return o2._pow(o1); ! } } *************** *** 857,861 **** **/ public PyObject __lshift__(PyObject o) { ! return invoke_ex("__lshift__", o); } --- 997,1011 ---- **/ public PyObject __lshift__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__lshift__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__lshift__", o2); ! else ! return o1._lshift(o2); ! } } *************** *** 865,869 **** **/ public PyObject __rlshift__(PyObject o) { ! return invoke_ex("__rlshift__", o); } --- 1015,1029 ---- **/ public PyObject __rlshift__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rlshift__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rlshift__", o2); ! else ! return o2._lshift(o1); ! } } *************** *** 884,888 **** **/ public PyObject __rshift__(PyObject o) { ! return invoke_ex("__rshift__", o); } --- 1044,1058 ---- **/ public PyObject __rshift__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rshift__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rshift__", o2); ! else ! return o1._rshift(o2); ! } } *************** *** 892,896 **** **/ public PyObject __rrshift__(PyObject o) { ! return invoke_ex("__rrshift__", o); } --- 1062,1076 ---- **/ public PyObject __rrshift__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rrshift__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rrshift__", o2); ! else ! return o2._rshift(o1); ! } } *************** *** 911,915 **** **/ public PyObject __and__(PyObject o) { ! return invoke_ex("__and__", o); } --- 1091,1105 ---- **/ public PyObject __and__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__and__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__and__", o2); ! else ! return o1._and(o2); ! } } *************** *** 919,923 **** **/ public PyObject __rand__(PyObject o) { ! return invoke_ex("__rand__", o); } --- 1109,1123 ---- **/ public PyObject __rand__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rand__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rand__", o2); ! else ! return o2._and(o1); ! } } *************** *** 938,942 **** **/ public PyObject __or__(PyObject o) { ! return invoke_ex("__or__", o); } --- 1138,1152 ---- **/ public PyObject __or__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__or__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__or__", o2); ! else ! return o1._or(o2); ! } } *************** *** 946,950 **** **/ public PyObject __ror__(PyObject o) { ! return invoke_ex("__ror__", o); } --- 1156,1170 ---- **/ public PyObject __ror__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__ror__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__ror__", o2); ! else ! return o2._or(o1); ! } } *************** *** 965,969 **** **/ public PyObject __xor__(PyObject o) { ! return invoke_ex("__xor__", o); } --- 1185,1199 ---- **/ public PyObject __xor__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__xor__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__xor__", o2); ! else ! return o1._xor(o2); ! } } *************** *** 973,977 **** **/ public PyObject __rxor__(PyObject o) { ! return invoke_ex("__rxor__", o); } --- 1203,1217 ---- **/ public PyObject __rxor__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__rxor__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__rxor__", o2); ! else ! return o2._xor(o1); ! } } *************** *** 986,988 **** --- 1226,1229 ---- return super.__ixor__(o); } + } Index: PyNone.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyNone.java,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** PyNone.java 1999/10/04 20:44:28 2.3 --- PyNone.java 2001/01/31 13:34:35 2.4 *************** *** 24,26 **** --- 24,36 ---- return "'None' object"; } + + public boolean isMappingType() { return false; } + public boolean isSequenceType() { return false; } + + // __class__ boilerplate -- see PyObject for details + public static PyClass __class__; + + protected PyClass getPyClass() { + return __class__; + } } Index: PyObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyObject.java,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** PyObject.java 2001/01/21 16:19:52 2.16 --- PyObject.java 2001/01/31 13:34:35 2.17 *************** *** 824,827 **** --- 824,828 ---- } + /** Implements cmp(this, other) *************** *** 1087,1090 **** --- 1088,1093 ---- public PyObject __pow__(PyObject o2, PyObject o3) throws PyException { return null; } + + // Generated by make_binops.py (Begin) *************** *** 1123,1165 **** * with these operands. **/ ! public final PyObject _add(PyObject o2_in) { ! PyObject o2 = o2_in; ! PyObject o1 = this; ! Object ctmp; ! if (o1.__class__ != o2.__class__) { ! ctmp = o1.__coerce_ex__(o2); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o1 = ((PyObject[])ctmp)[0]; ! o2 = ((PyObject[])ctmp)[1]; ! } else { ! o2 = (PyObject)ctmp; ! } ! } ! } else ctmp = null; ! ! if (ctmp != Py.None && (o1 = o1.__add__(o2)) != null) ! return o1; ! o1 = this; ! o2 = o2_in; ! if (o1.__class__ != o2.__class__) { ! ctmp=o2.__coerce_ex__(o1); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o2 = ((PyObject[])ctmp)[0]; ! o1 = ((PyObject[])ctmp)[1]; ! } else { ! o1 = (PyObject)ctmp; ! } ! } ! } ! if (ctmp != Py.None) { ! if (o1.__class__ == o2.__class__) ! o1 = o1.__add__(o2); ! else ! o1 = o2.__radd__(o1); ! if (o1 != null) ! return o1; ! } throw Py.TypeError( "__add__ nor __radd__ defined for these operands"); --- 1126,1136 ---- * with these operands. **/ ! public final PyObject _add(PyObject o2) { ! PyObject x = __add__(o2); ! if (x != null) ! return x; ! x = o2.__radd__(this); ! if (x != null) ! return x; throw Py.TypeError( "__add__ nor __radd__ defined for these operands"); *************** *** 1200,1242 **** * with these operands. **/ ! public final PyObject _sub(PyObject o2_in) { ! PyObject o2 = o2_in; ! PyObject o1 = this; ! Object ctmp; ! if (o1.__class__ != o2.__class__) { ! ctmp = o1.__coerce_ex__(o2); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o1 = ((PyObject[])ctmp)[0]; ! o2 = ((PyObject[])ctmp)[1]; ! } else { ! o2 = (PyObject)ctmp; ! } ! } ! } else ctmp = null; ! ! if (ctmp != Py.None && (o1 = o1.__sub__(o2)) != null) ! return o1; ! o1 = this; ! o2 = o2_in; ! if (o1.__class__ != o2.__class__) { ! ctmp=o2.__coerce_ex__(o1); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o2 = ((PyObject[])ctmp)[0]; ! o1 = ((PyObject[])ctmp)[1]; ! } else { ! o1 = (PyObject)ctmp; ! } ! } ! } ! if (ctmp != Py.None) { ! if (o1.__class__ == o2.__class__) ! o1 = o1.__sub__(o2); ! else ! o1 = o2.__rsub__(o1); ! if (o1 != null) ! return o1; ! } throw Py.TypeError( "__sub__ nor __rsub__ defined for these operands"); --- 1171,1181 ---- * with these operands. **/ ! public final PyObject _sub(PyObject o2) { ! PyObject x = __sub__(o2); ! if (x != null) ! return x; ! x = o2.__rsub__(this); ! if (x != null) ! return x; throw Py.TypeError( "__sub__ nor __rsub__ defined for these operands"); *************** *** 1277,1319 **** * with these operands. **/ ! public final PyObject _mul(PyObject o2_in) { ! PyObject o2 = o2_in; ! PyObject o1 = this; ! Object ctmp; ! if (o1.__class__ != o2.__class__) { ! ctmp = o1.__coerce_ex__(o2); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o1 = ((PyObject[])ctmp)[0]; ! o2 = ((PyObject[])ctmp)[1]; ! } else { ! o2 = (PyObject)ctmp; ! } ! } ! } else ctmp = null; ! ! if (ctmp != Py.None && (o1 = o1.__mul__(o2)) != null) ! return o1; ! o1 = this; ! o2 = o2_in; ! if (o1.__class__ != o2.__class__) { ! ctmp=o2.__coerce_ex__(o1); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o2 = ((PyObject[])ctmp)[0]; ! o1 = ((PyObject[])ctmp)[1]; ! } else { ! o1 = (PyObject)ctmp; ! } ! } ! } ! if (ctmp != Py.None) { ! if (o1.__class__ == o2.__class__) ! o1 = o1.__mul__(o2); ! else ! o1 = o2.__rmul__(o1); ! if (o1 != null) ! return o1; ! } throw Py.TypeError( "__mul__ nor __rmul__ defined for these operands"); --- 1216,1226 ---- * with these operands. **/ ! public final PyObject _mul(PyObject o2) { ! PyObject x = __mul__(o2); ! if (x != null) ! return x; ! x = o2.__rmul__(this); ! if (x != null) ! return x; throw Py.TypeError( "__mul__ nor __rmul__ defined for these operands"); *************** *** 1354,1396 **** * with these operands. **/ ! public final PyObject _div(PyObject o2_in) { ! PyObject o2 = o2_in; ! PyObject o1 = this; ! Object ctmp; ! if (o1.__class__ != o2.__class__) { ! ctmp = o1.__coerce_ex__(o2); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o1 = ((PyObject[])ctmp)[0]; ! o2 = ((PyObject[])ctmp)[1]; ! } else { ! o2 = (PyObject)ctmp; ! } ! } ! } else ctmp = null; ! ! if (ctmp != Py.None && (o1 = o1.__div__(o2)) != null) ! return o1; ! o1 = this; ! o2 = o2_in; ! if (o1.__class__ != o2.__class__) { ! ctmp=o2.__coerce_ex__(o1); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o2 = ((PyObject[])ctmp)[0]; ! o1 = ((PyObject[])ctmp)[1]; ! } else { ! o1 = (PyObject)ctmp; ! } ! } ! } ! if (ctmp != Py.None) { ! if (o1.__class__ == o2.__class__) ! o1 = o1.__div__(o2); ! else ! o1 = o2.__rdiv__(o1); ! if (o1 != null) ! return o1; ! } throw Py.TypeError( "__div__ nor __rdiv__ defined for these operands"); --- 1261,1271 ---- * with these operands. **/ ! public final PyObject _div(PyObject o2) { ! PyObject x = __div__(o2); ! if (x != null) ! return x; ! x = o2.__rdiv__(this); ! if (x != null) ! return x; throw Py.TypeError( "__div__ nor __rdiv__ defined for these operands"); *************** *** 1431,1473 **** * with these operands. **/ ! public final PyObject _mod(PyObject o2_in) { ! PyObject o2 = o2_in; ! PyObject o1 = this; ! Object ctmp; ! if (o1.__class__ != o2.__class__) { ! ctmp = o1.__coerce_ex__(o2); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o1 = ((PyObject[])ctmp)[0]; ! o2 = ((PyObject[])ctmp)[1]; ! } else { ! o2 = (PyObject)ctmp; ! } ! } ! } else ctmp = null; ! ! if (ctmp != Py.None && (o1 = o1.__mod__(o2)) != null) ! return o1; ! o1 = this; ! o2 = o2_in; ! if (o1.__class__ != o2.__class__) { ! ctmp=o2.__coerce_ex__(o1); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o2 = ((PyObject[])ctmp)[0]; ! o1 = ((PyObject[])ctmp)[1]; ! } else { ! o1 = (PyObject)ctmp; ! } ! } ! } ! if (ctmp != Py.None) { ! if (o1.__class__ == o2.__class__) ! o1 = o1.__mod__(o2); ! else ! o1 = o2.__rmod__(o1); ! if (o1 != null) ! return o1; ! } throw Py.TypeError( "__mod__ nor __rmod__ defined for these operands"); --- 1306,1316 ---- * with these operands. **/ ! public final PyObject _mod(PyObject o2) { ! PyObject x = __mod__(o2); ! if (x != null) ! return x; ! x = o2.__rmod__(this); ! if (x != null) ! return x; throw Py.TypeError( "__mod__ nor __rmod__ defined for... [truncated message content] |
From: Finn B. <bc...@us...> - 2001-01-31 13:16:39
|
Update of /cvsroot/jython/jython/Misc In directory usw-pr-cvs1:/tmp/cvs-serv10032 Modified Files: make_binops.py Log Message: Support for the reworked Coercion Model (pep-0208). Index: make_binops.py =================================================================== RCS file: /cvsroot/jython/jython/Misc/make_binops.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** make_binops.py 2000/10/08 13:45:48 1.2 --- make_binops.py 2001/01/31 13:16:37 1.3 *************** *** 41,83 **** * with these operands. **/ ! public final PyObject _%(name)s(PyObject o2_in) { ! PyObject o2 = o2_in; ! PyObject o1 = this; ! Object ctmp; ! if (o1.__class__ != o2.__class__) { ! ctmp = o1.__coerce_ex__(o2); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o1 = ((PyObject[])ctmp)[0]; ! o2 = ((PyObject[])ctmp)[1]; ! } else { ! o2 = (PyObject)ctmp; ! } ! } ! } else ctmp = null; ! ! if (ctmp != Py.None && (o1 = o1.__%(name)s__(o2)) != null) ! return o1; ! o1 = this; ! o2 = o2_in; ! if (o1.__class__ != o2.__class__) { ! ctmp=o2.__coerce_ex__(o1); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o2 = ((PyObject[])ctmp)[0]; ! o1 = ((PyObject[])ctmp)[1]; ! } else { ! o1 = (PyObject)ctmp; ! } ! } ! } ! if (ctmp != Py.None) { ! if (o1.__class__ == o2.__class__) ! o1 = o1.__%(name)s__(o2); ! else ! o1 = o2.__r%(name)s__(o1); ! if (o1 != null) ! return o1; ! } throw Py.TypeError( "__%(name)s__ nor __r%(name)s__ defined for these operands"); --- 41,51 ---- * with these operands. **/ ! public final PyObject _%(name)s(PyObject o2) { ! PyObject x = __%(name)s__(o2); ! if (x != null) ! return x; ! x = o2.__r%(name)s__(this); ! if (x != null) ! return x; throw Py.TypeError( "__%(name)s__ nor __r%(name)s__ defined for these operands"); *************** *** 149,157 **** template = comment + """\ public PyObject __%(name)s__(PyObject o) { ! return invoke_ex("__%(name)s__", o); } """ template2 = comment + """\ public PyObject __%(name)s__(PyObject o) { --- 117,136 ---- template = comment + """\ public PyObject __%(name)s__(PyObject o) { ! Object ctmp = __coerce_ex__(o); ! if (ctmp == null || ctmp == Py.None) ! return invoke_ex("__%(name)s__", o); ! else { ! PyObject o1 = ((PyObject[])ctmp)[0]; ! PyObject o2 = ((PyObject[])ctmp)[1]; ! if (this == o1) // Prevent recusion if __coerce__ return self ! return invoke_ex("__%(name)s__", o2); ! else ! return %(function)s; ! } } """ + template2 = comment + """\ public PyObject __%(name)s__(PyObject o) { *************** *** 166,171 **** fp.write(' // Binary ops\n\n') for name, op in binops: ! fp.write(template % {'name':name}) ! fp.write(template % {'name':'r'+name}) if name != 'divmod': fp.write(template2 % {'name':'i'+name --- 145,150 ---- fp.write(' // Binary ops\n\n') for name, op in binops: ! fp.write(template % {'name':name, 'function':'o1._%s(o2)' % name }) ! fp.write(template % {'name':'r'+name, 'function':'o2._%s(o1)' % name }) if name != 'divmod': fp.write(template2 % {'name':'i'+name |
From: Finn B. <bc...@us...> - 2001-01-31 10:38:38
|
Update of /cvsroot/jython/jython/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11390 Modified Files: javaos.py Log Message: Fix bug #130021 by returning a double in the right range. Index: javaos.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/javaos.py,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** javaos.py 2001/01/17 16:54:18 2.4 --- javaos.py 2001/01/31 10:38:36 2.5 *************** *** 63,66 **** if size == 0 and not f.exists(): raise OSError(0, 'No such file or directory', path) ! mtime = f.lastModified() return (0, 0, 0, 0, 0, 0, size, mtime, mtime, 0) --- 63,66 ---- if size == 0 and not f.exists(): raise OSError(0, 'No such file or directory', path) ! mtime = f.lastModified() / 1000.0 return (0, 0, 0, 0, 0, 0, size, mtime, mtime, 0) |
From: Finn B. <bc...@us...> - 2001-01-31 10:36:16
|
Update of /cvsroot/jython/jython/Lib In directory usw-pr-cvs1:/tmp/cvs-serv10847 Modified Files: getopt.py Log Message: Updated to use CPython 2.1a1 Index: getopt.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/getopt.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** getopt.py 2000/11/17 20:46:17 1.2 --- getopt.py 2001/01/31 10:36:14 1.3 *************** *** 18,31 **** # to class-based exceptions. class GetoptError(Exception): opt = '' msg = '' ! def __init__(self, *args): ! self.args = args ! if len(args) == 1: ! self.msg = args[0] ! elif len(args) == 2: ! self.msg = args[0] ! self.opt = args[1] def __str__(self): --- 18,30 ---- # to class-based exceptions. + __all__ = ["GetoptError","error","getopt"] + class GetoptError(Exception): opt = '' msg = '' ! def __init__(self, msg, opt): ! self.msg = msg ! self.opt = opt ! Exception.__init__(self, msg, opt) def __str__(self): *************** *** 66,71 **** else: longopts = list(longopts) ! longopts.sort() ! while args and args[0][:1] == '-' and args[0] != '-': if args[0] == '--': args = args[1:] --- 65,69 ---- else: longopts = list(longopts) ! while args and args[0].startswith('-') and args[0] != '-': if args[0] == '--': args = args[1:] *************** *** 81,87 **** try: i = opt.index('=') - opt, optarg = opt[:i], opt[i+1:] except ValueError: optarg = None has_arg, opt = long_has_args(opt, longopts) --- 79,86 ---- try: i = opt.index('=') except ValueError: optarg = None + else: + opt, optarg = opt[:i], opt[i+1:] has_arg, opt = long_has_args(opt, longopts) *************** *** 100,115 **** # full option name def long_has_args(opt, longopts): ! optlen = len(opt) ! for i in range(len(longopts)): ! x, y = longopts[i][:optlen], longopts[i][optlen:] ! if opt != x: ! continue ! if y != '' and y != '=' and i+1 < len(longopts): ! if opt == longopts[i+1][:optlen]: ! raise GetoptError('option --%s not a unique prefix' % opt, opt) ! if longopts[i][-1:] in ('=', ): ! return 1, longopts[i][:-1] ! return 0, longopts[i] ! raise GetoptError('option --%s not recognized' % opt, opt) def do_shorts(opts, optstring, shortopts, args): --- 99,121 ---- # full option name def long_has_args(opt, longopts): ! possibilities = [o for o in longopts if o.startswith(opt)] ! if not possibilities: ! raise GetoptError('option --%s not recognized' % opt, opt) ! # Is there an exact match? ! if opt in possibilities: ! return 0, opt ! elif opt + '=' in possibilities: ! return 1, opt ! # No exact match, so better be unique. ! if len(possibilities) > 1: ! # XXX since possibilities contains all valid continuations, might be ! # nice to work them into the error msg ! raise GetoptError('option --%s not a unique prefix' % opt, opt) ! assert len(possibilities) == 1 ! unique_match = possibilities[0] ! has_arg = unique_match.endswith('=') ! if has_arg: ! unique_match = unique_match[:-1] ! return has_arg, unique_match def do_shorts(opts, optstring, shortopts, args): |
From: Samuele P. <ped...@us...> - 2001-01-23 02:07:07
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv14302/org/python/core Modified Files: InternalTables2.java Log Message: solve b.actionPerformed= lambda e,me=b: None leak. Index: InternalTables2.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/InternalTables2.java,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** InternalTables2.java 2000/12/16 16:43:33 2.2 --- InternalTables2.java 2001/01/23 02:07:22 2.3 *************** *** 4,7 **** --- 4,8 ---- import java.util.*; + import java.lang.ref.*; public class InternalTables2 extends InternalTables1 { *************** *** 20,24 **** HashMap ads = (HashMap)adapters.get(o); if (ads == null) return null; ! return ads.get(evc); } --- 21,27 ---- HashMap ads = (HashMap)adapters.get(o); if (ads == null) return null; ! WeakReference adw = (WeakReference) ads.get(evc); ! if (adw == null) return null; ! return adw.get(); } *************** *** 29,33 **** adapters.put(o,ads); } ! ads.put(evc,ad); } --- 32,36 ---- adapters.put(o,ads); } ! ads.put(evc,new WeakReference(ad)); } *************** *** 63,76 **** public Object _next() { if (iterType == ADAPTER) { ! if (iter==null || !iter.hasNext() ) { ! if (grand.hasNext()) { ! cur = grand.next(); ! iter = ((HashMap)cur).values().iterator(); ! } else iter = null; ! } ! if (iter != null) { ! return iter.next().getClass().getInterfaces()[0]; ! } ! grand = null; } else if (iter.hasNext()) { --- 66,85 ---- public Object _next() { if (iterType == ADAPTER) { ! for(;;) { ! if (iter==null || !iter.hasNext() ) { ! if (grand.hasNext()) { ! cur = grand.next(); ! iter = ((HashMap)cur).values().iterator(); ! } else iter = null; ! } ! if (iter != null) { ! WeakReference adw = (WeakReference)iter.next(); ! Object ad = adw.get(); ! if (ad != null) return ad.getClass().getInterfaces()[0]; ! else continue; ! } ! grand = null; ! break; ! } } else if (iter.hasNext()) { |
From: Finn B. <bc...@us...> - 2001-01-21 16:24:57
|
Update of /cvsroot/jython/jython/org/python/modules In directory usw-pr-cvs1:/tmp/cvs-serv1051 Modified Files: cPickle.java Log Message: Added support for UNICODE and BINUNICODE. Index: cPickle.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/cPickle.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** cPickle.java 2000/12/11 18:46:30 1.13 --- cPickle.java 2001/01/21 16:25:08 1.14 *************** *** 451,454 **** --- 451,456 ---- final static char BINSTRING = 'T'; final static char SHORT_BINSTRING = 'U'; + final static char UNICODE = 'V'; + final static char BINUNICODE = 'X'; final static char APPEND = 'a'; final static char BUILD = 'b'; *************** *** 1062,1081 **** final private void save_string(PyObject object) { if (bin) { ! int l = object.__len__(); ! if (l < 256) { ! file.write(SHORT_BINSTRING); ! file.write((char)l); ! } else { ! file.write(BINSTRING); ! file.write((char)( l & 0xFF)); ! file.write((char)((l >>> 8 ) & 0xFF)); ! file.write((char)((l >>> 16) & 0xFF)); ! file.write((char)((l >>> 24) & 0xFF)); ! } ! file.write(object.toString()); } else { ! file.write(STRING); ! file.write(object.__repr__().toString()); file.write("\n"); } --- 1064,1096 ---- final private void save_string(PyObject object) { + boolean unicode = ((PyString) object).isunicode(); + String str = object.toString(); + if (bin) { ! if (unicode) ! str = codecs.PyUnicode_EncodeUTF8(str, "struct"); ! int l = str.length(); ! if (l < 256 && !unicode) { ! file.write(SHORT_BINSTRING); ! file.write((char)l); ! } else { ! if (unicode) ! file.write(BINUNICODE); ! else ! file.write(BINSTRING); ! file.write((char)( l & 0xFF)); ! file.write((char)((l >>> 8 ) & 0xFF)); ! file.write((char)((l >>> 16) & 0xFF)); ! file.write((char)((l >>> 24) & 0xFF)); ! } ! file.write(str); } else { ! if (unicode) { ! file.write(UNICODE); ! file.write(codecs.PyUnicode_EncodeRawUnicodeEscape(str, "strict", true)); ! } else { ! file.write(STRING); ! file.write(object.__repr__().toString()); ! } file.write("\n"); } *************** *** 1533,1536 **** --- 1548,1553 ---- case BINSTRING: load_binstring(); break; case SHORT_BINSTRING: load_short_binstring(); break; + case UNICODE: load_unicode(); break; + case BINUNICODE: load_binunicode(); break; case TUPLE: load_tuple(); break; case EMPTY_TUPLE: load_empty_tuple(); break; *************** *** 1659,1663 **** int i; char ch = '\0'; ! for (i = 1; i < line.length(); i++) { ch = line.charAt(i); if (ch == quote && nslash % 2 == 0) --- 1676,1681 ---- int i; char ch = '\0'; ! int n = line.length(); ! for (i = 1; i < n; i++) { ch = line.charAt(i); if (ch == quote && nslash % 2 == 0) *************** *** 1669,1673 **** } if (ch != quote) ! throw Py.ValueError("insecure string pickle "); for (i++ ; i < line.length(); i++) { --- 1687,1691 ---- } if (ch != quote) ! throw Py.ValueError("insecure string pickle"); for (i++ ; i < line.length(); i++) { *************** *** 1675,1679 **** throw Py.ValueError("insecure string pickle " + i); } ! value = org.python.parser.SimpleNode.parseString(line, 1, 0, 0); push(new PyString(value)); } --- 1693,1698 ---- throw Py.ValueError("insecure string pickle " + i); } ! value = PyString.decode_UnicodeEscape(line, 1, n-1, "strict", false); ! push(new PyString(value)); } *************** *** 1695,1698 **** --- 1714,1734 ---- } + + final private void load_unicode() { + String line = file.readlineNoNl(); + int n = line.length(); + String value = codecs.PyUnicode_DecodeRawUnicodeEscape(line, "strict"); + push(new PyString(value)); + } + + final private void load_binunicode() { + String d = file.read(4); + int len = d.charAt(0) | + (d.charAt(1)<<8) | + (d.charAt(2)<<16) | + (d.charAt(3)<<24); + String line = file.read(len); + push(new PyString(codecs.PyUnicode_DecodeUTF8(line, "strict"))); + } final private void load_tuple() { |
From: Finn B. <bc...@us...> - 2001-01-21 16:24:21
|
Update of /cvsroot/jython/jython/org/python/modules In directory usw-pr-cvs1:/tmp/cvs-serv839/modules Modified Files: _codecs.java Log Message: Moved UTF8 codec from modules to core. This codec is also used by cPickle and life freezing an application is so much simpler if the codecs is always available. Index: _codecs.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/_codecs.java,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** _codecs.java 2001/01/21 14:02:35 2.5 --- _codecs.java 2001/01/21 16:24:31 2.6 *************** *** 26,191 **** ! ! /* --- UTF-8 Codec -------------------------------------------------------- */ ! private static byte utf8_code_length[] = { ! /* Map UTF-8 encoded prefix byte to sequence length. zero means ! illegal prefix. see RFC 2279 for details */ ! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ! 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, ! 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0 ! }; ! ! ! ! ! public static PyTuple utf_8_decode(String str) { ! return utf_8_decode(str, null); ! } public static PyTuple utf_8_decode(String str, String errors) { int size = str.length(); ! StringBuffer unicode = new StringBuffer(size); ! ! ! /* Unpack UTF-8 encoded data */ ! for (int i = 0; i < size; ) { ! int ch = str.charAt(i); ! if (ch > 0xFF) { ! codecs.decoding_error("utf-8", unicode, errors, ! "ordinal not in range(255)"); ! i++; ! continue; ! } ! ! if (ch < 0x80) { ! unicode.append((char) ch); ! i++; ! continue; ! } ! ! int n = utf8_code_length[ch]; ! ! if (i + n > size) { ! codecs.decoding_error("utf-8", unicode, errors, ! "unexpected end of data"); ! i++; ! continue; ! } ! ! ! switch (n) { ! case 0: ! codecs.decoding_error("utf-8", unicode, errors, ! "unexpected code byte"); ! i++; ! continue; ! case 1: ! codecs.decoding_error("utf-8", unicode, errors, ! "internal error"); ! i++; ! continue; ! case 2: ! char ch1 = str.charAt(i+1); ! if ((ch1 & 0xc0) != 0x80) { ! codecs.decoding_error("utf-8", unicode, errors, ! "invalid data"); ! i++; ! continue; ! } ! ch = ((ch & 0x1f) << 6) + (ch1 & 0x3f); ! if (ch < 0x80) { ! codecs.decoding_error("utf-8", unicode, errors, ! "illegal encoding"); ! i++; ! continue; ! } else ! unicode.append((char) ch); ! break; ! ! case 3: ! ch1 = str.charAt(i+1); ! char ch2 = str.charAt(i+2); ! if ((ch1 & 0xc0) != 0x80 || (ch2 & 0xc0) != 0x80) { ! codecs.decoding_error("utf-8", unicode, errors, ! "invalid data"); ! i++; ! continue; ! } ! ch = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); ! if (ch < 0x800 || (ch >= 0xd800 && ch < 0xe000)) { ! codecs.decoding_error("utf-8", unicode, errors, ! "illegal encoding"); ! i++; ! continue; ! } else ! unicode.append((char) ch); ! break; ! ! case 4: ! ch1 = str.charAt(i+1); ! ch2 = str.charAt(i+2); ! char ch3 = str.charAt(i+3); ! if ((ch1 & 0xc0) != 0x80 || ! (ch2 & 0xc0) != 0x80 || ! (ch3 & 0xc0) != 0x80) { ! codecs.decoding_error("utf-8", unicode, errors, ! "invalid data"); ! i++; ! continue; ! } ! ch = ((ch & 0x7) << 18) + ((ch1 & 0x3f) << 12) + ! ((ch2 & 0x3f) << 6) + (ch3 & 0x3f); ! /* validate and convert to UTF-16 */ ! if ((ch < 0x10000) || /* minimum value allowed for 4 ! byte encoding */ ! (ch > 0x10ffff)) { /* maximum value allowed for ! UTF-16 */ ! codecs.decoding_error("utf-8", unicode, errors, ! "illegal encoding"); ! i++; ! continue; ! } ! /* compute and append the two surrogates: */ ! ! /* translate from 10000..10FFFF to 0..FFFF */ ! ch -= 0x10000; ! ! /* high surrogate = top 10 bits added to D800 */ ! unicode.append((char) (0xD800 + (ch >> 10))); ! ! /* low surrogate = bottom 10 bits added to DC00 */ ! unicode.append((char) (0xDC00 + (ch & ~0xFC00))); ! break; ! ! default: ! /* Other sizes are only needed for UCS-4 */ ! codecs.decoding_error("utf-8", unicode, errors, ! "unsupported Unicode code range"); ! i++; ! } ! i += n; ! } ! ! return codec_tuple(unicode.toString(), size); } - - public static PyTuple utf_8_encode(String str) { return utf_8_encode(str, null); --- 26,45 ---- ! private static PyTuple codec_tuple(String s, int len) { ! return new PyTuple(new PyObject[] { ! Py.java2py(s), ! Py.newInteger(len) ! }); ! } ! /* --- UTF-8 Codec -------------------------------------------------------- */ public static PyTuple utf_8_decode(String str, String errors) { int size = str.length(); ! return codec_tuple(codecs.PyUnicode_DecodeUTF8(str, errors), size); } public static PyTuple utf_8_encode(String str) { return utf_8_encode(str, null); *************** *** 194,248 **** public static PyTuple utf_8_encode(String str, String errors) { int size = str.length(); ! StringBuffer v = new StringBuffer(size * 3); ! ! for (int i = 0; i < size; ) { ! int ch = str.charAt(i++); ! if (ch < 0x80) ! v.append((char) ch); ! else if (ch < 0x0800) { ! v.append((char) (0xc0 | (ch >> 6))); ! v.append((char) (0x80 | (ch & 0x3f))); ! } else { ! if (0xD800 <= ch && ch <= 0xDFFF) { ! if (i != size) { ! int ch2 = str.charAt(i); ! if (0xDC00 <= ch2 && ch2 <= 0xDFFF) { ! /* combine the two values */ ! ch = ((ch - 0xD800)<<10 | (ch2-0xDC00))+0x10000; ! ! v.append((char)((ch >> 18) | 0xf0)); ! v.append((char)(0x80 | ((ch >> 12) & 0x3f))); ! i++; ! } ! } ! } else { ! v.append((char)(0xe0 | (ch >> 12))); ! } ! v.append((char) (0x80 | ((ch >> 6) & 0x3f))); ! v.append((char) (0x80 | (ch & 0x3f))); ! } ! } ! return codec_tuple(v.toString(), size); } - - - private static PyTuple codec_tuple(String s, int len) { - return new PyTuple(new PyObject[] { - Py.java2py(s), - Py.newInteger(len) - }); - } - - - - - - /* --- Character Mapping Codec -------------------------------------------- */ - public static PyTuple charmap_decode(String str, String errors, PyObject mapping) { --- 48,58 ---- public static PyTuple utf_8_encode(String str, String errors) { int size = str.length(); ! return codec_tuple(codecs.PyUnicode_EncodeUTF8(str, errors), size); } /* --- Character Mapping Codec -------------------------------------------- */ public static PyTuple charmap_decode(String str, String errors, PyObject mapping) { *************** *** 351,356 **** size); } - - --- 161,164 ---- |
From: Finn B. <bc...@us...> - 2001-01-21 16:24:20
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv839/core Modified Files: codecs.java Log Message: Moved UTF8 codec from modules to core. This codec is also used by cPickle and life freezing an application is so much simpler if the codecs is always available. Index: codecs.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/codecs.java,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** codecs.java 2001/01/21 14:02:35 2.4 --- codecs.java 2001/01/21 16:24:31 2.5 *************** *** 160,163 **** --- 160,348 ---- + /* --- UTF-8 Codec -------------------------------------------------------- */ + private static byte utf8_code_length[] = { + /* Map UTF-8 encoded prefix byte to sequence length. zero means + illegal prefix. see RFC 2279 for details */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0 + }; + + + public static String PyUnicode_DecodeUTF8(String str, String errors) { + int size = str.length(); + StringBuffer unicode = new StringBuffer(size); + + /* Unpack UTF-8 encoded data */ + for (int i = 0; i < size; ) { + int ch = str.charAt(i); + if (ch > 0xFF) { + codecs.decoding_error("utf-8", unicode, errors, + "ordinal not in range(255)"); + i++; + continue; + } + + if (ch < 0x80) { + unicode.append((char) ch); + i++; + continue; + } + + int n = utf8_code_length[ch]; + + if (i + n > size) { + codecs.decoding_error("utf-8", unicode, errors, + "unexpected end of data"); + i++; + continue; + } + + + switch (n) { + case 0: + codecs.decoding_error("utf-8", unicode, errors, + "unexpected code byte"); + i++; + continue; + case 1: + codecs.decoding_error("utf-8", unicode, errors, + "internal error"); + i++; + continue; + case 2: + char ch1 = str.charAt(i+1); + if ((ch1 & 0xc0) != 0x80) { + codecs.decoding_error("utf-8", unicode, errors, + "invalid data"); + i++; + continue; + } + ch = ((ch & 0x1f) << 6) + (ch1 & 0x3f); + if (ch < 0x80) { + codecs.decoding_error("utf-8", unicode, errors, + "illegal encoding"); + i++; + continue; + } else + unicode.append((char) ch); + break; + + case 3: + ch1 = str.charAt(i+1); + char ch2 = str.charAt(i+2); + if ((ch1 & 0xc0) != 0x80 || (ch2 & 0xc0) != 0x80) { + codecs.decoding_error("utf-8", unicode, errors, + "invalid data"); + i++; + continue; + } + ch = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); + if (ch < 0x800 || (ch >= 0xd800 && ch < 0xe000)) { + codecs.decoding_error("utf-8", unicode, errors, + "illegal encoding"); + i++; + continue; + } else + unicode.append((char) ch); + break; + + case 4: + ch1 = str.charAt(i+1); + ch2 = str.charAt(i+2); + char ch3 = str.charAt(i+3); + if ((ch1 & 0xc0) != 0x80 || + (ch2 & 0xc0) != 0x80 || + (ch3 & 0xc0) != 0x80) { + codecs.decoding_error("utf-8", unicode, errors, + "invalid data"); + i++; + continue; + } + ch = ((ch & 0x7) << 18) + ((ch1 & 0x3f) << 12) + + ((ch2 & 0x3f) << 6) + (ch3 & 0x3f); + /* validate and convert to UTF-16 */ + if ((ch < 0x10000) || /* minimum value allowed for 4 + byte encoding */ + (ch > 0x10ffff)) { /* maximum value allowed for + UTF-16 */ + codecs.decoding_error("utf-8", unicode, errors, + "illegal encoding"); + i++; + continue; + } + /* compute and append the two surrogates: */ + + /* translate from 10000..10FFFF to 0..FFFF */ + ch -= 0x10000; + + /* high surrogate = top 10 bits added to D800 */ + unicode.append((char) (0xD800 + (ch >> 10))); + + /* low surrogate = bottom 10 bits added to DC00 */ + unicode.append((char) (0xDC00 + (ch & ~0xFC00))); + break; + + default: + /* Other sizes are only needed for UCS-4 */ + codecs.decoding_error("utf-8", unicode, errors, + "unsupported Unicode code range"); + i++; + } + i += n; + } + + return unicode.toString(); + } + + + public static String PyUnicode_EncodeUTF8(String str, String errors) { + int size = str.length(); + StringBuffer v = new StringBuffer(size * 3); + + for (int i = 0; i < size; ) { + int ch = str.charAt(i++); + if (ch < 0x80) + v.append((char) ch); + else if (ch < 0x0800) { + v.append((char) (0xc0 | (ch >> 6))); + v.append((char) (0x80 | (ch & 0x3f))); + } else { + if (0xD800 <= ch && ch <= 0xDFFF) { + if (i != size) { + int ch2 = str.charAt(i); + if (0xDC00 <= ch2 && ch2 <= 0xDFFF) { + /* combine the two values */ + ch = ((ch - 0xD800)<<10 | (ch2-0xDC00))+0x10000; + + v.append((char)((ch >> 18) | 0xf0)); + v.append((char)(0x80 | ((ch >> 12) & 0x3f))); + i++; + } + } + } else { + v.append((char)(0xe0 | (ch >> 12))); + } + v.append((char) (0x80 | ((ch >> 6) & 0x3f))); + v.append((char) (0x80 | (ch & 0x3f))); + } + } + return v.toString(); + } + + /* --- 7-bit ASCII Codec -------------------------------------------- */ |
From: Finn B. <bc...@us...> - 2001-01-21 16:22:22
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv730 Modified Files: PyTableCode.java Log Message: call(): Makes exception text match CPython. Index: PyTableCode.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyTableCode.java,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** PyTableCode.java 2000/10/11 10:12:24 2.7 --- PyTableCode.java 2001/01/21 16:22:32 2.8 *************** *** 297,302 **** if (actual_args[index] != null) { throw Py.TypeError(prefix()+ ! "duplicate keyword argument: "+ ! call_keywords[i]); } actual_args[index] = --- 297,302 ---- if (actual_args[index] != null) { throw Py.TypeError(prefix()+ ! "got multiple values for keyword argument '"+ ! call_keywords[i] + "'"); } actual_args[index] = *************** *** 306,311 **** if (extra_keywords == null) { throw Py.TypeError(prefix()+ ! "unexpected keyword argument: "+ ! call_keywords[i]); } extra_keywords.__setitem__( --- 306,311 ---- if (extra_keywords == null) { throw Py.TypeError(prefix()+ ! "got an unexpected keyword argument '"+ ! call_keywords[i] + "'"); } extra_keywords.__setitem__( *************** *** 332,340 **** if (actual_args[i] == null) { if (co_argcount-i > defaults.length) { throw Py.TypeError( prefix()+ ! "not enough arguments; expected "+ ! (co_argcount-defaults.length)+" got "+ ! (call_args.length-call_keywords.length)); } actual_args[i] = defaults[defaults.length-(co_argcount-i)]; --- 332,342 ---- if (actual_args[i] == null) { if (co_argcount-i > defaults.length) { + int min = co_argcount-defaults.length; throw Py.TypeError( prefix()+ ! "takes at least " + min + ! (min == 1 ? " argument (" : " arguments (") + ! (call_args.length-call_keywords.length)+ ! " given)"); } actual_args[i] = defaults[defaults.length-(co_argcount-i)]; |
From: Finn B. <bc...@us...> - 2001-01-21 16:21:26
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv517 Modified Files: PyString.java Log Message: isunicode(): Added helper method. Returns true when the string contains a character > 255. Index: PyString.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyString.java,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -r2.33 -r2.34 *** PyString.java 2001/01/21 14:00:33 2.33 --- PyString.java 2001/01/21 16:21:36 2.34 *************** *** 1687,1690 **** --- 1687,1700 ---- } + public boolean isunicode() { + int n = string.length(); + for (int i = 0; i < n; i++) { + char ch = string.charAt(i); + if (ch > 255) + return true; + } + return false; + } + public PyString encode() { return encode(null, null); |
From: Finn B. <bc...@us...> - 2001-01-21 16:19:42
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv335 Modified Files: PyObject.java Log Message: _callextra(): make exception text match CPython. Index: PyObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyObject.java,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** PyObject.java 2000/12/22 21:20:29 2.15 --- PyObject.java 2001/01/21 16:19:52 2.16 *************** *** 325,336 **** int nstar = 0; if (kwargs != null) { PyObject keys = kwargs.__findattr__("keys"); if (keys == null) ! throw Py.TypeError("** argument must be a dictionary"); for (int i = 0; i < keywords.length; i++) if (kwargs.__finditem__(keywords[i]) != null) ! throw Py.TypeError( ! "keyword parameter redefined: " + keywords[i]); argslen += kwargs.__len__(); } --- 325,340 ---- int nstar = 0; + String name = ""; + if (this instanceof PyFunction) + name = ((PyFunction) this).__name__ + "() "; + if (kwargs != null) { PyObject keys = kwargs.__findattr__("keys"); if (keys == null) ! throw Py.TypeError(name + "argument after ** must be a dictionary"); for (int i = 0; i < keywords.length; i++) if (kwargs.__finditem__(keywords[i]) != null) ! throw Py.TypeError(name + ! "got multiple values for keyword argument '" + keywords[i] + "'"); argslen += kwargs.__len__(); } *************** *** 338,342 **** if (!(starargs instanceof PySequence || starargs instanceof PyInstance)) ! throw Py.TypeError("* argument must be a sequence"); nstar = starargs.__len__(); argslen += nstar; --- 342,346 ---- if (!(starargs instanceof PySequence || starargs instanceof PyInstance)) ! throw Py.TypeError(name + "argument after * must be a sequence"); nstar = starargs.__len__(); argslen += nstar; *************** *** 367,372 **** for (int i = 0; (key = keys.__finditem__(i)) != null; i++) { if (!(key instanceof PyString)) ! throw Py.TypeError( ! "** argumentr must be a dictionary with string keys"); newkeywords[keywords.length + i] = ((PyString) key).internedString(); --- 371,376 ---- for (int i = 0; (key = keys.__finditem__(i)) != null; i++) { if (!(key instanceof PyString)) ! throw Py.TypeError(name + ! "keywords must be strings"); newkeywords[keywords.length + i] = ((PyString) key).internedString(); |
From: Finn B. <bc...@us...> - 2001-01-21 16:18:46
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv32647 Modified Files: PyMethod.java Log Message: __call__(): Make exception text match CPython. Index: PyMethod.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyMethod.java,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** PyMethod.java 2000/10/10 20:01:42 2.7 --- PyMethod.java 2001/01/21 16:18:56 2.8 *************** *** 102,106 **** if (badcall) { throw Py.TypeError( ! "unbound method must be called with class instance 1st argument"); } else --- 102,106 ---- if (badcall) { throw Py.TypeError( ! "unbound method " + __name__ + "() must be called with instance as first argument"); } else |
From: Finn B. <bc...@us...> - 2001-01-21 14:04:22
|
Update of /cvsroot/jython/jython/org/python/modules/sre In directory usw-pr-cvs1:/tmp/cvs-serv11778/sre Modified Files: PatternObject.java SRE_STATE.java Log Message: Updated with changes to _sre.c: 2.52. Index: PatternObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/PatternObject.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** PatternObject.java 2000/10/28 11:58:20 1.4 --- PatternObject.java 2001/01/21 14:04:32 1.5 *************** *** 14,17 **** --- 14,18 ---- */ + package org.python.modules.sre; *************** *** 132,135 **** --- 133,137 ---- while (state.start <= state.end) { + state.state_reset(); state.ptr = state.start; int status = state.SRE_SEARCH(code, 0); Index: SRE_STATE.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/SRE_STATE.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** SRE_STATE.java 2000/10/28 11:56:18 1.3 --- SRE_STATE.java 2001/01/21 14:04:32 1.4 *************** *** 14,17 **** --- 14,19 ---- */ + // Last updated to _sre.c: 2.52 + package org.python.modules.sre; *************** *** 55,62 **** public static final int SRE_AT_BEGINNING = 0; public static final int SRE_AT_BEGINNING_LINE = 1; ! public static final int SRE_AT_BOUNDARY = 2; ! public static final int SRE_AT_NON_BOUNDARY = 3; ! public static final int SRE_AT_END = 4; ! public static final int SRE_AT_END_LINE = 5; public static final int SRE_CATEGORY_DIGIT = 0; --- 57,66 ---- public static final int SRE_AT_BEGINNING = 0; public static final int SRE_AT_BEGINNING_LINE = 1; ! public static final int SRE_AT_BEGINNING_STRING = 2; ! public static final int SRE_AT_BOUNDARY = 3; ! public static final int SRE_AT_NON_BOUNDARY = 4; ! public static final int SRE_AT_END = 5; ! public static final int SRE_AT_END_LINE = 6; ! public static final int SRE_AT_END_STRING = 7; public static final int SRE_CATEGORY_DIGIT = 0; *************** *** 229,232 **** --- 233,237 ---- switch (at) { case SRE_AT_BEGINNING: + case SRE_AT_BEGINNING_STRING: return ptr == beginning; *************** *** 240,243 **** --- 245,251 ---- return ptr == end || SRE_IS_LINEBREAK(str[ptr]); + case SRE_AT_END_STRING: + return ptr == end; + case SRE_AT_BOUNDARY: /* word boundary */ *************** *** 609,619 **** //TRACE(pidx, ptr, "ASSERT_NOT " + (int) pattern[pidx]); this.ptr = ptr - pattern[pidx + 1]; ! if (this.ptr < this.beginning) ! return 0; ! i = SRE_MATCH(pattern, pidx + 2, level + 1); ! if (i < 0) ! return i; ! if (i != 0) ! return 0; pidx += pattern[pidx]; break; --- 617,627 ---- //TRACE(pidx, ptr, "ASSERT_NOT " + (int) pattern[pidx]); this.ptr = ptr - pattern[pidx + 1]; ! if (this.ptr >= this.beginning) { ! i = SRE_MATCH(pattern, pidx + 2, level + 1); ! if (i < 0) ! return i; ! if (i != 0) ! return 0; ! } pidx += pattern[pidx]; break; *************** *** 647,657 **** exactly one character wide, and we're not already collecting backtracking points. for other cases, ! use the MAX_REPEAT operator instead */ /* <REPEAT_ONE> <skip> <1=min> <2=max> item <SUCCESS> tail */ ! //TRACE(pidx, ptr, "REPEAT_ONE " + (int)pattern[pidx+1] + " " + (int)pattern[pidx+2]); ! if (ptr + pattern[pidx+1] > end) return 0; /* cannot match */ --- 655,666 ---- exactly one character wide, and we're not already collecting backtracking points. for other cases, ! use the MAX_REPEAT operator */ /* <REPEAT_ONE> <skip> <1=min> <2=max> item <SUCCESS> tail */ ! int mincount = pattern[pidx+1]; ! //TRACE(pidx, ptr, "REPEAT_ONE " + mincount + " " + (int)pattern[pidx+2]); ! if (ptr + mincount > end) return 0; /* cannot match */ *************** *** 669,673 **** and backtrack if not. */ ! if (count < pattern[pidx+1]) return 0; --- 678,682 ---- and backtrack if not. */ ! if (count < mincount) return 0; *************** *** 682,691 **** chr = pattern[pidx + pattern[pidx]+1]; for (;;) { ! while (count >= pattern[pidx+1] && (ptr >= end || str[ptr] != chr)) { ptr--; count--; } ! if (count < pattern[pidx+1]) break; this.ptr = ptr; --- 691,700 ---- chr = pattern[pidx + pattern[pidx]+1]; for (;;) { ! while (count >= mincount && (ptr >= end || str[ptr] != chr)) { ptr--; count--; } ! if (count < mincount) break; this.ptr = ptr; *************** *** 700,704 **** /* general case */ lastmark = this.lastmark; ! while (count >= pattern[pidx+1]) { this.ptr = ptr; i = SRE_MATCH(pattern, pidx + pattern[pidx], level + 1); --- 709,713 ---- /* general case */ lastmark = this.lastmark; ! while (count >= mincount) { this.ptr = ptr; i = SRE_MATCH(pattern, pidx + pattern[pidx], level + 1); *************** *** 716,720 **** case SRE_OP_REPEAT: /* create repeat context. all the hard work is done ! by the UNTIL operator */ /* <REPEAT> <skip> <1=min> <2=max> item <UNTIL> tail */ --- 725,729 ---- case SRE_OP_REPEAT: /* create repeat context. all the hard work is done ! by the UNTIL operator (MAX_UNTIL, MIN_UNTIL) */ /* <REPEAT> <skip> <1=min> <2=max> item <UNTIL> tail */ *************** *** 786,789 **** --- 795,799 ---- return i; this.repeat = rp; + this.ptr = ptr; return 0; *************** *** 798,802 **** count = rp.count + 1; ! //TRACE(pidx, ptr, "MIN_UNTIL " + count); this.ptr = ptr; --- 808,812 ---- count = rp.count + 1; ! //TRACE(pidx, ptr, "MIN_UNTIL " + count + " " + rp.pidx); this.ptr = ptr; *************** *** 816,823 **** /* see if the tail matches */ this.repeat = rp.prev; ! /* RECURSIVE */ ! i = SRE_MATCH(pattern, pidx, level + 1); if (i != 0) return i; this.repeat = rp; --- 826,843 ---- /* see if the tail matches */ this.repeat = rp.prev; ! if (pattern[rp.pidx + 2] == 65535) { ! /* unbounded repeat */ ! for (;;) { ! i = SRE_MATCH(pattern, pidx, level + 1); ! if (i != 0 || ptr >= end) ! break; ! this.ptr = ++ptr; ! } ! } else ! i = SRE_MATCH(pattern, pidx, level + 1); if (i != 0) return i; + + this.ptr = ptr; this.repeat = rp; *************** *** 826,833 **** --- 846,855 ---- rp.count = count; + /* RECURSIVE */ i = SRE_MATCH(pattern, rp.pidx + 3, level + 1); if (i != 0) return i; rp.count = count - 1; + this.ptr = ptr; return 0; |
From: Finn B. <bc...@us...> - 2001-01-21 14:04:22
|
Update of /cvsroot/jython/jython/org/python/modules In directory usw-pr-cvs1:/tmp/cvs-serv11778 Modified Files: _sre.java Log Message: Updated with changes to _sre.c: 2.52. Index: _sre.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/_sre.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** _sre.java 2000/10/17 19:14:19 1.2 --- _sre.java 2001/01/21 14:04:32 1.3 *************** *** 22,25 **** --- 22,28 ---- public class _sre { + // update when constants are added or removed + public static int MAGIC = 20010115; + public static PatternObject compile(PyString pattern, int flags, PyObject code, |
From: Finn B. <bc...@us...> - 2001-01-21 14:02:25
|
Update of /cvsroot/jython/jython/org/python/modules In directory usw-pr-cvs1:/tmp/cvs-serv11257/modules Modified Files: _codecs.java Log Message: Moved the RawUnicodeEscape from Modules/_codecs to core/codecs. The encoding is used by cPickle, and keeping it in _codecs makes is very difficult to use cPickle in frozen applications. Index: _codecs.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/_codecs.java,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** _codecs.java 2000/12/04 21:23:06 2.4 --- _codecs.java 2001/01/21 14:02:35 2.5 *************** *** 561,645 **** public static PyTuple raw_unicode_escape_encode(String str, String errors) { ! return codec_tuple(encodeRawUnicodeEscape(str, errors), str.length()); } - - static char[] hexdigit = "0123456789ABCDEF".toCharArray(); - - private static String encodeRawUnicodeEscape(String str, String errors) { - int size = str.length(); - StringBuffer v = new StringBuffer(str.length()); - - for (int i = 0; i < size; i++) { - char ch = str.charAt(i); - if (ch >= 256) { - v.append("\\u"); - v.append(hexdigit[(ch >>> 12) & 0xF]); - v.append(hexdigit[(ch >>> 8) & 0xF]); - v.append(hexdigit[(ch >>> 4) & 0xF]); - v.append(hexdigit[ch & 0xF]); - } else - v.append(ch); - } - - return v.toString(); - } - - - public static PyTuple raw_unicode_escape_decode(String str, String errors) { ! return codec_tuple(decodeRawUnicodeEscape(str, errors), str.length()); } - - private static String decodeRawUnicodeEscape(String str, String errors) { - int size = str.length(); - StringBuffer v = new StringBuffer(size); - - for (int i = 0; i < size; ) { - char ch = str.charAt(i); - - /* Non-escape characters are interpreted as Unicode ordinals */ - if (ch != '\\') { - v.append(ch); - i++; - continue; - } - - /* \\u-escapes are only interpreted iff the number of leading - backslashes is odd */ - int bs = i; - while (i < size) { - ch = str.charAt(i); - if (ch != '\\') - break; - v.append(ch); - i++; - } - if (((i - bs) & 1) == 0 || i >= size || ch != 'u') { - continue; - } - v.setLength(v.length() - 1); - i++; - - /* \\uXXXX with 4 hex digits */ - int x = 0; - for (int j = 0; j < 4; j++) { - ch = str.charAt(i+j); - int d = Character.digit(ch, 16); - if (d == -1) { - codecs.decoding_error("unicode escape", v, errors, - "truncated \\uXXXX"); - break; - } - x = ((x<<4) & ~0xF) + d; - } - i += 4; - v.append((char) x); - } - return v.toString(); - } --- 561,575 ---- public static PyTuple raw_unicode_escape_encode(String str, String errors) { ! return codec_tuple(codecs.PyUnicode_EncodeRawUnicodeEscape(str, errors, false), ! str.length()); } public static PyTuple raw_unicode_escape_decode(String str, String errors) { ! return codec_tuple(codecs.PyUnicode_DecodeRawUnicodeEscape(str, errors), ! str.length()); } |
From: Finn B. <bc...@us...> - 2001-01-21 14:02:25
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv11257/core Modified Files: codecs.java Log Message: Moved the RawUnicodeEscape from Modules/_codecs to core/codecs. The encoding is used by cPickle, and keeping it in _codecs makes is very difficult to use cPickle in frozen applications. Index: codecs.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/codecs.java,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** codecs.java 2000/12/11 18:45:25 2.3 --- codecs.java 2001/01/21 14:02:35 2.4 *************** *** 195,198 **** --- 195,273 ---- + /* --- RawUnicodeEscape Codec -------------------------------------------- */ + + private static char[] hexdigit = "0123456789ABCDEF".toCharArray(); + + // The modified flag is used by cPickle. + public static String PyUnicode_EncodeRawUnicodeEscape(String str, String errors, + boolean modifed) { + + int size = str.length(); + StringBuffer v = new StringBuffer(str.length()); + + for (int i = 0; i < size; i++) { + char ch = str.charAt(i); + if (ch >= 256 || (modifed && (ch == '\n' || ch == '\\'))) { + v.append("\\u"); + v.append(hexdigit[(ch >>> 12) & 0xF]); + v.append(hexdigit[(ch >>> 8) & 0xF]); + v.append(hexdigit[(ch >>> 4) & 0xF]); + v.append(hexdigit[ch & 0xF]); + } else + v.append(ch); + } + + return v.toString(); + } + + + public static String PyUnicode_DecodeRawUnicodeEscape(String str, String errors) { + int size = str.length(); + StringBuffer v = new StringBuffer(size); + + for (int i = 0; i < size; ) { + char ch = str.charAt(i); + + /* Non-escape characters are interpreted as Unicode ordinals */ + if (ch != '\\') { + v.append(ch); + i++; + continue; + } + + /* \\u-escapes are only interpreted iff the number of leading + backslashes is odd */ + int bs = i; + while (i < size) { + ch = str.charAt(i); + if (ch != '\\') + break; + v.append(ch); + i++; + } + if (((i - bs) & 1) == 0 || i >= size || ch != 'u') { + continue; + } + v.setLength(v.length() - 1); + i++; + + /* \\uXXXX with 4 hex digits */ + int x = 0; + for (int j = 0; j < 4; j++) { + ch = str.charAt(i+j); + int d = Character.digit(ch, 16); + if (d == -1) { + codecs.decoding_error("unicode escape", v, errors, + "truncated \\uXXXX"); + break; + } + x = ((x<<4) & ~0xF) + d; + } + i += 4; + v.append((char) x); + } + return v.toString(); + } + /* --- Utility methods -------------------------------------------- */ |
From: Finn B. <bc...@us...> - 2001-01-21 14:00:23
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv10884 Modified Files: Py.java PyString.java __builtin__.java Log Message: Optimized iteration over a string by reducing the number of new objects created. Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** Py.java 2001/01/17 11:51:14 2.31 --- Py.java 2001/01/21 14:00:33 2.32 *************** *** 342,346 **** public static PyString newString(char c) { ! return makeCharacter(new Character(c)); } --- 342,346 ---- public static PyString newString(char c) { ! return makeCharacter(c); } *************** *** 1288,1296 **** private static PyString[] letters=null; static final PyString makeCharacter(Character o) { ! char c = o.charValue(); ! if (c > 255) { ! return new PyString(o.toString()); } --- 1288,1299 ---- private static PyString[] letters=null; + static final PyString makeCharacter(Character o) { ! return makeCharacter(o.charValue()); ! } ! ! static final PyString makeCharacter(char c) { if (c > 255) { ! return new PyString(new Character(c).toString()); } Index: PyString.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyString.java,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -r2.32 -r2.33 *** PyString.java 2000/12/15 22:55:54 2.32 --- PyString.java 2001/01/21 14:00:33 2.33 *************** *** 592,596 **** protected PyObject get(int i) { ! return new PyString(string.substring(i,i+1)); } --- 592,596 ---- protected PyObject get(int i) { ! return Py.newString(string.charAt(i)); } Index: __builtin__.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/__builtin__.java,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** __builtin__.java 2001/01/15 04:44:33 2.23 --- __builtin__.java 2001/01/21 14:00:33 2.24 *************** *** 305,309 **** int n = chars.length; for(i=0, j=0; i<n; i++) { ! args[0] = Py.makeCharacter(new Character(chars[i])); if (!f.__call__(args).__nonzero__()) continue; --- 305,309 ---- int n = chars.length; for(i=0, j=0; i<n; i++) { ! args[0] = Py.makeCharacter(chars[i]); if (!f.__call__(args).__nonzero__()) continue; |
From: Finn B. <bc...@us...> - 2001-01-21 13:50:37
|
Update of /cvsroot/jython/jython/Doc In directory usw-pr-cvs1:/tmp/cvs-serv9466 Modified Files: index.ht Log Message: Added a link to the lang-ref. Index: index.ht =================================================================== RCS file: /cvsroot/jython/jython/Doc/index.ht,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** index.ht 2001/01/16 20:38:42 1.5 --- index.ht 2001/01/21 13:50:47 1.6 *************** *** 75,78 **** --- 75,82 ---- programmers keep the Library Reference Manual under their pillow for easy access. + + <LI>The Python <A HREF="http://www.python.org/doc/current/ref/ref.html"> + Language Reference</A> (for language lawyers). + </UL> |
From: Finn B. <bc...@us...> - 2001-01-18 09:48:22
|
Update of /cvsroot/jython/htdocs In directory usw-pr-cvs1:/tmp/cvs-serv16935 Modified Files: NEWS.ht Log Message: Updated to 2.0. Index: NEWS.ht =================================================================== RCS file: /cvsroot/jython/htdocs/NEWS.ht,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** NEWS.ht 2001/01/15 19:51:51 1.6 --- NEWS.ht 2001/01/18 09:48:23 1.7 *************** *** 2,5 **** --- 2,11 ---- Jython NEWS + 17-Jan-2001 Jython 2.0 final release + + Bug fixes. + - Install the correct image for the local documention. + - Added os.linesep field. + 15-Jan-2001 Jython 2.0 release candidate 1 |
From: Finn B. <bc...@us...> - 2001-01-18 09:44:29
|
Update of /cvsroot/jython/htdocs In directory usw-pr-cvs1:/tmp/cvs-serv16332 Modified Files: index.ht Log Message: Updated to 2.0 Index: index.ht =================================================================== RCS file: /cvsroot/jython/htdocs/index.ht,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** index.ht 2001/01/16 20:34:33 1.13 --- index.ht 2001/01/18 09:44:30 1.14 *************** *** 20,37 **** <dl> ! <p><dt><b>Jython 2.0 release candidate 1 released!</b> ! <dd>Download the lastest relase of Jython <a href="download.html">here</a>, ! or <a href="NEWS.html">read a summary</a> ! of recent changes. (15-jan-2001). <p><dt><b>New website layout.</b> <dd>New colors and an icon created by Ivan Kougaenko. (15-jan-2001). - <p><dt><b>Jython 2.0 beta 2 released!</b> - <dd>The second beta release of Jython is available (10-jan-2001). - - <p><dt><b>Jython 2.0 beta 1 released!</b> - <dd>The first beta release of Jython is available (31-dec-2000). - <p><dt><b>Step by step installation instruction for MacOS.</b> <dd>L. Humbert has contributed a <a href="MacOS_Install.html">guide</a> --- 20,32 ---- <dl> ! <p><dt><b>Jython 2.0 released!</b> ! <dd>Download the lastest stable relase of Jython ! <a href="download.html">here</a>, or ! <a href="NEWS.html">read a summary</a> ! of recent changes. (17-jan-2001). <p><dt><b>New website layout.</b> <dd>New colors and an icon created by Ivan Kougaenko. (15-jan-2001). <p><dt><b>Step by step installation instruction for MacOS.</b> <dd>L. Humbert has contributed a <a href="MacOS_Install.html">guide</a> *************** *** 67,71 **** </dl> ! <font size=-1> last updated 15-jan-2001 </font> --- 62,66 ---- </dl> ! <font size=-1> last updated 17-jan-2001 </font> |