From: <pj...@us...> - 2009-05-31 03:27:45
|
Revision: 6433 http://jython.svn.sourceforge.net/jython/?rev=6433&view=rev Author: pjenvey Date: 2009-05-31 03:26:57 +0000 (Sun, 31 May 2009) Log Message: ----------- deprecate the no longer needed {str,unicode}.isunicode and remove cPickle's use of it Modified Paths: -------------- trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/core/PyUnicode.java trunk/jython/src/org/python/modules/cPickle.java Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2009-05-31 00:25:12 UTC (rev 6432) +++ trunk/jython/src/org/python/core/PyString.java 2009-05-31 03:26:57 UTC (rev 6433) @@ -2406,9 +2406,9 @@ return str_isunicode(); } - //XXX: need doc - @ExposedMethod/*(doc = BuiltinDocs.unicode_isunicode_doc)*/ + @ExposedMethod(doc = "isunicode is deprecated.") final boolean str_isunicode() { + Py.warning(Py.DeprecationWarning, "isunicode is deprecated."); int n = string.length(); for (int i = 0; i < n; i++) { char ch = string.charAt(i); Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2009-05-31 00:25:12 UTC (rev 6432) +++ trunk/jython/src/org/python/core/PyUnicode.java 2009-05-31 03:26:57 UTC (rev 6433) @@ -1318,10 +1318,11 @@ } return true; } - // XXX: needs doc + // end utf-16 aware - @ExposedMethod + @ExposedMethod(doc = "isunicode is deprecated.") final boolean unicode_isunicode() { + Py.warning(Py.DeprecationWarning, "isunicode is deprecated."); return true; } Modified: trunk/jython/src/org/python/modules/cPickle.java =================================================================== --- trunk/jython/src/org/python/modules/cPickle.java 2009-05-31 00:25:12 UTC (rev 6432) +++ trunk/jython/src/org/python/modules/cPickle.java 2009-05-31 03:26:57 UTC (rev 6433) @@ -1067,21 +1067,15 @@ final private void save_string(PyObject object) { - boolean unicode = ((PyString) object).isunicode(); String str = object.toString(); if (protocol > 0) { - if (unicode) - str = codecs.PyUnicode_EncodeUTF8(str, "struct"); int l = str.length(); - if (l < 256 && !unicode) { + if (l < 256) { file.write(SHORT_BINSTRING); file.write((char)l); } else { - if (unicode) - file.write(BINUNICODE); - else - file.write(BINSTRING); + file.write(BINSTRING); file.write((char)( l & 0xFF)); file.write((char)((l >>> 8 ) & 0xFF)); file.write((char)((l >>> 16) & 0xFF)); @@ -1089,14 +1083,8 @@ } file.write(str); } else { - if (unicode) { - file.write(UNICODE); - file.write(codecs.PyUnicode_EncodeRawUnicodeEscape(str, - "strict", true)); - } else { - file.write(STRING); - file.write(object.__repr__().toString()); - } + file.write(STRING); + file.write(object.__repr__().toString()); file.write("\n"); } put(putMemo(get_id(object), object)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 07:06:32
|
Revision: 6457 http://jython.svn.sourceforge.net/jython/?rev=6457&view=rev Author: pjenvey Date: 2009-06-06 07:06:19 +0000 (Sat, 06 Jun 2009) Log Message: ----------- o fix recompiling due to stale byte code not tagging an mtime on the new code o change importer isAcceptableBytecode -> getSourceMtime to fix zipimporter to check mtime against the actual bytecode's tagged mtime Modified Paths: -------------- trunk/jython/src/org/python/core/ClasspathPyImporter.java trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/core/util/importer.java trunk/jython/src/org/python/modules/zipimport/zipimporter.java Modified: trunk/jython/src/org/python/core/ClasspathPyImporter.java =================================================================== --- trunk/jython/src/org/python/core/ClasspathPyImporter.java 2009-06-06 05:45:22 UTC (rev 6456) +++ trunk/jython/src/org/python/core/ClasspathPyImporter.java 2009-06-06 07:06:19 UTC (rev 6457) @@ -1,3 +1,4 @@ +/* Copyright (c) Jython Developers */ package org.python.core; import java.io.IOException; @@ -63,8 +64,9 @@ } @Override - protected boolean isAcceptableBytecode(String searchPath, String entry) { - return true; + protected long getSourceMtime(String path) { + // Can't determine this easily + return -1; } @Override Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-06-06 05:45:22 UTC (rev 6456) +++ trunk/jython/src/org/python/core/imp.java 2009-06-06 07:06:19 UTC (rev 6457) @@ -474,10 +474,12 @@ boolean pkg = false; try { - pkg = dir.isDirectory() && caseok(dir, name) && (sourceFile.isFile() - || compiledFile.isFile()); + pkg = dir.isDirectory() && caseok(dir, name) + && (sourceFile.isFile() || compiledFile.isFile()); } catch (SecurityException e) { + // ok } + if (!pkg) { Py.writeDebug(IMPORT_LOG, "trying source " + dir.getPath()); sourceName = name + ".py"; @@ -506,7 +508,7 @@ } } return createFromSource(modName, makeStream(sourceFile), displaySourceName, - compiledFile.getPath()); + compiledFile.getPath(), pyTime); } return createFromSource(modName, makeStream(sourceFile), displaySourceName, compiledFile.getPath(), pyTime); @@ -519,6 +521,7 @@ displayCompiledName); } } catch (SecurityException e) { + // ok } return null; } Modified: trunk/jython/src/org/python/core/util/importer.java =================================================================== --- trunk/jython/src/org/python/core/util/importer.java 2009-06-06 05:45:22 UTC (rev 6456) +++ trunk/jython/src/org/python/core/util/importer.java 2009-06-06 07:06:19 UTC (rev 6457) @@ -1,3 +1,4 @@ +/* Copyright (c) Jython Developers */ package org.python.core.util; import java.io.IOException; @@ -127,7 +128,14 @@ public abstract void close(); } - protected abstract boolean isAcceptableBytecode(String searchPath, T entry); + /** + * Given a path to a compiled file in the archive, return the modification time of the + * matching .py file. + * + * @param path to the compiled file + * @return long mtime of the .py, or -1 if no source is available + */ + protected abstract long getSourceMtime(String path); /** * Return module information for the module with the fully qualified name. @@ -181,9 +189,9 @@ boolean ispackage = entry.type.contains(EntryType.IS_PACKAGE); boolean isbytecode = entry.type.contains(EntryType.IS_BYTECODE); - - if (isbytecode && !isAcceptableBytecode(searchPath, tocEntry)) { - continue; + long mtime = -1; + if (isbytecode) { + mtime = getSourceMtime(searchPath); } Bundle bundle = makeBundle(searchPath, tocEntry); @@ -191,10 +199,14 @@ try { if (isbytecode) { try { - codeBytes = imp.readCode(fullname, bundle.inputStream, true); + codeBytes = imp.readCode(fullname, bundle.inputStream, true, mtime); } catch (IOException ioe) { throw Py.ImportError(ioe.getMessage() + "[path=" + fullSearchPath + "]"); } + if (codeBytes == null) { + // bad magic number or non-matching mtime in byte code, try next + continue; + } } else { codeBytes = imp.compileSource(fullname, bundle.inputStream, fullSearchPath); } Modified: trunk/jython/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-06-06 05:45:22 UTC (rev 6456) +++ trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-06-06 07:06:19 UTC (rev 6457) @@ -12,6 +12,7 @@ import org.python.core.ArgParser; import org.python.core.Py; import org.python.core.PyDictionary; +import org.python.core.PyException; import org.python.core.PyInteger; import org.python.core.PyLong; import org.python.core.PyObject; @@ -299,31 +300,27 @@ } } - /** - * Determine if the byte code at path with the specified toc entry has a modification time - * greater than its accompanying source code's. - * - * @param path a String path to the byte code - * @param tocEntry the byte code's PyObject toc entry - * @return boolean whether or not the byte code is older - */ @Override - protected boolean isAcceptableBytecode(String path, PyObject tocEntry) { + protected long getSourceMtime(String path) { String sourcePath = path.substring(0, path.length() - 9) + ".py"; PyObject sourceTocEntry = files.__finditem__(sourcePath); if (sourceTocEntry == null) { - return true;// If there is no source, assume the bytecode is ok + return -1; } + + int time; + int date; try { - long bytecodeTime = dosTimeToEpoch(tocEntry.__finditem__(5).asInt(0), - tocEntry.__finditem__(6).asInt(0)); - long sourceTime = dosTimeToEpoch(sourceTocEntry.__finditem__(5).asInt(0), - sourceTocEntry.__finditem__(6).asInt(0)); - return bytecodeTime < sourceTime; + time = sourceTocEntry.__finditem__(5).asInt(); + date = sourceTocEntry.__finditem__(6).asInt(); + } catch (PyException pye) { + if (!pye.match(Py.TypeError)) { + throw pye; + } + time = -1; + date = -1; } - catch (PyObject.ConversionException ce) { - return false; - } + return dosTimeToEpoch(time, date); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-08 00:54:16
|
Revision: 6467 http://jython.svn.sourceforge.net/jython/?rev=6467&view=rev Author: pjenvey Date: 2009-06-08 00:30:12 +0000 (Mon, 08 Jun 2009) Log Message: ----------- don't reference the APIVersion field directly so it's not hardcoded into the .class Modified Paths: -------------- trunk/jython/src/org/python/compiler/ClassFile.java trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/compiler/ClassFile.java =================================================================== --- trunk/jython/src/org/python/compiler/ClassFile.java 2009-06-07 23:36:06 UTC (rev 6466) +++ trunk/jython/src/org/python/compiler/ClassFile.java 2009-06-08 00:30:12 UTC (rev 6467) @@ -1,6 +1,6 @@ // Copyright (c) Corporation for National Research Initiatives - package org.python.compiler; + import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -15,6 +15,8 @@ import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; +import org.python.core.imp; + public class ClassFile { ClassWriter cw; @@ -53,8 +55,8 @@ this.mtime = mtime; cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - methodVisitors = Collections.synchronizedList(new ArrayList()); - fieldVisitors = Collections.synchronizedList(new ArrayList()); + methodVisitors = Collections.synchronizedList(new ArrayList<MethodVisitor>()); + fieldVisitors = Collections.synchronizedList(new ArrayList<FieldVisitor>()); } public void setSource(String name) { @@ -96,7 +98,7 @@ throws IOException { for (int i=0; i<methodVisitors.size(); i++) { - MethodVisitor mv = (MethodVisitor)methodVisitors.get(i); + MethodVisitor mv = methodVisitors.get(i); mv.visitMaxs(0,0); mv.visitEnd(); } @@ -105,8 +107,9 @@ public void write(OutputStream stream) throws IOException { cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, this.name, null, this.superclass, interfaces); AnnotationVisitor av = cw.visitAnnotation("Lorg/python/compiler/APIVersion;", true); - //XXX: should imp.java really house this value or should imp.java point into org.python.compiler? - av.visit("value", new Integer(org.python.core.imp.APIVersion)); + // XXX: should imp.java really house this value or should imp.java point into + // org.python.compiler? + av.visit("value", new Integer(imp.getAPIVersion())); av.visitEnd(); av = cw.visitAnnotation("Lorg/python/compiler/MTime;", true); @@ -127,11 +130,4 @@ //debug(baos); baos.close(); } - - //XXX: this should go away when things stabilize. - private void debug(ByteArrayOutputStream baos) throws IOException { - FileOutputStream fos = new FileOutputStream("DEBUG.class"); - baos.writeTo(fos); - fos.close(); - } } Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-06-07 23:36:06 UTC (rev 6466) +++ trunk/jython/src/org/python/core/imp.java 2009-06-08 00:30:12 UTC (rev 6467) @@ -20,7 +20,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - public static final int APIVersion = 22; + private static final int APIVersion = 22; public static final int NO_MTIME = -1; @@ -990,4 +990,8 @@ modules.__setitem__(modName, ret); return ret; } + + public static int getAPIVersion() { + return APIVersion; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-07-15 20:05:58
|
Revision: 6539 http://jython.svn.sourceforge.net/jython/?rev=6539&view=rev Author: thobes Date: 2009-07-15 20:05:51 +0000 (Wed, 15 Jul 2009) Log Message: ----------- Changed the ContextManager interface to get the exception as one argument, this reduces the need fo object (re-) creation. This also reduces the overhead even more for the optimized context managers, since parts of the code that was previously generated in the compiled Python code is now part of the library in ContextGuard. Also fixed a bug in the code for turning generator functions into optimized context managers. Modified Paths: -------------- trunk/jython/src/org/python/compiler/CodeCompiler.java trunk/jython/src/org/python/core/ContextGuard.java trunk/jython/src/org/python/core/ContextManager.java trunk/jython/src/org/python/modules/_threading/Condition.java trunk/jython/src/org/python/modules/_threading/Lock.java Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-15 02:34:53 UTC (rev 6538) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-15 20:05:51 UTC (rev 6539) @@ -2278,7 +2278,7 @@ final Method contextGuard_getManager = Method.getMethod("org.python.core.ContextManager getManager (org.python.core.PyObject)"); final Method __enter__ = Method.getMethod("org.python.core.PyObject __enter__ (org.python.core.ThreadState)"); - final Method __exit__ = Method.getMethod("boolean __exit__ (org.python.core.ThreadState,org.python.core.PyObject,org.python.core.PyObject,org.python.core.PyObject)"); + final Method __exit__ = Method.getMethod("boolean __exit__ (org.python.core.ThreadState,org.python.core.PyException)"); // mgr = (EXPR) visit(node.getInternalContext_expr()); @@ -2313,9 +2313,7 @@ public void finalBody(CodeCompiler compiler) throws Exception { compiler.code.aload(mgr_tmp); loadThreadState(); - compiler.getNone(); - compiler.code.dup(); - compiler.code.dup(); + compiler.code.aconst_null(); compiler.code.invokeinterface(Type.getType(ContextManager.class).getInternalName(), __exit__.getName(), __exit__.getDescriptor()); compiler.code.pop(); } @@ -2355,25 +2353,15 @@ loadFrame(); code.invokestatic("org/python/core/Py", "setException", "(" + $throwable + $pyFrame + ")" + $pyExc); - code.pop(); + code.aload(mgr_tmp); + code.swap(); loadThreadState(); - code.getfield("org/python/core/ThreadState", "exception", $pyExc); - int ts_tmp = storeTop(); + code.swap(); + code.invokeinterface(Type.getType(ContextManager.class).getInternalName(), __exit__.getName(), __exit__.getDescriptor()); // # The exceptional case is handled here // exc = False # implicit // if not exit(*sys.exc_info()): - code.aload(mgr_tmp); - loadThreadState(); - code.aload(ts_tmp); - code.getfield("org/python/core/PyException", "type", $pyObj); - code.aload(ts_tmp); - code.getfield("org/python/core/PyException", "value", $pyObj); - code.aload(ts_tmp); - code.freeLocal(ts_tmp); - code.getfield("org/python/core/PyException", "traceback", "Lorg/python/core/PyTraceback;"); - code.checkcast("org/python/core/PyObject"); - code.invokeinterface(Type.getType(ContextManager.class).getInternalName(), __exit__.getName(), __exit__.getDescriptor()); code.ifne(label_end); // raise // # The exception is swallowed if exit() returns true Modified: trunk/jython/src/org/python/core/ContextGuard.java =================================================================== --- trunk/jython/src/org/python/core/ContextGuard.java 2009-07-15 02:34:53 UTC (rev 6538) +++ trunk/jython/src/org/python/core/ContextGuard.java 2009-07-15 20:05:51 UTC (rev 6539) @@ -17,9 +17,18 @@ return __enter__method.__call__(ts); } - public boolean __exit__(ThreadState ts, PyObject type, PyObject value, - PyObject traceback) { - return __exit__method.__call__(ts, type, value, traceback).__nonzero__(); + public boolean __exit__(ThreadState ts, PyException exception) { + final PyObject type, value, traceback; + if (exception != null) { + type = exception.type; + value = exception.value; + traceback = exception.traceback; + } else { + type = value = traceback = Py.None; + } + return __exit__method.__call__(ts, type, + value == null ? Py.None : value, + traceback == null ? Py.None : traceback).__nonzero__(); } public static ContextManager getManager(PyObject manager) { @@ -43,7 +52,7 @@ * finally: * print "done" */ - + public static PyObject makeManager(PyObject object) { if (object instanceof PyFunction) { PyFunction function = (PyFunction) object; @@ -125,19 +134,18 @@ return res; } - public boolean __exit__(ThreadState ts, PyObject type, PyObject value, - PyObject traceback) { - PyException ex = null; - if (type != null && type != Py.None) { - ex = Py.makeException(type, value, traceback); - frame.setGeneratorInput(ex); + public boolean __exit__(ThreadState ts, PyException exception) { + if (exception != null) { + frame.setGeneratorInput(exception); } - PyObject res = null; + final PyObject res; try { res = body(ts); } catch(PyException e) { - if (e == ex) { + if (e.equals(exception)) { return false; + } else { + throw e; } } if (frame.f_lasti != -1) { Modified: trunk/jython/src/org/python/core/ContextManager.java =================================================================== --- trunk/jython/src/org/python/core/ContextManager.java 2009-07-15 02:34:53 UTC (rev 6538) +++ trunk/jython/src/org/python/core/ContextManager.java 2009-07-15 20:05:51 UTC (rev 6539) @@ -7,5 +7,5 @@ public interface ContextManager { public PyObject __enter__(ThreadState ts); - public boolean __exit__(ThreadState ts, PyObject type, PyObject value, PyObject traceback); + public boolean __exit__(ThreadState ts, PyException exception); } Modified: trunk/jython/src/org/python/modules/_threading/Condition.java =================================================================== --- trunk/jython/src/org/python/modules/_threading/Condition.java 2009-07-15 02:34:53 UTC (rev 6538) +++ trunk/jython/src/org/python/modules/_threading/Condition.java 2009-07-15 20:05:51 UTC (rev 6539) @@ -2,6 +2,7 @@ import org.python.core.ContextManager; import org.python.core.Py; +import org.python.core.PyException; import org.python.core.PyNewWrapper; import org.python.core.PyObject; import org.python.core.PyType; @@ -65,7 +66,7 @@ _lock.release(); } - public boolean __exit__(ThreadState ts, PyObject type, PyObject value, PyObject traceback) { + public boolean __exit__(ThreadState ts, PyException exception) { _lock.release(); return false; } Modified: trunk/jython/src/org/python/modules/_threading/Lock.java =================================================================== --- trunk/jython/src/org/python/modules/_threading/Lock.java 2009-07-15 02:34:53 UTC (rev 6538) +++ trunk/jython/src/org/python/modules/_threading/Lock.java 2009-07-15 20:05:51 UTC (rev 6539) @@ -3,6 +3,7 @@ import java.util.concurrent.locks.ReentrantLock; import org.python.core.ContextManager; import org.python.core.Py; +import org.python.core.PyException; import org.python.core.PyNewWrapper; import org.python.core.PyObject; import org.python.core.PyType; @@ -76,7 +77,7 @@ return false; } - public boolean __exit__(ThreadState ts, PyObject type, PyObject value, PyObject traceback) { + public boolean __exit__(ThreadState ts, PyException exception) { _lock.unlock(); return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-07-19 08:15:59
|
Revision: 6548 http://jython.svn.sourceforge.net/jython/?rev=6548&view=rev Author: cgroves Date: 2009-07-19 08:15:53 +0000 (Sun, 19 Jul 2009) Log Message: ----------- Add an ant task to compile proxies This works by naively importing the modules with the proxy output directory set to the destination configured in the ant task. Eventually it's going to need to work with our Lib directory to generate proxies for all of our Java subclasses, but it currently fails miserably on various modules that aren't expecting to be straight-up imported. Modified Paths: -------------- trunk/jython/src/org/python/core/PyJavaType.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/expose/generate/ExposeTask.java trunk/jython/src/org/python/util/GlobMatchingTask.java trunk/jython/src/org/python/util/JycompileAntTask.java Added Paths: ----------- trunk/jython/src/org/python/util/CompileProxiesTask.java trunk/jython/src/org/python/util/FileNameMatchingTask.java Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2009-07-19 06:49:49 UTC (rev 6547) +++ trunk/jython/src/org/python/core/PyJavaType.java 2009-07-19 08:15:53 UTC (rev 6548) @@ -186,7 +186,7 @@ underlying_class = forClass; computeLinearMro(baseClass); } else { - needsInners.add(this); + needsInners.add(this); javaProxy = forClass; objtype = PyType.fromClassSkippingInners(Class.class, needsInners); // Wrapped Java types fill in their mro first using all of their interfaces then their Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-07-19 06:49:49 UTC (rev 6547) +++ trunk/jython/src/org/python/core/PyType.java 2009-07-19 08:15:53 UTC (rev 6548) @@ -1051,8 +1051,9 @@ PyObject dict = element.fastGetDict(); if (dict != null) { PyObject obj = dict.__finditem__(name); - if (obj != null) + if (obj != null) { return obj; + } } } return null; Modified: trunk/jython/src/org/python/expose/generate/ExposeTask.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposeTask.java 2009-07-19 06:49:49 UTC (rev 6547) +++ trunk/jython/src/org/python/expose/generate/ExposeTask.java 2009-07-19 08:15:53 UTC (rev 6548) @@ -8,8 +8,8 @@ import org.apache.tools.ant.BuildException; import org.objectweb.asm.ClassWriter; +import org.python.core.Options; import org.python.core.Py; -import org.python.core.Options; import org.python.util.GlobMatchingTask; public class ExposeTask extends GlobMatchingTask { Added: trunk/jython/src/org/python/util/CompileProxiesTask.java =================================================================== --- trunk/jython/src/org/python/util/CompileProxiesTask.java (rev 0) +++ trunk/jython/src/org/python/util/CompileProxiesTask.java 2009-07-19 08:15:53 UTC (rev 6548) @@ -0,0 +1,68 @@ +package org.python.util; + +import java.io.File; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +import org.apache.tools.ant.BuildException; +import org.python.core.Py; +import org.python.core.PySystemState; + +/** + * Compiles the Java proxies for Python classes in the Python modules in a given directory tree to + * another directory. + */ +public class CompileProxiesTask extends JycompileAntTask { + + @Override + public void process(Set<File> toCompile) throws BuildException { + // Run our superclass' compile first to check that everything has valid syntax before + // attempting to import it and to keep the imports from generating class files in the source + // directory + super.process(toCompile); + Properties props = new Properties(); + props.setProperty(PySystemState.PYTHON_CACHEDIR_SKIP, "true"); + PySystemState.initialize(props, null); + PySystemState sys = Py.getSystemState(); + // Part 2 of not spewing compilation in the source directory: import our compiled files + sys.path.insert(0, Py.newString(destDir.getAbsolutePath())); + sys.javaproxy_dir = destDir.getAbsolutePath(); + PythonInterpreter interp = new PythonInterpreter(); + for (String module : compiledModuleNames) { + try { + interp.exec("import " + module); + } catch (RuntimeException t) { + // We didn't get to import any of these files, so their compiled form can't hang + // around or we won't pick them up as needing compilation next time. + for (File f : compiledModuleFiles) { + f.delete(); + } + throw t; + } + // This module was successfully imported, so its compiled file can hang around + compiledModuleFiles.remove(0); + } + } + + @Override + protected void compile(File src, File compiled, String moduleName) { + try { + super.compile(src, compiled, moduleName); + } catch (BuildException ex) { + // This depends on the modtime of the source being newer than that of the compiled file + // to decide to do the import in process, so even though these files compiled properly, + // they need to be deleted to allow them to be imported in process next time around. + for (File f : compiledModuleFiles) { + f.delete(); + } + throw ex; + } + compiledModuleNames.add(moduleName); + compiledModuleFiles.add(compiled); + } + + private List<String> compiledModuleNames = Generic.list(); + + private List<File> compiledModuleFiles = Generic.list(); +} Added: trunk/jython/src/org/python/util/FileNameMatchingTask.java =================================================================== --- trunk/jython/src/org/python/util/FileNameMatchingTask.java (rev 0) +++ trunk/jython/src/org/python/util/FileNameMatchingTask.java 2009-07-19 08:15:53 UTC (rev 6548) @@ -0,0 +1,95 @@ +package org.python.util; + +import java.io.File; +import java.util.Set; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.taskdefs.MatchingTask; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.util.FileNameMapper; +import org.apache.tools.ant.util.SourceFileScanner; + +public abstract class FileNameMatchingTask extends MatchingTask { + + private Path src; + + protected File destDir; + + private Set<File> toProcess = Generic.set(); + + /** + * Set the source directories to find the class files to be exposed. + */ + public void setSrcdir(Path srcDir) { + if (src == null) { + src = srcDir; + } else { + src.append(srcDir); + } + } + + /** + * Gets the source dirs to find the class files to be exposed. + */ + public Path getSrcdir() { + return src; + } + + /** + * Set the destination directory into which the Java source files should be compiled. + * + * @param destDir + * the destination director + */ + public void setDestdir(File destDir) { + this.destDir = destDir; + } + + /** + * Gets the destination directory into which the java source files should be compiled. + * + * @return the destination directory + */ + public File getDestdir() { + return destDir; + } + + @Override + public void execute() throws BuildException { + checkParameters(); + toProcess.clear(); + for (String srcEntry : src.list()) { + File srcDir = getProject().resolveFile(srcEntry); + if (!srcDir.exists()) { + throw new BuildException("srcdir '" + srcDir.getPath() + "' does not exist!", + getLocation()); + } + String[] files = getDirectoryScanner(srcDir).getIncludedFiles(); + scanDir(srcDir, destDir != null ? destDir : srcDir, files); + } + process(toProcess); + } + + protected abstract void process(Set<File> matches); + + protected abstract FileNameMapper createMapper(); + + protected void scanDir(File srcDir, File destDir, String[] files) { + SourceFileScanner sfs = new SourceFileScanner(this); + for (File file : sfs.restrictAsFiles(files, srcDir, destDir, createMapper())) { + toProcess.add(file); + } + } + /** + * Check that all required attributes have been set and nothing silly has been entered. + */ + protected void checkParameters() throws BuildException { + if (src == null || src.size() == 0) { + throw new BuildException("srcdir attribute must be set!", getLocation()); + } + if (destDir != null && !destDir.isDirectory()) { + throw new BuildException("destination directory '" + destDir + "' does not exist " + + "or is not a directory", getLocation()); + } + } +} \ No newline at end of file Modified: trunk/jython/src/org/python/util/GlobMatchingTask.java =================================================================== --- trunk/jython/src/org/python/util/GlobMatchingTask.java 2009-07-19 06:49:49 UTC (rev 6547) +++ trunk/jython/src/org/python/util/GlobMatchingTask.java 2009-07-19 08:15:53 UTC (rev 6548) @@ -1,101 +1,19 @@ package org.python.util; -import java.io.File; -import java.util.Set; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.MatchingTask; -import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.GlobPatternMapper; -import org.apache.tools.ant.util.SourceFileScanner; -public abstract class GlobMatchingTask extends MatchingTask { +public abstract class GlobMatchingTask extends FileNameMatchingTask { - private Path src; - - protected File destDir; - - private Set<File> toExpose = Generic.set(); - - /** - * Set the source directories to find the class files to be exposed. - */ - public void setSrcdir(Path srcDir) { - if (src == null) { - src = srcDir; - } else { - src.append(srcDir); - } - } - - /** - * Gets the source dirs to find the class files to be exposed. - */ - public Path getSrcdir() { - return src; - } - - /** - * Set the destination directory into which the Java source files should be compiled. - * - * @param destDir - * the destination director - */ - public void setDestdir(File destDir) { - this.destDir = destDir; - } - - /** - * Gets the destination directory into which the java source files should be compiled. - * - * @return the destination directory - */ - public File getDestdir() { - return destDir; - } - @Override - public void execute() throws BuildException { - checkParameters(); - toExpose.clear(); - for (String srcEntry : src.list()) { - File srcDir = getProject().resolveFile(srcEntry); - if (!srcDir.exists()) { - throw new BuildException("srcdir '" + srcDir.getPath() + "' does not exist!", - getLocation()); - } - String[] files = getDirectoryScanner(srcDir).getIncludedFiles(); - scanDir(srcDir, destDir != null ? destDir : srcDir, files); - } - process(toExpose); + protected FileNameMapper createMapper() { + FileNameMapper mapper = new GlobPatternMapper(); + mapper.setFrom(getFrom()); + mapper.setTo(getTo()); + return mapper; } - protected abstract void process(Set<File> matches); - protected abstract String getFrom(); protected abstract String getTo(); - - protected void scanDir(File srcDir, File destDir, String[] files) { - GlobPatternMapper m = new GlobPatternMapper(); - m.setFrom(getFrom()); - m.setTo(getTo()); - SourceFileScanner sfs = new SourceFileScanner(this); - for (File file : sfs.restrictAsFiles(files, srcDir, destDir, m)) { - toExpose.add(file); - } - } - - /** - * Check that all required attributes have been set and nothing silly has been entered. - */ - protected void checkParameters() throws BuildException { - if (src == null || src.size() == 0) { - throw new BuildException("srcdir attribute must be set!", getLocation()); - } - if (destDir != null && !destDir.isDirectory()) { - throw new BuildException("destination directory '" + destDir + "' does not exist " - + "or is not a directory", getLocation()); - } - } -} \ No newline at end of file +} Modified: trunk/jython/src/org/python/util/JycompileAntTask.java =================================================================== --- trunk/jython/src/org/python/util/JycompileAntTask.java 2009-07-19 06:49:49 UTC (rev 6547) +++ trunk/jython/src/org/python/util/JycompileAntTask.java 2009-07-19 08:15:53 UTC (rev 6548) @@ -59,10 +59,12 @@ imp.cacheCompiledSource(src.getAbsolutePath(), compiled.getAbsolutePath(), bytes); } + @Override protected String getFrom() { return "*.py"; } + @Override protected String getTo() { return "*$py.class"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-07-26 15:23:45
|
Revision: 6589 http://jython.svn.sourceforge.net/jython/?rev=6589&view=rev Author: cgroves Date: 2009-07-26 15:23:38 +0000 (Sun, 26 Jul 2009) Log Message: ----------- Grooming Modified Paths: -------------- trunk/jython/src/org/python/compiler/AdapterMaker.java trunk/jython/src/org/python/compiler/ClassConstants.java trunk/jython/src/org/python/compiler/JavaMaker.java trunk/jython/src/org/python/compiler/ProxyMaker.java trunk/jython/src/org/python/core/MakeProxies.java trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/compiler/AdapterMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/AdapterMaker.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/compiler/AdapterMaker.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -1,8 +1,6 @@ // Copyright (c) Corporation for National Research Initiatives - package org.python.compiler; -import java.io.OutputStream; import java.lang.reflect.Method; import java.util.HashSet; @@ -10,40 +8,27 @@ import org.objectweb.asm.Opcodes; import org.python.util.Generic; +public class AdapterMaker extends ProxyMaker { -public class AdapterMaker extends ProxyMaker -{ - public AdapterMaker(Class<?> interfac) { - super(interfac.getName()+"$Adapter", interfac); + public AdapterMaker(String adapterName, Class<?> interfac) { + super(adapterName, Object.class, new Class<?>[] {interfac}); } + @Override public void build() throws Exception { names = Generic.set(); - int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNCHRONIZED; classfile = new ClassFile(myClass, "java/lang/Object", access); - classfile.addInterface(mapClass(interfaces[0])); - addMethods(interfaces[0], new HashSet<String>()); addConstructors(Object.class); doConstants(); } - - public static String makeAdapter(Class interfac, OutputStream ostream) - throws Exception - { - AdapterMaker pm = new AdapterMaker(interfac); - pm.build(); - pm.classfile.write(ostream); - return pm.myClass; - } - @Override public void doConstants() throws Exception { for (String name : names) { - classfile.addField(name, "Lorg/python/core/PyObject;", Opcodes.ACC_PUBLIC); + classfile.addField(name, $pyObj, Opcodes.ACC_PUBLIC); } } @@ -51,15 +36,11 @@ public void addMethod(Method method, int access) throws Exception { Class<?>[] parameters = method.getParameterTypes(); Class<?> ret = method.getReturnType(); - String sig = makeSignature(parameters, ret); - String name = method.getName(); names.add(name); - - Code code = classfile.addMethod(name, sig, Opcodes.ACC_PUBLIC); - + Code code = classfile.addMethod(name, makeSig(ret, parameters), Opcodes.ACC_PUBLIC); code.aload(0); - code.getfield(classfile.name, name, "Lorg/python/core/PyObject;"); + code.getfield(classfile.name, name, $pyObj); code.dup(); Label returnNull = new Label(); code.ifnull(returnNull); Modified: trunk/jython/src/org/python/compiler/ClassConstants.java =================================================================== --- trunk/jython/src/org/python/compiler/ClassConstants.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/compiler/ClassConstants.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -24,5 +24,4 @@ final static String $str = "Ljava/lang/String;"; final static String $strArr = "[Ljava/lang/String;"; final static String $throwable = "Ljava/lang/Throwable;"; - } Modified: trunk/jython/src/org/python/compiler/JavaMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/JavaMaker.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/compiler/JavaMaker.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -6,7 +6,7 @@ import org.python.core.PyObject; -public class JavaMaker extends ProxyMaker implements ClassConstants { +public class JavaMaker extends ProxyMaker { public String pythonClass, pythonModule; @@ -35,8 +35,7 @@ callSuper(code, "<init>", name, parameters, null, sig); code.visitVarInsn(ALOAD, 0); getArgs(code, parameters); - - code.visitMethodInsn(INVOKEVIRTUAL, classfile.name, "__initProxy__", "([Ljava/lang/Object;)V"); + code.visitMethodInsn(INVOKEVIRTUAL, classfile.name, "__initProxy__", makeSig("V", $objArr)); code.visitInsn(RETURN); } @@ -46,14 +45,14 @@ super.addProxy(); // _initProxy method - Code code = classfile.addMethod("__initProxy__", "([Ljava/lang/Object;)V", Modifier.PUBLIC); + Code code = classfile.addMethod("__initProxy__", makeSig("V", $objArr), Modifier.PUBLIC); code.visitVarInsn(ALOAD, 0); code.visitLdcInsn(pythonModule); code.visitLdcInsn(pythonClass); - code.visitVarInsn(ALOAD, 1); - code.visitMethodInsn(INVOKESTATIC, "org/python/core/Py", "initProxy", "(" + $pyProxy + $str + $str + $objArr + ")V"); + code.visitMethodInsn(INVOKESTATIC, "org/python/core/Py", "initProxy", + makeSig("V", $pyProxy, $str, $str, $objArr)); code.visitInsn(RETURN); } Modified: trunk/jython/src/org/python/compiler/ProxyMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -1,9 +1,6 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.compiler; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -11,13 +8,13 @@ import java.util.Map; import java.util.Set; +import org.objectweb.asm.Label; +import org.objectweb.asm.Opcodes; import org.python.core.Py; import org.python.core.PyMethod; import org.python.core.PyObject; import org.python.core.PyProxy; import org.python.core.PyReflectedFunction; -import org.objectweb.asm.Label; -import org.objectweb.asm.Opcodes; import org.python.util.Generic; public class ProxyMaker implements ClassConstants, Opcodes @@ -34,7 +31,7 @@ public static final int tOther=9; public static final int tNone=10; - public static Map<Class<?>, Integer> types=fillTypes(); + public static Map<Class<?>, Integer> types = fillTypes(); public static Map<Class<?>, Integer> fillTypes() { Map<Class<?>, Integer> typeMap = Generic.map(); @@ -51,10 +48,15 @@ } public static int getType(Class<?> c) { - if (c == null) return tNone; + if (c == null) { + return tNone; + } Object i = types.get(c); - if (i == null) return tOther; - else return ((Integer)i).intValue(); + if (i == null) { + return tOther; + } else { + return ((Integer)i); + } } /** @@ -89,35 +91,58 @@ Set<String> names; Set<String> supernames = Generic.set(); public ClassFile classfile; + /** The name of the class to build. */ public String myClass; - public ProxyMaker(String classname, Class<?> superclass) { - this.myClass = "org.python.proxies."+classname; - if (superclass.isInterface()) { - this.superclass = Object.class; - this.interfaces = new Class[] {superclass}; - } else { - this.superclass = superclass; - this.interfaces = new Class[0]; - } + /** + * Creates a proxy class maker that produces classes named + * <code>org.python.proxies.(superclassName)</code> with <code>superclass</code> as an + * implemented interface or extended class, depending on the its type. + * + * @deprecated - Use {@link ProxyMaker#ProxyMaker(String, Class, Class[]) + + */ + @Deprecated + public ProxyMaker(String superclassName, Class<?> superclass) { + this("org.python.proxies." + superclassName, + superclass.isInterface() ? Object.class : superclass, + superclass.isInterface() ? new Class<?>[] { superclass} : new Class<?>[0]); + } - public ProxyMaker(String myClass, Class<?> superclass, Class<?>[] interfaces) { - this.myClass = myClass; - if (superclass == null) + /** + * Creates a proxy class maker that produces classes named <code>proxyClassName</code> that + * extends <code>superclass</code> and implements the interfaces in <code>interfaces</code>. + */ + public ProxyMaker(String proxyClassName, Class<?> superclass, Class<?>... interfaces) { + this.myClass = proxyClassName; + if (superclass == null) { superclass = Object.class; + } + if (superclass.isInterface()) { + throw new IllegalArgumentException("Given an interface, " + superclass.getName() + + ", for a proxy superclass"); + } this.superclass = superclass; - if (interfaces == null) + if (interfaces == null) { interfaces = new Class[0]; + } + for (Class<?> interfac : interfaces) { + if (!interfac.isInterface()) { + throw new IllegalArgumentException( + "All classes in the interfaces array must be interfaces, unlike " + + interfac.getName()); + } + } this.interfaces = interfaces; } public static String mapClass(Class<?> c) { String name = c.getName(); int index = name.indexOf("."); - if (index == -1) + if (index == -1) { return name; - + } StringBuffer buf = new StringBuffer(name.length()); int last_index = 0; while (index != -1) { @@ -149,20 +174,25 @@ } } - public static String makeSignature(Class<?>[] sig, Class<?> ret) { - StringBuffer buf=new StringBuffer(); - buf.append("("); - for (Class<?> element : sig) { - buf.append(mapType(element)); + public static String makeSig(Class<?> ret, Class<?>... sig) { + String[] mapped = new String[sig.length]; + for (int i = 0; i < mapped.length; i++) { + mapped[i] = mapType(sig[i]); } - buf.append(")"); - buf.append(mapType(ret)); - return buf.toString(); + return makeSig(mapType(ret), mapped); } + public static String makeSig(String returnType, String... parameterTypes) { + StringBuilder buf = new StringBuilder("("); + for (String param : parameterTypes) { + buf.append(param); + } + return buf.append(')').append(returnType).toString(); + } + public void doConstants() throws Exception { - Code code = classfile.addMethod("<clinit>", "()V", Modifier.STATIC); + Code code = classfile.addMethod("<clinit>", makeSig("V"), Modifier.STATIC); code.return_(); } @@ -276,8 +306,8 @@ String jcallName) throws Exception { - code.invokevirtual("org/python/core/PyObject", jcallName, "(" + $objArr + ")" + $pyObj); - code.invokestatic("org/python/core/Py", "py2"+name, "(" + $pyObj + ")"+type); + code.invokevirtual("org/python/core/PyObject", jcallName, makeSig($pyObj, $objArr)); + code.invokestatic("org/python/core/Py", "py2"+name, makeSig(type, $pyObj)); } @@ -385,10 +415,10 @@ doJavaCall(code, "void", "V", jcallName); break; default: - code.invokevirtual("org/python/core/PyObject", jcallName, "(" + $objArr + ")" + $pyObj); + code.invokevirtual("org/python/core/PyObject", jcallName, makeSig($pyObj, $objArr)); code.ldc(ret.getName()); - code.invokestatic("java/lang/Class","forName", "(" + $str + ")" + $clss); - code.invokestatic("org/python/core/Py", "tojava", "(" + $pyObj + $clss + ")" + $obj); + code.invokestatic("java/lang/Class","forName", makeSig($clss, $str)); + code.invokestatic("org/python/core/Py", "tojava", makeSig($obj, $pyObj, $clss)); // I guess I need this checkcast to keep the verifier happy code.checkcast(mapClass(ret)); break; @@ -429,7 +459,7 @@ code.aload(instLocal); code.aload(excLocal); - code.invokevirtual("org/python/core/PyObject", "_jthrow", "(" + $throwable + ")V"); + code.invokevirtual("org/python/core/PyObject", "_jthrow", makeSig("V", $throwable)); code.visitTryCatchBlock(start, end, handlerStart, "java/lang/Throwable"); code.freeLocal(excLocal); @@ -450,7 +480,7 @@ Class<?>[] parameters = method.getParameterTypes(); Class<?> ret = method.getReturnType(); - String sig = makeSignature(parameters, ret); + String sig = makeSig(ret, parameters); String name = method.getName(); names.add(name); @@ -462,8 +492,8 @@ if (!isAbstract) { int tmp = code.getLocal("org/python/core/PyObject"); - code.invokestatic("org/python/compiler/ProxyMaker", "findPython", "(" + $pyProxy + $str - + ")" + $pyObj); + code.invokestatic("org/python/compiler/ProxyMaker", "findPython", + makeSig($pyObj, $pyProxy, $str)); code.astore(tmp); code.aload(tmp); @@ -480,8 +510,8 @@ addSuperMethod("super__"+name, name, superClass, parameters, ret, sig, access); } else { - code.invokestatic("org/python/compiler/ProxyMaker", "findPython", "(" + $pyProxy + $str - + ")" + $pyObj); + code.invokestatic("org/python/compiler/ProxyMaker", "findPython", + makeSig($pyObj, $pyProxy, $str)); code.dup(); Label returnNull = new Label(); code.ifnull(returnNull); @@ -506,10 +536,9 @@ protected void addMethods(Class<?> c, Set<String> t) throws Exception { Method[] methods = c.getDeclaredMethods(); for (Method method : methods) { - String s = methodString(method); - if (t.contains(s)) + if (!t.add(methodString(method))) { continue; - t.add(s); + } int access = method.getModifiers(); if (Modifier.isStatic(access) || Modifier.isPrivate(access)) { @@ -528,16 +557,18 @@ } } else if (Modifier.isFinal(access)) { continue; + } else if (!Modifier.isPublic(access)) { + continue; // package protected by process of elimination; we can't override } addMethod(method, access); } Class<?> sc = c.getSuperclass(); - if (sc != null) + if (sc != null) { addMethods(sc, t); + } - Class<?>[] ifaces = c.getInterfaces(); - for (Class<?> iface : ifaces) { + for (Class<?> iface : c.getInterfaces()) { addMethods(iface, t); } } @@ -556,15 +587,17 @@ String name = mapClass(c); for (Constructor<?> constructor : constructors) { int access = constructor.getModifiers(); - if (Modifier.isPrivate(access)) + if (Modifier.isPrivate(access)) { continue; - if (Modifier.isNative(access)) + } + if (Modifier.isNative(access)) { access = access & ~Modifier.NATIVE; - if (Modifier.isProtected(access)) + } + if (Modifier.isProtected(access)) { access = access & ~Modifier.PROTECTED | Modifier.PUBLIC; + } Class<?>[] parameters = constructor.getParameterTypes(); - String sig = makeSignature(parameters, Void.TYPE); - addConstructor(name, parameters, Void.TYPE, sig, access); + addConstructor(name, parameters, Void.TYPE, makeSig(Void.TYPE, parameters), access); } } @@ -585,7 +618,6 @@ public void addSuperMethod(Method method, int access) throws Exception { Class<?>[] parameters = method.getParameterTypes(); Class<?> ret = method.getReturnType(); - String sig = makeSignature(parameters, ret); String superClass = mapClass(method.getDeclaringClass()); String superName = method.getName(); String methodName = superName; @@ -594,7 +626,7 @@ access &= ~Modifier.FINAL; } addSuperMethod(methodName, superName, superClass, parameters, - ret, sig, access); + ret, makeSig(ret, parameters), access); } public void addSuperMethod(String methodName, @@ -612,10 +644,11 @@ first that redefines the JC method foo. */ try { - superclass.getMethod(methodName,parameters); + superclass.getMethod(methodName, parameters); return; - } catch(NoSuchMethodException e) { - } catch(SecurityException e) { + } catch (NoSuchMethodException e) { + // OK, no one else defines it, so we need to + } catch (SecurityException e) { return; } } @@ -626,66 +659,65 @@ public void addProxy() throws Exception { // implement PyProxy interface - classfile.addField("__proxy", "Lorg/python/core/PyObject;", - Modifier.PROTECTED); + classfile.addField("__proxy", $pyObj, Modifier.PROTECTED); // setProxy methods - Code code = classfile.addMethod("_setPyInstance", - "(Lorg/python/core/PyObject;)V", - Modifier.PUBLIC); + Code code = classfile.addMethod("_setPyInstance", makeSig("V", $pyObj), Modifier.PUBLIC); code.aload(0); code.aload(1); - code.putfield(classfile.name, "__proxy", "Lorg/python/core/PyObject;"); + code.putfield(classfile.name, "__proxy", $pyObj); code.return_(); // getProxy method - code = classfile.addMethod("_getPyInstance", - "()Lorg/python/core/PyObject;", - Modifier.PUBLIC); + code = classfile.addMethod("_getPyInstance", makeSig($pyObj), Modifier.PUBLIC); code.aload(0); - code.getfield(classfile.name, "__proxy", "Lorg/python/core/PyObject;"); + code.getfield(classfile.name, "__proxy", $pyObj); code.areturn(); + String pySys = "Lorg/python/core/PySystemState;"; // implement PyProxy interface - classfile.addField("__systemState", - "Lorg/python/core/PySystemState;", - Modifier.PROTECTED | Modifier.TRANSIENT); + classfile.addField("__systemState", pySys, Modifier.PROTECTED | Modifier.TRANSIENT); // setProxy method code = classfile.addMethod("_setPySystemState", - "(Lorg/python/core/PySystemState;)V", + makeSig("V", pySys), Modifier.PUBLIC); code.aload(0); code.aload(1); - code.putfield(classfile.name, "__systemState", "Lorg/python/core/PySystemState;"); + code.putfield(classfile.name, "__systemState", pySys); code.return_(); // getProxy method - code = classfile.addMethod("_getPySystemState", - "()Lorg/python/core/PySystemState;", - Modifier.PUBLIC); + code = classfile.addMethod("_getPySystemState", makeSig(pySys), Modifier.PUBLIC); code.aload(0); - code.getfield(classfile.name, "__systemState", "Lorg/python/core/PySystemState;"); + code.getfield(classfile.name, "__systemState", pySys); code.areturn(); } public void addClassDictInit() throws Exception { // classDictInit method classfile.addInterface(mapClass(org.python.core.ClassDictInit.class)); - Code code = classfile.addMethod("classDictInit", - "(" + $pyObj + ")V", - Modifier.PUBLIC | Modifier.STATIC); + Code code = classfile.addMethod("classDictInit", makeSig("V", $pyObj), + Modifier.PUBLIC | Modifier.STATIC); code.aload(0); code.ldc("__supernames__"); int strArray = CodeCompiler.makeStrings(code, supernames); code.aload(strArray); code.freeLocal(strArray); - code.invokestatic("org/python/core/Py", "java2py", "(" + $obj + ")" + $pyObj); - code.invokevirtual("org/python/core/PyObject", "__setitem__", "(" + $str + $pyObj + ")V"); + code.invokestatic("org/python/core/Py", "java2py", makeSig($pyObj, $obj)); + code.invokevirtual("org/python/core/PyObject", "__setitem__", makeSig("V", $str, $pyObj)); code.return_(); } + /** + * Builds this proxy and writes its bytecode to <code>out</code>. + */ + public void build(OutputStream out) throws Exception { + build(); + classfile.write(out); + } + public void build() throws Exception { names = Generic.set(); int access = superclass.getModifiers(); @@ -712,23 +744,4 @@ doConstants(); addClassDictInit(); } - - public static File makeFilename(String name, File dir) { - int index = name.indexOf("."); - if (index == -1) - return new File(dir, name+".class"); - - return makeFilename(name.substring(index+1, name.length()), - new File(dir, name.substring(0, index))); - } - - // This is not general enough - public static OutputStream getFile(String d, String name) - throws IOException - { - File dir = new File(d); - File file = makeFilename(name, dir); - file.getParentFile().mkdirs(); - return new FileOutputStream(file); - } } Modified: trunk/jython/src/org/python/core/MakeProxies.java =================================================================== --- trunk/jython/src/org/python/core/MakeProxies.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/core/MakeProxies.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -32,16 +32,16 @@ public static Class<?> makeAdapter(Class<?> c) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - String name; + AdapterMaker maker = new AdapterMaker(proxyPrefix + c.getName(), c); try { - name = AdapterMaker.makeAdapter(c, bytes); + maker.build(bytes); } catch (Exception exc) { throw Py.JavaError(exc); } - Py.saveClassFile(name, bytes); + Py.saveClassFile(maker.myClass, bytes); - return makeClass(c, null, name, bytes); + return makeClass(c, null, maker.myClass, bytes); } private static final String proxyPrefix = "org.python.proxies."; @@ -82,9 +82,8 @@ fullProxyName, dict); try { - jm.build(); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - jm.classfile.write(bytes); + jm.build(bytes); if (customProxyName != null) { Py.saveClassFile(fullProxyName, bytes, Py.getSystemState().javaproxy_dir); } else { Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/core/Py.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -1143,7 +1143,7 @@ return pye; } - + /** * @deprecated As of Jython 2.5, use {@link PyException#match} instead. */ @@ -1448,7 +1448,7 @@ throw Py.TypeError("None required for void return"); } } - + private final static PyString[] letters = new PyString[256]; static { @@ -1767,10 +1767,12 @@ if (dirname == null) { return; } - byte[] bytes = baos.toByteArray(); + saveClassFile(name, baos.toByteArray(), dirname); + } + + public static void saveClassFile(String name, byte[] bytes, String dirname) { File dir = new File(dirname); File file = makeFilename(name, dir); - new File(file.getParent()).mkdirs(); try { FileOutputStream o = new FileOutputStream(file); @@ -1991,7 +1993,7 @@ PyObject closure) { return func.__call__(arg1, arg2, arg3); } - + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject arg2, PyObject arg3, PyObject arg4, PyObject globals, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 04:40:23
|
Revision: 6603 http://jython.svn.sourceforge.net/jython/?rev=6603&view=rev Author: fwierzbicki Date: 2009-07-30 04:40:15 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Oops, created new cast warnings in compiler package, fixed. Also fixed some of the warnings in the antlr package, but things are a little tricky there. Modified Paths: -------------- trunk/jython/src/org/python/antlr/GrammarActions.java trunk/jython/src/org/python/antlr/PythonTokenSource.java trunk/jython/src/org/python/antlr/PythonTree.java trunk/jython/src/org/python/compiler/CodeCompiler.java trunk/jython/src/org/python/compiler/Module.java Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -217,7 +217,7 @@ return new For(t, target, iter, b, o); } - stmt makeTryExcept(Token t, List body, List handlers, List orelse, List finBody) { + stmt makeTryExcept(Token t, List body, List<excepthandler> handlers, List orelse, List finBody) { List<stmt> b = castStmts(body); List<excepthandler> e = handlers; List<stmt> o = castStmts(orelse); @@ -695,7 +695,7 @@ if (isTuple) { List<slice> st; - List etypes = new ArrayList(); + List<expr> etypes = new ArrayList<expr>(); for (Object o : sltypes) { if (o instanceof Index) { Index i = (Index)o; @@ -706,8 +706,7 @@ } } if (!extslice) { - List<expr> es = etypes; - expr t = new Tuple(begin, es, expr_contextType.Load); + expr t = new Tuple(begin, etypes, expr_contextType.Load); s = new Index(begin, t); } } else if (sltypes.size() == 1) { Modified: trunk/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTokenSource.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/antlr/PythonTokenSource.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -83,7 +83,7 @@ int sp=-1; // grow upwards /** The queue of tokens */ - Vector tokens = new Vector(); + Vector<Token> tokens = new Vector<Token>(); /** We pull real tokens from this lexer */ CommonTokenStream stream; @@ -134,7 +134,7 @@ public Token nextToken() { // if something in queue, just remove and return it if (tokens.size() > 0) { - Token t = (Token)tokens.firstElement(); + Token t = tokens.firstElement(); tokens.removeElementAt(0); //System.out.println(filename + t); return t; @@ -264,7 +264,7 @@ } } } - List hiddenTokens = stream.getTokens(lastTokenAddedIndex + 1,t.getTokenIndex() - 1); + List<Token> hiddenTokens = stream.getTokens(lastTokenAddedIndex + 1,t.getTokenIndex() - 1); if (hiddenTokens != null) { tokens.addAll(hiddenTokens); } Modified: trunk/jython/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTree.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/antlr/PythonTree.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -251,19 +251,19 @@ } //XXX: From here down copied from org.antlr.runtime.tree.BaseTree - protected List children; + protected List<PythonTree> children; public PythonTree getChild(int i) { if ( children==null || i>=children.size() ) { return null; } - return (PythonTree)children.get(i); + return children.get(i); } /** Get the children internal List; note that if you directly mess with * the list, do so at your own risk. */ - public List getChildren() { + public List<PythonTree> getChildren() { return children; } @@ -333,7 +333,7 @@ } /** Add all elements of kids list as children of this node */ - public void addChildren(List kids) { + public void addChildren(List<PythonTree> kids) { for (int i = 0; i < kids.size(); i++) { PythonTree t = (PythonTree) kids.get(i); addChild(t); @@ -382,13 +382,13 @@ int replacingHowMany = stopChildIndex - startChildIndex + 1; int replacingWithHowMany; PythonTree newTree = (PythonTree)t; - List newChildren = null; + List<PythonTree> newChildren = null; // normalize to a list of children to add: newChildren if ( newTree.isNil() ) { newChildren = newTree.children; } else { - newChildren = new ArrayList(1); + newChildren = new ArrayList<PythonTree>(1); newChildren.add(newTree); } replacingWithHowMany = newChildren.size(); @@ -432,8 +432,8 @@ } /** Override in a subclass to change the impl of children list */ - protected List createChildrenList() { - return new ArrayList(); + protected List<PythonTree> createChildrenList() { + return new ArrayList<PythonTree>(); } /** Set the parent and child index values for all child of t */ Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -555,7 +555,7 @@ doFinallysDownTo(bcfLevel); - code.goto_((Label)breakLabels.peek()); + code.goto_(breakLabels.peek()); return null; } @@ -568,7 +568,7 @@ doFinallysDownTo(bcfLevel); - code.goto_((Label)continueLabels.peek()); + code.goto_(continueLabels.peek()); return Exit; } @@ -691,7 +691,7 @@ code.astore(locals); for (int i = 0; i < v.size(); i++) { - String type = (String) v.elementAt(i); + String type = v.elementAt(i); if (type == null) continue; code.aload(locals); @@ -717,8 +717,7 @@ Label end = new Label(); code.label(end); for (int i = 0; i < exceptionHandlers.size(); ++i) { - ExceptionHandler handler = - (ExceptionHandler)exceptionHandlers.elementAt(i); + ExceptionHandler handler = exceptionHandlers.elementAt(i); handler.exceptionEnds.addElement(end); } } @@ -728,8 +727,7 @@ Label start = new Label(); code.label(start); for (int i = 0; i < exceptionHandlers.size(); ++i) { - ExceptionHandler handler = - (ExceptionHandler)exceptionHandlers.elementAt(i); + ExceptionHandler handler = exceptionHandlers.elementAt(i); handler.exceptionStarts.addElement(start); } } @@ -742,7 +740,7 @@ code.astore(locals); for (int i = 0; i < v.size(); i++) { - String type = (String) v.elementAt(i); + String type = v.elementAt(i); if (type == null) continue; code.aload(locals); @@ -1063,8 +1061,8 @@ @Override public Object visitWhile(While node) throws Exception { int savebcf = beginLoop(); - Label continue_loop = (Label)continueLabels.peek(); - Label break_loop = (Label)breakLabels.peek(); + Label continue_loop = continueLabels.peek(); + Label break_loop = breakLabels.peek(); Label start_loop = new Label(); @@ -1097,8 +1095,8 @@ @Override public Object visitFor(For node) throws Exception { int savebcf = beginLoop(); - Label continue_loop = (Label)continueLabels.peek(); - Label break_loop = (Label)breakLabels.peek(); + Label continue_loop = continueLabels.peek(); + Label break_loop = breakLabels.peek(); Label start_loop = new Label(); Label next_loop = new Label(); @@ -1280,14 +1278,12 @@ private void doFinallysDownTo(int level) throws Exception { Stack<ExceptionHandler> poppedHandlers = new Stack<ExceptionHandler>(); while (exceptionHandlers.size() > level) { - ExceptionHandler handler = - (ExceptionHandler)exceptionHandlers.pop(); + ExceptionHandler handler = exceptionHandlers.pop(); inlineFinally(handler); poppedHandlers.push(handler); } while (poppedHandlers.size() > 0) { - ExceptionHandler handler = - (ExceptionHandler)poppedHandlers.pop(); + ExceptionHandler handler = poppedHandlers.pop(); reenterProtectedBody(handler); exceptionHandlers.push(handler); } Modified: trunk/jython/src/org/python/compiler/Module.java =================================================================== --- trunk/jython/src/org/python/compiler/Module.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/compiler/Module.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -475,7 +475,7 @@ yields[0] = start; for (int i = 1; i < yields.length; i++) { - yields[i] = (Label) compiler.yields.get(i-1); + yields[i] = compiler.yields.get(i-1); } c.tableswitch(0, yields.length - 1, start, yields); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 12:09:22
|
Revision: 6604 http://jython.svn.sourceforge.net/jython/?rev=6604&view=rev Author: fwierzbicki Date: 2009-07-30 12:09:14 +0000 (Thu, 30 Jul 2009) Log Message: ----------- More compiler warning fixes. Modified Paths: -------------- trunk/jython/src/org/python/antlr/PythonTree.java trunk/jython/src/org/python/compiler/Module.java trunk/jython/src/org/python/compiler/ScopesCompiler.java trunk/jython/src/org/python/core/PyList.java Modified: trunk/jython/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTree.java 2009-07-30 04:40:15 UTC (rev 6603) +++ trunk/jython/src/org/python/antlr/PythonTree.java 2009-07-30 12:09:14 UTC (rev 6604) @@ -202,7 +202,7 @@ buf.append(' '); } for (int i = 0; children != null && i < children.size(); i++) { - PythonTree t = (PythonTree)children.get(i); + PythonTree t = children.get(i); if (i > 0) { buf.append(' '); } @@ -269,7 +269,7 @@ public PythonTree getFirstChildWithType(int type) { for (int i = 0; children!=null && i < children.size(); i++) { - PythonTree t = (PythonTree) children.get(i); + PythonTree t = children.get(i); if ( t.getAntlrType()==type ) { return t; } @@ -306,7 +306,7 @@ if ( this.children!=null ) { // must copy, this has children already int n = childTree.children.size(); for (int i = 0; i < n; i++) { - PythonTree c = (PythonTree)childTree.children.get(i); + PythonTree c = childTree.children.get(i); this.children.add(c); // handle double-link stuff for each child of nil root c.setParent(this); @@ -335,7 +335,7 @@ /** Add all elements of kids list as children of this node */ public void addChildren(List<PythonTree> kids) { for (int i = 0; i < kids.size(); i++) { - PythonTree t = (PythonTree) kids.get(i); + PythonTree t = kids.get(i); addChild(t); } } @@ -359,7 +359,7 @@ if ( children==null ) { return null; } - PythonTree killed = (PythonTree)children.remove(i); + PythonTree killed = children.remove(i); // walk rest and decrement their child indexes this.freshenParentAndChildIndexes(i); return killed; @@ -398,7 +398,7 @@ if ( delta == 0 ) { int j = 0; // index into new children for (int i=startChildIndex; i<=stopChildIndex; i++) { - PythonTree child = (PythonTree)newChildren.get(j); + PythonTree child = newChildren.get(j); children.set(i, child); child.setParent(this); child.setChildIndex(i); @@ -413,7 +413,7 @@ int indexToDelete = startChildIndex+numNewChildren; for (int c=indexToDelete; c<=stopChildIndex; c++) { // delete same index, shifting everybody down each time - PythonTree killed = (PythonTree)children.remove(indexToDelete); + PythonTree killed = children.remove(indexToDelete); } freshenParentAndChildIndexes(startChildIndex); } Modified: trunk/jython/src/org/python/compiler/Module.java =================================================================== --- trunk/jython/src/org/python/compiler/Module.java 2009-07-30 04:40:15 UTC (rev 6603) +++ trunk/jython/src/org/python/compiler/Module.java 2009-07-30 12:09:14 UTC (rev 6604) @@ -332,7 +332,7 @@ Hashtable<Constant,Constant> constants; private Constant findConstant(Constant c) { - Constant ret = (Constant)constants.get(c); + Constant ret = constants.get(c); if (ret != null) return ret; ret = c; @@ -620,7 +620,7 @@ public String getFilename() { return sfilename; } public ScopeInfo getScopeInfo(PythonTree node) { - return (ScopeInfo) scopes.get(node); + return scopes.get(node); } public void error(String msg,boolean err,PythonTree node) Modified: trunk/jython/src/org/python/compiler/ScopesCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/ScopesCompiler.java 2009-07-30 04:40:15 UTC (rev 6603) +++ trunk/jython/src/org/python/compiler/ScopesCompiler.java 2009-07-30 12:09:14 UTC (rev 6604) @@ -66,7 +66,7 @@ level--; ScopeInfo up = null; if (!scopes.empty()) { - up = (ScopeInfo) scopes.pop(); + up = scopes.pop(); } //Go into the stack to find a non class containing scope to use making the closure //See PEP 227 @@ -74,7 +74,7 @@ ScopeInfo referenceable = up; for (int i = scopes.size() - 1; i >= 0 && referenceable.kind == CLASSSCOPE; i--, dist++) { - referenceable = ((ScopeInfo) scopes.get(i)); + referenceable = (scopes.get(i)); } cur.cook(referenceable, dist, code_compiler); cur.dump(); // debug Modified: trunk/jython/src/org/python/core/PyList.java =================================================================== --- trunk/jython/src/org/python/core/PyList.java 2009-07-30 04:40:15 UTC (rev 6603) +++ trunk/jython/src/org/python/core/PyList.java 2009-07-30 12:09:14 UTC (rev 6604) @@ -287,7 +287,7 @@ if (list instanceof ArrayList) { ((ArrayList) list).ensureCapacity(newSize); } - List oldList = new ArrayList<PyObject>(list); + List<PyObject> oldList = new ArrayList<PyObject>(list); for (int i = 1; i < count; i++) { list.addAll(oldList); } @@ -1152,7 +1152,7 @@ stop = start; } int n = sliceLength(start, stop, step); - List newList; + List<PyObject> newList; if (step == 1) { newList = new ArrayList<PyObject>(list.subList(start, stop)); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-31 14:41:29
|
Revision: 6613 http://jython.svn.sourceforge.net/jython/?rev=6613&view=rev Author: fwierzbicki Date: 2009-07-31 14:41:13 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Added Override annotations. Modified Paths: -------------- trunk/jython/src/org/python/antlr/BaseParser.java trunk/jython/src/org/python/antlr/ParseException.java trunk/jython/src/org/python/antlr/PythonErrorNode.java trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java trunk/jython/src/org/python/compiler/CodeCompiler.java Modified: trunk/jython/src/org/python/antlr/BaseParser.java =================================================================== --- trunk/jython/src/org/python/antlr/BaseParser.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/antlr/BaseParser.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -42,6 +42,7 @@ } + @Override public Token nextToken() { startPos = getCharPositionInLine(); return super.nextToken(); @@ -53,6 +54,7 @@ super(lexer); } + @Override public Token nextToken() { startPos = getCharPositionInLine(); return super.nextToken(); Modified: trunk/jython/src/org/python/antlr/ParseException.java =================================================================== --- trunk/jython/src/org/python/antlr/ParseException.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/antlr/ParseException.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -1,6 +1,5 @@ package org.python.antlr; -import org.python.antlr.PythonTree; import org.python.core.Py; import org.python.core.PyObject; Modified: trunk/jython/src/org/python/antlr/PythonErrorNode.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonErrorNode.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/antlr/PythonErrorNode.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -20,18 +20,22 @@ this.errorNode = errorNode; } + @Override public boolean isNil() { return errorNode.isNil(); } + @Override public int getAntlrType() { return errorNode.getType(); } + @Override public String getText() { return errorNode.getText(); } + @Override public String toString() { return errorNode.toString(); } Modified: trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -8,6 +8,7 @@ public class PythonTreeAdaptor extends CommonTreeAdaptor { + @Override public void setTokenBoundaries(Object t, Token startToken, Token stopToken) { if (t==null) { return; @@ -33,10 +34,12 @@ pt.setCharStopIndex(stopChar); } + @Override public Object create(Token token) { return new PythonTree(token); } + @Override public Object errorNode(TokenStream input, Token start, Token stop, RecognitionException e) { @@ -45,6 +48,7 @@ return t; } + @Override public Object dupNode(Object t) { if (t == null) { return null; @@ -52,16 +56,19 @@ return create(((PythonTree) t).getToken()); } + @Override public boolean isNil(Object tree) { return ((PythonTree)tree).isNil(); } + @Override public void addChild(Object t, Object child) { if ( t!=null && child!=null ) { ((PythonTree)t).addChild((PythonTree)child); } } + @Override public Object becomeRoot(Object newRoot, Object oldRoot) { //System.out.println("becomeroot new "+newRoot.toString()+" old "+oldRoot); PythonTree newRootTree = (PythonTree)newRoot; @@ -85,6 +92,7 @@ return newRootTree; } + @Override public Object rulePostProcessing(Object root) { //System.out.println("rulePostProcessing: "+((PythonTree)root).toStringTree()); PythonTree r = (PythonTree)root; @@ -102,6 +110,7 @@ return r; } + @Override public Object create(int tokenType, Token fromToken) { fromToken = createToken(fromToken); //((ClassicToken)fromToken).setType(tokenType); @@ -110,6 +119,7 @@ return t; } + @Override public Object create(int tokenType, Token fromToken, String text) { fromToken = createToken(fromToken); fromToken.setType(tokenType); @@ -118,33 +128,40 @@ return t; } + @Override public Object create(int tokenType, String text) { Token fromToken = createToken(tokenType, text); PythonTree t = (PythonTree)create(fromToken); return t; } + @Override public int getType(Object t) { ((PythonTree)t).getType(); return 0; } + @Override public String getText(Object t) { return ((PythonTree)t).getText(); } + @Override public Object getChild(Object t, int i) { return ((PythonTree)t).getChild(i); } + @Override public void setChild(Object t, int i, Object child) { ((PythonTree)t).setChild(i, (PythonTree)child); } + @Override public Object deleteChild(Object t, int i) { return ((PythonTree)t).deleteChild(i); } + @Override public int getChildCount(Object t) { return ((PythonTree)t).getChildCount(); } Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -89,8 +89,7 @@ import org.objectweb.asm.commons.Method; -public class CodeCompiler extends Visitor implements Opcodes, ClassConstants //, PythonGrammarTreeConstants -{ +public class CodeCompiler extends Visitor implements Opcodes, ClassConstants { public static final Object Exit=new Integer(1); public static final Object NoExit=null; @@ -127,13 +126,13 @@ public Stack<ExceptionHandler> exceptionHandlers; public Vector<Label> yields = new Vector<Label>(); - /* break/continue finally's level. - * This is the lowest level in the exceptionHandlers which should - * be executed at break or continue. - * It is saved/updated/restored when compiling loops. - * A similar level for returns is not needed because a new CodeCompiler - * is used for each PyCode, ie. each 'function'. - * When returning through finally's all the exceptionHandlers are executed. + /* + * break/continue finally's level. This is the lowest level in the + * exceptionHandlers which should be executed at break or continue. It is + * saved/updated/restored when compiling loops. A similar level for + * returns is not needed because a new CodeCompiler is used for each + * PyCode, in other words: each 'function'. When returning through + * finally's all the exceptionHandlers are executed. */ public int bcfLevel = 0; @@ -202,13 +201,11 @@ code.freeLocal(tmp); } - public void set(PythonTree node, int tmp) throws Exception { temporary = tmp; visit(node); } - private void saveAugTmps(PythonTree node, int count) throws Exception { if (count >= 4) { augtmp4 = code.getLocal("Lorg/python/core/PyObject;"); @@ -234,7 +231,6 @@ code.aload(augtmp4); } - private void restoreAugTmps(PythonTree node, int count) throws Exception { code.aload(augtmp1); code.freeLocal(augtmp1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-08-11 06:45:10
|
Revision: 6662 http://jython.svn.sourceforge.net/jython/?rev=6662&view=rev Author: cgroves Date: 2009-08-11 06:45:00 +0000 (Tue, 11 Aug 2009) Log Message: ----------- Documentation and formatting cleanup Modified Paths: -------------- trunk/jython/src/org/python/core/PyOverridableNew.java trunk/jython/src/org/python/expose/ExposedNew.java trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java trunk/jython/src/org/python/expose/generate/NewExposer.java Modified: trunk/jython/src/org/python/core/PyOverridableNew.java =================================================================== --- trunk/jython/src/org/python/core/PyOverridableNew.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/core/PyOverridableNew.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -1,32 +1,30 @@ package org.python.core; - /** - * A __new__ function that tells its subclasses to just init if __new__ is being - * called on the type the function was defined on. Otherwise, it just leaves - * initting up to the subtype otherwise. + * A __new__ function that tells its subclasses to just init if __new__ is being called on the type + * the function was defined on. Otherwise, it just leaves initting up to the subtype otherwise. */ public abstract class PyOverridableNew extends PyNewWrapper { @Override public PyObject new_impl(boolean init, PyType subtype, PyObject[] args, String[] keywords) { - if (for_type==subtype) { + if (for_type == subtype) { return createOfType(init, args, keywords); } else { return createOfSubtype(subtype); } } - + /** * Called when new is invoked on the type the new was defined on. - * + * * @param init - if the new object should be initted. * @param args - args passed to call * @param keywords - keywords passed to call * @return - the new object. */ public abstract PyObject createOfType(boolean init, PyObject[] args, String[] keywords); - + /** Called when new is invoked on a subtype of for_type. */ public abstract PyObject createOfSubtype(PyType subtype); } Modified: trunk/jython/src/org/python/expose/ExposedNew.java =================================================================== --- trunk/jython/src/org/python/expose/ExposedNew.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/expose/ExposedNew.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -8,23 +8,22 @@ import org.python.core.PyInteger; /** + * <p> * Can appear on two forms of methods to indicate a method should be part of the __new__ object * creation. Can only appear once per exposed type. - * + *<p> * In the first form, the method must be static and take the arguments * <code>PyNewWrapper new_, boolean init, PyType - subtype, PyObject[] args, String[] keywords</code>. - * In this case, the method has full responsibility for creating and initting the object and will be - * invoked for every subtype of this exposed type. Essentially its for object instantation that must - * be called for every instance of that object. See {@link PyInteger#int_new} for an example of this - * type of ExposedNew. - * + subtype, PyObject[] args, String[] keywords</code>. In this case, the method has full + * responsibility for creating and initting the object and will be invoked for every subtype of this + * exposed type. Essentially it's for object instantiation that must be called for every instance of + * that object. See {@link PyInteger#int_new} for an example of this type of ExposedNew. + *<p> * In the second form, the method must be an instance method that takes the standard Jython call * arguments, <code>PyObject[] args, String[] keywords</code>. In this case, the basic new * functionality is handled by PyOverridableNew and the method with ExposedNew is called as __init__ * as part of that process. This allows subtypes to completely redefine new and create objects * however they like. - * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) Modified: trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -170,13 +170,13 @@ methodExposers, descExposers.values(), newExposer); - for(MethodExposer exposer : methodExposers) { + for (MethodExposer exposer : methodExposers) { addInnerClass(exposer.getGeneratedType()); } - for(DescriptorExposer exposer : descExposers.values()) { + for (DescriptorExposer exposer : descExposers.values()) { addInnerClass(exposer.getGeneratedType()); } - if(newExposer != null) { + if (newExposer != null) { addInnerClass(newExposer.getGeneratedType()); } addInnerClass(typeExposer.getGeneratedType()); Modified: trunk/jython/src/org/python/expose/generate/NewExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/NewExposer.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/expose/generate/NewExposer.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -1,12 +1,8 @@ package org.python.expose.generate; -import java.lang.reflect.Method; - import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.python.core.PyNewWrapper; -import org.python.core.PyObject; -import org.python.core.PyType; public class NewExposer extends Exposer { @@ -18,13 +14,13 @@ super(PyNewWrapper.class, onType.getClassName() + "$exposed___new__"); this.onType = onType; this.name = methodName; - if((access & Opcodes.ACC_STATIC) == 0) { + if ((access & Opcodes.ACC_STATIC) == 0) { throwInvalid("Full methods for @ExposedNew must be static"); } - if(!Type.getReturnType(desc).equals(PYOBJ)) { + if (!Type.getReturnType(desc).equals(PYOBJ)) { throwInvalid("@ExposedNew methods must return PyObject"); } - if(exceptions != null && exceptions.length > 0) { + if (exceptions != null && exceptions.length > 0) { throwInvalid("@ExposedNew methods may not throw checked exceptions"); } } @@ -59,9 +55,5 @@ } public static final String NEW_DESCRIPTOR = Type.getMethodDescriptor(PYOBJ, - new Type[] {PYNEWWRAPPER, - BOOLEAN, - PYTYPE, - APYOBJ, - ASTRING}); + new Type[] {PYNEWWRAPPER, BOOLEAN, PYTYPE, APYOBJ, ASTRING}); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-09-09 03:47:32
|
Revision: 6770 http://jython.svn.sourceforge.net/jython/?rev=6770&view=rev Author: pjenvey Date: 2009-09-09 03:47:22 +0000 (Wed, 09 Sep 2009) Log Message: ----------- regen per r6769 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 Modified: trunk/jython/src/org/python/antlr/ast/AssertDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/AssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/AttributeDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/BinOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/BreakDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/CallDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/CompareDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ContinueDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/DeleteDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/DictDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ExecDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ExprDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ForDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/GlobalDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/IfDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/IfExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ImportDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ImportDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/IndexDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IndexDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/IndexDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/LambdaDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/LambdaDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/LambdaDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ListCompDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ListCompDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ListCompDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ListDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ListDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ListDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ModuleDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ModuleDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ModuleDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/NameDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/NameDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/NameDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/NumDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/NumDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/NumDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/PassDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/PassDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/PassDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/PrintDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/PrintDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/PrintDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/RaiseDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/RaiseDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/RaiseDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ReprDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ReprDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ReprDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/ReturnDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ReturnDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/ReturnDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/SliceDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/SliceDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/SliceDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/StrDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/StrDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/StrDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/SuiteDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/SuiteDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/SuiteDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/TupleDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TupleDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/TupleDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/UnaryOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/UnaryOpDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/UnaryOpDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/WhileDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/WhileDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/WhileDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/WithDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/WithDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/WithDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/YieldDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/YieldDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/YieldDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/aliasDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/aliasDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/aliasDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/argumentsDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/argumentsDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/argumentsDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/comprehensionDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/comprehensionDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/comprehensionDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/ast/keywordDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/keywordDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/ast/keywordDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/AddDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/AddDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/AddDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/AndDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/AndDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/AndDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/AugLoadDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/AugLoadDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/AugLoadDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/AugStoreDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/AugStoreDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/AugStoreDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/BitAndDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/BitAndDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/BitAndDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/BitOrDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/BitOrDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/BitOrDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/BitXorDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/BitXorDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/BitXorDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/DelDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/DelDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/DelDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/DivDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/DivDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/DivDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/EqDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/EqDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/EqDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/FloorDivDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/FloorDivDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/FloorDivDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/GtDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/GtDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/GtDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/GtEDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/GtEDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/GtEDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/InDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/InDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/InDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/InvertDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/InvertDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/InvertDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/IsDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/IsDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/IsDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/IsNotDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/IsNotDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/IsNotDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/LShiftDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/LShiftDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/LShiftDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/LoadDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/LoadDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/LoadDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/LtDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/LtDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/LtDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + 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 Modified: trunk/jython/src/org/python/antlr/op/LtEDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/LtEDerived.java 2009-09-09 03:45:43 UTC (rev 6769) +++ trunk/jython/src/org/python/antlr/op/LtEDerived.java 2009-09-09 03:47:22 UTC (rev 6770) @@ -768,7 +768,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[]where_type=new PyType[1]; + PyObject[]where_type=new PyObject[1]; PyObject impl=self_type.lookup_where("__cmp__",where_type); // Full Compatibility with CPython __cmp__: // If ... [truncated message content] |
From: <pj...@us...> - 2009-10-02 03:45:45
|
Revision: 6823 http://jython.svn.sourceforge.net/jython/?rev=6823&view=rev Author: pjenvey Date: 2009-10-02 03:45:27 +0000 (Fri, 02 Oct 2009) Log Message: ----------- pass the cached type through constructors Modified Paths: -------------- trunk/jython/src/org/python/antlr/PythonTree.java trunk/jython/src/org/python/core/PyDictionary.java trunk/jython/src/org/python/core/PyFunction.java trunk/jython/src/org/python/core/PyGenerator.java trunk/jython/src/org/python/core/PyMethod.java trunk/jython/src/org/python/core/PyStaticMethod.java trunk/jython/src/org/python/core/PyTraceback.java Modified: trunk/jython/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTree.java 2009-10-02 01:46:27 UTC (rev 6822) +++ trunk/jython/src/org/python/antlr/PythonTree.java 2009-10-02 03:45:27 UTC (rev 6823) @@ -25,6 +25,7 @@ } public PythonTree(PyType subType) { + super(subType); node = new CommonTree(); } Modified: trunk/jython/src/org/python/core/PyDictionary.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionary.java 2009-10-02 01:46:27 UTC (rev 6822) +++ trunk/jython/src/org/python/core/PyDictionary.java 2009-10-02 03:45:27 UTC (rev 6823) @@ -33,6 +33,7 @@ * Create an empty dictionary. */ public PyDictionary() { + super(TYPE); table = Generic.concurrentMap(); } @@ -48,6 +49,7 @@ * Create a new dictionary which is based on given map. */ public PyDictionary(Map<PyObject, PyObject> t) { + super(TYPE); table = Generic.concurrentMap(); table.putAll(t); } Modified: trunk/jython/src/org/python/core/PyFunction.java =================================================================== --- trunk/jython/src/org/python/core/PyFunction.java 2009-10-02 01:46:27 UTC (rev 6822) +++ trunk/jython/src/org/python/core/PyFunction.java 2009-10-02 03:45:27 UTC (rev 6823) @@ -57,6 +57,7 @@ public PyFunction(PyObject globals, PyObject[] defaults, PyCode code, PyObject doc, PyObject[] closure_cells) { + super(TYPE); func_globals = globals; __name__ = code.co_name; __doc__ = doc != null ? doc : Py.None; Modified: trunk/jython/src/org/python/core/PyGenerator.java =================================================================== --- trunk/jython/src/org/python/core/PyGenerator.java 2009-10-02 01:46:27 UTC (rev 6822) +++ trunk/jython/src/org/python/core/PyGenerator.java 2009-10-02 03:45:27 UTC (rev 6823) @@ -7,6 +7,8 @@ @ExposedType(name = "generator", base = PyObject.class, isBaseType = false) public class PyGenerator extends PyIterator { + public static final PyType TYPE = PyType.fromClass(PyGenerator.class); + @ExposedGet protected PyFrame gi_frame; @@ -18,6 +20,7 @@ private PyObject closure; public PyGenerator(PyFrame frame, PyObject closure) { + super(TYPE); gi_frame = frame; this.closure = closure; Modified: trunk/jython/src/org/python/core/PyMethod.java =================================================================== --- trunk/jython/src/org/python/core/PyMethod.java 2009-10-02 01:46:27 UTC (rev 6822) +++ trunk/jython/src/org/python/core/PyMethod.java 2009-10-02 03:45:27 UTC (rev 6823) @@ -28,6 +28,7 @@ public PyObject im_self; public PyMethod(PyObject function, PyObject self, PyObject type) { + super(TYPE); if (self == Py.None){ self = null; } Modified: trunk/jython/src/org/python/core/PyStaticMethod.java =================================================================== --- trunk/jython/src/org/python/core/PyStaticMethod.java 2009-10-02 01:46:27 UTC (rev 6822) +++ trunk/jython/src/org/python/core/PyStaticMethod.java 2009-10-02 03:45:27 UTC (rev 6823) @@ -15,6 +15,7 @@ protected PyObject callable; public PyStaticMethod(PyObject callable) { + super(TYPE); this.callable = callable; } Modified: trunk/jython/src/org/python/core/PyTraceback.java =================================================================== --- trunk/jython/src/org/python/core/PyTraceback.java 2009-10-02 01:46:27 UTC (rev 6822) +++ trunk/jython/src/org/python/core/PyTraceback.java 2009-10-02 03:45:27 UTC (rev 6823) @@ -23,6 +23,7 @@ public int tb_lineno; public PyTraceback(PyTraceback next, PyFrame frame) { + super(TYPE); tb_next = next; tb_frame = frame; tb_lineno = frame.getline(); 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:51:08
|
Revision: 6845 http://jython.svn.sourceforge.net/jython/?rev=6845&view=rev Author: pjenvey Date: 2009-10-07 02:50:46 +0000 (Wed, 07 Oct 2009) Log Message: ----------- regen per r6844 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 Modified: trunk/jython/src/org/python/antlr/ast/AssertDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/AssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/AttributeDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/BinOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/BreakDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/CallDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/CompareDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/ContinueDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/DeleteDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/DictDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/ExecDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/ExprDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/ForDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/GlobalDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/IfDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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) { Modified: trunk/jython/src/org/python/antlr/ast/IfExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-10-07 02:48:36 UTC (rev 6844) +++ trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-10-07 02:50:46 UTC (rev 6845) @@ -981,43 +981,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 ... [truncated message content] |
From: <pj...@us...> - 2009-10-10 06:05:43
|
Revision: 6852 http://jython.svn.sourceforge.net/jython/?rev=6852&view=rev Author: pjenvey Date: 2009-10-10 06:05:26 +0000 (Sat, 10 Oct 2009) Log Message: ----------- add a flag to sys as a faster SystemRestart check for the code objects. otherwise currentThread().isInterrupted() is now a noticable performance hit Modified Paths: -------------- trunk/jython/src/org/python/core/PyBaseCode.java trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/org/python/core/PyTableCode.java trunk/jython/src/org/python/util/jython.java Modified: trunk/jython/src/org/python/core/PyBaseCode.java =================================================================== --- trunk/jython/src/org/python/core/PyBaseCode.java 2009-10-10 05:44:16 UTC (rev 6851) +++ trunk/jython/src/org/python/core/PyBaseCode.java 2009-10-10 06:05:26 UTC (rev 6852) @@ -98,7 +98,7 @@ // Check for interruption, which is used for restarting the interpreter // on Jython - if (Thread.currentThread().isInterrupted()) { + if (ts.systemState._systemRestart && Thread.currentThread().isInterrupted()) { throw new PyException(_systemrestart.SystemRestart); } return ret; Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-10-10 05:44:16 UTC (rev 6851) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-10-10 06:05:26 UTC (rev 6852) @@ -144,6 +144,9 @@ private int recursionlimit = 1000; + /** true when a SystemRestart is triggered. */ + public boolean _systemRestart = false; + public PySystemState() { initialize(); modules = new PyStringMap(); Modified: trunk/jython/src/org/python/core/PyTableCode.java =================================================================== --- trunk/jython/src/org/python/core/PyTableCode.java 2009-10-10 05:44:16 UTC (rev 6851) +++ trunk/jython/src/org/python/core/PyTableCode.java 2009-10-10 06:05:26 UTC (rev 6852) @@ -198,7 +198,7 @@ // Check for interruption, which is used for restarting the interpreter // on Jython - if (Thread.currentThread().isInterrupted()) { + if (ts.systemState._systemRestart && Thread.currentThread().isInterrupted()) { throw new PyException(_systemrestart.SystemRestart); } return ret; Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2009-10-10 05:44:16 UTC (rev 6851) +++ trunk/jython/src/org/python/util/jython.java 2009-10-10 06:05:26 UTC (rev 6852) @@ -355,8 +355,9 @@ * Run any finalizations on the current interpreter in preparation for a SytemRestart. */ public static void shutdownInterpreter() { - // Stop all the active threads + // Stop all the active threads and signal the SystemRestart thread.interruptAllThreads(); + Py.getSystemState()._systemRestart = true; // Close all sockets -- not all of their operations are stopped by // Thread.interrupt (in particular pre-nio sockets) try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-10-14 06:37:57
|
Revision: 6857 http://jython.svn.sourceforge.net/jython/?rev=6857&view=rev Author: pjenvey Date: 2009-10-14 06:37:50 +0000 (Wed, 14 Oct 2009) Log Message: ----------- add classmethod docs Modified Paths: -------------- trunk/jython/src/org/python/core/PyClassMethodDescr.java trunk/jython/src/org/python/core/PyDictionary.java trunk/jython/src/org/python/core/PyFloat.java trunk/jython/src/org/python/expose/ExposedClassMethod.java Modified: trunk/jython/src/org/python/core/PyClassMethodDescr.java =================================================================== --- trunk/jython/src/org/python/core/PyClassMethodDescr.java 2009-10-14 06:02:01 UTC (rev 6856) +++ trunk/jython/src/org/python/core/PyClassMethodDescr.java 2009-10-14 06:37:50 UTC (rev 6857) @@ -1,5 +1,7 @@ +/* Copyright (c) Jython Developers */ package org.python.core; +import org.python.expose.ExposedGet; import org.python.expose.ExposedMethod; import org.python.expose.ExposedType; @@ -8,10 +10,11 @@ public static final PyType TYPE = PyType.fromClass(PyClassMethodDescr.class); - PyClassMethodDescr(PyType t, PyBuiltinCallable meth) { - super(t, meth); + PyClassMethodDescr(PyType type, PyBuiltinCallable meth) { + super(type, meth); } + @Override public PyObject __get__(PyObject obj, PyObject type) { return classmethod_descriptor___get__(obj, type); } @@ -33,4 +36,10 @@ checkGetterType((PyType)type); return meth.bind(type); } + + @Override + @ExposedGet(name = "__doc__") + public String getDoc() { + return super.getDoc(); + } } Modified: trunk/jython/src/org/python/core/PyDictionary.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionary.java 2009-10-14 06:02:01 UTC (rev 6856) +++ trunk/jython/src/org/python/core/PyDictionary.java 2009-10-14 06:37:50 UTC (rev 6857) @@ -92,7 +92,7 @@ return dict_fromkeys(TYPE, keys, value); } - @ExposedClassMethod(defaults = "Py.None") + @ExposedClassMethod(defaults = "Py.None", doc = BuiltinDocs.dict_fromkeys_doc) final static PyObject dict_fromkeys(PyType type, PyObject keys, PyObject value) { PyObject d = type.__call__(); for (PyObject o : keys.asIterable()) { Modified: trunk/jython/src/org/python/core/PyFloat.java =================================================================== --- trunk/jython/src/org/python/core/PyFloat.java 2009-10-14 06:02:01 UTC (rev 6856) +++ trunk/jython/src/org/python/core/PyFloat.java 2009-10-14 06:37:50 UTC (rev 6857) @@ -647,7 +647,7 @@ public static volatile Format double_format = Format.BE; public static volatile Format float_format = Format.BE; - @ExposedClassMethod + @ExposedClassMethod(doc = BuiltinDocs.float___getformat___doc) public static String float___getformat__(PyType type, String typestr) { if ("double".equals(typestr)) { return double_format.format(); @@ -658,7 +658,7 @@ } } - @ExposedClassMethod + @ExposedClassMethod(doc = BuiltinDocs.float___setformat___doc) public static void float___setformat__(PyType type, String typestr, String format) { Format new_format = null; if (!"double".equals(typestr) && !"float".equals(typestr)) { Modified: trunk/jython/src/org/python/expose/ExposedClassMethod.java =================================================================== --- trunk/jython/src/org/python/expose/ExposedClassMethod.java 2009-10-14 06:02:01 UTC (rev 6856) +++ trunk/jython/src/org/python/expose/ExposedClassMethod.java 2009-10-14 06:37:50 UTC (rev 6857) @@ -22,4 +22,9 @@ * @return default arguments. Starts at the number of arguments - defaults.length. */ String[] defaults() default {}; + + /** + * Returns the __doc__ String for this method. + */ + String doc() default ""; } 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:38:53
|
Revision: 6904 http://jython.svn.sourceforge.net/jython/?rev=6904&view=rev Author: pjenvey Date: 2009-10-26 06:38:28 +0000 (Mon, 26 Oct 2009) Log Message: ----------- regen per r6903 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 Modified: trunk/jython/src/org/python/antlr/ast/AssertDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/AssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/AttributeDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/BinOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/BreakDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/CallDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/CompareDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ContinueDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/DeleteDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/DictDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ExecDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ExprDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ForDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/GlobalDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/IfDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/IfExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ImportDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ImportDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/IndexDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IndexDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/IndexDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/LambdaDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/LambdaDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/LambdaDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ListCompDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ListCompDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ListCompDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ListDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ListDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ListDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ModuleDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ModuleDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ModuleDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/NameDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/NameDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/NameDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/NumDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/NumDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/NumDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/PassDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/PassDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/PassDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/PrintDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/PrintDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/PrintDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/RaiseDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/RaiseDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/RaiseDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ReprDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ReprDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ReprDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/ReturnDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ReturnDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/ReturnDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/SliceDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/SliceDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/SliceDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/StrDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/StrDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/StrDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/SuiteDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/SuiteDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/SuiteDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java 2009-10-26 06:36:47 UTC (rev 6903) +++ trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java 2009-10-26 06:38:28 UTC (rev 6904) @@ -1054,18 +1054,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__() { Modified: trunk/jython/src/org/python/antlr/ast/TupleDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TupleDerived.java 2009-10-26 06:36:47 UTC (r... [truncated message content] |
From: <pj...@us...> - 2010-03-15 01:37:37
|
Revision: 6986 http://jython.svn.sourceforge.net/jython/?rev=6986&view=rev Author: pjenvey Date: 2010-03-15 01:37:30 +0000 (Mon, 15 Mar 2010) Log Message: ----------- coding standards, rename minLong -> MIN_LONG Modified Paths: -------------- trunk/jython/src/org/python/core/PyInteger.java trunk/jython/src/org/python/core/PyLong.java trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/modules/struct.java Modified: trunk/jython/src/org/python/core/PyInteger.java =================================================================== --- trunk/jython/src/org/python/core/PyInteger.java 2010-03-14 21:39:57 UTC (rev 6985) +++ trunk/jython/src/org/python/core/PyInteger.java 2010-03-15 01:37:30 UTC (rev 6986) @@ -21,11 +21,18 @@ public static final PyType TYPE = PyType.fromClass(PyInteger.class); /** The minimum value of an int represented by a BigInteger */ - public static final BigInteger minInt = BigInteger.valueOf(Integer.MIN_VALUE); + public static final BigInteger MIN_INT = BigInteger.valueOf(Integer.MIN_VALUE); /** The maximum value of an int represented by a BigInteger */ - public static final BigInteger maxInt = BigInteger.valueOf(Integer.MAX_VALUE); + public static final BigInteger MAX_INT = BigInteger.valueOf(Integer.MAX_VALUE); + /** @deprecated Use MIN_INT instead. */ + @Deprecated + public static final BigInteger minInt = MIN_INT; + /** @deprecated Use MAX_INT instead. */ + @Deprecated + public static final BigInteger maxInt = MAX_INT; + private int value; public PyInteger(PyType subType, int v) { Modified: trunk/jython/src/org/python/core/PyLong.java =================================================================== --- trunk/jython/src/org/python/core/PyLong.java 2010-03-14 21:39:57 UTC (rev 6985) +++ trunk/jython/src/org/python/core/PyLong.java 2010-03-15 01:37:30 UTC (rev 6986) @@ -21,11 +21,21 @@ public static final PyType TYPE = PyType.fromClass(PyLong.class); - public static final BigInteger minLong = BigInteger.valueOf(Long.MIN_VALUE); - public static final BigInteger maxLong = BigInteger.valueOf(Long.MAX_VALUE); - public static final BigInteger maxULong = + public static final BigInteger MIN_LONG = BigInteger.valueOf(Long.MIN_VALUE); + public static final BigInteger MAX_LONG = BigInteger.valueOf(Long.MAX_VALUE); + public static final BigInteger MAX_ULONG = BigInteger.valueOf(1).shiftLeft(64).subtract(BigInteger.valueOf(1)); + /** @deprecated Use MIN_INT instead. */ + @Deprecated + public static final BigInteger minLong = MIN_LONG; + /** @deprecated Use MAX_INT instead. */ + @Deprecated + public static final BigInteger maxLong = MAX_LONG; + /** @deprecated Use MAX_ULONG instead. */ + @Deprecated + public static final BigInteger maxULong = MAX_ULONG; + private BigInteger value; public PyLong(PyType subType, BigInteger v) { @@ -194,7 +204,7 @@ } public long getLong(long min, long max, String overflowMsg) { - if (value.compareTo(maxLong) <= 0 && value.compareTo(minLong) >= 0) { + if (value.compareTo(MAX_LONG) <= 0 && value.compareTo(MIN_LONG) >= 0) { long v = value.longValue(); if (v >= min && v <= max) { return v; @@ -853,7 +863,7 @@ @ExposedMethod(doc = BuiltinDocs.long___int___doc) final PyObject long___int__() { - if (value.compareTo(PyInteger.maxInt) <= 0 && value.compareTo(PyInteger.minInt) >= 0) { + if (value.compareTo(PyInteger.MAX_INT) <= 0 && value.compareTo(PyInteger.MIN_INT) >= 0) { return Py.newInteger(value.intValue()); } return long___long__(); @@ -960,8 +970,8 @@ @Override public int asIndex(PyObject err) { - boolean tooLow = value.compareTo(PyInteger.minInt) < 0; - boolean tooHigh = value.compareTo(PyInteger.maxInt) > 0; + boolean tooLow = value.compareTo(PyInteger.MIN_INT) < 0; + boolean tooHigh = value.compareTo(PyInteger.MAX_INT) > 0; if (tooLow || tooHigh) { if (err != null) { throw new PyException(err, "cannot fit 'long' into an index-sized integer"); Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2010-03-14 21:39:57 UTC (rev 6985) +++ trunk/jython/src/org/python/core/PyString.java 2010-03-15 01:37:30 UTC (rev 6986) @@ -1570,7 +1570,7 @@ bi = new BigInteger("-" + s, base); } else bi = new BigInteger(s, base); - if (bi.compareTo(PyInteger.maxInt) > 0 || bi.compareTo(PyInteger.minInt) < 0) { + if (bi.compareTo(PyInteger.MAX_INT) > 0 || bi.compareTo(PyInteger.MIN_INT) < 0) { throw Py.OverflowError("long int too large to convert to int"); } return bi.intValue(); Modified: trunk/jython/src/org/python/modules/struct.java =================================================================== --- trunk/jython/src/org/python/modules/struct.java 2010-03-14 21:39:57 UTC (rev 6985) +++ trunk/jython/src/org/python/modules/struct.java 2010-03-15 01:37:30 UTC (rev 6986) @@ -342,7 +342,7 @@ BigInteger get_ulong(PyObject value) { if (value instanceof PyLong){ BigInteger v = (BigInteger)value.__tojava__(BigInteger.class); - if (v.compareTo(PyLong.maxULong) > 0){ + if (v.compareTo(PyLong.MAX_ULONG) > 0){ throw StructError("unsigned long int too long to convert"); } return v; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2010-04-09 05:06:14
|
Revision: 7009 http://jython.svn.sourceforge.net/jython/?rev=7009&view=rev Author: pjenvey Date: 2010-04-09 05:06:08 +0000 (Fri, 09 Apr 2010) Log Message: ----------- replace __int/long/float__ with asInt/Long/Double where appropriate Modified Paths: -------------- trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/modules/_sre.java trunk/jython/src/org/python/modules/jffi/Util.java trunk/jython/src/org/python/modules/math.java trunk/jython/src/org/python/modules/struct.java Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2010-04-09 04:40:52 UTC (rev 7008) +++ trunk/jython/src/org/python/core/PyString.java 2010-04-09 05:06:08 UTC (rev 7009) @@ -2714,36 +2714,13 @@ return s; } - private String formatFloatDecimal(PyObject arg, boolean truncate) { - PyFloat argAsFloat; - if (arg instanceof PyFloat) { - // Fast path - argAsFloat = (PyFloat)arg; - } else { - // Use __float__ - if (arg instanceof PyInteger || arg instanceof PyLong) { - // Typical cases, safe to call __float__: - argAsFloat = arg.__float__(); - } else { - try { - // We can't simply call arg.__float__() because PyString implements - // it without exposing it to python (i.e, str instances has no - // __float__ attribute). So, we would support strings as arguments - // for %g format, which is forbidden by CPython tests (on - // test_format.py). - argAsFloat = (PyFloat)arg.__getattr__("__float__").__call__(); - } catch (PyException e) { - // XXX: Swallow customs AttributeError throws from __float__ methods - // No better alternative for the moment - if (e.match(Py.AttributeError)) { - throw Py.TypeError("float argument required"); + private double asDouble(PyObject obj) { + try { + return obj.asDouble(); + } catch (PyException pye) { + throw !pye.match(Py.TypeError) ? pye : Py.TypeError("float argument required"); } - throw e; } - } - } - return formatFloatDecimal(argAsFloat.getValue(), truncate); - } private String formatFloatDecimal(double v, boolean truncate) { checkPrecision("decimal"); @@ -2772,7 +2749,7 @@ boolean truncate) { StringBuilder buf = new StringBuilder(); - double v = arg.__float__().getValue(); + double v = asDouble(arg); boolean isNegative = false; if (v < 0) { v = -v; @@ -2971,10 +2948,8 @@ string = formatFloatExponential(arg, c, false); break; case 'f': - case 'F': - string = formatFloatDecimal(arg, false); -// if (altFlag && string.indexOf('.') == -1) -// string += '.'; + case 'F': + string = formatFloatDecimal(asDouble(arg), false); break; case 'g': case 'G': @@ -2983,7 +2958,7 @@ precision = 6; } - double v = arg.__float__().getValue(); + double v = asDouble(arg); int exponent = (int)ExtraMath.closeFloor(Math.log10(Math.abs(v == 0 ? 1 : v))); if (v == Double.POSITIVE_INFINITY) { string = "inf"; @@ -2991,7 +2966,7 @@ string = "-inf"; } else if (exponent >= -4 && exponent < precision) { precision -= exponent + 1; - string = formatFloatDecimal(arg, !altFlag); + string = formatFloatDecimal(v, !altFlag); // XXX: this block may be unnecessary now if (altFlag && string.indexOf('.') == -1) { Modified: trunk/jython/src/org/python/modules/_sre.java =================================================================== --- trunk/jython/src/org/python/modules/_sre.java 2010-04-09 04:40:52 UTC (rev 7008) +++ trunk/jython/src/org/python/modules/_sre.java 2010-04-09 05:06:08 UTC (rev 7009) @@ -12,60 +12,34 @@ * CNRI. Hewlett-Packard provided funding for 1.6 integration and * other compatibility work. */ - package org.python.modules; -import java.util.Iterator; -import org.python.core.Py; -import org.python.core.PyInteger; -import org.python.core.PyList; -import org.python.core.PyLong; import org.python.core.PyObject; import org.python.core.PyString; import org.python.modules.sre.PatternObject; import org.python.modules.sre.SRE_STATE; - public class _sre { public static int MAGIC = SRE_STATE.SRE_MAGIC; // workaround the fact that H, I types are unsigned, but we are not really using them as such - //XXX: May not be the right size, but I suspect it is -- see sre_compile.py + // XXX: May not be the right size, but I suspect it is -- see sre_compile.py public static int CODESIZE = 4; - public static PatternObject compile(PyString pattern, int flags, - PyObject code, int groups, - PyObject groupindex, - PyObject indexgroup) { - int[] ccode = null; - if (code instanceof PyList) { - int n = code.__len__(); - ccode = new int[n]; - int i = 0; - for (PyObject item : code.asIterable()) { - ccode[i] = (int)((PyLong)item.__long__()).getValue().longValue(); - i++; - } - } else { - throw Py.TypeError("Expected list"); + public static PatternObject compile(PyString pattern, int flags, PyObject code, int groups, + PyObject groupindex, PyObject indexgroup) { + int[] ccode = new int[code.__len__()]; + int i = 0; + for (PyObject item : code.asIterable()) { + ccode[i++] = (int)item.asLong(); } - - PatternObject po = new PatternObject(pattern, - flags, - ccode, - groups, - groupindex, - indexgroup); - return po; + return new PatternObject(pattern, flags, ccode, groups, groupindex, indexgroup); } - - public static int getcodesize() { return CODESIZE; } - public static int getlower(int ch, int flags) { return SRE_STATE.getlower(ch, flags); } Modified: trunk/jython/src/org/python/modules/jffi/Util.java =================================================================== --- trunk/jython/src/org/python/modules/jffi/Util.java 2010-04-09 04:40:52 UTC (rev 7008) +++ trunk/jython/src/org/python/modules/jffi/Util.java 2010-04-09 05:06:08 UTC (rev 7009) @@ -88,13 +88,7 @@ } public static final long int64Value(PyObject value) { - if (value instanceof PyLong) { - return ((PyLong) value).getLong(Long.MIN_VALUE, Long.MAX_VALUE); - } else if (value instanceof PyInteger) { - return value.asInt(); - } else { - return ((PyLong) value.__long__()).getLong(Long.MIN_VALUE, Long.MAX_VALUE); - } + return value.asLong(); } public static final long uint64Value(PyObject value) { Modified: trunk/jython/src/org/python/modules/math.java =================================================================== --- trunk/jython/src/org/python/modules/math.java 2010-04-09 04:40:52 UTC (rev 7008) +++ trunk/jython/src/org/python/modules/math.java 2010-04-09 05:06:08 UTC (rev 7009) @@ -53,7 +53,7 @@ } public static double floor(PyObject v) { - return floor(v.__float__().getValue()); + return floor(v.asDouble()); } public static double floor(double v) { @@ -69,7 +69,7 @@ if (v instanceof PyLong) { doubleValue = calculateLongLog((PyLong)v); } else { - doubleValue = log(v.__float__().getValue()); + doubleValue = log(v.asDouble()); } if (base != null) { return check(applyLoggedBase(doubleValue, base)); @@ -89,7 +89,7 @@ if (base instanceof PyLong) { loggedBase = calculateLongLog((PyLong)base); } else { - loggedBase = log(base.__float__().getValue()); + loggedBase = log(base.asDouble()); } return check(loggedValue / loggedBase); } @@ -103,7 +103,7 @@ } public static double sin(PyObject v) { - return sin(v.__float__().getValue()); + return sin(v.asDouble()); } public static double sin(double v) { @@ -111,7 +111,7 @@ } public static double sqrt(PyObject v) { - return sqrt(v.__float__().getValue()); + return sqrt(v.asDouble()); } public static double sqrt(double v) { @@ -129,7 +129,7 @@ if (x <= 0.0) throw Py.ValueError("math domain error"); return log10(x) + (e[0]*8.0)*log10(2.0); } - return log10(v.__float__().getValue()); + return log10(v.asDouble()); } private static double log10(double v) { Modified: trunk/jython/src/org/python/modules/struct.java =================================================================== --- trunk/jython/src/org/python/modules/struct.java 2010-04-09 04:40:52 UTC (rev 7008) +++ trunk/jython/src/org/python/modules/struct.java 2010-04-09 05:06:08 UTC (rev 7009) @@ -351,7 +351,7 @@ } double get_float(PyObject value) { - return value.__float__().getValue(); + return value.asDouble(); } @@ -1000,7 +1000,7 @@ throw Py.TypeError("pack_into takes an array arg"); // as well as a buffer, what else? } PyArray buffer = (PyArray)args[argstart]; - int offset = args[argstart + 1].__int__().asInt(); + int offset = args[argstart + 1].asInt(); ByteStream res = pack(format, f, size, argstart + 2, args); if (res.pos > buffer.__len__()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2010-04-14 01:59:21
|
Revision: 7025 http://jython.svn.sourceforge.net/jython/?rev=7025&view=rev Author: pjenvey Date: 2010-04-14 01:59:14 +0000 (Wed, 14 Apr 2010) Log Message: ----------- small posix cleanup, remove its now unneeded initEncoding workaround Modified Paths: -------------- trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/org/python/modules/posix/Hider.java trunk/jython/src/org/python/modules/posix/PosixModule.java Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2010-04-13 02:16:14 UTC (rev 7024) +++ trunk/jython/src/org/python/core/PySystemState.java 2010-04-14 01:59:14 UTC (rev 7025) @@ -169,13 +169,7 @@ 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(); - } + initEncoding(); __displayhook__ = new PySystemStateFunctions("displayhook", 10, 1, 1); __excepthook__ = new PySystemStateFunctions("excepthook", 30, 3, 3); Modified: trunk/jython/src/org/python/modules/posix/Hider.java =================================================================== --- trunk/jython/src/org/python/modules/posix/Hider.java 2010-04-13 02:16:14 UTC (rev 7024) +++ trunk/jython/src/org/python/modules/posix/Hider.java 2010-04-14 01:59:14 UTC (rev 7025) @@ -25,8 +25,9 @@ * @param native whether the underlying posix is native */ public static void hideFunctions(Class<?> cls, PyObject dict, OS os, boolean isNative) { + PosixImpl posixImpl = isNative ? PosixImpl.NATIVE : PosixImpl.JAVA; for (Method method: cls.getDeclaredMethods()) { - if (isHidden(method, os, isNative ? PosixImpl.NATIVE : PosixImpl.JAVA)) { + if (isHidden(method, os, posixImpl)) { dict.__setitem__(method.getName(), null); } } Modified: trunk/jython/src/org/python/modules/posix/PosixModule.java =================================================================== --- trunk/jython/src/org/python/modules/posix/PosixModule.java 2010-04-13 02:16:14 UTC (rev 7024) +++ trunk/jython/src/org/python/modules/posix/PosixModule.java 2010-04-14 01:59:14 UTC (rev 7025) @@ -118,6 +118,7 @@ // Hide from Python Hider.hideFunctions(PosixModule.class, dict, os, nativePosix); dict.__setitem__("classDictInit", null); + dict.__setitem__("__init__", null); dict.__setitem__("getPOSIX", null); dict.__setitem__("getOSName", null); dict.__setitem__("badFD", null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-04-27 06:07:14
|
Revision: 7051 http://jython.svn.sourceforge.net/jython/?rev=7051&view=rev Author: zyasoft Date: 2010-04-27 06:07:08 +0000 (Tue, 27 Apr 2010) Log Message: ----------- Now nulls the ref to the args array for #1586 instead of clearing the array, so callee code has no copy responsibility (Phil Jenvey's suggestion). Backed out change to thread.PyLocal accordingly in r7047. Bumped bytecode magic. Modified Paths: -------------- trunk/jython/src/org/python/compiler/CodeCompiler.java trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/modules/thread/PyLocal.java Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2010-04-26 18:39:57 UTC (rev 7050) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2010-04-27 06:07:08 UTC (rev 7051) @@ -413,6 +413,12 @@ code.freeLocal(array); } + public void freeArrayRef(int array) { + code.aconst_null(); + code.astore(array); + code.freeLocal(array); + } + public Str getDocStr(java.util.List<stmt> suite) { if (suite.size() > 0) { stmt stmt = suite.get(0); @@ -1811,7 +1817,7 @@ stackConsume(3); // target + starargs + kwargs code.invokevirtual(p(PyObject.class), "_callextra", sig(PyObject.class, PyObject[].class, String[].class, PyObject.class, PyObject.class)); - freeArray(argArray); + freeArrayRef(argArray); } else if (keys.size() > 0) { loadThreadState(); stackProduce(p(ThreadState.class)); @@ -1823,7 +1829,7 @@ stackConsume(2); // target + ts code.invokevirtual(p(PyObject.class), "__call__", sig(PyObject.class, ThreadState.class, PyObject[].class, String[].class)); - freeArray(argArray); + freeArrayRef(argArray); } else { loadThreadState(); stackProduce(p(ThreadState.class)); Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2010-04-26 18:39:57 UTC (rev 7050) +++ trunk/jython/src/org/python/core/imp.java 2010-04-27 06:07:08 UTC (rev 7051) @@ -21,7 +21,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - private static final int APIVersion = 29; + private static final int APIVersion = 30; public static final int NO_MTIME = -1; Modified: trunk/jython/src/org/python/modules/thread/PyLocal.java =================================================================== --- trunk/jython/src/org/python/modules/thread/PyLocal.java 2010-04-26 18:39:57 UTC (rev 7050) +++ trunk/jython/src/org/python/modules/thread/PyLocal.java 2010-04-27 06:07:08 UTC (rev 7051) @@ -59,9 +59,7 @@ if (where[0] == TYPE && args.length > 0) { throw Py.TypeError("Initialization arguments are not supported"); } - // caller zeros out `args` - this.args = new PyObject[args.length]; - System.arraycopy(args, 0, this.args, 0, args.length); + this.args = args; this.keywords = keywords; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-06-23 20:25:14
|
Revision: 7067 http://jython.svn.sourceforge.net/jython/?rev=7067&view=rev Author: zyasoft Date: 2010-06-23 20:25:08 +0000 (Wed, 23 Jun 2010) Log Message: ----------- PyType#class_to_type should only have weak ref to Java classes being so mapped - this is important so that GC can occur on these classes Modified Paths: -------------- trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/util/Generic.java Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2010-06-16 14:46:34 UTC (rev 7066) +++ trunk/jython/src/org/python/core/PyType.java 2010-06-23 20:25:08 UTC (rev 7067) @@ -1251,9 +1251,11 @@ return newtype; } + // XXX what's the proper scope of this synchronization? given module import lock, might be + // ok to omit this sync here... public static synchronized PyType fromClass(Class<?> c) { if (class_to_type == null) { - class_to_type = Generic.map(); + class_to_type = Generic.synchronizedWeakHashMap(); addFromClass(PyType.class, null); } PyType type = class_to_type.get(c); Modified: trunk/jython/src/org/python/util/Generic.java =================================================================== --- trunk/jython/src/org/python/util/Generic.java 2010-06-16 14:46:34 UTC (rev 7066) +++ trunk/jython/src/org/python/util/Generic.java 2010-06-23 20:25:08 UTC (rev 7067) @@ -6,12 +6,14 @@ import java.util.AbstractSet; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -56,6 +58,11 @@ return new HashMap<K, V>(); } + public static <K, V> Map<K, V> synchronizedWeakHashMap() { + return Collections.synchronizedMap(new WeakHashMap<K, V>()); + } + + /** * Makes a ConcurrentMap using generic types inferred from whatever this is being * assigned to. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-08-21 03:42:56
|
Revision: 7099 http://jython.svn.sourceforge.net/jython/?rev=7099&view=rev Author: zyasoft Date: 2010-08-21 03:42:48 +0000 (Sat, 21 Aug 2010) Log Message: ----------- Standard refactoring of some core Python types so that their implementation (including subclasses) do not access the underlying backing field, but uses an accessor. More fixes for #1645. In addition, there's support for defaultdict providing atomic construction of values for associated keys, using Guava MapMaker's makeComputingMap. This is a rather cool example of the additional abstraction provided by the refactoring (namely PyDictionary#getMap). Some tests are needed to demo how sweet this really is :) Note that we cannot, given our constructors calling super in a chain, readily remove extraneous fields that are not used, either through the use of abstract classes to share implementation; or violate safe publication by calling it later, outside the constructor. (There are in fact tests that fail without safe publication.) But this is a minor concern. Modified Paths: -------------- trunk/jython/src/org/python/core/FilelikeInputStream.java trunk/jython/src/org/python/core/JavaImportHelper.java trunk/jython/src/org/python/core/PyDictionary.java trunk/jython/src/org/python/core/PyFile.java trunk/jython/src/org/python/core/PyFileReader.java trunk/jython/src/org/python/core/PyFileWriter.java trunk/jython/src/org/python/core/PyFloat.java trunk/jython/src/org/python/core/PyInteger.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/core/PyUnicode.java trunk/jython/src/org/python/core/StdoutWrapper.java trunk/jython/src/org/python/core/__builtin__.java trunk/jython/src/org/python/core/codecs.java trunk/jython/src/org/python/modules/_collections/PyDefaultDict.java Modified: trunk/jython/src/org/python/core/FilelikeInputStream.java =================================================================== --- trunk/jython/src/org/python/core/FilelikeInputStream.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/FilelikeInputStream.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -31,8 +31,8 @@ } else if(len == 0) { return 0; } - String result = ((PyString)filelike.__getattr__("read") - .__call__(new PyInteger(len))).string; + String result = ((PyString) filelike.__getattr__("read") + .__call__(new PyInteger(len))).getString(); if(result.length() == 0) { return -1; } Modified: trunk/jython/src/org/python/core/JavaImportHelper.java =================================================================== --- trunk/jython/src/org/python/core/JavaImportHelper.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/JavaImportHelper.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -117,7 +117,7 @@ while (iterator.hasNext()) { Object obj = iterator.next(); if (obj instanceof PyString) { - obj = ((PyString)obj).string; + obj = ((PyString) obj).getString(); } if (obj instanceof String) { String fromName = (String) obj; Modified: trunk/jython/src/org/python/core/PyDictionary.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionary.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/PyDictionary.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -31,8 +31,12 @@ public static final PyType TYPE = PyType.fromClass(PyDictionary.class); - protected final ConcurrentMap<PyObject, PyObject> table; + private final ConcurrentMap<PyObject, PyObject> map; + public ConcurrentMap<PyObject, PyObject> getMap() { + return map; + } + /** * Create an empty dictionary. */ @@ -45,7 +49,7 @@ */ public PyDictionary(PyType type, int capacity) { super(type); - table = new ConcurrentHashMap<PyObject, PyObject>(capacity, Generic.CHM_LOAD_FACTOR, + map = new ConcurrentHashMap<PyObject, PyObject>(capacity, Generic.CHM_LOAD_FACTOR, Generic.CHM_CONCURRENCY_LEVEL); } @@ -54,7 +58,7 @@ */ public PyDictionary(PyType type) { super(type); - table = Generic.concurrentMap(); + map = Generic.concurrentMap(); } /** @@ -65,14 +69,27 @@ } /** - * Create a new derived dictionary which is based on the given map. + * Create a new dictionary which is populated with entries the given map. */ public PyDictionary(PyType type, Map<PyObject, PyObject> map) { this(type, Math.max((int) (map.size() / Generic.CHM_LOAD_FACTOR) + 1, Generic.CHM_INITIAL_CAPACITY)); - table.putAll(map); + this.map.putAll(map); } + /** + * Create a new dictionary without initializing table. Used for dictionary + * factories, with different backing maps, at the cost that it prevents us from making table be final. + */ + // TODO we may want to revisit this API, but our chain calling of super makes this tough + protected PyDictionary(PyType type, boolean initializeBacking) { + super(type); + if (initializeBacking) { + map = Generic.concurrentMap(); + } else { + map = null; // for later initialization + } + } /** * Create a new dictionary with the element as content. @@ -84,7 +101,7 @@ public PyDictionary(PyObject elements[]) { this(); for (int i = 0; i < elements.length; i += 2) { - table.put(elements[i], elements[i + 1]); + map.put(elements[i], elements[i + 1]); } } @@ -103,7 +120,7 @@ } @ExposedClassMethod(defaults = "Py.None", doc = BuiltinDocs.dict_fromkeys_doc) - final static PyObject dict_fromkeys(PyType type, PyObject keys, PyObject value) { + static PyObject dict_fromkeys(PyType type, PyObject keys, PyObject value) { PyObject d = type.__call__(); for (PyObject o : keys.asIterable()) { d.__setitem__(o, value); @@ -118,12 +135,12 @@ @ExposedMethod(doc = BuiltinDocs.dict___len___doc) final int dict___len__() { - return table.size(); + return getMap().size(); } @Override public boolean __nonzero__() { - return table.size() != 0; + return getMap().size() != 0; } @Override @@ -133,12 +150,12 @@ @Override public PyObject __finditem__(PyObject key) { - return table.get(key); + return getMap().get(key); } @ExposedMethod(doc = BuiltinDocs.dict___getitem___doc) protected final PyObject dict___getitem__(PyObject key) { - PyObject result = table.get(key); + PyObject result = getMap().get(key); if (result != null) { return result; } @@ -161,7 +178,7 @@ @ExposedMethod(doc = BuiltinDocs.dict___setitem___doc) final void dict___setitem__(PyObject key, PyObject value) { - table.put(key, value); + getMap().put(key, value); } @Override @@ -171,7 +188,7 @@ @ExposedMethod(doc = BuiltinDocs.dict___delitem___doc) final void dict___delitem__(PyObject key) { - Object ret = table.remove(key); + Object ret = getMap().remove(key); if (ret == null) { throw Py.KeyError(key.toString()); } @@ -200,7 +217,7 @@ } StringBuilder buf = new StringBuilder("{"); - for (Entry<PyObject, PyObject> entry : table.entrySet()) { + for (Entry<PyObject, PyObject> entry : getMap().entrySet()) { buf.append((entry.getKey()).__repr__().toString()); buf.append(": "); buf.append((entry.getValue()).__repr__().toString()); @@ -229,8 +246,8 @@ return null; } PyDictionary other = (PyDictionary)otherObj; - int an = table.size(); - int bn = other.table.size(); + int an = getMap().size(); + int bn = other.getMap().size(); if (an != bn) { return Py.False; } @@ -314,8 +331,8 @@ return -2; } PyDictionary other = (PyDictionary)otherObj; - int an = table.size(); - int bn = other.table.size(); + int an = getMap().size(); + int bn = other.getMap().size(); if (an < bn) { return -1; } @@ -364,7 +381,7 @@ @ExposedMethod(doc = BuiltinDocs.dict_has_key_doc) final boolean dict_has_key(PyObject key) { - return table.containsKey(key); + return getMap().containsKey(key); } @Override @@ -390,7 +407,7 @@ @ExposedMethod(defaults = "Py.None", doc = BuiltinDocs.dict_get_doc) final PyObject dict_get(PyObject key, PyObject defaultObj) { - PyObject o = table.get(key); + PyObject o = getMap().get(key); return o == null ? defaultObj : o; } @@ -413,7 +430,7 @@ @ExposedMethod(doc = BuiltinDocs.dict_copy_doc) final PyDictionary dict_copy() { - return new PyDictionary(table); // no need to clone() + return new PyDictionary(getMap()); // no need to clone() } /** @@ -425,7 +442,7 @@ @ExposedMethod(doc = BuiltinDocs.dict_clear_doc) final void dict_clear() { - table.clear(); + getMap().clear(); } /** @@ -479,7 +496,7 @@ */ private void merge(PyObject other) { if (other instanceof PyDictionary) { - table.putAll(((PyDictionary)other).table); + getMap().putAll(((PyDictionary) other).getMap()); } else if (other instanceof PyStringMap) { mergeFromKeys(other, ((PyStringMap)other).keys()); } else { @@ -552,14 +569,14 @@ @ExposedMethod(defaults = "Py.None", doc = BuiltinDocs.dict_setdefault_doc) final PyObject dict_setdefault(PyObject key, PyObject failobj) { - PyObject oldValue = table.putIfAbsent(key, failobj); + PyObject oldValue = getMap().putIfAbsent(key, failobj); return oldValue == null ? failobj : oldValue; } // XXX: needs __doc__ but CPython does not define setifabsent @ExposedMethod(defaults = "Py.None") final PyObject dict_setifabsent(PyObject key, PyObject failobj) { - PyObject oldValue = table.putIfAbsent(key, failobj); + PyObject oldValue = getMap().putIfAbsent(key, failobj); return oldValue == null ? Py.None : oldValue; } @@ -582,13 +599,13 @@ @ExposedMethod(defaults = "null", doc = BuiltinDocs.dict_pop_doc) final PyObject dict_pop(PyObject key, PyObject defaultValue) { - if (!table.containsKey(key)) { + if (!map.containsKey(key)) { if (defaultValue == null) { throw Py.KeyError("popitem(): dictionary is empty"); } return defaultValue; } - return table.remove(key); + return getMap().remove(key); } @@ -602,7 +619,7 @@ @ExposedMethod(doc = BuiltinDocs.dict_popitem_doc) final PyObject dict_popitem() { - Iterator<Entry<PyObject, PyObject>> it = table.entrySet().iterator(); + Iterator<Entry<PyObject, PyObject>> it = getMap().entrySet().iterator(); if (!it.hasNext()) { throw Py.KeyError("popitem(): dictionary is empty"); } @@ -622,8 +639,8 @@ @ExposedMethod(doc = BuiltinDocs.dict_items_doc) final PyList dict_items() { - List<PyObject> list = new ArrayList<PyObject>(table.size()); - for (Entry<PyObject, PyObject> entry : table.entrySet()) { + List<PyObject> list = new ArrayList<PyObject>(getMap().size()); + for (Entry<PyObject, PyObject> entry : getMap().entrySet()) { list.add(new PyTuple(entry.getKey(), entry.getValue())); } return PyList.fromList(list); @@ -638,12 +655,12 @@ @ExposedMethod(doc = BuiltinDocs.dict_keys_doc) final PyList dict_keys() { - return PyList.fromList(new ArrayList<PyObject>(table.keySet())); + return PyList.fromList(new ArrayList<PyObject>(getMap().keySet())); } @ExposedMethod(doc = BuiltinDocs.dict_values_doc) final PyList dict_values() { - return PyList.fromList(new ArrayList<PyObject>(table.values())); + return PyList.fromList(new ArrayList<PyObject>(getMap().values())); } /** @@ -655,7 +672,7 @@ @ExposedMethod(doc = BuiltinDocs.dict_iteritems_doc) final PyObject dict_iteritems() { - return new ItemsIter(table.entrySet()); + return new ItemsIter(getMap().entrySet()); } /** @@ -667,7 +684,7 @@ @ExposedMethod(doc = BuiltinDocs.dict_iterkeys_doc) final PyObject dict_iterkeys() { - return new ValuesIter(table.keySet()); + return new ValuesIter(getMap().keySet()); } /** @@ -679,7 +696,7 @@ @ExposedMethod(doc = BuiltinDocs.dict_itervalues_doc) final PyObject dict_itervalues() { - return new ValuesIter(table.values()); + return new ValuesIter(getMap().values()); } @Override @@ -687,6 +704,21 @@ return dict___hash__(); } + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PyDictionary other = (PyDictionary) obj; + if (this.map != other.map && (this.map == null || !this.map.equals(other.map))) { + return false; + } + return true; + } + @ExposedMethod(doc = BuiltinDocs.dict___hash___doc) final int dict___hash__() { throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); @@ -715,7 +747,7 @@ @Override public PyObject __iternext__() { - if (table.size() != size) { + if (getMap().size() != size) { throw Py.RuntimeError("dictionary changed size during iteration"); } if (!iterator.hasNext()) { @@ -738,7 +770,7 @@ @Override public PyObject __iternext__() { - if (table.size() != size) { + if (getMap().size() != size) { throw Py.RuntimeError("dictionary changed size during iteration"); } if (!iterator.hasNext()) { @@ -757,81 +789,81 @@ */ /** @see java.util.Map#entrySet() */ public Set entrySet() { - return new PyMapEntrySet(table.entrySet()); + return new PyMapEntrySet(getMap().entrySet()); } /** @see java.util.Map#keySet() */ public Set keySet() { - return new PyMapKeyValSet(table.keySet()); + return new PyMapKeyValSet(getMap().keySet()); } /** @see java.util.Map#values() */ public Collection values() { - return new PyMapKeyValSet(table.values()); + return new PyMapKeyValSet(getMap().values()); } /** @see java.util.Map#putAll(Map map) */ public void putAll(Map map) { for (Object o : map.entrySet()) { Entry entry = (Entry)o; - table.put(Py.java2py(entry.getKey()), Py.java2py(entry.getValue())); + getMap().put(Py.java2py(entry.getKey()), Py.java2py(entry.getValue())); } } /** @see java.util.Map#remove(Object key) */ public Object remove(Object key) { - return tojava(table.remove(Py.java2py(key))); + return tojava(getMap().remove(Py.java2py(key))); } /** @see java.util.Map#put(Object key, Object value) */ public Object put(Object key, Object value) { - return tojava(table.put(Py.java2py(key), Py.java2py(value))); + return tojava(getMap().put(Py.java2py(key), Py.java2py(value))); } /** @see java.util.Map#get(Object key) */ public Object get(Object key) { - return tojava(table.get(Py.java2py(key))); + return tojava(getMap().get(Py.java2py(key))); } /** @see java.util.Map#containsValue(Object key) */ public boolean containsValue(Object value) { - return table.containsValue(Py.java2py(value)); + return getMap().containsValue(Py.java2py(value)); } /** @see java.util.Map#containsValue(Object key) */ public boolean containsKey(Object key) { - return table.containsKey(Py.java2py(key)); + return getMap().containsKey(Py.java2py(key)); } /** @see java.util.Map#isEmpty() */ public boolean isEmpty() { - return table.isEmpty(); + return getMap().isEmpty(); } /** @see java.util.Map#size() */ public int size() { - return table.size(); + return getMap().size(); } /** Convert return values to java objects */ - final static Object tojava(Object val) { + static Object tojava(Object val) { return val == null ? null : ((PyObject)val).__tojava__(Object.class); } public Object putIfAbsent(Object key, Object value) { - return tojava(table.putIfAbsent(Py.java2py(key), Py.java2py(value))); + return tojava(getMap().putIfAbsent(Py.java2py(key), Py.java2py(value))); } public boolean remove(Object key, Object value) { - return table.remove(Py.java2py(key), Py.java2py(value)); + return getMap().remove(Py.java2py(key), Py.java2py(value)); } public boolean replace(Object key, Object oldValue, Object newValue) { - return table.replace(Py.java2py(key), Py.java2py(oldValue), Py.java2py(newValue)); + return getMap().replace(Py.java2py(key), Py.java2py(oldValue), Py.java2py(newValue)); } public Object replace(Object key, Object value) { - return tojava(table.replace(Py.java2py(key), Py.java2py(value))); + return tojava(getMap().replace(Py.java2py(key), Py.java2py(value))); } } @@ -926,6 +958,11 @@ return new SimpleEntry(key, value); } + @Override + public int hashCode() { + return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode()); + } + } /** Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/PyFile.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -389,7 +389,7 @@ if (obj instanceof PyUnicode) { return ((PyUnicode)obj).encode(); } else if (obj instanceof PyString) { - return ((PyString)obj).string; + return ((PyString) obj).getString(); } else if (binary && obj instanceof PyArray) { return ((PyArray)obj).tostring(); } Modified: trunk/jython/src/org/python/core/PyFileReader.java =================================================================== --- trunk/jython/src/org/python/core/PyFileReader.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/PyFileReader.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -155,7 +155,7 @@ int size = 0; do { final PyString line = readline(-1); - int len = line.string.length(); + int len = line.getString().length(); if (len == 0) { // EOF break; Modified: trunk/jython/src/org/python/core/PyFileWriter.java =================================================================== --- trunk/jython/src/org/python/core/PyFileWriter.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/PyFileWriter.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -51,9 +51,9 @@ public void write(PyObject o) { if (o instanceof PyUnicode) { - write(((PyUnicode) o).string); + write(((PyUnicode) o).getString()); } else if (o instanceof PyString) { - write(((PyString) o).string); + write(((PyString) o).getString()); } else { throw Py.TypeError("write requires a string as its argument"); } Modified: trunk/jython/src/org/python/core/PyFloat.java =================================================================== --- trunk/jython/src/org/python/core/PyFloat.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/PyFloat.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -268,11 +268,11 @@ } } - private static final boolean canCoerce(PyObject other) { + private static boolean canCoerce(PyObject other) { return other instanceof PyFloat || other instanceof PyInteger || other instanceof PyLong; } - private static final double coerce(PyObject other) { + private static double coerce(PyObject other) { if (other instanceof PyFloat) { return ((PyFloat) other).getValue(); } else if (other instanceof PyInteger) { Modified: trunk/jython/src/org/python/core/PyInteger.java =================================================================== --- trunk/jython/src/org/python/core/PyInteger.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/PyInteger.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -33,7 +33,7 @@ @Deprecated public static final BigInteger maxInt = MAX_INT; - private int value; + private final int value; public PyInteger(PyType subType, int v) { super(subType); Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/PyObject.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -26,7 +26,7 @@ public static final PyType TYPE = PyType.fromClass(PyObject.class); /** The type of this object. */ - PyType objtype; + protected PyType objtype; /** * An underlying Java instance that this object is wrapping or is a subclass Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2010-08-21 03:30:41 UTC (rev 7098) +++ trunk/jython/src/org/python/core/PyString.java 2010-08-21 03:42:48 UTC (rev 7099) @@ -17,9 +17,13 @@ public class PyString extends PyBaseString { public static final PyType TYPE = PyType.fromClass(PyString.class); - protected String string; + protected String string; // cannot make final because of Python intern support protected transient boolean interned=false; + public String getString() { + return string; + } + // for PyJavaClass.init() public PyString() { this(TYPE, ""); @@ -57,7 +61,7 @@ } @ExposedNew - final static PyObject str_new(PyNewWrapper new_, boolean init, PyType subtype, + static PyObject str_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("str", args, keywords, new String[] { "object" }, 0); PyObject S = ap.getPyObject(0, null); @@ -75,18 +79,19 @@ } public int[] toCodePoints() { - int n = string.length(); + int n = getString().length(); int[] codePoints = new int[n]; for (int i = 0; i < n; i++) { - codePoints[i] = string.charAt(i); + codePoints[i] = getString().charAt(i); } return codePoints; } public String substring(int start, int end) { - return string.substring(start, end); + return getString().substring(start, end); } + @Override public PyString __str__() { return str___str__(); } @@ -96,43 +101,47 @@ if (getClass() == PyString.class) { return this; } - return new PyString(string); + return new PyString(getString()); } + @Override public PyUnicode __unicode__() { return new PyUnicode(this); } + @Override public int __len__() { return str___len__(); } @ExposedMethod(doc = BuiltinDocs.str___len___doc) final int str___len__() { - return string.length(); + return getString().length(); } + @Override public String toString() { - return string; + return getString(); } public String internedString() { if (interned) - return string; + return getString(); else { - string = string.intern(); + string = getString().intern(); interned = true; - return string; + return getString(); } } + @Override public PyString __repr__() { return str___repr__(); } @ExposedMethod(doc = BuiltinDocs.str___repr___doc) final PyString str___repr__() { - return new PyString(encode_UnicodeEscape(string, true)); + return new PyString(encode_UnicodeEscape(getString(), true)); } private static char[] hexdigit = "0123456789abcdef".toCharArray(); @@ -475,6 +484,7 @@ return seq___getslice__(start, stop, step); } + @Override public int __cmp__(PyObject other) { return str___cmp__(other); } @@ -484,10 +494,11 @@ if (!(other instanceof PyString)) return -2; - int c = string.compareTo(((PyString)other).string); + int c = getString().compareTo(((PyString) other).getString()); return c < 0 ? -1 : c > 0 ? 1 : 0; } + @Override public PyObject __eq__(PyObject other) { return str___eq__(other); } @@ -497,9 +508,10 @@ String s = coerce(other); if (s == null) return null; - return string.equals(s) ? Py.True : Py.False; + return getString().equals(s) ? Py.True : Py.False; } + @Override public PyObject __ne__(PyObject other) { return str___ne__(other); } @@ -509,9 +521,10 @@ String s = coerce(other); if (s == null) return null; - return string.equals(s) ? Py.False : Py.True; + return getString().equals(s) ? Py.False : Py.True; } + @Override public PyObject __lt__(PyObject other) { return str___lt__(other); } @@ -521,9 +534,10 @@ String s = coerce(other); if (s == null) return null; - return string.compareTo(s) < 0 ? Py.True : Py.False; + return getString().compareTo(s) < 0 ? Py.True : Py.False; } + @Override public PyObject __le__(PyObject other) { return str___le__(other); } @@ -533,9 +547,10 @@ String s = coerce(other); if (s == null) return null; - return string.compareTo(s) <= 0 ? Py.True : Py.False; + return getString().compareTo(s) <= 0 ? Py.True : Py.False; } + @Override public PyObject __gt__(PyObject other) { return str___gt__(other); } @@ -545,9 +560,10 @@ String s = coerce(other); if (s == null) return null; - return string.compareTo(s) > 0 ? Py.True : Py.False; + return getString().compareTo(s) > 0 ? Py.True : Py.False; } + @Override public PyObject __ge__(PyObject other) { return str___ge__(other); } @@ -557,7 +573,7 @@ String s = coerce(other); if (s == null) return null; - return string.compareTo(s) >= 0 ? Py.True : Py.False; + return getString().compareTo(s) >= 0 ? Py.True : Py.False; } private static String coerce(PyObject o) { @@ -566,13 +582,29 @@ return null; } + @Override public int hashCode() { return str___hash__(); } +// @Override +// public boolean equals(Object obj) { +// if (obj == null) { +// return false; +// } +// if (getClass() != obj.getClass()) { +// return false; +// } +// final PyString other = (PyString) obj; +// if ((this.string == null) ? (other.string != null) : !this.string.equals(other.string)) { +// return false; +// } +// return true; +// } + @ExposedMethod(doc = BuiltinDocs.str___hash___doc) final int str___hash__() { - return string.hashCode(); + return getString().hashCode(); } /** @@ -581,23 +613,24 @@ * corresponding char. */ public byte[] toBytes() { - return StringUtil.toBytes(string); + return StringUtil.toBytes(getString()); } + @Override public Object __tojava__(Class<?> c) { if (c.isAssignableFrom(String.class)) { - return string; + return getString(); } if (c == Character.TYPE || c == Character.class) - if (string.length() == 1) - return new Character(string.charAt(0)); + if (getString().length() == 1) + return new Character(getString().charAt(0)); if (c.isArray()) { if (c.getComponentType() == Byte.TYPE) return toBytes(); if (c.getComponentType() == Character.TYPE) - return string.toCharArray(); + return getString().toCharArray(); } if (c.isInstance(this)) @@ -607,7 +640,7 @@ } protected PyObject pyget(int i) { - return Py.newString(string.charAt(i)); + return Py.newString(getString().charAt(i)); } protected PyObject getslice(int start, int stop, int step) { @@ -620,7 +653,7 @@ char new_chars[] = new char[n]; int j = 0; for (int i=start; j<n; i+=step) - new_chars[j++] = string.charAt(i); + new_chars[j++] = getString().charAt(i); return createInstance(new String(new_chars), true); } @@ -635,6 +668,7 @@ return new PyString(str); } + @Override public boolean __contains__(PyObject o) { return str___contains__(o); } @@ -644,14 +678,14 @@ if (!(o instanceof PyString)) throw Py.TypeError("'in <string>' requires string as left operand"); PyString other = (PyString) o; - return string.indexOf(other.string) >= 0; + return getString().indexOf(other.getString()) >= 0; } protected PyObject repeat(int count) { if(count < 0) { count = 0; } - int s = string.length(); + int s = getString().length(); if((long)s * count > Integer.MAX_VALUE) { // Since Strings store their data in an array, we can't make one // longer than Integer.MAX_VALUE. Without this check we get @@ -661,7 +695,7 @@ } char new_chars[] = new char[s * count]; for(int i = 0; i < count; i++) { - string.getChars(0, s, new_chars, i * s); + getString().getChars(0, s, new_chars, i * s); } return createInstance(new String(new_chars)); } @@ -692,6 +726,7 @@ return repeat(o.asIndex(Py.OverflowError)); } + @Override public PyObject __add__(PyObject other) { return str___add__(other); } @@ -703,30 +738,33 @@ } if (other instanceof PyString) { PyString otherStr = (PyString)other; - return new PyString(string.concat(otherStr.string)); + return new PyString(getString().concat(otherStr.getString())); } return null; } @ExposedMethod(doc = BuiltinDocs.str___getnewargs___doc) final PyTuple str___getnewargs__() { - return new PyTuple(new PyString(this.string)); + return new PyTuple(new PyString(this.getString())); } + @Override public PyTuple __getnewargs__() { return str___getnewargs__(); } + @Override public PyObject __mod__(PyObject other) { return str___mod__(other); } @ExposedMethod(doc = BuiltinDocs.str___mod___doc) public PyObject str___mod__(PyObject other){ - StringFormatter fmt = new StringFormatter(string, false); + StringFormatter fmt = new StringFormatter(getString(), false); return fmt.format(other); } + @Override public PyObject __int__() { try { @@ -739,27 +777,33 @@ } } + @Override public PyObject __long__() { return atol(10); } + @Override public PyFloat __float__() { return new PyFloat(atof()); } + @Override public PyObject __pos__() { throw Py.TypeError("bad operand type for unary +"); } + @Override public PyObject __neg__() { throw Py.TypeError("bad operand type for unary -"); } + @Override public PyObject __invert__() { throw Py.TypeError("bad operand type for unary ~"); } @SuppressWarnings("fallthrough") + @Override public PyComplex __complex__() { boolean got_re = false; boolean got_im = false; @@ -767,8 +811,8 @@ boolean sw_error = false; int s = 0; - int n = string.length(); - while (s < n && Character.isSpaceChar(string.charAt(s))) + int n = getString().length(); + while (s < n && Character.isSpaceChar(getString().charAt(s))) s++; if (s == n) { @@ -781,7 +825,7 @@ int sign = 1; do { - char c = string.charAt(s); + char c = getString().charAt(s); switch (c) { case '-': sign = -1; @@ -793,7 +837,7 @@ } // a character is guaranteed, but it better be a digit // or J or j - c = string.charAt(++s); // eat the sign character + c = getString().charAt(++s); // eat the sign character // and check the next if (!Character.isDigit(c) && c!='J' && c!='j') sw_error = true; @@ -817,7 +861,7 @@ break; case ' ': - while (s < n && Character.isSpaceChar(string.charAt(s))) + while (s < n && Character.isSpaceChar(getString().charAt(s))) s++; if (s != n) sw_error = true; @@ -829,15 +873,15 @@ sw_error = true; break; } - int end = endDouble(string, s); - z = Double.valueOf(string.substring(s, end)).doubleValue(); + int end = endDouble(getString(),s); + z = Double.valueOf(getString().substring(s, end)).doubleValue(); if (z == Double.POSITIVE_INFINITY) { - throw Py.ValueError(String.format("float() out of range: %.150s", string)); + throw Py.ValueError(String.format("float() out of range: %.150s", getString())); } s=end; if (s < n) { - c = string.charAt(s); + c = getString().charAt(s); if (c == 'J' || c == 'j') { break; } @@ -861,7 +905,7 @@ if (sw_error) { throw Py.ValueError("malformed string for complex() " + - string.substring(s)); + getString().substring(s)); } return new PyComplex(x,y); @@ -895,7 +939,7 @@ @ExposedMethod(doc = BuiltinDocs.str_lower_doc) final String str_lower() { - return string.toLowerCase(); + return getString().toLowerCase(); } public String upper() { @@ -904,7 +948,7 @@ @ExposedMethod(doc = BuiltinDocs.str_upper_doc) final String str_upper() { - return string.toUpperCase(); + return getString().toUpperCase(); } public String title() { @@ -913,7 +957,7 @@ @ExposedMethod(doc = BuiltinDocs.str_title_doc) final String str_title() { - char[] chars = string.toCharArray(); + char[] chars = getString().toCharArray(); int n = chars.length; boolean previous_is_cased = false; @@ -940,7 +984,7 @@ @ExposedMethod(doc = BuiltinDocs.str_swapcase_doc) final String str_swapcase() { - char[] chars = string.toCharArray(); + char[] chars = getString().toCharArray(); int n=chars.length; for (int i=0; i<n; i++) { char c = chars[i]; @@ -964,7 +1008,7 @@ @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_strip_doc) final String str_strip(String sep) { - char[] chars = string.toCharArray(); + char[] chars = getString().toCharArray(); int n=chars.length; int start=0; if (sep == null) @@ -984,7 +1028,7 @@ if (end >= start) { return (end < n-1 || start > 0) - ? string.substring(start, end+1) : string; + ? getString().substring(start, end+1) : getString(); } else { return ""; } @@ -1000,7 +1044,7 @@ @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_lstrip_doc) final String str_lstrip(String sep) { - char[] chars = string.toCharArray(); + char[] chars = getString().toCharArray(); int n=chars.length; int start=0; if (sep == null) @@ -1010,7 +1054,7 @@ while (start < n && sep.indexOf(chars[start]) >= 0) start++; - return (start > 0) ? string.substring(start, n) : string; + return (start > 0) ? getString().substring(start, n) : getString(); } public String rstrip(String sep) { @@ -1019,7 +1063,7 @@ @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_rstrip_doc) final String str_rstrip(String sep) { - char[] chars = string.toCharArray(); + char[] chars = getString().toCharArray(); int n=chars.length; int end=n-1; if (sep == null) @@ -1029,7 +1073,7 @@ while (end >= 0 && sep.indexOf(chars[end]) >= 0) end--; - return (end < n-1) ? string.substring(0, end+1) : string; + return (end < n-1) ? getString().substring(0, end+1) : getString(); } @@ -1056,7 +1100,7 @@ PyList list = new PyList(); - char[] chars = string.toCharArray(); + char[] chars = getString().toCharArray(); int n=chars.length; if (maxsplit < 0) @@ -1108,7 +1152,7 @@ } PyList list = new PyList(); - char[] chars = string.toCharArray(); + char[] chars = getString().toCharArray(); if (maxsplit < 0) { maxsplit = chars.length; @@ -1165,7 +1209,7 @@ if (sepObj instanceof PyUnicode) { return unicodePartition(sepObj); } else if (sepObj instanceof PyString) { - sep = ((PyString)sepObj).string; + sep = ((PyString) sepObj).getString(); } else { throw Py.TypeError("expected a character buffer object"); } @@ -1174,10 +1218,10 @@ throw Py.ValueError("empty separator"); } - int index = string.indexOf(sep); + int index = getString().indexOf(sep); if (index != -1) { return new PyTuple(fromSubstring(0, index), sepObj, - fromSubstring(index + sep.length(), string.length())); + fromSubstring(index + sep.length(), getString().length())); } else { return new PyTuple(this, Py.EmptyString, Py.EmptyString); } @@ -1185,7 +1229,7 @@ final PyTuple unicodePartition(PyObject sepObj) { PyUnicode strObj = __unicode__(); - String str = strObj.string; + String str = strObj.getString(); // Will throw a TypeError if not a basestring String sep = sepObj.asString(); @@ -1216,7 +1260,7 @@ if (sepObj instanceof PyUnicode) { return unicodePartition(sepObj); } else if (sepObj instanceof PyString) { - sep = ((PyString)sepObj).string; + sep = ((PyString) sepObj).getString(); } else { throw Py.TypeError("expected a character buffer object"); } @@ -1225,10 +1269,10 @@ throw Py.ValueError("empty separator"); } - int index = string.lastIndexOf(sep); + int index = getString().lastIndexOf(sep); if (index != -1) { return new PyTuple(fromSubstring(0, index), sepObj, - fromSubstring(index + sep.length(), string.length())); + fromSubstring(index + sep.length(), getString().length())); } else { return new PyTuple(Py.EmptyString, Py.EmptyString, this); } @@ -1236,7 +1280,7 @@ final PyTuple unicodeRpartition(PyObject sepObj) { PyUnicode strObj = __unicode__(); - String str = strObj.string; + String str = strObj.getString(); // Will throw a TypeError if not a basestring String sep = sepObj.asString(); @@ -1259,7 +1303,7 @@ private PyList splitfields(String sep, int maxsplit) { PyList list = new PyList(); - int length = string.length(); + int length = getString().length(); if (maxsplit < 0) maxsplit = length + 1; @@ -1268,12 +1312,12 @@ int sepLength = sep.length(); int index; if((sep.length() == 0) && (maxsplit != 0)) { - index = string.indexOf(sep, lastbreak); + index = getString().indexOf(sep, lastbreak); list.append(fromSubstring(lastbreak, index)); splits++; } while (splits < maxsplit) { - index = string.indexOf(sep, lastbreak); + index = getString().indexOf(sep, lastbreak); if (index == -1) break; if(sep.length() == 0) @@ -1291,7 +1335,7 @@ private PyList rsplitfields(String sep, int maxsplit) { PyList list = new PyList(); - int length = string.length(); + int length = getString().length(); if (maxsplit < 0) { maxsplit = length + 1; } @@ -1302,7 +1346,7 @@ int sepLength = sep.length(); while (index > 0 && splits < maxsplit) { - int i = string.lastIndexOf(sep, index - sepLength); + int i = getString().lastIndexOf(sep, index - sepLength); if (i == index) { i -= sepLength; } @@ -1331,7 +1375,7 @@ final PyList str_splitlines(boolean keepends) { PyList list = new PyList(); - char[] chars = string.toCharArray(); + char[] chars = getString().toCharArray(); int n=chars.length; int j = 0; @@ -1361,7 +1405,7 @@ } protected PyString fromSubstring(int begin, int end) { - return createInstance(string.substring(begin, end), true); + return createInstance(getString().substring(begin, end), true); } public int index(String sub) { @@ -1421,14 +1465,14 @@ int[] indices = translateIndices(start, end); int n = sub.length(); if(n == 0) { - if (start > string.length()) { + if (start > getString().length()) { return 0; } return indices[1] - indices[0] + 1; } int count = 0; while(true){ - int index = string.indexOf(sub, indices[0]); + int index = getString().indexOf(sub, indices[0]); indices[0] = index + n; if(indices[0] > indices[1] || index == -1) { break; @@ -1453,7 +1497,7 @@ @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_find_doc) final int str_find(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); - int index = string.indexOf(sub, indices[0]); + int index = getString().indexOf(sub, indices[0]); if (index < start || index > indices[1]) { return -1; } @@ -1475,7 +1519,7 @@ @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_rfind_doc) final int str_rfind(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); - int index = string.lastIndexOf(sub, indices[1] - sub.length()); + int index = getString().lastIndexOf(sub, indices[1] - sub.length()); if (index < start) { return -1; } @@ -1484,20 +1528,20 @@ public double atof() { StringBuilder s = null; - int n = string.length(); + int n = getString().length(); for (int i = 0; i < n; i++) { - char ch = string.charAt(i); + char ch = getString().charAt(i); if (ch == '\u0000') { throw Py.ValueError("null byte in argument for float()"); } if (Character.isDigit(ch)) { if (s == null) - s = new StringBuilder(string); + s = new StringBuilder(getString()); int val = Character.digit(ch, 10); s.setCharAt(i, Character.forDigit(val, 10)); } } - String sval = string; + String sval = getString(); if (s != null) sval = s.toString(); try { @@ -1513,7 +1557,7 @@ return Double.valueOf(sval).doubleValue(); } catch (NumberFormatException exc) { - throw Py.ValueError("invalid literal for __float__: "+string); + throw Py.ValueError("invalid literal for __float__: "+getString()); } } @@ -1527,26 +1571,26 @@ } int b = 0; - int e = string.length(); + int e = getString().length(); - while (b < e && Character.isWhitespace(string.charAt(b))) + while (b < e && Character.isWhitespace(getString().charAt(b))) b++; - while (e > b && Character.isWhitespace(string.charAt(e-1))) + while (e > b && Character.isWhitespace(getString().charAt(e-1))) e--; char sign = 0; if (b < e) { - sign = string.charAt(b); + sign = getString().charAt(b); if (sign == '-' || sign == '+') { b++; - while (b < e && Character.isWhitespace(string.charAt(b))) b++; + while (b < e && Character.isWhitespace(getString().charAt(b))) b++; } if (base == 0 || base == 16) { - if (string.charAt(b) == '0') { + if (getString().charAt(b) == '0') { if (b < e-1 && - Character.toUpperCase(string.charAt(b+1)) == 'X') { + Character.toUpperCase(getString().charAt(b+1)) == 'X') { base = 16; b += 2; } else { @@ -1560,9 +1604,9 @@ if (base == 0) base = 10; - String s = string; - if (b > 0 || e < string.length()) - s = string.substring(b, e); + String s = getString(); + if (b > 0 || e < getString().length()) + s = getString().substring(b, e); try { BigInteger bi; @@ -1575,9 +1619,9 @@ } return bi.intValue(); } catch (NumberFormatException exc) { - throw Py.ValueError("invalid literal for int() with base " + base + ": " + string); + throw Py.ValueError("invalid literal for int() with base " + base + ": " + getString()); } catch (StringIndexOutOfBoundsException exc) { - throw Py.ValueError("invalid literal for int() with base " + base + ": " + string); + throw Py.ValueError("invalid literal for int() with base " + base + ": " + getString()); } } @@ -1586,7 +1630,7 @@ } public PyLong atol(int base) { - String str = string; + String str = getString(); int b = 0; int e = str.length(); @@ -1599,7 +1643,7 @@ char sign = 0; if (b < e) { - sign = string.charAt(b); + sign = getString().charAt(b); if (sign == '-' || sign == '+') { b++; while (b < e && Character.isWhitespace(str.charAt(b))) b++; @@ -1607,9 +1651,9 @@ if (base == 0 || base == 16) { - if (string.charAt(b) == '0') { + if (getString().charAt(b) == '0') { if (b < e-1 && - Character.toUpperCase(string.charAt(b+1)) == 'X') { + Character.toUpperCase(getString().charAt(b+1)) == 'X') { base = 16; b += 2; } else { @@ -1649,10 +1693,10 @@ 0,0, "invalid decimal Unicode string"); } else { - throw Py.ValueError("invalid literal for long() with base " + base + ": " + string); + throw Py.ValueError("invalid literal for long() with base " + base + ": " + getString()); } } catch (StringIndexOutOfBoundsException exc) { - throw Py.ValueError("invalid literal for long() with base " + base + ": " + string); + throw Py.ValueError("invalid literal for long() with base " + base + ": " + getString()); } } @@ -1682,10 +1726,10 @@ @ExposedMethod(defaults="null", doc = BuiltinDocs.str_ljust_doc) final String str_ljust(int width, String fillchar) { char pad = parse_fillchar("ljust", fillchar); - int n = width-string.length(); + int n = width-getString().length(); if (n <= 0) - return string; - return string+padding(n, pad); + return getString(); + return getString()+padding(n, pad); } public String rjust(int width) { @@ -1695,10 +1739,10 @@ @ExposedMethod(defaults="null", doc = BuiltinDocs.str_rjust_doc) final String str_rjust(int width, String fillchar) { char pad = parse_fillchar("rjust", fillchar); - int n = width-string.length(); + int n = width-getString().length(); if (n <= 0) - return string; - return padding(n, pad)+string; + return getString(); + return padding(n, pad)+getString(); } public String center(int width) { @@ -1708,14 +1752,14 @@ @ExposedMethod(defaults="null", doc = BuiltinDocs.str_center_doc) final String str_center(int width, String fillchar) { char pad = parse_fillchar("center", fillchar); - int n = width-string.length(); + int n = width-getString().length(); if (n <= 0) - return string; + return getString(); int half = n/2; if (n%2 > 0 && width%2 > 0) half += 1; - return padding(half, pad)+string+padding(n-half, pad); + return padding(half, pad)+getString()+padding(n-half, pad); } public String zfill(int width) { @@ -1724,7 +1768,7 @@ @ExposedMethod(doc = BuiltinDocs.str_zfill_doc) final String str_zfill(int width) { - String s = string; + String s = getString(); int n = s.length(); if (n >= width) return s; @@ -1758,7 +1802,7 @@ @ExposedMethod(defaults = "8", doc = BuiltinDocs.str_expandtabs_doc) final String str_expandtabs(int tabsize) { - String s = string; + String s = getString(); StringBuilder buf = new StringBuilder((int)(s.length()*1.5)); char[] chars = s.toCharArray(); int n = chars.length; @@ -1789,10 +1833,10 @@ @ExposedMethod(doc = BuiltinDocs.str_capitalize_doc) final String str_capitalize() { - if (string.length() == 0) - return string; - String first = string.substring(0,1).toUpperCase(); - return first.concat(string.substring(1).toLowerCase()); + if (getString().length() == 0) + return getString(); + String first = getString().substring(0,1).toUpperCase(); + return first.concat(getString().substring(1).toLowerCase()); } @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_replace_doc) @@ -1805,25 +1849,25 @@ } protected PyString replace(PyString oldPiece, PyString newPiece, int maxsplit) { - int len = string.length(); - int old_len = oldPiece.string.length(); + int len = getString().length(); + int old_len = oldPiece.getString().length(); if (len == 0) { if (maxsplit == -1 && old_len == 0) { - return createInstance(newPiece.string, true); + return createInstance(newPiece.getString(), true); } - return createInstance(string, true); + return createInstance(getString(), true); } - if (old_len == 0 && newPiece.string.length() != 0 && maxsplit !=0) { + if (old_len == 0 && newPiece.getString().length() != 0 && maxsplit !=0) { // old="" and new != "", interleave new piece with each char in original, taking in effect maxsplit StringBuilder buffer = new StringBuilder(); int i = 0; - buffer.append(newPiece.string); + buffer.append(newPiece.getString()); for (; i < len && (i < maxsplit-1 || maxsplit == -1); i++) { - buffer.append(string.charAt(i)); - buffer.append(newPiece.string); + buffer.append(getString().charAt(i)); + buffer.append(newPiece.getString()); } - buffer.append(string.substring(i)); + buffer.append(getString().substring(i)); return createInstance(buffer.toString(), true); } @@ -1835,7 +1879,7 @@ } } - return newPiece.join(splitfields(oldPiece.string, maxsplit)); + return newPiece.join(splitfields(oldPiece.getString(), maxsplit)); } public PyString join(PyObject seq) { @@ -1864,7 +1908,7 @@ // join if appropriate int i = 0; long size = 0; - int sepLen = string.length(); + int sepLen = getString().length(); for (; i < seqLen; i++) { item = seq.pyget(i); if (!(item instanceof PyString)) { @@ -1880,7 +1924,7 @@ if (i != 0) { size += sepLen; } - size += ((PyString)item).string.length(); + size += ((PyString) item).getString().length(); if (size > Integer.MAX_VALUE) { throw Py.OverflowError("join() result is too long for a Python string"); } @@ -1891,9 +1935,9 @@ for (i = 0; i < seqLen; i++) { item = seq.pyget(i); if (i != 0) { - buf.append(string); + buf.append(getString()); } - buf.append(((PyString)item).string); + buf.append(((PyString) item).getString()); } return new PyString(buf.toString()); } @@ -1923,9 +1967,9 @@ String sep = null; if (seqLen > 1) { if (this instanceof PyUnicode) { - sep = string; + sep = getString(); } else { - sep = ((PyUnicode)decode()).string; + sep = ((PyUnicode) decode()).getString(); // In case decode()'s codec mutated seq seqLen = seq.__len__(); } @@ -1933,7 +1977,7 @@ // At least two items to join, or one that isn't exact Unicode long size = 0; - int sepLen = string.length(); + int sepLen = getString().length(); StringBuilder buf = new StringBuilder(); String itemString; for (int i = 0; i < seqLen; i++) { @@ -1949,7 +1993,7 @@ // In case decode()'s codec mutated seq seqLen = seq.__len__(); } - itemString = ((PyUnicode)item).string; + itemString = ((PyUnicode) item).getString(); if (i != 0) { size += sepLen; @@ -1981,11 +2025,11 @@ int[] indices = translateIndices(start, end); if (prefix instanceof PyString) { - String strPrefix = ((PyString)prefix).string; + String strPrefix = ((PyString) prefix).getString(); if (indices[1] - indices[0] < strPrefix.length()) return false; - return string.startsWith(strPrefix, indices[0]); + return getString().startsWith(strPrefix, indices[0]); } else if (prefix instanceof PyTuple) { PyObject[] prefixes = ((PyTuple)prefix).getArray(); @@ -1993,11 +2037,11 @@ if (!(prefixes[i] instanceof PyString)) throw Py.TypeError("expected a character buffer object"); - String strPrefix = ((PyString)prefixes[i]).string; + String strPrefix = ((PyString) prefixes[i]).getString(); if (indices[1] - indices[0] < strPrefix.length()) continue; - if (string.startsWith(strPrefix, indices[0])) + if (getString().startsWith(strPrefix, indices[0])) return true; } return false; @@ -2022,9 +2066,9 @@ final boolean str_endswith(PyObject suffix, int start, PyObject end) { int[] indices = translateIndices(start, end); - String substr = string.substring(indices[0], indices[1]); + String substr = getString().substring(indices[0], indices[1]); if (suffix instanceof PyString) { - return substr.endsWith(((PyString)suffix).string); + return substr.endsWith(((PyString) suffix).getString()); } else if (suffix instanceof PyTuple) { PyObject[] suffixes = ((PyTuple)suffix).getArray(); @@ -2032,7 +2076,7 @@ if (!(suffixes[i] instanceof PyString)) throw Py.TypeError("expected a character buffer object"); - if (substr.endsWith(((PyString)suffixes[i]).string)) + if (substr.endsWith(((PyString) suffixes[i]).getString())) return true; } return false; @@ -2053,11 +2097,11 @@ protected int[] translateIndices(int start, PyObject end) { int iEnd; if(end == null) { - iEnd = string.length(); + iEnd = getString().length(); } else { iEnd = end.asInt(); } - int n = string.length(); + int n = getString().length(); if(iEnd < 0) { iEnd = n + iEnd; if(iEnd < 0) { @@ -2092,9 +2136,9 @@ throw Py.ValueError( "translation table must be 256 characters long"); - StringBuilder buf = new StringBuilder(string.length()); - for (int i=0; i < string.length(); i++) { - char c = string.charAt(i); + StringBuilder buf = new StringBuilder(getString().length()); + for (int i=0; i < getString().length(); i++) { + char c = getString().charAt(i); if (deletechars != null && deletechars.indexOf(c) >= 0) continue; try { @@ -2110,9 +2154,9 @@ //XXX: is this needed? public String translate(PyObject table) { - StringBuilder v = new StringBuilder(string.length()); - for (int i=0; i < string.length(); i++) { - char ch = string.charAt(i); + StringBuilder v = new StringBuilder(getString().length()); + for (int i=0; i < getString().length(); i++) { + char ch = getString().charAt(i); PyObject w = Py.newInteger(ch); PyObject x = table.__finditem__(w); @@ -2152,15 +2196,15 @@ @ExposedMethod(doc = Builti... [truncated message content] |
From: <otm...@us...> - 2010-11-09 22:55:22
|
Revision: 7170 http://jython.svn.sourceforge.net/jython/?rev=7170&view=rev Author: otmarhumbel Date: 2010-11-09 22:55:15 +0000 (Tue, 09 Nov 2010) Log Message: ----------- allow PyStringMap to be bootstrapped without a warning; fixes issue #1671 Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/util/PyServlet.java trunk/jython/src/org/python/util/PythonInterpreter.java trunk/jython/src/org/python/util/jython.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2010-11-06 00:15:33 UTC (rev 7169) +++ trunk/jython/src/org/python/core/Py.java 2010-11-09 22:55:15 UTC (rev 7170) @@ -576,6 +576,14 @@ return new PyString(s); } + public static PyStringMap newStringMap() { + // enable lazy bootstrapping (see issue #1671) + if (!PyType.hasBuilder(PyStringMap.class)) { + BOOTSTRAP_TYPES.add(PyStringMap.class); + } + return new PyStringMap(); + } + public static PyUnicode newUnicode(char c) { return (PyUnicode) makeCharacter(c, true); } Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2010-11-06 00:15:33 UTC (rev 7169) +++ trunk/jython/src/org/python/core/PyType.java 2010-11-09 22:55:15 UTC (rev 7170) @@ -1201,6 +1201,10 @@ return createType(c, needsInners); } + static boolean hasBuilder(Class<?> c) { + return classToBuilder.containsKey(c); + } + private static TypeBuilder getBuilder(Class<?> c) { if (classToBuilder == null) { // PyType itself has yet to be initialized. This should be a bootstrap type, so it'll Modified: trunk/jython/src/org/python/util/PyServlet.java =================================================================== --- trunk/jython/src/org/python/util/PyServlet.java 2010-11-06 00:15:33 UTC (rev 7169) +++ trunk/jython/src/org/python/util/PyServlet.java 2010-11-09 22:55:15 UTC (rev 7170) @@ -121,7 +121,7 @@ protected static PythonInterpreter createInterpreter(ServletContext servletContext) { String rootPath = getRootPath(servletContext); PySystemState sys = new PySystemState(); - PythonInterpreter interp = new PythonInterpreter(new PyStringMap(), sys); + PythonInterpreter interp = new PythonInterpreter(Py.newStringMap(), sys); sys.path.append(new PyString(rootPath)); String modulesDir = rootPath + "WEB-INF" + File.separator + "jython"; Modified: trunk/jython/src/org/python/util/PythonInterpreter.java =================================================================== --- trunk/jython/src/org/python/util/PythonInterpreter.java 2010-11-06 00:15:33 UTC (rev 7169) +++ trunk/jython/src/org/python/util/PythonInterpreter.java 2010-11-09 22:55:15 UTC (rev 7170) @@ -94,7 +94,7 @@ protected PythonInterpreter(PyObject dict, PySystemState systemState, boolean useThreadLocalState) { if (dict == null) { - dict = new PyStringMap(); + dict = Py.newStringMap(); } globals = dict; Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2010-11-06 00:15:33 UTC (rev 7169) +++ trunk/jython/src/org/python/util/jython.java 2010-11-09 22:55:15 UTC (rev 7170) @@ -98,7 +98,7 @@ throw Py.ValueError("jar file missing '__run__.py'"); } - PyStringMap locals = new PyStringMap(); + PyStringMap locals = Py.newStringMap(); // Stripping the stuff before the last File.separator fixes Bug #931129 by // keeping illegal characters out of the generated proxy class name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-03-19 20:03:26
|
Revision: 7246 http://jython.svn.sourceforge.net/jython/?rev=7246&view=rev Author: pjenvey Date: 2011-03-19 20:03:20 +0000 (Sat, 19 Mar 2011) Log Message: ----------- add -3 and Py.warnPy3k Modified Paths: -------------- trunk/jython/src/org/python/core/Options.java trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/org/python/util/jython.java Modified: trunk/jython/src/org/python/core/Options.java =================================================================== --- trunk/jython/src/org/python/core/Options.java 2011-03-18 02:25:16 UTC (rev 7245) +++ trunk/jython/src/org/python/core/Options.java 2011-03-19 20:03:20 UTC (rev 7246) @@ -75,6 +75,9 @@ /** Force stdin, stdout and stderr to be unbuffered, and opened in * binary mode */ public static boolean unbuffered = false; + + /** Whether -3 (py3k warnings) were enabled via the command line. */ + public static boolean py3kwarning = false; //XXX: place holder public static int bytes_warning = 0; Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2011-03-18 02:25:16 UTC (rev 7245) +++ trunk/jython/src/org/python/core/Py.java 2011-03-19 20:03:20 UTC (rev 7246) @@ -410,6 +410,16 @@ warning(BytesWarning, message); } + public static void warnPy3k(String message) { + warnPy3k(message, 1); + } + + public static void warnPy3k(String message, int stacklevel) { + if (Options.py3kwarning) { + warning(DeprecationWarning, message, stacklevel); + } + } + private static PyObject warnings_mod; private static PyObject importWarnings() { @@ -438,6 +448,10 @@ } public static void warning(PyObject category, String message) { + warning(category, message, 1); + } + + public static void warning(PyObject category, String message, int stacklevel) { PyObject func = null; PyObject mod = importWarnings(); if (mod != null) { @@ -447,7 +461,7 @@ System.err.println(warn_hcategory(category) + ": " + message); return; } else { - func.__call__(Py.newString(message), category); + func.__call__(Py.newString(message), category, Py.newInteger(stacklevel)); } } Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2011-03-18 02:25:16 UTC (rev 7245) +++ trunk/jython/src/org/python/core/PySystemState.java 2011-03-19 20:03:20 UTC (rev 7246) @@ -70,8 +70,7 @@ // for tests that would need to pass but today would not. public final static int maxsize = Integer.MAX_VALUE; - //XXX: place holder - public final static boolean py3kwarning = false; + public static boolean py3kwarning = false; public final static Class flags = Options.class; @@ -190,6 +189,7 @@ currentWorkingDir = new File("").getAbsolutePath(); + py3kwarning = Options.py3kwarning; // Set up the initial standard ins and outs String mode = Options.unbuffered ? "b" : ""; int buffering = Options.unbuffered ? 0 : 1; Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2011-03-18 02:25:16 UTC (rev 7245) +++ trunk/jython/src/org/python/util/jython.java 2011-03-19 20:03:20 UTC (rev 7246) @@ -39,6 +39,7 @@ private static final String usage = usageHeader + "Options and arguments:\n" + //(and corresponding environment variables):\n" + + //"-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n" + "-c cmd : program passed in as string (terminates option list)\n" + //"-d : debug output from parser (also PYTHONDEBUG=x)\n" + "-Dprop=v : Set the property `prop' to value `v'\n"+ @@ -52,14 +53,18 @@ //"-O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n" + //"-OO : remove doc-strings in addition to the -O optimizations\n" + "-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n" + + // XXX: support -s + //"-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n" + "-S : don't imply 'import site' on initialization\n" + //"-t : issue warnings about inconsistent tab usage (-tt: issue errors)\n" + "-u : unbuffered binary stdout and stderr\n" + // (also PYTHONUNBUFFERED=x)\n" + //" see man page for details on internal buffering relating to '-u'\n" + "-v : verbose (trace import statements)\n" + // (also PYTHONVERBOSE=x)\n" + + " can be supplied multiple times to increase verbosity\n" + "-V : print the Python version number and exit (also --version)\n" + "-W arg : warning control (arg is action:message:category:module:lineno)\n" + //"-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n" + + "-3 : warn about Python 3.x incompatibilities that 2to3 cannot trivially fix\n" + "file : program read from script file\n" + "- : program read from stdin (default; interactive mode if a tty)\n" + "arg ... : arguments passed to program in sys.argv[1:]\n" + @@ -498,6 +503,8 @@ argv[i] = args[index]; } return true; + } else if (arg.startsWith("-3")) { + Options.py3kwarning = true; } else { String opt = args[index]; if (opt.startsWith("--")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-03-20 19:41:37
|
Revision: 7251 http://jython.svn.sourceforge.net/jython/?rev=7251&view=rev Author: pjenvey Date: 2011-03-20 19:41:31 +0000 (Sun, 20 Mar 2011) Log Message: ----------- o add Py.writeUnraisable o remove the no longer needed formatException <oldclass>.__module__ workaround o cleanup class/instance __repr__ Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyClass.java trunk/jython/src/org/python/core/PyFinalizableInstance.java trunk/jython/src/org/python/core/PyInstance.java trunk/jython/src/org/python/modules/_weakref/AbstractReference.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2011-03-20 06:07:17 UTC (rev 7250) +++ trunk/jython/src/org/python/core/Py.java 2011-03-20 19:41:31 UTC (rev 7251) @@ -1168,6 +1168,10 @@ } public static String formatException(PyObject type, PyObject value) { + return formatException(type, value, false); + } + + public static String formatException(PyObject type, PyObject value, boolean useRepr) { StringBuilder buf = new StringBuilder(); if (PyException.isExceptionClass(type)) { @@ -1178,10 +1182,7 @@ } PyObject moduleName = type.__findattr__("__module__"); if (moduleName == null) { - // XXX: Workaround the fact that PyClass lacks __module__ - if (!(type instanceof PyClass)) { - buf.append("<unknown>"); - } + buf.append("<unknown>"); } else { String moduleStr = moduleName.toString(); if (!moduleStr.equals("exceptions")) { @@ -1191,11 +1192,11 @@ } buf.append(className); } else { - buf.append(type.__str__()); + buf.append(useRepr ? type.__repr__() : type.__str__()); } if (value != null && value != Py.None) { // only print colon if the str() of the object is not the empty string - PyObject s = value.__str__(); + PyObject s = useRepr ? value.__repr__() : value.__str__(); if (!(s instanceof PyString) || s.__len__() != 0) { buf.append(": "); } @@ -1204,7 +1205,18 @@ return buf.toString(); } + public static void writeUnraisable(Exception exc, PyObject obj) { + if (exc instanceof PyException) { + PyException pye = (PyException) exc; + stderr.println(String.format("Exception %s in %s ignored", + formatException(pye.type, pye.value, true), obj)); + } else { + // XXX: this could be better handled + exc.printStackTrace(); + } + } + /* Equivalent to Python's assert statement */ public static void assert_(PyObject test, PyObject message) { if (!test.__nonzero__()) { Modified: trunk/jython/src/org/python/core/PyClass.java =================================================================== --- trunk/jython/src/org/python/core/PyClass.java 2011-03-20 06:07:17 UTC (rev 7250) +++ trunk/jython/src/org/python/core/PyClass.java 2011-03-20 19:41:31 UTC (rev 7251) @@ -229,13 +229,8 @@ @Override public String toString() { PyObject mod = __dict__.__finditem__("__module__"); - String smod; - if (mod == null || !(mod instanceof PyString)) { - smod = "<unknown>"; - } else { - smod = ((PyString) mod).toString(); - } - return "<class " + smod + "." + __name__ + " at " + Py.idstr(this) + ">"; + String modStr = (mod == null || !Py.isInstance(mod, PyString.TYPE)) ? "?" : mod.toString(); + return String.format("<class %s.%s at %s>", modStr, __name__, Py.idstr(this)); } public boolean isSubClass(PyClass superclass) { Modified: trunk/jython/src/org/python/core/PyFinalizableInstance.java =================================================================== --- trunk/jython/src/org/python/core/PyFinalizableInstance.java 2011-03-20 06:07:17 UTC (rev 7250) +++ trunk/jython/src/org/python/core/PyFinalizableInstance.java 2011-03-20 19:41:31 UTC (rev 7251) @@ -12,14 +12,14 @@ * This is a special class due to performance. Defining * finalize() on a class, makes the class a lot slower. */ +public class PyFinalizableInstance extends PyInstance { -public class PyFinalizableInstance extends PyInstance -{ public PyFinalizableInstance(PyClass iclass) { super(iclass); } // __del__ method is invoked upon object finalization. + @Override protected void finalize() { try { instclass.__del__.__call__(this); @@ -28,12 +28,10 @@ PyObject method = instclass.__del__; try { method = __findattr__("__del__"); - } catch (PyException e) { ; } - - Py.stderr.println("Exception " + - Py.formatException(exc.type, exc.value) + - " in " + method + - " ignored"); + } catch (PyException e) { + // nothing we can do + } + Py.writeUnraisable(exc, method); } } } Modified: trunk/jython/src/org/python/core/PyInstance.java =================================================================== --- trunk/jython/src/org/python/core/PyInstance.java 2011-03-20 06:07:17 UTC (rev 7250) +++ trunk/jython/src/org/python/core/PyInstance.java 2011-03-20 19:41:31 UTC (rev 7251) @@ -381,18 +381,9 @@ */ protected PyString makeDefaultRepr() { PyObject mod = instclass.__dict__.__finditem__("__module__"); - String smod; - if(mod == Py.None) { - smod = ""; - } else { - if(mod == null || !(mod instanceof PyString)) { - smod = "<unknown>."; - } else { - smod = ((PyString)mod).toString() + '.'; - } - } - return new PyString("<" + smod + instclass.__name__ + " instance at " + - Py.idstr(this) + ">"); + String modStr = (mod == null || !Py.isInstance(mod, PyString.TYPE)) ? "?" : mod.toString(); + return new PyString(String.format("<%s.%s instance at %s>", modStr, instclass.__name__, + Py.idstr(this))); } @Override Modified: trunk/jython/src/org/python/modules/_weakref/AbstractReference.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/AbstractReference.java 2011-03-20 06:07:17 UTC (rev 7250) +++ trunk/jython/src/org/python/modules/_weakref/AbstractReference.java 2011-03-20 19:41:31 UTC (rev 7251) @@ -27,9 +27,7 @@ try { callback.__call__(this); } catch (Exception exc) { - // XXX: Should trigger the equiv. of CPython's - // PyErr_WriteUnraisable - exc.printStackTrace(); + Py.writeUnraisable(exc, callback); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |