From: <pj...@us...> - 2008-10-12 22:18:20
|
Revision: 5381 http://jython.svn.sourceforge.net/jython/?rev=5381&view=rev Author: pjenvey Date: 2008-10-12 22:18:06 +0000 (Sun, 12 Oct 2008) Log Message: ----------- better unhashable TypeError messages Modified Paths: -------------- trunk/jython/src/org/python/core/PyDictionary.java trunk/jython/src/org/python/core/PyList.java trunk/jython/src/org/python/core/PySlice.java trunk/jython/src/templates/object.derived Modified: trunk/jython/src/org/python/core/PyDictionary.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionary.java 2008-10-12 20:10:04 UTC (rev 5380) +++ trunk/jython/src/org/python/core/PyDictionary.java 2008-10-12 22:18:06 UTC (rev 5381) @@ -661,7 +661,7 @@ @ExposedMethod final int dict___hash__() { - throw Py.TypeError("unhashable type"); + throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); } public boolean isSequenceType() { Modified: trunk/jython/src/org/python/core/PyList.java =================================================================== --- trunk/jython/src/org/python/core/PyList.java 2008-10-12 20:10:04 UTC (rev 5380) +++ trunk/jython/src/org/python/core/PyList.java 2008-10-12 22:18:06 UTC (rev 5381) @@ -730,7 +730,7 @@ @ExposedMethod final int list___hash__() { - throw Py.TypeError("unhashable type"); + throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); } public PyTuple __getnewargs__() { Modified: trunk/jython/src/org/python/core/PySlice.java =================================================================== --- trunk/jython/src/org/python/core/PySlice.java 2008-10-12 20:10:04 UTC (rev 5380) +++ trunk/jython/src/org/python/core/PySlice.java 2008-10-12 22:18:06 UTC (rev 5381) @@ -71,7 +71,7 @@ @ExposedMethod final int slice___hash__() { - throw Py.TypeError("unhashable type"); + throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); } public PyString __str__() { Modified: trunk/jython/src/templates/object.derived =================================================================== --- trunk/jython/src/templates/object.derived 2008-10-12 20:10:04 UTC (rev 5380) +++ trunk/jython/src/templates/object.derived 2008-10-12 22:18:06 UTC (rev 5381) @@ -78,7 +78,7 @@ throw Py.TypeError("__hash__ should return a int"); } if (self_type.lookup("__eq__") != null || self_type.lookup("__cmp__") != null) { - throw Py.TypeError("unhashable type"); + throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); } return super.hashCode(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-10-25 21:51:54
|
Revision: 5506 http://jython.svn.sourceforge.net/jython/?rev=5506&view=rev Author: pjenvey Date: 2008-10-25 21:47:49 +0000 (Sat, 25 Oct 2008) Log Message: ----------- o back set with ConcurrentHashSet (just wraps ConcurrentHashMap) to make it thread safe o make frozenset immutable from the Java side's Set interface methods -- avoid unmodifiableSet because that complicates BaseSet Modified Paths: -------------- trunk/jython/src/org/python/core/BaseSet.java trunk/jython/src/org/python/core/PyFrozenSet.java trunk/jython/src/org/python/core/PyFrozenSetDerived.java trunk/jython/src/org/python/core/PySet.java trunk/jython/src/org/python/core/PySetIterator.java trunk/jython/src/templates/frozenset.derived Added Paths: ----------- trunk/jython/src/org/python/core/util/ConcurrentHashSet.java Modified: trunk/jython/src/org/python/core/BaseSet.java =================================================================== --- trunk/jython/src/org/python/core/BaseSet.java 2008-10-24 00:48:16 UTC (rev 5505) +++ trunk/jython/src/org/python/core/BaseSet.java 2008-10-25 21:47:49 UTC (rev 5506) @@ -8,51 +8,46 @@ public abstract class BaseSet extends PyObject implements Set { - /** - * The underlying container. HashSet is used rather than Set because - * clone is protected on Object and I didn't want to cast. - */ - protected HashSet _set; + /** The underlying Set. */ + protected Set _set; /** - * Create a new, empty set instance. - */ - public BaseSet() { - super(); - _set = new HashSet(); - } - - /** - * Create a new set instance from the values of the iterable object. + * Create a new Python set instance from the specified Set object. * - * @param data An iterable instance. + * @param set An Set object. */ - public BaseSet(PyObject data) { - super(); - _set = new HashSet(); - _update(data); + protected BaseSet(Set set) { + _set = set; } - public BaseSet(PyType type) { + protected BaseSet(PyType type, Set set) { super(type); - _set = new HashSet(); + _set = set; } + protected void _update(PyObject data) throws PyIgnoreMethodTag { + update(_set, data); + } + /** * Update the underlying set with the contents of the iterable. * * @param data An iterable instance. * @throws PyIgnoreMethodTag Ignore. */ - protected void _update(PyObject data) throws PyIgnoreMethodTag { + protected static Set update(Set set, PyObject data) throws PyIgnoreMethodTag { + if (data == null) { + return set; + } if (data instanceof BaseSet) { // Skip the iteration if both are sets - _set.addAll(((BaseSet)data)._set); - return; + set.addAll(((BaseSet)data)._set); + return set; } for (PyObject item : data.asIterable()) { - _set.add(item); + set.add(item); } + return set; } /** @@ -458,17 +453,15 @@ protected static BaseSet makeNewSet(PyType type, PyObject iterable) { BaseSet so; if (type == PySet.TYPE) { - so = new PySet(); + so = new PySet(iterable); } else if (type == PyFrozenSet.TYPE) { - so = new PyFrozenSet(); + so = new PyFrozenSet(iterable); } else if (Py.isSubClass(type, PySet.TYPE)) { so = new PySetDerived(type); + so._update(iterable); } else { - so = new PyFrozenSetDerived(type); + so = new PyFrozenSetDerived(type, iterable); } - if (iterable != null) { - so._update(iterable); - } return so; } Modified: trunk/jython/src/org/python/core/PyFrozenSet.java =================================================================== --- trunk/jython/src/org/python/core/PyFrozenSet.java 2008-10-24 00:48:16 UTC (rev 5505) +++ trunk/jython/src/org/python/core/PyFrozenSet.java 2008-10-25 21:47:49 UTC (rev 5506) @@ -1,5 +1,9 @@ package org.python.core; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; + import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; import org.python.expose.ExposedType; @@ -11,15 +15,15 @@ public static final PyType TYPE = PyType.fromClass(PyFrozenSet.class); public PyFrozenSet() { - super(); + super(new HashSet<PyObject>()); } - public PyFrozenSet(PyType type) { - super(type); + public PyFrozenSet(PyObject data) { + super(update(new HashSet<PyObject>(), data)); } - public PyFrozenSet(PyObject data) { - super(data); + public PyFrozenSet(PyType type, PyObject data) { + super(type, update(new HashSet<PyObject>(), data)); } @ExposedNew @@ -32,7 +36,7 @@ if (new_.for_type == subtype) { if (iterable == null) { fset = Py.EmptyFrozenSet; - } else if (iterable.getClass() == PyFrozenSet.class) { + } else if (iterable.getType() == TYPE) { fset = (PyFrozenSet)iterable; } else { fset = new PyFrozenSet(iterable); @@ -41,10 +45,7 @@ } } } else { - fset = new PyFrozenSetDerived(subtype); - if (iterable != null) { - fset._update(iterable); - } + fset = new PyFrozenSetDerived(subtype, iterable); } return fset; @@ -177,4 +178,44 @@ public int hashCode() { return frozenset___hash__(); } + + public void clear() { + throw new UnsupportedOperationException(); + } + + public boolean add(Object o) { + throw new UnsupportedOperationException(); + } + + public boolean remove(Object o) { + throw new UnsupportedOperationException(); + } + + public boolean addAll(Collection c) { + throw new UnsupportedOperationException(); + } + + public boolean removeAll(Collection c) { + throw new UnsupportedOperationException(); + } + + public boolean retainAll(Collection c) { + throw new UnsupportedOperationException(); + } + + public Iterator iterator() { + return new Iterator() { + Iterator i = _set.iterator(); + + public boolean hasNext() { + return i.hasNext(); + } + public Object next() { + return i.next(); + } + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } } Modified: trunk/jython/src/org/python/core/PyFrozenSetDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFrozenSetDerived.java 2008-10-24 00:48:16 UTC (rev 5505) +++ trunk/jython/src/org/python/core/PyFrozenSetDerived.java 2008-10-25 21:47:49 UTC (rev 5506) @@ -36,8 +36,8 @@ dict=new PyStringMap(); } - public PyFrozenSetDerived(PyType subtype) { - super(subtype); + public PyFrozenSetDerived(PyType subtype,PyObject data) { + super(subtype,data); slots=new PyObject[subtype.getNumSlots()]; dict=subtype.instDict(); } Modified: trunk/jython/src/org/python/core/PySet.java =================================================================== --- trunk/jython/src/org/python/core/PySet.java 2008-10-24 00:48:16 UTC (rev 5505) +++ trunk/jython/src/org/python/core/PySet.java 2008-10-25 21:47:49 UTC (rev 5506) @@ -3,6 +3,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; +import org.python.core.util.ConcurrentHashSet; import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; import org.python.expose.ExposedType; @@ -14,15 +15,15 @@ public static final PyType TYPE = PyType.fromClass(PySet.class); public PySet() { - super(); + super(new ConcurrentHashSet<PyObject>()); } public PySet(PyType type) { - super(type); + super(type, new ConcurrentHashSet<PyObject>()); } public PySet(PyObject data) { - super(data); + super(update(new ConcurrentHashSet<PyObject>(), data)); } @ExposedNew @@ -37,8 +38,7 @@ } _set.clear(); - PyObject o = args[0]; - _update(o); + _update(args[0]); } @ExposedMethod(type = MethodType.BINARY) @@ -245,11 +245,11 @@ final PyObject set_pop() { Iterator iterator = _set.iterator(); try { - Object first = iterator.next(); + Object first = iterator.next(); _set.remove(first); - return (PyObject) first; + return (PyObject)first; } catch (NoSuchElementException e) { - throw new PyException(Py.KeyError, "pop from an empty set"); + throw new PyException(Py.KeyError, "pop from an empty set"); } } Modified: trunk/jython/src/org/python/core/PySetIterator.java =================================================================== --- trunk/jython/src/org/python/core/PySetIterator.java 2008-10-24 00:48:16 UTC (rev 5505) +++ trunk/jython/src/org/python/core/PySetIterator.java 2008-10-25 21:47:49 UTC (rev 5506) @@ -2,18 +2,20 @@ import java.util.Iterator; import java.util.Set; -import java.util.ConcurrentModificationException; public class PySetIterator extends PyObject { - private Set _set; - private int _count; - private Iterator _iterator; + private Set set; + + private int size; + + private Iterator<PyObject> iterator; + public PySetIterator(Set set) { super(); - this._set = set; - this._count = 0; - this._iterator = set.iterator(); + this.set = set; + size = set.size(); + iterator = set.iterator(); } public PyObject __iter__() { @@ -22,24 +24,12 @@ /** * Returns the next item in the iteration or raises a StopIteration. - * <p/> - * <p/> - * This differs from the core Jython Set iterator in that it checks if - * the underlying Set changes in size during the course and upon completion - * of the iteration. A RuntimeError is raised if the Set ever changes size - * or is concurrently modified. - * </p> * * @return the next item in the iteration */ public PyObject next() { PyObject o = this.__iternext__(); if (o == null) { - if (this._count != this._set.size()) { - // CPython throws an exception even if you have iterated through the - // entire set, this is not true for Java, so check by hand - throw Py.RuntimeError("dictionary changed size during iteration"); - } throw Py.StopIteration(""); } return o; @@ -48,18 +38,15 @@ /** * Returns the next item in the iteration. * - * @return the next item in the iteration - * or null to signal the end of the iteration + * @return the next item in the iteration or null to signal the end of the iteration */ public PyObject __iternext__() { - if (this._iterator.hasNext()) { - this._count++; - try { - return Py.java2py(this._iterator.next()); - } catch (ConcurrentModificationException e) { - throw Py.RuntimeError("dictionary changed size during iteration"); - } + if (set.size() != size) { + throw Py.RuntimeError("set changed size during iteration"); } + if (iterator.hasNext()) { + return iterator.next(); + } return null; } } Added: trunk/jython/src/org/python/core/util/ConcurrentHashSet.java =================================================================== --- trunk/jython/src/org/python/core/util/ConcurrentHashSet.java (rev 0) +++ trunk/jython/src/org/python/core/util/ConcurrentHashSet.java 2008-10-25 21:47:49 UTC (rev 5506) @@ -0,0 +1,90 @@ +/* Copyright (c) Jython Developers */ +package org.python.core.util; + +import java.util.AbstractSet; +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * A Set backed by ConcurrentHashMap. + */ +public class ConcurrentHashSet<E> extends AbstractSet<E> { + + /** The backing Map. */ + private ConcurrentHashMap<E, Object> map; + + /** Backing's KeySet. */ + private transient Set<E> keySet; + + /** Dummy value to associate with the key in the backing map. */ + private static final Object PRESENT = new Object(); + + public ConcurrentHashSet() { + map = new ConcurrentHashMap<E, Object>(); + keySet = map.keySet(); + } + + public ConcurrentHashSet(int initialCapacity) { + map = new ConcurrentHashMap<E, Object>(initialCapacity); + keySet = map.keySet(); + } + + public ConcurrentHashSet(int initialCapacity, float loadFactor, int concurrencyLevel) { + map = new ConcurrentHashMap<E, Object>(initialCapacity, loadFactor, concurrencyLevel); + keySet = map.keySet(); + } + + public int size() { + return map.size(); + } + + public boolean isEmpty() { + return map.isEmpty(); + } + + public boolean contains(Object o) { + return map.containsKey(o); + } + + public Iterator<E> iterator() { + return keySet.iterator(); + } + + public Object[] toArray() { + return keySet.toArray(); + } + + public <T> T[] toArray(T[] a) { + return keySet.toArray(a); + } + + public boolean add(E e) { + return map.put(e, PRESENT) == null; + } + + public boolean remove(Object o) { + return map.remove(o) != null; + } + + public boolean removeAll(Collection<?> c) { + return keySet.removeAll(c); + } + + public boolean retainAll(Collection<?> c) { + return keySet.retainAll(c); + } + + public void clear() { + map.clear(); + } + + public boolean equals(Object o) { + return keySet.equals(o); + } + + public int hashCode() { + return keySet.hashCode(); + } +} Modified: trunk/jython/src/templates/frozenset.derived =================================================================== --- trunk/jython/src/templates/frozenset.derived 2008-10-24 00:48:16 UTC (rev 5505) +++ trunk/jython/src/templates/frozenset.derived 2008-10-25 21:47:49 UTC (rev 5506) @@ -1,4 +1,4 @@ base_class: PyFrozenSet want_dict: true -ctr: +ctr: PyObject data incl: object This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-11-23 04:18:54
|
Revision: 5609 http://jython.svn.sourceforge.net/jython/?rev=5609&view=rev Author: pjenvey Date: 2008-11-23 04:18:48 +0000 (Sun, 23 Nov 2008) Log Message: ----------- ((PyInteger)obj.__int__()).getValue() -> obj.asInt() to avoid potential ClassCastException mayhem now that __int__ can return longs. as a side effect TypeErrors are raised on conversion failure rather than AttributeErrors (which is usually more appropriate anyway) fixes #1052 Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/Fetch.java trunk/jython/src/com/ziclix/python/sql/Procedure.java trunk/jython/src/com/ziclix/python/sql/PyCursor.java trunk/jython/src/com/ziclix/python/sql/PyStatement.java trunk/jython/src/org/python/core/PyArray.java trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/modules/imp.java trunk/jython/src/org/python/modules/struct.java trunk/jython/src/org/python/modules/thread/thread.java trunk/jython/src/org/python/modules/time/Time.java Modified: trunk/jython/src/com/ziclix/python/sql/Fetch.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/Fetch.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/com/ziclix/python/sql/Fetch.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -304,7 +304,7 @@ for (int i = 0, len = procedure.columns.__len__(); i < len; i++) { PyObject column = procedure.columns.__getitem__(i); - int colType = ((PyInteger)column.__getitem__(Procedure.COLUMN_TYPE).__int__()).getValue(); + int colType = column.__getitem__(Procedure.COLUMN_TYPE).asInt(); switch (colType) { @@ -316,7 +316,7 @@ a[2] = Py.newInteger(-1); a[3] = column.__getitem__(Procedure.LENGTH); - switch (((PyInteger)a[1].__int__()).getValue()) { + switch (a[1].asInt()) { case Types.BIGINT: case Types.BIT: @@ -335,7 +335,7 @@ break; } - int nullable = ((PyInteger)column.__getitem__(Procedure.NULLABLE).__int__()).getValue(); + int nullable = column.__getitem__(Procedure.NULLABLE).asInt(); a[6] = (nullable == DatabaseMetaData.procedureNullable) ? Py.One : Py.Zero; @@ -363,8 +363,8 @@ for (int i = 0, j = 0, len = procedure.columns.__len__(); i < len; i++) { PyObject obj = Py.None; PyObject column = procedure.columns.__getitem__(i); - int colType = ((PyInteger)column.__getitem__(Procedure.COLUMN_TYPE).__int__()).getValue(); - int dataType = ((PyInteger)column.__getitem__(Procedure.DATA_TYPE).__int__()).getValue(); + int colType = column.__getitem__(Procedure.COLUMN_TYPE).asInt(); + int dataType = column.__getitem__(Procedure.DATA_TYPE).asInt(); switch (colType) { Modified: trunk/jython/src/com/ziclix/python/sql/Procedure.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/Procedure.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/com/ziclix/python/sql/Procedure.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -165,8 +165,8 @@ if (normal) { statement = cursor.connection.connection.prepareCall(sqlString); } else { - int t = ((PyInteger)rsType.__int__()).getValue(); - int c = ((PyInteger)rsConcur.__int__()).getValue(); + int t = rsType.asInt(); + int c = rsConcur.asInt(); statement = cursor.connection.connection.prepareCall(sqlString, t, c); } @@ -202,7 +202,7 @@ // do nothing with params at the moment for (int i = 0, len = this.columns.__len__(), binding = 0; i < len; i++) { PyObject column = this.columns.__getitem__(i); - int colType = ((PyInteger)column.__getitem__(COLUMN_TYPE).__int__()).getValue(); + int colType = column.__getitem__(COLUMN_TYPE).asInt(); switch (colType) { @@ -213,7 +213,7 @@ PyInteger key = Py.newInteger(binding++); if (bindings.__finditem__(key) == null) { - int dataType = ((PyInteger)column.__getitem__(DATA_TYPE).__int__()).getValue(); + int dataType = column.__getitem__(DATA_TYPE).asInt(); bindings.__setitem__(key, Py.newInteger(dataType)); } @@ -256,7 +256,7 @@ if (this.columns != Py.None) { for (int i = 0, len = this.columns.__len__(); i < len; i++) { PyObject column = this.columns.__getitem__(i); - int colType = ((PyInteger)column.__getitem__(COLUMN_TYPE).__int__()).getValue(); + int colType = column.__getitem__(COLUMN_TYPE).asInt(); switch (colType) { @@ -326,8 +326,8 @@ for (int i = 0, len = this.columns.__len__(); i < len; i++) { PyObject column = this.columns.__getitem__(i); - int colType = ((PyInteger)column.__getitem__(COLUMN_TYPE).__int__()).getValue(); - int dataType = ((PyInteger)column.__getitem__(DATA_TYPE).__int__()).getValue(); + int colType = column.__getitem__(COLUMN_TYPE).asInt(); + int dataType = column.__getitem__(DATA_TYPE).asInt(); String dataTypeName = column.__getitem__(DATA_TYPE_NAME).toString(); switch (colType) { Modified: trunk/jython/src/com/ziclix/python/sql/PyCursor.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/PyCursor.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/com/ziclix/python/sql/PyCursor.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -180,9 +180,9 @@ public void __setattr__(String name, PyObject value) { if ("arraysize".equals(name)) { - this.arraysize = ((PyInteger)value.__int__()).getValue(); + this.arraysize = value.asInt(); } else if ("softspace".equals(name)) { - this.softspace = ((PyInteger)value.__int__()).getValue(); + this.softspace = value.asInt(); } else if ("datahandler".equals(name)) { this.datahandler = (DataHandler)value.__tojava__(DataHandler.class); } else { @@ -398,8 +398,8 @@ sqlStatement = this.connection.connection.createStatement(); } } else { - int t = ((PyInteger)this.rsType.__int__()).getValue(); - int c = ((PyInteger)this.rsConcur.__int__()).getValue(); + int t = this.rsType.asInt(); + int c = this.rsConcur.asInt(); if (prepared) { sqlStatement = this.connection.connection.prepareStatement(sqlString, t, c); @@ -414,7 +414,7 @@ } if (maxRows != Py.None) { - stmt.statement.setMaxRows(((PyInteger)maxRows.__int__()).getValue()); + stmt.statement.setMaxRows(maxRows.asInt()); } } catch (AbstractMethodError e) { throw zxJDBC.makeException(zxJDBC.NotSupportedError, zxJDBC.getString("nodynamiccursors")); @@ -457,7 +457,7 @@ Statement stmt = procedure.prepareCall(this.rsType, this.rsConcur); if (maxRows != Py.None) { - stmt.setMaxRows(((PyInteger)maxRows.__int__()).getValue()); + stmt.setMaxRows(maxRows.asInt()); } // get the bindings per the stored proc spec @@ -897,7 +897,7 @@ PyCursor cursor = (PyCursor)__self__; switch (index) { case 0 : - return cursor.fetchmany(((PyInteger)arg.__int__()).getValue()); + return cursor.fetchmany(arg.asInt()); case 5 : cursor.execute(arg, Py.None, Py.None, Py.None); return Py.None; @@ -911,7 +911,7 @@ cursor.executemany(arg, Py.None, Py.None, Py.None); return Py.None; case 10 : - cursor.scroll(((PyInteger)arg.__int__()).getValue(), "relative"); + cursor.scroll(arg.asInt(), "relative"); return Py.None; case 11 : cursor.execute(arg, Py.None, Py.None, Py.None); @@ -938,7 +938,7 @@ cursor.executemany(arga, argb, Py.None, Py.None); return Py.None; case 10 : - cursor.scroll(((PyInteger)arga.__int__()).getValue(), argb.toString()); + cursor.scroll(arga.asInt(), argb.toString()); return Py.None; default : throw info.unexpectedCall(2, false); Modified: trunk/jython/src/com/ziclix/python/sql/PyStatement.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/PyStatement.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/com/ziclix/python/sql/PyStatement.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -300,7 +300,7 @@ if (binding != null) { try { - int bindingValue = ((PyInteger)binding.__int__()).getValue(); + int bindingValue = binding.asInt(); datahandler.setJDBCObject(preparedStatement, column, param, bindingValue); } catch (PyException e) { Modified: trunk/jython/src/org/python/core/PyArray.java =================================================================== --- trunk/jython/src/org/python/core/PyArray.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/org/python/core/PyArray.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -438,7 +438,7 @@ return s.toString().charAt(0); } else if (obj.__nonzero__()) { - return ((PyInteger)obj.__int__()).getValue(); + return obj.asInt(); } else { return -1; Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/org/python/core/PyString.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -2953,7 +2953,9 @@ } int val; try { - val = ((PyInteger)arg.__int__()).getValue(); + // Explicitly __int__ so we can look for an AttributeError (which is + // less invasive to mask than a TypeError) + val = arg.__int__().asInt(); } catch (PyException e){ if (Py.matchException(e, Py.AttributeError)) { throw Py.TypeError("%c requires int or char"); Modified: trunk/jython/src/org/python/modules/imp.java =================================================================== --- trunk/jython/src/org/python/modules/imp.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/org/python/modules/imp.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -180,7 +180,7 @@ public static PyObject load_module(String name, PyObject file, PyObject filename, PyTuple data) { PyObject mod = Py.None; PySystemState sys = Py.getSystemState(); - int type = ((PyInteger)data.__getitem__(2).__int__()).getValue(); + int type = data.__getitem__(2).asInt(); while(mod == Py.None) { Object o = file.__tojava__(InputStream.class); if (o == Py.NoConversion) { Modified: trunk/jython/src/org/python/modules/struct.java =================================================================== --- trunk/jython/src/org/python/modules/struct.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/org/python/modules/struct.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -329,7 +329,7 @@ int get_int(PyObject value) { try { - return ((PyInteger)value.__int__()).getValue(); + return value.asInt(); } catch (PyException ex) { throw StructError("required argument is not an integer"); } Modified: trunk/jython/src/org/python/modules/thread/thread.java =================================================================== --- trunk/jython/src/org/python/modules/thread/thread.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/org/python/modules/thread/thread.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -101,7 +101,7 @@ return stack_size; case 1: long old_stack_size = stack_size; - int proposed_stack_size = ((PyInteger)args[0].__int__()).getValue(); + int proposed_stack_size = args[0].asInt(); if (proposed_stack_size != 0 && proposed_stack_size < 32768) { // as specified by Python, Java quietly ignores what // it considers are too small Modified: trunk/jython/src/org/python/modules/time/Time.java =================================================================== --- trunk/jython/src/org/python/modules/time/Time.java 2008-11-23 04:15:40 UTC (rev 5608) +++ trunk/jython/src/org/python/modules/time/Time.java 2008-11-23 04:18:48 UTC (rev 5609) @@ -154,7 +154,7 @@ private static int item(PyTuple tup, int i) { // knows about and asserts format on tuple items. See // documentation for Python's time module for details. - int val = ((PyInteger)tup.__getitem__(i).__int__()).getValue(); + int val = tup.__getitem__(i).asInt(); boolean valid = true; switch (i) { case 0: break; // year This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-22 03:21:49
|
Revision: 5786 http://jython.svn.sourceforge.net/jython/?rev=5786&view=rev Author: cgroves Date: 2008-12-22 03:21:46 +0000 (Mon, 22 Dec 2008) Log Message: ----------- Use Generic.map to create genericized versions of all the newly HashMapped instances. Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/handler/RowIdHandler.java trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java trunk/jython/src/org/python/modules/_weakref/GlobalRef.java trunk/jython/src/org/python/modules/cPickle.java Modified: trunk/jython/src/com/ziclix/python/sql/handler/RowIdHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/handler/RowIdHandler.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/com/ziclix/python/sql/handler/RowIdHandler.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -12,13 +12,13 @@ import com.ziclix.python.sql.DataHandler; import java.util.Map; -import java.util.HashMap; import java.sql.Statement; import java.sql.SQLException; import java.lang.reflect.Method; import org.python.core.PyObject; import org.python.core.Py; +import org.python.util.Generic; /** * Handle the rowid methods since the API is not available until JDBC 3.0. @@ -29,7 +29,7 @@ */ public abstract class RowIdHandler extends FilterDataHandler { - private static Map ROWIDS = new HashMap(); + private static Map<Class<?>, Object> ROWIDS = Generic.map(); private static Object CHECKED = new Object(); public RowIdHandler(DataHandler handler) { @@ -52,7 +52,7 @@ */ public PyObject getRowId(Statement stmt) throws SQLException { - Class c = stmt.getClass(); + Class<?> c = stmt.getClass(); Object o = ROWIDS.get(c); if (o == null) { Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/org/python/core/PySystemState.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -7,7 +7,6 @@ import java.net.URL; import java.net.URLDecoder; import java.security.AccessControlException; -import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; @@ -21,6 +20,7 @@ import org.python.core.packagecache.SysPackageManager; import org.python.modules.Setup; import org.python.modules.zipimport.zipimporter; +import org.python.util.Generic; /** * The "sys" module. @@ -31,7 +31,7 @@ public static final String PYTHON_CACHEDIR = "python.cachedir"; public static final String PYTHON_CACHEDIR_SKIP = "python.cachedir.skip"; protected static final String CACHEDIR_DEFAULT_NAME = "cachedir"; - + public static final String JYTHON_JAR = "jython.jar"; public static final String JYTHON_COMPLETE_JAR = "jython-complete.jar"; @@ -76,7 +76,7 @@ public static PackageManager packageManager; public static File cachedir; - + private static PyList defaultPath; private static PyList defaultArgv; private static PyObject defaultExecutable; @@ -86,7 +86,7 @@ public static PyObject exec_prefix = Py.EmptyString; private static boolean initialized = false; - + /** The arguments passed to this program on the command line. */ public PyList argv = new PyList(); @@ -127,7 +127,7 @@ public PyObject last_traceback = Py.None; public PyObject __name__ = new PyString("sys"); - + public PyObject __dict__; private int recursionlimit = 1000; @@ -170,7 +170,7 @@ __dict__.__setitem__("displayhook", __displayhook__); __dict__.__setitem__("excepthook", __excepthook__); } - + void reload() throws PyIgnoreMethodTag { __dict__.invoke("update", getType().fastGetDict()); } @@ -426,7 +426,7 @@ platform = new PyString("java" + version); } - private static void initRegistry(Properties preProperties, Properties postProperties, + private static void initRegistry(Properties preProperties, Properties postProperties, boolean standalone, String jarFileName) { if (registry != null) { @@ -641,8 +641,8 @@ private static PyList initArgv(String[] args) { PyList argv = new PyList(); if (args != null) { - for (int i=0; i<args.length; i++) { - argv.append(new PyString(args[i])); + for (String arg : args) { + argv.append(new PyString(arg)); } } return argv; @@ -697,15 +697,15 @@ } private static void initBuiltins(Properties props) { - builtinNames = new HashMap<String,String>(); + builtinNames = Generic.map(); // add the oddball builtins that are specially handled builtinNames.put("__builtin__", ""); builtinNames.put("sys", ""); // add builtins specified in the Setup.java file - for (int i=0; i < Setup.builtinModules.length; i++) - addBuiltin(Setup.builtinModules[i]); + for (String builtinModule : Setup.builtinModules) + addBuiltin(builtinModule); // add builtins specified in the registry file String builtinprop = props.getProperty("python.modules.builtin", ""); @@ -723,7 +723,7 @@ } public static String getBuiltin(String name) { - return (String)builtinNames.get(name); + return builtinNames.get(name); } private static PyList initPath(Properties props, boolean standalone, String jarFileName) { @@ -737,15 +737,15 @@ // standalone jython: add the /Lib directory inside JYTHON_JAR to the path addPaths(path, jarFileName + "/Lib"); } - + return path; } - + /** * Check if we are in standalone mode. - * + * * @param jarFileName The name of the jar file - * + * * @return <code>true</code> if we have a standalone .jar file, <code>false</code> otherwise. */ private static boolean isStandalone(String jarFileName) { @@ -888,7 +888,6 @@ if (o == Py.None) return; - PySystemState sys = Py.getThreadState().systemState; PySystemState.builtins.__setitem__("_", Py.None); Py.stdout.println(o.__repr__()); PySystemState.builtins.__setitem__("_", o); Modified: trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -4,6 +4,7 @@ package org.python.core.packagecache; import org.python.core.Options; +import org.python.util.Generic; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -19,9 +20,6 @@ import java.net.URL; import java.net.URLConnection; import java.security.AccessControlException; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -37,7 +35,7 @@ /** * Message log method - hook. This default impl does nothing. - * + * * @param msg message text */ protected void message(String msg) { @@ -45,7 +43,7 @@ /** * Warning log method - hook. This default impl does nothing. - * + * * @param warn warning text */ protected void warning(String warn) { @@ -53,7 +51,7 @@ /** * Comment log method - hook. This default impl does nothing. - * + * * @param msg message text */ protected void comment(String msg) { @@ -61,7 +59,7 @@ /** * Debug log method - hook. This default impl does nothing. - * + * * @param msg message text */ protected void debug(String msg) { @@ -72,7 +70,7 @@ * by {@link #addJarToPackages} in order to filter out classes whose name * contains '$' (e.g. inner classes,...). Should be used or overriden by * derived classes too. Also to be used in {@link #doDir}. - * + * * @param name class/pkg name * @param pkg if true, name refers to a pkg * @return true if name must be filtered out @@ -87,7 +85,7 @@ * classes. Should be used or overriden by derived classes too. Also to be * used in {@link #doDir}. Access perms can be read with * {@link #checkAccess}. - * + * * @param name class name * @param acc class access permissions as int * @return true if name must be filtered out @@ -100,11 +98,11 @@ private Map<String,JarXEntry> jarfiles; - private static String vectorToString(List vec) { - int n = vec.size(); + private static String listToString(List<String> list) { + int n = list.size(); StringBuilder ret = new StringBuilder(); for (int i = 0; i < n; i++) { - ret.append((String) vec.get(i)); + ret.append(list.get(i)); if (i < n - 1) { ret.append(","); } @@ -114,7 +112,7 @@ // Add a single class from zipFile to zipPackages // Only add valid, public classes - private void addZipEntry(Map zipPackages, ZipEntry entry, + private void addZipEntry(Map<String, List<String>[]> zipPackages, ZipEntry entry, ZipInputStream zip) throws IOException { String name = entry.getName(); // System.err.println("entry: "+name); @@ -142,9 +140,9 @@ return; } - List[] vec = (List[]) zipPackages.get(packageName); + List<String>[] vec = zipPackages.get(packageName); if (vec == null) { - vec = new ArrayList[] { new ArrayList(), new ArrayList() }; + vec = new List[] { Generic.list(), Generic.list() }; zipPackages.put(packageName, vec); } int access = checkAccess(zip); @@ -156,8 +154,8 @@ } // Extract all of the packages in a single jarfile - private Map getZipPackages(InputStream jarin) throws IOException { - Map zipPackages = new HashMap(); + private Map<String, String> getZipPackages(InputStream jarin) throws IOException { + Map<String, List<String>[]> zipPackages = Generic.map(); ZipInputStream zip = new ZipInputStream(jarin); @@ -168,16 +166,17 @@ } // Turn each vector into a comma-separated String - for (Object key : zipPackages.keySet()) { - List[] vec = (List[]) zipPackages.get(key); - String classes = vectorToString(vec[0]); + Map<String, String> transformed = Generic.map(); + for (String key : zipPackages.keySet()) { + List<String>[] vec = zipPackages.get(key); + String classes = listToString(vec[0]); if (vec[1].size() > 0) { - classes += '@' + vectorToString(vec[1]); + classes += '@' + listToString(vec[1]); } - zipPackages.put(key, classes); + transformed.put(key, classes); } - return zipPackages; + return transformed; } /** @@ -247,7 +246,7 @@ return; } - Map zipPackages = null; + Map<String, String> zipPackages = null; long mtime = 0; String jarcanon = null; @@ -264,7 +263,7 @@ jarcanon = jarurl.toString(); } - entry = (JarXEntry) this.jarfiles.get(jarcanon); + entry = this.jarfiles.get(jarcanon); if ((entry == null || !(new File(entry.cachefile).exists())) && cache) { @@ -345,7 +344,7 @@ // Read in cache file storing package info for a single .jar // Return null and delete this cachefile if it is invalid - private Map readCacheFile(JarXEntry entry, String jarcanon) { + private Map<String, String> readCacheFile(JarXEntry entry, String jarcanon) { String cachefile = entry.cachefile; long mtime = entry.mtime; @@ -361,7 +360,7 @@ deleteCacheFile(cachefile); return null; } - Map packs = new HashMap(); + Map<String, String> packs = Generic.map(); try { while (true) { String packageName = istream.readUTF(); @@ -406,7 +405,7 @@ */ protected void initCache() { this.indexModified = false; - this.jarfiles = new HashMap(); + this.jarfiles = Generic.map(); try { DataInputStream istream = inOpenIndex(); @@ -419,8 +418,7 @@ String jarcanon = istream.readUTF(); String cachefile = istream.readUTF(); long mtime = istream.readLong(); - this.jarfiles - .put(jarcanon, new JarXEntry(cachefile, mtime)); + this.jarfiles.put(jarcanon, new JarXEntry(cachefile, mtime)); } } catch (EOFException eof) { ; Modified: trunk/jython/src/org/python/modules/_weakref/GlobalRef.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/GlobalRef.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/org/python/modules/_weakref/GlobalRef.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -5,7 +5,6 @@ import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; import java.util.ArrayList; -import java.util.HashMap; import java.util.Map; import java.util.List; @@ -13,6 +12,7 @@ import org.python.core.PyException; import org.python.core.PyList; import org.python.core.PyObject; +import org.python.util.Generic; public class GlobalRef extends WeakReference { @@ -27,7 +27,7 @@ private static RefReaperThread reaperThread; - private static Map objects = new HashMap(); + private static Map<GlobalRef, GlobalRef> objects = Generic.map(); static { initReaperThread(); @@ -122,7 +122,7 @@ } public static GlobalRef newInstance(PyObject object) { - GlobalRef ref = (GlobalRef)objects.get(new GlobalRef(object)); + GlobalRef ref = objects.get(new GlobalRef(object)); if (ref == null) { ref = new GlobalRef(object); objects.put(ref, ref); Modified: trunk/jython/src/org/python/modules/cPickle.java =================================================================== --- trunk/jython/src/org/python/modules/cPickle.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/org/python/modules/cPickle.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -13,7 +13,6 @@ package org.python.modules; import java.math.BigInteger; -import java.util.HashMap; import java.util.Map; import org.python.core.ClassDictInit; @@ -44,6 +43,7 @@ import org.python.core.codecs; import org.python.core.exceptions; import org.python.core.imp; +import org.python.util.Generic; /** * @@ -1512,11 +1512,8 @@ } + private static Map<PyObject,PyObject> classmap = Generic.map(); - - - private static Map<PyObject,PyObject> classmap = new HashMap<PyObject,PyObject>(); - final private static PyObject whichmodule(PyObject cls, PyObject clsname) { @@ -1705,7 +1702,7 @@ private IOFile file; - public Map<String,PyObject> memo = new HashMap<String,PyObject>(); + public Map<String,PyObject> memo = Generic.map(); /** * For the benefit of persistency modules written using pickle, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-30 21:09:21
|
Revision: 5818 http://jython.svn.sourceforge.net/jython/?rev=5818&view=rev Author: cgroves Date: 2008-12-30 21:09:17 +0000 (Tue, 30 Dec 2008) Log Message: ----------- Looks like the regrtest run by the buildbot needs derived classes Modified Paths: -------------- trunk/jython/src/templates/mappings Added Paths: ----------- trunk/jython/src/org/python/core/ClasspathPyImporterDerived.java trunk/jython/src/templates/ClasspathPyImporter.derived Added: trunk/jython/src/org/python/core/ClasspathPyImporterDerived.java =================================================================== --- trunk/jython/src/org/python/core/ClasspathPyImporterDerived.java (rev 0) +++ trunk/jython/src/org/python/core/ClasspathPyImporterDerived.java 2008-12-30 21:09:17 UTC (rev 5818) @@ -0,0 +1,1136 @@ +/* Generated file, do not modify. See jython/src/templates/gderived.py. */ +package org.python.core; + +public class ClasspathPyImporterDerived extends ClasspathPyImporter implements Slotted { + + public PyObject getSlot(int index) { + return slots[index]; + } + + public void setSlot(int index,PyObject value) { + slots[index]=value; + } + + private PyObject[]slots; + + public ClasspathPyImporterDerived(PyType subtype) { + super(subtype); + slots=new PyObject[subtype.getNumSlots()]; + } + + public PyString __str__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__str__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__str__(); + } + + public PyString __repr__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__repr__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__repr__(); + } + + public PyString __hex__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__hex__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__hex__(); + } + + public PyString __oct__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__oct__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__oct__(); + } + + public PyFloat __float__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__float__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyFloat) + return(PyFloat)res; + throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); + } + return super.__float__(); + } + + public PyComplex __complex__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__complex__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyComplex) + return(PyComplex)res; + throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); + } + return super.__complex__(); + } + + public PyObject __pos__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__pos__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__pos__(); + } + + public PyObject __neg__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__neg__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__neg__(); + } + + public PyObject __abs__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__abs__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__abs__(); + } + + public PyObject __invert__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__invert__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__invert__(); + } + + public PyObject __reduce__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__reduce__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__reduce__(); + } + + public PyObject __add__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__add__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__add__(other); + } + + public PyObject __radd__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__radd__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__radd__(other); + } + + public PyObject __sub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__sub__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__sub__(other); + } + + public PyObject __rsub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rsub__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rsub__(other); + } + + public PyObject __mul__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__mul__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__mul__(other); + } + + public PyObject __rmul__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rmul__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rmul__(other); + } + + public PyObject __div__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__div__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__div__(other); + } + + public PyObject __rdiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rdiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rdiv__(other); + } + + public PyObject __floordiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__floordiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__floordiv__(other); + } + + public PyObject __rfloordiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rfloordiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rfloordiv__(other); + } + + public PyObject __truediv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__truediv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__truediv__(other); + } + + public PyObject __rtruediv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rtruediv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rtruediv__(other); + } + + public PyObject __mod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__mod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__mod__(other); + } + + public PyObject __rmod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rmod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rmod__(other); + } + + public PyObject __divmod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__divmod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__divmod__(other); + } + + public PyObject __rdivmod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rdivmod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rdivmod__(other); + } + + public PyObject __rpow__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rpow__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rpow__(other); + } + + public PyObject __lshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__lshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__lshift__(other); + } + + public PyObject __rlshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rlshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rlshift__(other); + } + + public PyObject __rshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rshift__(other); + } + + public PyObject __rrshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rrshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rrshift__(other); + } + + public PyObject __and__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__and__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__and__(other); + } + + public PyObject __rand__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rand__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rand__(other); + } + + public PyObject __or__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__or__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__or__(other); + } + + public PyObject __ror__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ror__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ror__(other); + } + + public PyObject __xor__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__xor__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__xor__(other); + } + + public PyObject __rxor__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rxor__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rxor__(other); + } + + public PyObject __lt__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__lt__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__lt__(other); + } + + public PyObject __le__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__le__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__le__(other); + } + + public PyObject __gt__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__gt__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__gt__(other); + } + + public PyObject __ge__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ge__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ge__(other); + } + + public PyObject __eq__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__eq__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__eq__(other); + } + + public PyObject __ne__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ne__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ne__(other); + } + + public PyObject __iadd__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__iadd__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__iadd__(other); + } + + public PyObject __isub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__isub__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__isub__(other); + } + + public PyObject __imul__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__imul__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__imul__(other); + } + + public PyObject __idiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__idiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__idiv__(other); + } + + public PyObject __ifloordiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ifloordiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ifloordiv__(other); + } + + public PyObject __itruediv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__itruediv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__itruediv__(other); + } + + public PyObject __imod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__imod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__imod__(other); + } + + public PyObject __ipow__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ipow__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ipow__(other); + } + + public PyObject __ilshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ilshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ilshift__(other); + } + + public PyObject __irshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__irshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__irshift__(other); + } + + public PyObject __iand__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__iand__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__iand__(other); + } + + public PyObject __ior__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ior__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ior__(other); + } + + public PyObject __ixor__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ixor__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ixor__(other); + } + + public PyObject __int__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__int__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyInteger||res instanceof PyLong) + return(PyObject)res; + throw Py.TypeError("__int__"+" should return an integer"); + } + return super.__int__(); + } + + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + + public int hashCode() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__hash__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyInteger) { + return((PyInteger)res).getValue(); + } else + if (res instanceof PyLong) { + return((PyLong)res).getValue().intValue(); + } + throw Py.TypeError("__hash__ should return a int"); + } + if (self_type.lookup("__eq__")!=null||self_type.lookup("__cmp__")!=null) { + throw Py.TypeError(String.format("unhashable type: '%.200s'",getType().fastGetName())); + } + return super.hashCode(); + } + + public PyUnicode __unicode__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__unicode__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyUnicode) + return(PyUnicode)res; + if (res instanceof PyString) + return new PyUnicode((PyString)res); + throw Py.TypeError("__unicode__"+" should return a "+"unicode"); + } + return super.__unicode__(); + } + + public int __cmp__(PyObject other) { + PyType self_type=getType(); + PyType[]where_type=new PyType[1]; + PyObject impl=self_type.lookup_where("__cmp__",where_type); + // Full Compatibility with CPython __cmp__: + // If the derived type don't override __cmp__, the + // *internal* super().__cmp__ should be called, not the + // exposed one. The difference is that the exposed __cmp__ + // throws a TypeError if the argument is an instance of the same type. + if (impl==null||where_type[0]==TYPE||Py.isSubClass(TYPE,where_type[0])) { + return super.__cmp__(other); + } + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) { + return-2; + } + int c=res.asInt(); + return c<0?-1:c>0?1:0; + } + + public boolean __nonzero__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__nonzero__"); + if (impl==null) { + impl=self_type.lookup("__len__"); + if (impl==null) + return super.__nonzero__(); + } + PyObject o=impl.__get__(this,self_type).__call__(); + Class c=o.getClass(); + if (c!=PyInteger.class&&c!=PyBoolean.class) { + throw Py.TypeError(String.format("__nonzero__ should return bool or int, returned %s",self_type.getName())); + } + return o.__nonzero__(); + } + + public boolean __contains__(PyObject o) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__contains__"); + if (impl==null) + return super.__contains__(o); + return impl.__get__(this,self_type).__call__(o).__nonzero__(); + } + + public int __len__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__len__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyInteger) + return((PyInteger)res).getValue(); + throw Py.TypeError("__len__ should return a int"); + } + return super.__len__(); + } + + public PyObject __iter__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__iter__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + impl=self_type.lookup("__getitem__"); + if (impl==null) + return super.__iter__(); + return new PySequenceIter(this); + } + + public PyObject __iternext__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("next"); + if (impl!=null) { + try { + return impl.__get__(this,self_type).__call__(); + } catch (PyException exc) { + if (Py.matchException(exc,Py.StopIteration)) + return null; + throw exc; + } + } + return super.__iternext__(); // ??? + } + + public PyObject __finditem__(PyObject key) { // ??? + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(key); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + + public PyObject __getitem__(PyObject key) { + // Same as __finditem__, without swallowing LookupErrors. This allows + // __getitem__ implementations written in Python to raise custom + // exceptions (such as subclasses of KeyError). + // + // We are forced to duplicate the code, instead of defining __finditem__ + // in terms of __getitem__. That's because PyObject defines __getitem__ + // in terms of __finditem__. Therefore, we would end with an infinite + // loop when self_type.lookup("__getitem__") returns null: + // + // __getitem__ -> super.__getitem__ -> __finditem__ -> __getitem__ + // + // By duplicating the (short) lookup and call code, we are safe, because + // the call chains will be: + // + // __finditem__ -> super.__finditem__ + // + // __getitem__ -> super.__getitem__ -> __finditem__ -> super.__finditem__ + + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(key); + return super.__getitem__(key); + } + + public void __setitem__(PyObject key,PyObject value) { // ??? + PyType self_type=getType(); + PyObject impl=self_type.lookup("__setitem__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(key,value); + return; + } + super.__setitem__(key,value); + } + + public PyObject __getslice__(PyObject start,PyObject stop,PyObject step) { // ??? + if (step!=null) { + return __getitem__(new PySlice(start,stop,step)); + } + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getslice__"); + if (impl!=null) { + PyObject[]indices=PySlice.indices2(this,start,stop); + return impl.__get__(this,self_type).__call__(indices[0],indices[1]); + } + return super.__getslice__(start,stop,step); + } + + public void __setslice__(PyObject start,PyObject stop,PyObject step,PyObject value) { + if (step!=null) { + __setitem__(new PySlice(start,stop,step),value); + return; + } + PyType self_type=getType(); + PyObject impl=self_type.lookup("__setslice__"); + if (impl!=null) { + PyObject[]indices=PySlice.indices2(this,start,stop); + impl.__get__(this,self_type).__call__(indices[0],indices[1],value); + return; + } + super.__setslice__(start,stop,step,value); + } + + public void __delslice__(PyObject start,PyObject stop,PyObject step) { + if (step!=null) { + __delitem__(new PySlice(start,stop,step)); + return; + } + PyType self_type=getType(); + PyObject impl=self_type.lookup("__delslice__"); + if (impl!=null) { + PyObject[]indices=PySlice.indices2(this,start,stop); + impl.__get__(this,self_type).__call__(indices[0],indices[1]); + return; + } + super.__delslice__(start,stop,step); + } + + public void __delitem__(PyObject key) { // ??? + PyType self_type=getType(); + PyObject impl=self_type.lookup("__delitem__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(key); + return; + } + super.__delitem__(key); + } + + public PyObject __call__(PyObject args[],String keywords[]) { + ThreadState ts=Py.getThreadState(); + if (ts.recursion_depth++>ts.systemState.getrecursionlimit()) + throw Py.RuntimeError("maximum __call__ recursion depth exceeded"); + try { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__call__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(args,keywords); + return super.__call__(args,keywords); + } finally { + --ts.recursion_depth; + } + } + + public PyObject __findattr_ex__(String name) { + PyType self_type=getType(); + // TODO: We should speed this up. As the __getattribute__ slot almost never + // changes, it is a good candidate for caching, as PyClass does with + // __getattr__. See #1102. + PyObject getattribute=self_type.lookup("__getattribute__"); + PyString py_name=null; + PyException firstAttributeError=null; + try { + if (getattribute!=null) { + py_name=PyString.fromInterned(name); + return getattribute.__get__(this,self_type).__call__(py_name); + } else { + Py.Warning(String.format("__getattribute__ not found on type %s",self_type.getName())); + PyObject ret=super.__findattr_ex__(name); + if (ret!=null) { + return ret; + } // else: pass through to __getitem__ invocation + } + } catch (PyException e) { + if (!Py.matchException(e,Py.AttributeError)) { + throw e; + } else { + firstAttributeError=e; // saved to avoid swallowing custom AttributeErrors + // and pass through to __getattr__ invocation. + } + } + PyObject getattr=self_type.lookup("__getattr__"); + if (getattr!=null) { + if (py_name==null) { + py_name=PyString.fromInterned(name); + } + return getattr.__get__(this,self_type).__call__(py_name); + } + if (firstAttributeError!=null) { + throw firstAttributeError; + } + return null; + } + + public void __setattr__(String name,PyObject value) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__setattr__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value); + return; + } + super.__setattr__(name,value); + } + + public void __delattr__(String name) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__delattr__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(PyString.fromInterned(name)); + return; + } + super.__delattr__(name); + } + + public PyObject __get__(PyObject obj,PyObject type) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__get__"); + if (impl!=null) { + if (obj==null) + obj=Py.None; + if (type==null) + type=Py.None; + return impl.__get__(this,self_type).__call__(obj,type); + } + return super.__get__(obj,type); + } + + public void __set__(PyObject obj,PyObject value) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__set__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(obj,value); + return; + } + super.__set__(obj,value); + } + + public void __delete__(PyObject obj) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__delete__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(obj); + return; + } + super.__delete__(obj); + } + + public PyObject __pow__(PyObject other,PyObject modulo) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__pow__"); + if (impl!=null) { + PyObject res; + if (modulo==null) { + res=impl.__get__(this,self_type).__call__(other); + } else { + res=impl.__get__(this,self_type).__call__(other,modulo); + } + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__pow__(other,modulo); + } + + public void dispatch__init__(PyType type,PyObject[]args,String[]keywords) { + PyType self_type=getType(); + if (self_type.isSubType(type)) { + PyObject impl=self_type.lookup("__init__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(args,keywords); + if (res!=Py.None) { + throw Py.TypeError(String.format("__init__() should return None, not '%.200s'",res.getType().fastGetName())); + } + proxyInit(); + } + } + } + + public PyObject __index__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__index__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyInteger||res instanceof PyLong) { + return res; + } + throw Py.TypeError(String.format("__index__ returned non-(int,long) (type %s)",res.getType().fastGetName())); + } + return super.__index__(); + } + + public Object __tojava__(Class c) { + // If we are not being asked by the "default" conversion to java, then + // we can provide this as the result, as long as it is a instance of the + // specified class. Without this, derived.__tojava__(PyObject.class) + // would broke. (And that's not pure speculation: PyReflectedFunction's + // ReflectedArgs asks for things like that). + if ((c!=Object.class)&&(c.isInstance(this))) { + return this; + } + // Otherwise, we call the derived __tojava__, if it exists: + PyType self_type=getType(); + PyObject impl=self_type.lookup("__tojava__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava__(Object.class); + return super.__tojava__(c); + } + + public Object __coerce_ex__(PyObject o) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__coerce__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(o); + if (res==Py.NotImplemented) + return Py.None; + if (!(res instanceof PyTuple)) + throw Py.TypeError("__coerce__ didn't return a 2-tuple"); + return((PyTuple)res).getArray(); + } + return super.__coerce_ex__(o); + } + + public String toString() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__repr__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (!(res instanceof PyString)) + throw Py.TypeError("__repr__ returned non-string (type "+res.getType().fastGetName()+")"); + return((PyString)res).toString(); + } + return super.toString(); + } + +} Added: trunk/jython/src/templates/ClasspathPyImporter.derived =================================================================== --- trunk/jython/src/templates/ClasspathPyImporter.derived (rev 0) +++ trunk/jython/src/templates/ClasspathPyImporter.derived 2008-12-30 21:09:17 UTC (rev 5818) @@ -0,0 +1,4 @@ +base_class: ClasspathPyImporter +want_dict: false +ctr +incl: object Modified: trunk/jython/src/templates/mappings =================================================================== --- trunk/jython/src/templates/mappings 2008-12-30 17:17:26 UTC (rev 5817) +++ trunk/jython/src/templates/mappings 2008-12-30 21:09:17 UTC (rev 5818) @@ -7,6 +7,7 @@ # lines; one for their expose, and one for their derived class. BaseException.derived:org.python.core.PyBaseExceptionDerived +ClasspathPyImporter.derived:org.python.core.ClasspathPyImporterDerived array.derived:org.python.core.PyArrayDerived bool.derived:org.python.core.PyBooleanDerived classmethod.derived:org.python.core.PyClassMethodDerived This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-10 00:01:11
|
Revision: 6321 http://jython.svn.sourceforge.net/jython/?rev=6321&view=rev Author: pjenvey Date: 2009-05-10 00:00:52 +0000 (Sun, 10 May 2009) Log Message: ----------- o set std{in,out,err}.encoding to the file.encoding property (which is usually accurate), and only when those are ttys fixes #1314 o force file.encoding to utf-8 on darwin instead of MacRoman. JRuby also does this, CPython uses utf-8 there too Modified Paths: -------------- trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/shell/jython Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-05-09 22:30:55 UTC (rev 6320) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-05-10 00:00:52 UTC (rev 6321) @@ -164,20 +164,20 @@ // Set up the initial standard ins and outs String mode = Options.unbuffered ? "b" : ""; int buffering = Options.unbuffered ? 0 : 1; - stdout = new PyFile(System.out, "<stdout>", "w" + mode, buffering, false); - stderr = new PyFile(System.err, "<stderr>", "w" + mode, 0, false); - stdin = new PyFile(System.in, "<stdin>", "r" + mode, buffering, false); + stdin = __stdin__ = new PyFile(System.in, "<stdin>", "r" + mode, buffering, false); + stdout = __stdout__ = new PyFile(System.out, "<stdout>", "w" + mode, buffering, false); + stderr = __stderr__ = new PyFile(System.err, "<stderr>", "w" + mode, 0, false); + if (Py.getSystemState() != null) { + // XXX: initEncoding fails without an existing sys module as it can't import + // os (for os.isatty). In that case PySystemState.doInitialize calls it for + // us. The correct fix for this is rewriting the posix/nt module portions of + // os in Java + initEncoding(); + } + __displayhook__ = new PySystemStateFunctions("displayhook", 10, 1, 1); __excepthook__ = new PySystemStateFunctions("excepthook", 30, 3, 3); - String encoding = registry.getProperty("python.console.encoding", "US-ASCII"); - ((PyFile)stdout).encoding = encoding; - ((PyFile)stderr).encoding = encoding; - ((PyFile)stdin).encoding = encoding; - __stdout__ = stdout; - __stderr__ = stderr; - __stdin__ = stdin; - if (builtins == null) { builtins = getDefaultBuiltins(); } @@ -215,6 +215,25 @@ } } + private void initEncoding() { + String encoding; + try { + encoding = System.getProperty("file.encoding"); + } catch (SecurityException se) { + encoding = null; + } + if (encoding == null) { + return; + } + + for (PyFile stdStream : new PyFile[] {(PyFile)this.stdin, (PyFile)this.stdout, + (PyFile)this.stderr}) { + if (stdStream.isatty()) { + stdStream.encoding = encoding; + } + } + } + // might be nice to have something general here, but for now these // seem to be the only values that need to be explicitly shadowed private Shadow shadowing; @@ -815,6 +834,8 @@ Py.defaultSystemState.setClassLoader(classLoader); } Py.initClassExceptions(getDefaultBuiltins()); + // defaultSystemState can't init its own encoding, see its constructor + Py.defaultSystemState.initEncoding(); // Make sure that Exception classes have been loaded new PySyntaxError("", 1, 1, "", ""); return Py.defaultSystemState; Modified: trunk/jython/src/shell/jython =================================================================== --- trunk/jython/src/shell/jython 2009-05-09 22:30:55 UTC (rev 6320) +++ trunk/jython/src/shell/jython 2009-05-10 00:00:52 UTC (rev 6321) @@ -16,7 +16,8 @@ # ----- Identify OS we are running under -------------------------------------- case "`uname`" in - CYGWIN*) cygwin=true + CYGWIN*) cygwin=true;; + Darwin) darwin=true;; esac # ----- Verify and set required environment variables ------------------------- @@ -107,6 +108,8 @@ JAVA_STACK=-Xss1024k fi +JAVA_ENCODING="" + # Split out any -J argument for passing to the JVM. # Scanning for args is aborted by '--'. while [ $# -gt 0 ] ; do @@ -127,7 +130,10 @@ echo "(Prepend -J in front of these options when using 'jython' command)" exit else - java_args=("${java_args[@]}" "${1:2}") + if [ "${val:0:16}" = "-Dfile.encoding=" ]; then + JAVA_ENCODING=$val + fi + java_args=("${java_args[@]}" "${1:2}") fi ;; # Match switches that take an argument @@ -195,6 +201,11 @@ shift done +# Force file.encoding to UTF-8 when on Mac, since Apple JDK defaults to MacRoman (JRUBY-3576) +if [[ $darwin && -z "$JAVA_ENCODING" ]]; then + java_args=("${java_args[@]}" "-Dfile.encoding=UTF-8") +fi + # Append the rest of the arguments python_args=("${python_args[@]}" "$@") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-10 21:44:50
|
Revision: 6332 http://jython.svn.sourceforge.net/jython/?rev=6332&view=rev Author: pjenvey Date: 2009-05-10 21:44:46 +0000 (Sun, 10 May 2009) Log Message: ----------- remove redundant cast Modified Paths: -------------- trunk/jython/src/org/python/antlr/ast/AssertDerived.java trunk/jython/src/org/python/antlr/ast/AssignDerived.java trunk/jython/src/org/python/antlr/ast/AttributeDerived.java trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java trunk/jython/src/org/python/antlr/ast/BinOpDerived.java trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java trunk/jython/src/org/python/antlr/ast/BreakDerived.java trunk/jython/src/org/python/antlr/ast/CallDerived.java trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java trunk/jython/src/org/python/antlr/ast/CompareDerived.java trunk/jython/src/org/python/antlr/ast/ContinueDerived.java trunk/jython/src/org/python/antlr/ast/DeleteDerived.java trunk/jython/src/org/python/antlr/ast/DictDerived.java trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java trunk/jython/src/org/python/antlr/ast/ExecDerived.java trunk/jython/src/org/python/antlr/ast/ExprDerived.java trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java trunk/jython/src/org/python/antlr/ast/ForDerived.java trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java trunk/jython/src/org/python/antlr/ast/GlobalDerived.java trunk/jython/src/org/python/antlr/ast/IfDerived.java trunk/jython/src/org/python/antlr/ast/IfExpDerived.java trunk/jython/src/org/python/antlr/ast/ImportDerived.java trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java trunk/jython/src/org/python/antlr/ast/IndexDerived.java trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java trunk/jython/src/org/python/antlr/ast/LambdaDerived.java trunk/jython/src/org/python/antlr/ast/ListCompDerived.java trunk/jython/src/org/python/antlr/ast/ListDerived.java trunk/jython/src/org/python/antlr/ast/ModuleDerived.java trunk/jython/src/org/python/antlr/ast/NameDerived.java trunk/jython/src/org/python/antlr/ast/NumDerived.java trunk/jython/src/org/python/antlr/ast/PassDerived.java trunk/jython/src/org/python/antlr/ast/PrintDerived.java trunk/jython/src/org/python/antlr/ast/RaiseDerived.java trunk/jython/src/org/python/antlr/ast/ReprDerived.java trunk/jython/src/org/python/antlr/ast/ReturnDerived.java trunk/jython/src/org/python/antlr/ast/SliceDerived.java trunk/jython/src/org/python/antlr/ast/StrDerived.java trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java trunk/jython/src/org/python/antlr/ast/SuiteDerived.java trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java trunk/jython/src/org/python/antlr/ast/TupleDerived.java trunk/jython/src/org/python/antlr/ast/UnaryOpDerived.java trunk/jython/src/org/python/antlr/ast/WhileDerived.java trunk/jython/src/org/python/antlr/ast/WithDerived.java trunk/jython/src/org/python/antlr/ast/YieldDerived.java trunk/jython/src/org/python/antlr/ast/aliasDerived.java trunk/jython/src/org/python/antlr/ast/argumentsDerived.java trunk/jython/src/org/python/antlr/ast/comprehensionDerived.java trunk/jython/src/org/python/antlr/ast/keywordDerived.java trunk/jython/src/org/python/antlr/op/AddDerived.java trunk/jython/src/org/python/antlr/op/AndDerived.java trunk/jython/src/org/python/antlr/op/AugLoadDerived.java trunk/jython/src/org/python/antlr/op/AugStoreDerived.java trunk/jython/src/org/python/antlr/op/BitAndDerived.java trunk/jython/src/org/python/antlr/op/BitOrDerived.java trunk/jython/src/org/python/antlr/op/BitXorDerived.java trunk/jython/src/org/python/antlr/op/DelDerived.java trunk/jython/src/org/python/antlr/op/DivDerived.java trunk/jython/src/org/python/antlr/op/EqDerived.java trunk/jython/src/org/python/antlr/op/FloorDivDerived.java trunk/jython/src/org/python/antlr/op/GtDerived.java trunk/jython/src/org/python/antlr/op/GtEDerived.java trunk/jython/src/org/python/antlr/op/InDerived.java trunk/jython/src/org/python/antlr/op/InvertDerived.java trunk/jython/src/org/python/antlr/op/IsDerived.java trunk/jython/src/org/python/antlr/op/IsNotDerived.java trunk/jython/src/org/python/antlr/op/LShiftDerived.java trunk/jython/src/org/python/antlr/op/LoadDerived.java trunk/jython/src/org/python/antlr/op/LtDerived.java trunk/jython/src/org/python/antlr/op/LtEDerived.java trunk/jython/src/org/python/antlr/op/ModDerived.java trunk/jython/src/org/python/antlr/op/MultDerived.java trunk/jython/src/org/python/antlr/op/NotDerived.java trunk/jython/src/org/python/antlr/op/NotEqDerived.java trunk/jython/src/org/python/antlr/op/NotInDerived.java trunk/jython/src/org/python/antlr/op/OrDerived.java trunk/jython/src/org/python/antlr/op/ParamDerived.java trunk/jython/src/org/python/antlr/op/PowDerived.java trunk/jython/src/org/python/antlr/op/RShiftDerived.java trunk/jython/src/org/python/antlr/op/StoreDerived.java trunk/jython/src/org/python/antlr/op/SubDerived.java trunk/jython/src/org/python/antlr/op/UAddDerived.java trunk/jython/src/org/python/antlr/op/USubDerived.java trunk/jython/src/org/python/core/ClasspathPyImporterDerived.java trunk/jython/src/org/python/core/PyArrayDerived.java trunk/jython/src/org/python/core/PyBaseExceptionDerived.java trunk/jython/src/org/python/core/PyBooleanDerived.java trunk/jython/src/org/python/core/PyClassMethodDerived.java trunk/jython/src/org/python/core/PyComplexDerived.java trunk/jython/src/org/python/core/PyDictionaryDerived.java trunk/jython/src/org/python/core/PyEnumerateDerived.java trunk/jython/src/org/python/core/PyFileDerived.java trunk/jython/src/org/python/core/PyFloatDerived.java trunk/jython/src/org/python/core/PyFrozenSetDerived.java trunk/jython/src/org/python/core/PyIntegerDerived.java trunk/jython/src/org/python/core/PyListDerived.java trunk/jython/src/org/python/core/PyLongDerived.java trunk/jython/src/org/python/core/PyModuleDerived.java trunk/jython/src/org/python/core/PyObjectDerived.java trunk/jython/src/org/python/core/PyPropertyDerived.java trunk/jython/src/org/python/core/PySetDerived.java trunk/jython/src/org/python/core/PySliceDerived.java trunk/jython/src/org/python/core/PyStringDerived.java trunk/jython/src/org/python/core/PySuperDerived.java trunk/jython/src/org/python/core/PyTupleDerived.java trunk/jython/src/org/python/core/PyTypeDerived.java trunk/jython/src/org/python/core/PyUnicodeDerived.java trunk/jython/src/org/python/modules/_collections/PyDefaultDictDerived.java trunk/jython/src/org/python/modules/_collections/PyDequeDerived.java trunk/jython/src/org/python/modules/_csv/PyDialectDerived.java trunk/jython/src/org/python/modules/_functools/PyPartialDerived.java trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java trunk/jython/src/org/python/modules/random/PyRandomDerived.java trunk/jython/src/org/python/modules/thread/PyLocalDerived.java trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java trunk/jython/src/templates/object.derived Modified: trunk/jython/src/org/python/antlr/ast/AssertDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/AssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/AttributeDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/BinOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/BreakDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/CallDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/CompareDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ContinueDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/DeleteDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/DictDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ExecDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ExprDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ForDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/GlobalDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/IfDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/IfExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ImportDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ImportDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/IndexDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IndexDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/IndexDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/LambdaDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/LambdaDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/LambdaDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ListCompDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ListCompDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ListCompDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ListDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ListDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ListDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ModuleDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ModuleDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ModuleDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/NameDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/NameDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/NameDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/NumDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/NumDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/NumDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/PassDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/PassDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/PassDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/PrintDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/PrintDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/PrintDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/RaiseDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/RaiseDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/RaiseDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ReprDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ReprDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ReprDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/ReturnDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ReturnDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/ReturnDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/SliceDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/SliceDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/SliceDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/StrDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/StrDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/StrDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/SuiteDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/SuiteDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/SuiteDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/TupleDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TupleDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/TupleDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/UnaryOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/UnaryOpDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/UnaryOpDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/WhileDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/WhileDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/WhileDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/WithDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/WithDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/WithDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/YieldDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/YieldDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/YieldDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/aliasDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/aliasDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/aliasDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/argumentsDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/argumentsDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/argumentsDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/comprehensionDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/comprehensionDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/comprehensionDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/ast/keywordDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/keywordDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/ast/keywordDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/AddDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/AddDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/AddDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/AndDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/AndDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/AndDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/AugLoadDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/AugLoadDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/AugLoadDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/AugStoreDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/AugStoreDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/AugStoreDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/BitAndDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/BitAndDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/BitAndDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/BitOrDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/BitOrDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/BitOrDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/BitXorDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/BitXorDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/BitXorDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/DelDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/DelDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/DelDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/DivDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/DivDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/DivDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/EqDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/EqDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/EqDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/FloorDivDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/FloorDivDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/FloorDivDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/GtDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/GtDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/GtDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/GtEDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/GtEDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/GtEDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/InDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/InDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/InDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/InvertDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/InvertDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/InvertDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/IsDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/IsDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/IsDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/IsNotDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/IsNotDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/IsNotDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/LShiftDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/LShiftDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/LShiftDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/LoadDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/LoadDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/LoadDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/LtDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/LtDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/LtDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/LtEDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/LtEDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/LtEDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); Modified: trunk/jython/src/org/python/antlr/op/ModDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/ModDerived.java 2009-05-10 20:29:04 UTC (rev 6331) +++ trunk/jython/src/org/python/antlr/op/ModDerived.java 2009-05-10 21:44:46 UTC (rev 6332) @@ -715,7 +715,7 @@ if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; + return res; throw Py.TypeError("__int__"+" should return an integer"); } return s... [truncated message content] |
From: <otm...@us...> - 2009-06-11 11:55:22
|
Revision: 6473 http://jython.svn.sourceforge.net/jython/?rev=6473&view=rev Author: otmarhumbel Date: 2009-06-11 11:55:18 +0000 (Thu, 11 Jun 2009) Log Message: ----------- removal of unnecessary imports Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/DataHandler.java trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java trunk/jython/src/com/ziclix/python/sql/handler/MySQLDataHandler.java trunk/jython/src/org/python/core/ParserFacade.java Modified: trunk/jython/src/com/ziclix/python/sql/DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-06-09 01:12:21 UTC (rev 6472) +++ trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-06-11 11:55:18 UTC (rev 6473) @@ -12,7 +12,6 @@ import org.python.core.PyFile; import org.python.core.PyObject; import org.python.core.PyList; -import org.python.core.PyString; import org.python.core.util.StringUtil; import java.io.BufferedInputStream; Modified: trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java 2009-06-09 01:12:21 UTC (rev 6472) +++ trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java 2009-06-11 11:55:18 UTC (rev 6473) @@ -8,12 +8,6 @@ */ package com.ziclix.python.sql; -import org.python.core.Py; -import org.python.core.PyFile; -import org.python.core.PyObject; -import org.python.core.PyString; -import org.python.core.util.StringUtil; - import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.ByteArrayInputStream; @@ -27,6 +21,11 @@ import java.sql.SQLException; import java.sql.Types; +import org.python.core.Py; +import org.python.core.PyFile; +import org.python.core.PyObject; +import org.python.core.util.StringUtil; + /** * Support for JDBC 2.x type mappings, including Arrays, CLOBs and BLOBs. * Modified: trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java 2009-06-09 01:12:21 UTC (rev 6472) +++ trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java 2009-06-11 11:55:18 UTC (rev 6473) @@ -8,14 +8,6 @@ */ package com.ziclix.python.sql; -import org.python.core.Py; -import org.python.core.PyFile; -import org.python.core.PyLong; -import org.python.core.PyObject; -import org.python.core.PyList; -import org.python.core.PyString; -import org.python.core.util.StringUtil; - import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.InputStream; @@ -32,6 +24,13 @@ import java.sql.Timestamp; import java.sql.Types; +import org.python.core.Py; +import org.python.core.PyFile; +import org.python.core.PyList; +import org.python.core.PyLong; +import org.python.core.PyObject; +import org.python.core.util.StringUtil; + /** * A copy of the DataHandler class as it was before Jython 2.5. By that version, * some backward-incompatible changes was made, as returning datetime.* Modified: trunk/jython/src/com/ziclix/python/sql/handler/MySQLDataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/handler/MySQLDataHandler.java 2009-06-09 01:12:21 UTC (rev 6472) +++ trunk/jython/src/com/ziclix/python/sql/handler/MySQLDataHandler.java 2009-06-11 11:55:18 UTC (rev 6473) @@ -8,11 +8,6 @@ */ package com.ziclix.python.sql.handler; -import com.ziclix.python.sql.DataHandler; -import org.python.core.PyFile; -import org.python.core.PyObject; -import org.python.core.util.StringUtil; - import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -20,6 +15,12 @@ import java.sql.SQLException; import java.sql.Types; +import org.python.core.PyFile; +import org.python.core.PyObject; +import org.python.core.util.StringUtil; + +import com.ziclix.python.sql.DataHandler; + /** * MySQL specific data handling. * Modified: trunk/jython/src/org/python/core/ParserFacade.java =================================================================== --- trunk/jython/src/org/python/core/ParserFacade.java 2009-06-09 01:12:21 UTC (rev 6472) +++ trunk/jython/src/org/python/core/ParserFacade.java 2009-06-11 11:55:18 UTC (rev 6473) @@ -21,14 +21,13 @@ import org.antlr.runtime.CharStream; import org.antlr.runtime.CommonTokenStream; - import org.python.antlr.BaseParser; -import org.python.antlr.ParseException; import org.python.antlr.NoCloseReaderStream; -import org.python.antlr.PythonTree; +import org.python.antlr.ParseException; import org.python.antlr.PythonLexer; import org.python.antlr.PythonPartial; import org.python.antlr.PythonTokenSource; +import org.python.antlr.PythonTree; import org.python.antlr.base.mod; import org.python.core.io.StreamIO; import org.python.core.io.TextIOInputStream; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-07-26 16:32:14
|
Revision: 6590 http://jython.svn.sourceforge.net/jython/?rev=6590&view=rev Author: cgroves Date: 2009-07-26 16:32:05 +0000 (Sun, 26 Jul 2009) Log Message: ----------- Add Py.javas2pys. It takes a varargs array of Object and returns a corresponding array of PyObject. Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/DataHandler.java trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java trunk/jython/src/com/ziclix/python/sql/PyCursor.java trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/jsr223/PyScriptEngine.java Modified: trunk/jython/src/com/ziclix/python/sql/DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -507,9 +507,9 @@ public static final DataHandler getSystemDataHandler() { DataHandler dh = new DataHandler(); - for (int i = 0; i < SYSTEM_DATAHANDLERS.length; i++) { + for (String element : SYSTEM_DATAHANDLERS) { try { - Class c = Class.forName(SYSTEM_DATAHANDLERS[i]); + Class c = Class.forName(element); Constructor cons = c.getConstructor(new Class[]{DataHandler.class}); dh = (DataHandler) cons.newInstance(new Object[]{dh}); } catch (Throwable t) {} @@ -524,7 +524,7 @@ * @return a list of datahandlers */ public PyObject __chain__() { - return new PyList(new PyObject[] { Py.java2py(this) }); + return new PyList(Py.javas2pys(this)); } /** Modified: trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -446,7 +446,7 @@ * @return a list of datahandlers */ public PyObject __chain__() { - return new PyList(new PyObject[] { Py.java2py(this) }); + return new PyList(Py.javas2pys(this)); } } Modified: trunk/jython/src/com/ziclix/python/sql/PyCursor.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/PyCursor.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/com/ziclix/python/sql/PyCursor.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -750,13 +750,11 @@ SQLWarning warning = event.getWarning(); while (warning != null) { - PyObject[] warn = new PyObject[] { - // there are three parts: (reason, state, vendorCode) - Py.java2py(warning.getMessage()), - Py.java2py(warning.getSQLState()), - Py.newInteger(warning.getErrorCode()) - }; + // there are three parts: (reason, state, vendorCode) + PyObject[] warn = + Py.javas2pys(warning.getMessage(), warning.getSQLState(), warning.getErrorCode()); + // add the warning to the list ((PyList)this.warnings).append(new PyTuple(warn)); Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/org/python/core/Py.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -853,9 +853,7 @@ if (args == null || args.length == 0) { pargs = Py.EmptyObjects; } else { - pargs = new PyObject[args.length]; - for(int i=0; i<args.length; i++) - pargs[i] = Py.java2py(args[i]); + pargs = Py.javas2pys(args); } instance = pyc.__call__(pargs); instance.javaProxy = proxy; @@ -1487,6 +1485,20 @@ } /** + * Uses the PyObjectAdapter passed to {@link PySystemState#initialize} to turn + * <code>objects</code> into an array of PyObjects. + * + * @see ClassicPyObjectAdapter - default PyObjectAdapter type + */ + public static PyObject[] javas2pys(Object... objects) { + PyObject[] objs = new PyObject[objects.length]; + for (int i = 0; i < objs.length; i++) { + objs[i] = java2py(objects[i]); + } + return objs; + } + + /** * @return the ExtensiblePyObjectAdapter used by java2py. */ public static ExtensiblePyObjectAdapter getAdapter() { Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/org/python/core/PyObject.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -51,7 +51,7 @@ if (Py.BOOTSTRAP_TYPES.size() > 0) { Py.writeWarning("init", "Bootstrap types weren't encountered in bootstrapping: " + Py.BOOTSTRAP_TYPES); - + } } @@ -325,7 +325,7 @@ public PyObject __call__(PyObject args[], String keywords[]) { throw Py.TypeError(String.format("'%s' object is not callable", getType().fastGetName())); } - + public PyObject __call__(ThreadState state, PyObject args[], String keywords[]) { return __call__(args, keywords); } @@ -350,7 +350,7 @@ newArgs[0] = arg1; return __call__(newArgs, keywords); } - + public PyObject __call__(ThreadState state, PyObject arg1, PyObject args[], String keywords[]) { return __call__(arg1, args, keywords); } @@ -366,7 +366,7 @@ public PyObject __call__(PyObject args[]) { return __call__(args, Py.NoKeywords); } - + public PyObject __call__(ThreadState state, PyObject args[]) { return __call__(args); } @@ -380,7 +380,7 @@ public PyObject __call__() { return __call__(Py.EmptyObjects, Py.NoKeywords); } - + public PyObject __call__(ThreadState state) { return __call__(); } @@ -396,7 +396,7 @@ public PyObject __call__(PyObject arg0) { return __call__(new PyObject[] { arg0 }, Py.NoKeywords); } - + public PyObject __call__(ThreadState state, PyObject arg0) { return __call__(arg0); } @@ -431,7 +431,7 @@ public PyObject __call__(PyObject arg0, PyObject arg1, PyObject arg2) { return __call__(new PyObject[] { arg0, arg1, arg2 }, Py.NoKeywords); } - + public PyObject __call__(ThreadState state, PyObject arg0, PyObject arg1, PyObject arg2) { return __call__(arg0, arg1, arg2); } @@ -452,7 +452,7 @@ new PyObject[] { arg0, arg1, arg2, arg3 }, Py.NoKeywords); } - + public PyObject __call__(ThreadState state, PyObject arg0, PyObject arg1, PyObject arg2, PyObject arg3) { return __call__(arg0, arg1, arg2, arg3); } @@ -3496,12 +3496,8 @@ * A convenience function for PyProxys. */ public PyObject _jcallexc(Object[] args) throws Throwable { - PyObject[] pargs = new PyObject[args.length]; try { - for (int i = 0; i < args.length; i++) { - pargs[i] = Py.java2py(args[i]); - } - return __call__(pargs); + return __call__(Py.javas2pys(args)); } catch (PyException e) { if (e.value.getJavaProxy() != null) { Object t = e.value.__tojava__(Throwable.class); Modified: trunk/jython/src/org/python/jsr223/PyScriptEngine.java =================================================================== --- trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -66,43 +66,49 @@ private PyCode compileScript(String script, ScriptContext context) throws ScriptException { try { String filename = (String) context.getAttribute(ScriptEngine.FILENAME); - if (filename == null) + if (filename == null) { return interp.compile(script); - else + } else { return interp.compile(script, filename); + } } catch (PyException pye) { throw scriptException(pye); } } - + private PyCode compileScript(Reader reader, ScriptContext context) throws ScriptException { try { String filename = (String) context.getAttribute(ScriptEngine.FILENAME); - if (filename == null) + if (filename == null) { return interp.compile(reader); - else + } else { return interp.compile(reader, filename); + } } catch (PyException pye) { throw scriptException(pye); } } - public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException { + public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, + NoSuchMethodException { try { - if (!(thiz instanceof PyObject)) + if (!(thiz instanceof PyObject)) { thiz = Py.java2py(thiz); - return ((PyObject) thiz).invoke(name, java2py(args)).__tojava__(Object.class); + } + return ((PyObject) thiz).invoke(name, Py.javas2pys(args)).__tojava__(Object.class); } catch (PyException pye) { return throwInvokeException(pye, name); } } - public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException { + public Object invokeFunction(String name, Object... args) throws ScriptException, + NoSuchMethodException { try { PyObject function = interp.get(name); - if (function == null) + if (function == null) { throw new NoSuchMethodException(name); - return function.__call__(java2py(args)).__tojava__(Object.class); + } + return function.__call__(Py.javas2pys(args)).__tojava__(Object.class); } catch (PyException pye) { return throwInvokeException(pye, name); } @@ -113,23 +119,28 @@ } public <T> T getInterface(Object obj, Class<T> clazz) { - if (obj == null) + if (obj == null) { throw new IllegalArgumentException("object expected"); - if (clazz == null || !clazz.isInterface()) + } + if (clazz == null || !clazz.isInterface()) { throw new IllegalArgumentException("interface expected"); - final Object thiz = Py.java2py(obj); - return (T) Proxy.newProxyInstance( + } + final PyObject thiz = Py.java2py(obj); + @SuppressWarnings("unchecked") + T proxy = (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[] { clazz }, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { - return ((PyObject) thiz).invoke(method.getName(), java2py(args)).__tojava__(Object.class); + PyObject result = thiz.invoke(method.getName(), Py.javas2pys(args)); + return result.__tojava__(Object.class); } catch (PyException pye) { return throwInvokeException(pye, method.getName()); } } }); + return proxy; } private static Object throwInvokeException(PyException pye, String methodName) @@ -162,11 +173,11 @@ offset == null ? 0 : offset.asInt()); } else if (tb != null) { String filename; - if (tb.tb_frame == null || tb.tb_frame.f_code == null) + if (tb.tb_frame == null || tb.tb_frame.f_code == null) { filename = null; - else + } else { filename = tb.tb_frame.f_code.co_filename; - + } se = new ScriptException( Py.formatException(type, value), filename, @@ -182,14 +193,6 @@ return se; } - private static PyObject[] java2py(Object[] args) { - PyObject wrapped[] = new PyObject[args.length]; - for (int i = 0; i < args.length; i++) { - wrapped[i] = Py.java2py(args[i]); - } - return wrapped; - } - private class PyCompiledScript extends CompiledScript { private PyCode code; @@ -197,10 +200,12 @@ this.code = code; } + @Override public ScriptEngine getEngine() { return PyScriptEngine.this; } + @Override public Object eval(ScriptContext ctx) throws ScriptException { return PyScriptEngine.this.eval(code, ctx); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-09 00:05:21
|
Revision: 6635 http://jython.svn.sourceforge.net/jython/?rev=6635&view=rev Author: pjenvey Date: 2009-08-09 00:05:01 +0000 (Sun, 09 Aug 2009) Log Message: ----------- handle Oracle TIMESTAMPTZ/LTZ (currently dropping the tz like cx_oracle does) and specially handle its DATE and NUMERIC refs #1421 Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java 2009-08-06 20:17:09 UTC (rev 6634) +++ trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java 2009-08-09 00:05:01 UTC (rev 6635) @@ -16,6 +16,7 @@ import oracle.sql.BLOB; import oracle.sql.ROWID; import org.python.core.Py; +import org.python.core.PyInteger; import org.python.core.PyObject; import java.io.BufferedInputStream; @@ -23,7 +24,9 @@ import java.sql.CallableStatement; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.ResultSetMetaData; import java.sql.SQLException; +import java.sql.Timestamp; import java.sql.Types; /** @@ -66,12 +69,17 @@ switch (type) { - case OracleTypes.ROWID: - stmt.setString(index, (String) object.__tojava__(String.class)); + case Types.DATE: + // Oracle DATE is a timestamp with one second precision + Timestamp timestamp = (Timestamp) object.__tojava__(Timestamp.class); + if (timestamp != Py.NoConversion) { + stmt.setTimestamp(index, timestamp); + } else { + super.setJDBCObject(stmt, index, object, type); + } break; case Types.DECIMAL: - // Oracle is annoying Object input = object.__tojava__(Double.class); @@ -94,6 +102,18 @@ String msg = zxJDBC.getString("errorSettingIndex", vals); throw new SQLException(msg); + + case OracleTypes.ROWID: + stmt.setString(index, (String) object.__tojava__(String.class)); + break; + + case OracleTypes.TIMESTAMPLTZ: + case OracleTypes.TIMESTAMPTZ: + // XXX: We should include time zone information, but cx_Oracle currently + // doesn't either + super.setJDBCObject(stmt, index, object, Types.TIMESTAMP); + break; + default : super.setJDBCObject(stmt, index, object, type); } @@ -108,11 +128,55 @@ switch (type) { + case Types.DATE: + // Oracle DATE is a timestamp with one second precision + obj = Py.newDatetime(set.getTimestamp(col)); + break; + + case Types.NUMERIC: + // Oracle NUMBER encompasses all numeric types + String number = set.getString(col); + if (number == null) { + obj = Py.None; + break; + } + + ResultSetMetaData metaData = set.getMetaData(); + int scale = metaData.getScale(col); + int precision = metaData.getPrecision(col); + if (scale == -127) { + if (precision == 0) { + // Unspecified precision. Normally an integer from a sequence but + // possibly any kind of number + obj = number.indexOf('.') == -1 + ? PyInteger.TYPE.__call__(Py.newString(number)) + : Py.newDecimal(number); + } else { + // Floating point binary precision + obj = Py.newFloat(set.getBigDecimal(col).doubleValue()); + } + } else { + // Decimal precision. A plain integer when without a scale. Maybe a + // plain integer when NUMBER(0,0) (scale and precision unknown, + // similar to NUMBER(0,-127) above) + obj = scale == 0 && (precision != 0 || number.indexOf('.') == -1) + ? PyInteger.TYPE.__call__(Py.newString(number)) + : Py.newDecimal(number); + } + break; + case Types.BLOB: BLOB blob = ((OracleResultSet) set).getBLOB(col); obj = blob == null ? Py.None : Py.java2py(read(blob.getBinaryStream())); break; + case OracleTypes.TIMESTAMPLTZ: + case OracleTypes.TIMESTAMPTZ: + // XXX: We should include time zone information, but cx_Oracle currently + // doesn't either + obj = super.getPyObject(set, col, Types.TIMESTAMP); + break; + case OracleTypes.ROWID: ROWID rowid = ((OracleResultSet) set).getROWID(col); Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-08-06 20:17:09 UTC (rev 6634) +++ trunk/jython/src/org/python/core/Py.java 2009-08-09 00:05:01 UTC (rev 6635) @@ -618,6 +618,15 @@ newInteger(timestamp.getNanos() / 1000)}); } + public static PyObject newDecimal(String decimal) { + if (decimal == null) { + return Py.None; + } + PyObject decimalModule = __builtin__.__import__("decimal"); + PyObject decimalClass = decimalModule.__getattr__("Decimal"); + return decimalClass.__call__(newString(decimal)); + } + public static PyCode newCode(int argcount, String varnames[], String filename, String name, boolean args, boolean keywords, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-10-07 02:48:55
|
Revision: 6844 http://jython.svn.sourceforge.net/jython/?rev=6844&view=rev Author: pjenvey Date: 2009-10-07 02:48:36 +0000 (Wed, 07 Oct 2009) Log Message: ----------- optimize attr lookup on Deriveds inheriting object.__getattribute__: don't bother going through the descriptor. Derived's __findattr_ex__ now lives in a Deriveds util class (like java.util.Arrays/Collections but trickier to pronounce) so it can toggle the package private fast path flag on PyType fixes #1102 Modified Paths: -------------- trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/templates/object.derived Added Paths: ----------- trunk/jython/src/org/python/core/Deriveds.java Added: trunk/jython/src/org/python/core/Deriveds.java =================================================================== --- trunk/jython/src/org/python/core/Deriveds.java (rev 0) +++ trunk/jython/src/org/python/core/Deriveds.java 2009-10-07 02:48:36 UTC (rev 6844) @@ -0,0 +1,63 @@ +/* Copyright (c) Jython Developers */ +package org.python.core; + +/** + * Derived classes utility methods. + */ +public class Deriveds { + + /** + * Derived's __findattr_ex__ implementation. + * + * This resides here (in org.python.core) because it manipulates PyType, and doesn't + * call any of the Derived classes' superclass methods. + */ + public static PyObject __findattr_ex__(PyObject self, String name) { + PyType type = self.getType(); + PyException firstAttributeError = null; + PyString pyName = null; + + try { + if (type.getUsesObjectGetattribute()) { + // Fast path: don't bother calling through the descriptor if using the + // generic __getattribute__ + PyObject result = self.object___findattr__(name); + if (result != null) { + return result; + } + // pass through to __getattr__ + } else { + PyObject getattribute = type.lookup("__getattribute__"); + if (getattribute == null) { + // This shouldn't happen + throw Py.SystemError(String.format("__getattribute__ not found on type %s", + type.getName())); + } + + if (getattribute == PyObject.objectGetattribute) { + type.setUsesObjectGetattribute(true); + } + pyName = PyString.fromInterned(name); + return getattribute.__get__(self, type).__call__(pyName); + } + } catch (PyException pye) { + if (!pye.match(Py.AttributeError)) { + throw pye; + } else { + // saved to avoid swallowing custom AttributeErrors, and pass through to + // __getattr__ + firstAttributeError = pye; + } + } + + PyObject getattr = type.lookup("__getattr__"); + if (getattr != null) { + return getattr.__get__(self, type).__call__(pyName != null + ? pyName : PyString.fromInterned(name)); + } + if (firstAttributeError != null) { + throw firstAttributeError; + } + return null; + } +} Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2009-10-06 20:32:55 UTC (rev 6843) +++ trunk/jython/src/org/python/core/PyObject.java 2009-10-07 02:48:36 UTC (rev 6844) @@ -38,6 +38,9 @@ /** Primitives classes their wrapper classes. */ private static final Map<Class<?>, Class<?>> primitiveMap = Generic.map(); + /** object.__getattribute__ descriptor, cached for use by Deriveds.__findattr_ex__. */ + static final PyObject objectGetattribute; + static { primitiveMap.put(Character.TYPE, Character.class); primitiveMap.put(Boolean.TYPE, Boolean.class); @@ -51,8 +54,9 @@ if (Py.BOOTSTRAP_TYPES.size() > 0) { Py.writeWarning("init", "Bootstrap types weren't encountered in bootstrapping: " + Py.BOOTSTRAP_TYPES); + } - } + objectGetattribute = TYPE.__findattr__("__getattribute__"); } public PyObject(PyType objtype) { @@ -3693,7 +3697,6 @@ // name must be interned final PyObject object___findattr__(String name) { - PyObject descr = objtype.lookup(name); PyObject res; @@ -3727,7 +3730,6 @@ final void object___setattr__(String name, PyObject value) { PyObject descr = objtype.lookup(name); - boolean set = false; if (descr != null) { @@ -3771,7 +3773,6 @@ final void object___delattr__(String name) { PyObject descr = objtype.lookup(name); - boolean delete = false; if (descr != null) { Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-10-06 20:32:55 UTC (rev 6843) +++ trunk/jython/src/org/python/core/PyType.java 2009-10-07 02:48:36 UTC (rev 6844) @@ -78,6 +78,9 @@ /** Whether finalization is required for this type's instances (implements __del__). */ private boolean needs_finalizer; + /** Whether this type's __getattribute__ is object.__getattribute__. */ + private volatile boolean usesObjectGetattribute; + /** The number of __slots__ defined. */ private int numSlots; @@ -685,6 +688,7 @@ mro = savedMro; throw t; } + postSetattr("__getattribute__"); } private void setIsBaseType(boolean isBaseType) { @@ -1329,6 +1333,12 @@ } }); } + } else if (name == "__getattribute__") { + traverse_hierarchy(false, new OnType() { + public boolean onType(PyType type) { + return (type.usesObjectGetattribute = false); + } + }); } } @@ -1381,6 +1391,12 @@ } }); } + } else if (name == "__getattribute__") { + traverse_hierarchy(false, new OnType() { + public boolean onType(PyType type) { + return (type.usesObjectGetattribute = false); + } + }); } } @@ -1480,6 +1496,14 @@ return doc; } + boolean getUsesObjectGetattribute() { + return usesObjectGetattribute; + } + + void setUsesObjectGetattribute(boolean usesObjectGetattribute) { + this.usesObjectGetattribute = usesObjectGetattribute; + } + public Object __tojava__(Class<?> c) { if (underlying_class != null && (c == Object.class || c == Class.class || c == Serializable.class)) { Modified: trunk/jython/src/templates/object.derived =================================================================== --- trunk/jython/src/templates/object.derived 2009-10-06 20:32:55 UTC (rev 6843) +++ trunk/jython/src/templates/object.derived 2009-10-07 02:48:36 UTC (rev 6844) @@ -314,44 +314,7 @@ } public PyObject __findattr_ex__(String name) { - PyType self_type = getType(); - // TODO: We should speed this up. As the __getattribute__ slot almost never - // changes, it is a good candidate for caching, as PyClass does with - // __getattr__. See #1102. - PyObject getattribute = self_type.lookup("__getattribute__"); - PyString py_name = null; - PyException firstAttributeError = null; - try { - if (getattribute != null) { - py_name = PyString.fromInterned(name); - return getattribute.__get__(this,self_type).__call__(py_name); - } else { - Py.Warning(String.format("__getattribute__ not found on type %s", - self_type.getName())); - PyObject ret = super.__findattr_ex__(name); - if (ret != null) { - return ret; - } // else: pass through to __getitem__ invocation - } - } catch (PyException e) { - if (!e.match(Py.AttributeError)) { - throw e; - } else { - firstAttributeError = e; // saved to avoid swallowing custom AttributeErrors - // and pass through to __getattr__ invocation. - } - } - PyObject getattr = self_type.lookup("__getattr__"); - if (getattr != null) { - if (py_name == null) { - py_name = PyString.fromInterned(name); - } - return getattr.__get__(this,self_type).__call__(py_name); - } - if (firstAttributeError != null) { - throw firstAttributeError; - } - return null; + return Deriveds.__findattr_ex__(this, name); } public void __setattr__(String name,PyObject value) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-10-26 06:37:03
|
Revision: 6903 http://jython.svn.sourceforge.net/jython/?rev=6903&view=rev Author: pjenvey Date: 2009-10-26 06:36:47 +0000 (Mon, 26 Oct 2009) Log Message: ----------- move Derived's dispatch__init__ guard into PyType and the rest of it into Deriveds Modified Paths: -------------- trunk/jython/src/org/python/core/Deriveds.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/modules/thread/PyLocal.java trunk/jython/src/templates/object.derived Modified: trunk/jython/src/org/python/core/Deriveds.java =================================================================== --- trunk/jython/src/org/python/core/Deriveds.java 2009-10-26 04:16:36 UTC (rev 6902) +++ trunk/jython/src/org/python/core/Deriveds.java 2009-10-26 06:36:47 UTC (rev 6903) @@ -10,6 +10,20 @@ private static final PyObject objectGetattribute = PyObject.TYPE.__findattr__("__getattribute__"); + public static void dispatch__init__(PyObject self, PyObject[] args, String[] keywords) { + PyType type = self.getType(); + PyObject init = type.lookup("__init__"); + if (init == null) { + return; + } + PyObject result = init.__get__(self, type).__call__(args, keywords); + if (result != Py.None) { + throw Py.TypeError(String.format("__init__() should return None, not '%.200s'", + result.getType().fastGetName())); + } + self.proxyInit(); + } + /** * Deriveds' __findattr_ex__ implementation. * Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2009-10-26 04:16:36 UTC (rev 6902) +++ trunk/jython/src/org/python/core/PyObject.java 2009-10-26 06:36:47 UTC (rev 6903) @@ -114,13 +114,14 @@ /** * Dispatch __init__ behavior */ - public void dispatch__init__(PyType type, PyObject[] args, String[] keywords) {} + public void dispatch__init__(PyObject[] args, String[] keywords) { + } /** * Attempts to automatically initialize our Java proxy if we have one and it wasn't initialized * by our __init__. */ - protected void proxyInit() { + void proxyInit() { Class<?> c = getType().getProxyType(); if (javaProxy != null || c == null) { return; Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-10-26 04:16:36 UTC (rev 6902) +++ trunk/jython/src/org/python/core/PyType.java 2009-10-26 06:36:47 UTC (rev 6903) @@ -1477,11 +1477,13 @@ } PyObject obj = invokeNew(new_, this, true, args, keywords); - // special case type(x) - if (this == TYPE && args.length == 1 && keywords.length == 0) { + // When the call was type(something) or the returned object is not an instance of + // type, it won't be initialized + if ((this == TYPE && args.length == 1 && keywords.length == 0) + || !obj.getType().isSubType(this)) { return obj; } - obj.dispatch__init__(this, args, keywords); + obj.dispatch__init__(args, keywords); return obj; } Modified: trunk/jython/src/org/python/modules/thread/PyLocal.java =================================================================== --- trunk/jython/src/org/python/modules/thread/PyLocal.java 2009-10-26 04:16:36 UTC (rev 6902) +++ trunk/jython/src/org/python/modules/thread/PyLocal.java 2009-10-26 06:36:47 UTC (rev 6903) @@ -81,7 +81,7 @@ if (ldict == null) { ldict = new PyDictionary(); tdict.set(ldict); - dispatch__init__(getType(), args, keywords); + dispatch__init__(args, keywords); } return ldict; } Modified: trunk/jython/src/templates/object.derived =================================================================== --- trunk/jython/src/templates/object.derived 2009-10-26 04:16:36 UTC (rev 6902) +++ trunk/jython/src/templates/object.derived 2009-10-26 06:36:47 UTC (rev 6903) @@ -385,19 +385,8 @@ return super.__pow__(other, modulo); } - public void dispatch__init__(PyType type,PyObject[] args,String[] keywords) { - PyType self_type = getType(); - if (self_type.isSubType(type)) { - PyObject impl = self_type.lookup("__init__"); - if (impl != null) { - PyObject res = impl.__get__(this,self_type).__call__(args,keywords); - if (res != Py.None) { - throw Py.TypeError(String.format("__init__() should return None, not '%.200s'", - res.getType().fastGetName())); - } - proxyInit(); - } - } + public void dispatch__init__(PyObject[] args, String[] keywords) { + Deriveds.dispatch__init__(this, args, keywords); } public PyObject __index__() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-10-26 21:06:05
|
Revision: 6908 http://jython.svn.sourceforge.net/jython/?rev=6908&view=rev Author: pjenvey Date: 2009-10-26 21:05:42 +0000 (Mon, 26 Oct 2009) Log Message: ----------- bool/slice aren't base types, they dont need Deriveds Modified Paths: -------------- trunk/jython/src/org/python/core/PyBoolean.java trunk/jython/src/org/python/core/PySlice.java trunk/jython/src/templates/mappings Removed Paths: ------------- trunk/jython/src/org/python/core/PyBooleanDerived.java trunk/jython/src/org/python/core/PySliceDerived.java trunk/jython/src/templates/bool.derived trunk/jython/src/templates/slice.derived Modified: trunk/jython/src/org/python/core/PyBoolean.java =================================================================== --- trunk/jython/src/org/python/core/PyBoolean.java 2009-10-26 20:11:44 UTC (rev 6907) +++ trunk/jython/src/org/python/core/PyBoolean.java 2009-10-26 21:05:42 UTC (rev 6908) @@ -14,34 +14,23 @@ public static final PyType TYPE = PyType.fromClass(PyBoolean.class); @ExposedNew - public static PyObject bool_new(PyNewWrapper new_, - boolean init, - PyType subtype, - PyObject[] args, - String[] keywords) { + public static PyObject bool_new(PyNewWrapper new_, boolean init, PyType subtype, + PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("bool", args, keywords, new String[] {"x"}, 0); - PyObject x = ap.getPyObject(0, null); - if (x == null) { + PyObject obj = ap.getPyObject(0, null); + if (obj == null) { return Py.False; } - if (new_.for_type == subtype) { - return x.__nonzero__() ? Py.True : Py.False; - } else { - return new PyBooleanDerived(subtype, x.__nonzero__()); - } + return obj.__nonzero__() ? Py.True : Py.False; } private boolean value; - public PyBoolean(PyType subType, boolean v) { - super(subType, v ? 1 : 0); - value = v; + public PyBoolean(boolean value) { + super(TYPE, value ? 1 : 0); + this.value = value; } - public PyBoolean(boolean v) { - this(TYPE, v); - } - public int getValue() { return value ? 1 : 0; } Deleted: trunk/jython/src/org/python/core/PyBooleanDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyBooleanDerived.java 2009-10-26 20:11:44 UTC (rev 6907) +++ trunk/jython/src/org/python/core/PyBooleanDerived.java 2009-10-26 21:05:42 UTC (rev 6908) @@ -1,1116 +0,0 @@ -/* Generated file, do not modify. See jython/src/templates/gderived.py. */ -package org.python.core; - -import java.io.Serializable; - -public class PyBooleanDerived extends PyBoolean implements Slotted { - - public PyObject getSlot(int index) { - return slots[index]; - } - - public void setSlot(int index,PyObject value) { - slots[index]=value; - } - - private PyObject[]slots; - - private PyObject dict; - - public PyObject fastGetDict() { - return dict; - } - - public PyObject getDict() { - return dict; - } - - public void setDict(PyObject newDict) { - if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { - dict=newDict; - } else { - throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); - } - } - - public void delDict() { - // deleting an object's instance dict makes it grow a new one - dict=new PyStringMap(); - } - - public PyBooleanDerived(PyType subtype,boolean v) { - super(subtype,v); - slots=new PyObject[subtype.getNumSlots()]; - dict=subtype.instDict(); - } - - public PyString __str__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__str__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__str__(); - } - - public PyString __repr__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__repr__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__repr__(); - } - - public PyString __hex__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__hex__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__hex__(); - } - - public PyString __oct__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__oct__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__oct__(); - } - - public PyFloat __float__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__float__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyFloat) - return(PyFloat)res; - throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); - } - return super.__float__(); - } - - public PyComplex __complex__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__complex__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyComplex) - return(PyComplex)res; - throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); - } - return super.__complex__(); - } - - public PyObject __pos__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__pos__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__pos__(); - } - - public PyObject __neg__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__neg__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__neg__(); - } - - public PyObject __abs__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__abs__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__abs__(); - } - - public PyObject __invert__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__invert__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__invert__(); - } - - public PyObject __reduce__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__reduce__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__reduce__(); - } - - public PyObject __add__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__add__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__add__(other); - } - - public PyObject __radd__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__radd__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__radd__(other); - } - - public PyObject __sub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__sub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__sub__(other); - } - - public PyObject __rsub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rsub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rsub__(other); - } - - public PyObject __mul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__mul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__mul__(other); - } - - public PyObject __rmul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rmul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rmul__(other); - } - - public PyObject __div__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__div__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__div__(other); - } - - public PyObject __rdiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rdiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rdiv__(other); - } - - public PyObject __floordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__floordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__floordiv__(other); - } - - public PyObject __rfloordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rfloordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rfloordiv__(other); - } - - public PyObject __truediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__truediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__truediv__(other); - } - - public PyObject __rtruediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rtruediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rtruediv__(other); - } - - public PyObject __mod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__mod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__mod__(other); - } - - public PyObject __rmod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rmod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rmod__(other); - } - - public PyObject __divmod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__divmod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__divmod__(other); - } - - public PyObject __rdivmod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rdivmod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rdivmod__(other); - } - - public PyObject __rpow__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rpow__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rpow__(other); - } - - public PyObject __lshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__lshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__lshift__(other); - } - - public PyObject __rlshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rlshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rlshift__(other); - } - - public PyObject __rshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rshift__(other); - } - - public PyObject __rrshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rrshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rrshift__(other); - } - - public PyObject __and__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__and__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__and__(other); - } - - public PyObject __rand__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rand__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rand__(other); - } - - public PyObject __or__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__or__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__or__(other); - } - - public PyObject __ror__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ror__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ror__(other); - } - - public PyObject __xor__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__xor__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__xor__(other); - } - - public PyObject __rxor__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rxor__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rxor__(other); - } - - public PyObject __lt__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__lt__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__lt__(other); - } - - public PyObject __le__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__le__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__le__(other); - } - - public PyObject __gt__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__gt__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__gt__(other); - } - - public PyObject __ge__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ge__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ge__(other); - } - - public PyObject __eq__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__eq__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__eq__(other); - } - - public PyObject __ne__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ne__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ne__(other); - } - - public PyObject __iadd__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__iadd__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__iadd__(other); - } - - public PyObject __isub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__isub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__isub__(other); - } - - public PyObject __imul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__imul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__imul__(other); - } - - public PyObject __idiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__idiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__idiv__(other); - } - - public PyObject __ifloordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ifloordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ifloordiv__(other); - } - - public PyObject __itruediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__itruediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__itruediv__(other); - } - - public PyObject __imod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__imod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__imod__(other); - } - - public PyObject __ipow__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ipow__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ipow__(other); - } - - public PyObject __ilshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ilshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ilshift__(other); - } - - public PyObject __irshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__irshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__irshift__(other); - } - - public PyObject __iand__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__iand__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__iand__(other); - } - - public PyObject __ior__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ior__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ior__(other); - } - - public PyObject __ixor__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ixor__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ixor__(other); - } - - public PyObject __int__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__int__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyInteger||res instanceof PyLong) - return res; - throw Py.TypeError("__int__"+" should return an integer"); - } - return super.__int__(); - } - - public PyObject __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong||res instanceof PyInteger) - return res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - - public int hashCode() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__hash__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyInteger) { - return((PyInteger)res).getValue(); - } else - if (res instanceof PyLong) { - return((PyLong)res).getValue().intValue(); - } - throw Py.TypeError("__hash__ should return a int"); - } - if (self_type.lookup("__eq__")!=null||self_type.lookup("__cmp__")!=null) { - throw Py.TypeError(String.format("unhashable type: '%.200s'",getType().fastGetName())); - } - return super.hashCode(); - } - - public PyUnicode __unicode__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__unicode__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyUnicode) - return(PyUnicode)res; - if (res instanceof PyString) - return new PyUnicode((PyString)res); - throw Py.TypeError("__unicode__"+" should return a "+"unicode"); - } - return super.__unicode__(); - } - - public int __cmp__(PyObject other) { - PyType self_type=getType(); - PyObject[]where_type=new PyObject[1]; - PyObject impl=self_type.lookup_where("__cmp__",where_type); - // Full Compatibility with CPython __cmp__: - // If the derived type don't override __cmp__, the - // *internal* super().__cmp__ should be called, not the - // exposed one. The difference is that the exposed __cmp__ - // throws a TypeError if the argument is an instance of the same type. - if (impl==null||where_type[0]==TYPE||Py.isSubClass(TYPE,where_type[0])) { - return super.__cmp__(other); - } - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) { - return-2; - } - int c=res.asInt(); - return c<0?-1:c>0?1:0; - } - - public boolean __nonzero__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__nonzero__"); - if (impl==null) { - impl=self_type.lookup("__len__"); - if (impl==null) - return super.__nonzero__(); - } - PyObject o=impl.__get__(this,self_type).__call__(); - Class c=o.getClass(); - if (c!=PyInteger.class&&c!=PyBoolean.class) { - throw Py.TypeError(String.format("__nonzero__ should return bool or int, returned %s",self_type.getName())); - } - return o.__nonzero__(); - } - - public boolean __contains__(PyObject o) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__contains__"); - if (impl==null) - return super.__contains__(o); - return impl.__get__(this,self_type).__call__(o).__nonzero__(); - } - - public int __len__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__len__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyInteger) - return((PyInteger)res).getValue(); - throw Py.TypeError("__len__ should return a int"); - } - return super.__len__(); - } - - public PyObject __iter__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__iter__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - impl=self_type.lookup("__getitem__"); - if (impl==null) - return super.__iter__(); - return new PySequenceIter(this); - } - - public PyObject __iternext__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("next"); - if (impl!=null) { - try { - return impl.__get__(this,self_type).__call__(); - } catch (PyException exc) { - if (exc.match(Py.StopIteration)) - return null; - throw exc; - } - } - return super.__iternext__(); // ??? - } - - public PyObject __finditem__(PyObject key) { // ??? - PyType self_type=getType(); - PyObject impl=self_type.lookup("__getitem__"); - if (impl!=null) - try { - return impl.__get__(this,self_type).__call__(key); - } catch (PyException exc) { - if (exc.match(Py.LookupError)) - return null; - throw exc; - } - return super.__finditem__(key); - } - - public PyObject __finditem__(int key) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__getitem__"); - if (impl!=null) - try { - return impl.__get__(this,self_type).__call__(new PyInteger(key)); - } catch (PyException exc) { - if (exc.match(Py.LookupError)) - return null; - throw exc; - } - return super.__finditem__(key); - } - - public PyObject __getitem__(PyObject key) { - // Same as __finditem__, without swallowing LookupErrors. This allows - // __getitem__ implementations written in Python to raise custom - // exceptions (such as subclasses of KeyError). - // - // We are forced to duplicate the code, instead of defining __finditem__ - // in terms of __getitem__. That's because PyObject defines __getitem__ - // in terms of __finditem__. Therefore, we would end with an infinite - // loop when self_type.lookup("__getitem__") returns null: - // - // __getitem__ -> super.__getitem__ -> __finditem__ -> __getitem__ - // - // By duplicating the (short) lookup and call code, we are safe, because - // the call chains will be: - // - // __finditem__ -> super.__finditem__ - // - // __getitem__ -> super.__getitem__ -> __finditem__ -> super.__finditem__ - - PyType self_type=getType(); - PyObject impl=self_type.lookup("__getitem__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(key); - return super.__getitem__(key); - } - - public void __setitem__(PyObject key,PyObject value) { // ??? - PyType self_type=getType(); - PyObject impl=self_type.lookup("__setitem__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(key,value); - return; - } - super.__setitem__(key,value); - } - - public PyObject __getslice__(PyObject start,PyObject stop,PyObject step) { // ??? - if (step!=null) { - return __getitem__(new PySlice(start,stop,step)); - } - PyType self_type=getType(); - PyObject impl=self_type.lookup("__getslice__"); - if (impl!=null) { - PyObject[]indices=PySlice.indices2(this,start,stop); - return impl.__get__(this,self_type).__call__(indices[0],indices[1]); - } - return super.__getslice__(start,stop,step); - } - - public void __setslice__(PyObject start,PyObject stop,PyObject step,PyObject value) { - if (step!=null) { - __setitem__(new PySlice(start,stop,step),value); - return; - } - PyType self_type=getType(); - PyObject impl=self_type.lookup("__setslice__"); - if (impl!=null) { - PyObject[]indices=PySlice.indices2(this,start,stop); - impl.__get__(this,self_type).__call__(indices[0],indices[1],value); - return; - } - super.__setslice__(start,stop,step,value); - } - - public void __delslice__(PyObject start,PyObject stop,PyObject step) { - if (step!=null) { - __delitem__(new PySlice(start,stop,step)); - return; - } - PyType self_type=getType(); - PyObject impl=self_type.lookup("__delslice__"); - if (impl!=null) { - PyObject[]indices=PySlice.indices2(this,start,stop); - impl.__get__(this,self_type).__call__(indices[0],indices[1]); - return; - } - super.__delslice__(start,stop,step); - } - - public void __delitem__(PyObject key) { // ??? - PyType self_type=getType(); - PyObject impl=self_type.lookup("__delitem__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(key); - return; - } - super.__delitem__(key); - } - - public PyObject __call__(PyObject args[],String keywords[]) { - ThreadState ts=Py.getThreadState(); - if (ts.recursion_depth++>ts.systemState.getrecursionlimit()) - throw Py.RuntimeError("maximum __call__ recursion depth exceeded"); - try { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__call__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(args,keywords); - return super.__call__(args,keywords); - } finally { - --ts.recursion_depth; - } - } - - public PyObject __findattr_ex__(String name) { - return Deriveds.__findattr_ex__(this,name); - } - - public void __setattr__(String name,PyObject value) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__setattr__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value); - return; - } - super.__setattr__(name,value); - } - - public void __delattr__(String name) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__delattr__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(PyString.fromInterned(name)); - return; - } - super.__delattr__(name); - } - - public PyObject __get__(PyObject obj,PyObject type) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__get__"); - if (impl!=null) { - if (obj==null) - obj=Py.None; - if (type==null) - type=Py.None; - return impl.__get__(this,self_type).__call__(obj,type); - } - return super.__get__(obj,type); - } - - public void __set__(PyObject obj,PyObject value) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__set__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(obj,value); - return; - } - super.__set__(obj,value); - } - - public void __delete__(PyObject obj) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__delete__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(obj); - return; - } - super.__delete__(obj); - } - - public PyObject __pow__(PyObject other,PyObject modulo) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__pow__"); - if (impl!=null) { - PyObject res; - if (modulo==null) { - res=impl.__get__(this,self_type).__call__(other); - } else { - res=impl.__get__(this,self_type).__call__(other,modulo); - } - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__pow__(other,modulo); - } - - public void dispatch__init__(PyObject[]args,String[]keywords) { - Deriveds.dispatch__init__(this,args,keywords); - } - - public PyObject __index__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__index__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyInteger||res instanceof PyLong) { - return res; - } - throw Py.TypeError(String.format("__index__ returned non-(int,long) (type %s)",res.getType().fastGetName())); - } - return super.__index__(); - } - - public Object __tojava__(Class c) { - // If we are not being asked by the "default" conversion to java, then - // we can provide this as the result, as long as it is a instance of the - // specified class. Without this, derived.__tojava__(PyObject.class) - // would broke. (And that's not pure speculation: PyReflectedFunction's - // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { - return this; - } - // Otherwise, we call the derived __tojava__, if it exists: - PyType self_type=getType(); - PyObject impl=self_type.lookup("__tojava__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava__(Object.class); - return super.__tojava__(c); - } - - public Object __coerce_ex__(PyObject o) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__coerce__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(o); - if (res==Py.NotImplemented) - return Py.None; - if (!(res instanceof PyTuple)) - throw Py.TypeError("__coerce__ didn't return a 2-tuple"); - return((PyTuple)res).getArray(); - } - return super.__coerce_ex__(o); - } - - public String toString() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__repr__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (!(res instanceof PyString)) - throw Py.TypeError("__repr__ returned non-string (type "+res.getType().fastGetName()+")"); - return((PyString)res).toString(); - } - return super.toString(); - } - -} Modified: trunk/jython/src/org/python/core/PySlice.java =================================================================== --- trunk/jython/src/org/python/core/PySlice.java 2009-10-26 20:11:44 UTC (rev 6907) +++ trunk/jython/src/org/python/core/PySlice.java 2009-10-26 21:05:42 UTC (rev 6908) @@ -24,15 +24,11 @@ public PyObject step = Py.None; public PySlice() { - this(TYPE); + super(TYPE); } - public PySlice(PyType type) { - super(type); - } - public PySlice(PyObject start, PyObject stop, PyObject step) { - this(TYPE); + super(TYPE); if (start != null) { this.start = start; } @@ -45,24 +41,26 @@ } @ExposedNew - @ExposedMethod - final void slice___init__(PyObject[] args, String[] keywords) { + static PyObject slice_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, + String[] keywords) { if (args.length == 0) { throw Py.TypeError("slice expected at least 1 arguments, got " + args.length); } else if (args.length > 3) { throw Py.TypeError("slice expected at most 3 arguments, got " + args.length); } ArgParser ap = new ArgParser("slice", args, keywords, "start", "stop", "step"); + PySlice slice = new PySlice(); if (args.length == 1) { - stop = ap.getPyObject(0); + slice.stop = ap.getPyObject(0); } else if (args.length == 2) { - start = ap.getPyObject(0); - stop = ap.getPyObject(1); + slice.start = ap.getPyObject(0); + slice.stop = ap.getPyObject(1); } else if (args.length == 3) { - start = ap.getPyObject(0); - stop = ap.getPyObject(1); - step = ap.getPyObject(2); + slice.start = ap.getPyObject(0); + slice.stop = ap.getPyObject(1); + slice.step = ap.getPyObject(2); } + return slice; } @Override Deleted: trunk/jython/src/org/python/core/PySliceDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySliceDerived.java 2009-10-26 20:11:44 UTC (rev 6907) +++ trunk/jython/src/org/python/core/PySliceDerived.java 2009-10-26 21:05:42 UTC (rev 6908) @@ -1,1116 +0,0 @@ -/* Generated file, do not modify. See jython/src/templates/gderived.py. */ -package org.python.core; - -import java.io.Serializable; - -public class PySliceDerived extends PySlice implements Slotted { - - public PyObject getSlot(int index) { - return slots[index]; - } - - public void setSlot(int index,PyObject value) { - slots[index]=value; - } - - private PyObject[]slots; - - private PyObject dict; - - public PyObject fastGetDict() { - return dict; - } - - public PyObject getDict() { - return dict; - } - - public void setDict(PyObject newDict) { - if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { - dict=newDict; - } else { - throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); - } - } - - public void delDict() { - // deleting an object's instance dict makes it grow a new one - dict=new PyStringMap(); - } - - public PySliceDerived(PyType subtype) { - super(subtype); - slots=new PyObject[subtype.getNumSlots()]; - dict=subtype.instDict(); - } - - public PyString __str__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__str__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__str__(); - } - - public PyString __repr__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__repr__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__repr__(); - } - - public PyString __hex__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__hex__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__hex__(); - } - - public PyString __oct__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__oct__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__oct__(); - } - - public PyFloat __float__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__float__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyFloat) - return(PyFloat)res; - throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); - } - return super.__float__(); - } - - public PyComplex __complex__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__complex__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyComplex) - return(PyComplex)res; - throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); - } - return super.__complex__(); - } - - public PyObject __pos__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__pos__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__pos__(); - } - - public PyObject __neg__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__neg__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__neg__(); - } - - public PyObject __abs__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__abs__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__abs__(); - } - - public PyObject __invert__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__invert__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__invert__(); - } - - public PyObject __reduce__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__reduce__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__reduce__(); - } - - public PyObject __add__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__add__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__add__(other); - } - - public PyObject __radd__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__radd__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__radd__(other); - } - - public PyObject __sub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__sub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__sub__(other); - } - - public PyObject __rsub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rsub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rsub__(other); - } - - public PyObject __mul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__mul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__mul__(other); - } - - public PyObject __rmul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rmul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rmul__(other); - } - - public PyObject __div__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__div__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__div__(other); - } - - public PyObject __rdiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rdiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rdiv__(other); - } - - public PyObject __floordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__floordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__floordiv__(other); - } - - public PyObject __rfloordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rfloordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rfloordiv__(other); - } - - public PyObject __truediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__truediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__truediv__(other); - } - - public PyObject __rtruediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rtruediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rtruediv__(other); - } - - public PyObject __mod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__mod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__mod__(other); - } - - public PyObject __rmod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rmod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rmod__(other); - } - - public PyObject __divmod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__divmod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__divmod__(other); - } - - public PyObject __rdivmod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rdivmod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rdivmod__(other); - } - - public PyObject __rpow__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rpow__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rpow__(other); - } - - public PyObject __lshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__lshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__lshift__(other); - } - - public PyObject __rlshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rlshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rlshift__(other); - } - - public PyObject __rshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rshift__(other); - } - - public PyObject __rrshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rrshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rrshift__(other); - } - - public PyObject __and__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__and__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__and__(other); - } - - public PyObject __rand__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rand__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rand__(other); - } - - public PyObject __or__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__or__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__or__(other); - } - - public PyObject __ror__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ror__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ror__(other); - } - - public PyObject __xor__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__xor__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__xor__(other); - } - - public PyObject __rxor__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rxor__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rxor__(other); - } - - public PyObject __lt__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__lt__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__lt__(other); - } - - public PyObject __le__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__le__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__le__(other); - } - - public PyObject __gt__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__gt__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__gt__(other); - } - - ... [truncated message content] |