From: <zy...@us...> - 2009-04-18 02:31:20
|
Revision: 6239 http://jython.svn.sourceforge.net/jython/?rev=6239&view=rev Author: zyasoft Date: 2009-04-18 02:31:16 +0000 (Sat, 18 Apr 2009) Log Message: ----------- Cleanup. Modified Paths: -------------- branches/newlist/src/org/python/core/PyList.java branches/newlist/src/org/python/core/PyTuple.java Modified: branches/newlist/src/org/python/core/PyList.java =================================================================== --- branches/newlist/src/org/python/core/PyList.java 2009-04-18 01:06:26 UTC (rev 6238) +++ branches/newlist/src/org/python/core/PyList.java 2009-04-18 02:31:16 UTC (rev 6239) @@ -1,4 +1,4 @@ - // Copyright (c) Corporation for National Research Initiatives +// Copyright (c) Corporation for National Research Initiatives package org.python.core; import java.util.ArrayList; @@ -140,11 +140,9 @@ } else if (value instanceof PySequence) { setsliceIterator(start, stop, step, value.asIterable().iterator()); } else if (value != null && !(value instanceof List)) { - //XXX: can we avoid copying here? Needed to pass test_userlist value = new PyList(value); setsliceIterator(start, stop, step, value.asIterable().iterator()); } else { -// System.err.println("List"); List valueList = (List) value.__tojava__(List.class); if (valueList != null && valueList != Py.NoConversion) { setsliceList(start, stop, step, valueList); @@ -782,7 +780,6 @@ if (c instanceof PySequenceList) { return list.containsAll(c); } else { - //XXX: FJW this seems unnecessary. return list.containsAll(new PyList(c)); } } @@ -948,52 +945,8 @@ copy[i] = ((PyObject) copy[i]).__tojava__(Object.class); } return copy; -// System.err.println("toArray:" + this); -// System.err.println(CallStackUtil.getCallStackAsString()); -// return list.toArray(); } - // from http://roncox.org/20 - XXX just here for debugging - static class CallStackUtil { - - public synchronized static String getCallStackAsString() { - StringBuilder sb = new StringBuilder(); - - StackTraceElement[] stackTraceElements = - Thread.currentThread().getStackTrace(); - - String[] array = getCallStackAsStringArray(stackTraceElements); - - for (int i = 0; i < array.length; i++) { - sb.append(array[i] + "\n"); - } - return sb.toString(); - } - - public synchronized static String[] getCallStackAsStringArray() { - StackTraceElement[] stackTraceElements = - Thread.currentThread().getStackTrace(); - - String[] array = getCallStackAsStringArray(stackTraceElements); - - return array; - } - - private synchronized static String[] getCallStackAsStringArray(StackTraceElement[] stackTraceElements) { - ArrayList<String> list = new ArrayList<String>(); - String[] array = new String[1]; - - for (int i = 0; i < stackTraceElements.length; i++) { - StackTraceElement element = stackTraceElements[i]; - String classname = element.getClassName(); - String methodName = element.getMethodName(); - int lineNumber = element.getLineNumber(); - list.add(classname + "." + methodName + ":" + lineNumber); - } - return list.toArray(array); - } - } - @Override public Object[] toArray(Object[] a) { Object copy[] = list.toArray(); Modified: branches/newlist/src/org/python/core/PyTuple.java =================================================================== --- branches/newlist/src/org/python/core/PyTuple.java 2009-04-18 01:06:26 UTC (rev 6238) +++ branches/newlist/src/org/python/core/PyTuple.java 2009-04-18 02:31:16 UTC (rev 6239) @@ -33,7 +33,6 @@ public PyTuple(PyType subtype, PyObject[] elements) { super(subtype); -// System.err.println("Initializing from " + Arrays.toString(elements)); if (elements == null) { array = new PyObject[0]; } else { @@ -58,7 +57,6 @@ } private static PyTuple fromArrayNoCopy(PyObject[] elements) { -// System.err.println("newtuple (no copy):" + Arrays.toString(elements)); return new PyTuple(elements, false); } private volatile List<PyObject> cachedList = null; @@ -73,10 +71,8 @@ @ExposedNew final static PyObject tuple_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { -// System.err.println("tuple_new"); ArgParser ap = new ArgParser("newtuple", args, keywords, new String[]{"sequence"}, 0); PyObject S = ap.getPyObject(0, null); -// System.err.println("newtuple: new_=" + new_ + ",S=" + S); if (new_.for_type == subtype) { if (S == null) { return EMPTY_TUPLE; @@ -154,6 +150,7 @@ return fromArrayNoCopy(newArray); } + @Override public int __len__() { return tuple___len__(); } @@ -198,6 +195,7 @@ return super.__le__(o); } + @Override public PyObject __add__(PyObject generic_other) { return tuple___add__(generic_other); } @@ -241,6 +239,7 @@ return repeat(o.asIndex(Py.OverflowError)); } + @Override public PyObject __iter__() { return tuple___iter__(); } @@ -269,10 +268,12 @@ return new PyTuple(new PyTuple(getArray())); } + @Override public PyTuple __getnewargs__() { return tuple___getnewargs__(); } + @Override public int hashCode() { return tuple___hash__(); } @@ -300,6 +301,7 @@ return o.__repr__().toString(); } + @Override public String toString() { return tuple___repr__(); } @@ -335,9 +337,6 @@ return new PyTuple(elements); } - // Make PyTuple immutable from the collections interfaces by overriding - // all the mutating methods to throw UnsupportedOperationException exception. - // This is how Collections.unmodifiableList() does it. public Iterator iterator() { return new Iterator() { @@ -469,8 +468,8 @@ public boolean equals(Object o) { if (o instanceof PyTuple) { return Arrays.equals(array, ((PyTuple) o).array); - } else if (o instanceof List) { // XXX copied from PyList, but... - return o.equals(this); // XXX shouldn't this compare using py2java? + } else if (o instanceof List) { + return o.equals(this); } return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |