From: <cg...@us...> - 2009-09-05 23:48:47
|
Revision: 6756 http://jython.svn.sourceforge.net/jython/?rev=6756&view=rev Author: cgroves Date: 2009-09-05 23:48:38 +0000 (Sat, 05 Sep 2009) Log Message: ----------- There's no reason to set the nextVisit booleans in visit as visitAnnotation will set both of them before every call to visit, and the wrong boolean was being set for mtime anyway. Bring things into line with the coding standards while I'm in here. Modified Paths: -------------- branches/customizable-proxymaker/src/org/python/core/AnnotationReader.java Modified: branches/customizable-proxymaker/src/org/python/core/AnnotationReader.java =================================================================== --- branches/customizable-proxymaker/src/org/python/core/AnnotationReader.java 2009-09-05 10:54:53 UTC (rev 6755) +++ branches/customizable-proxymaker/src/org/python/core/AnnotationReader.java 2009-09-05 23:48:38 UTC (rev 6756) @@ -11,21 +11,21 @@ import org.objectweb.asm.commons.EmptyVisitor; /** - * This class reads a classfile from a byte array and pulls out the value of the class annotation - * for APIVersion, which can then be retrieved by a call to getVersion(). - * - * Hopefully the use of ClassReader in this implementation is not too expensive. I suspect it is not + * Reads the bytecode of a compiled Python source file and pulls out the values of the class + * annotations for APIVersion and MTime. + */ +/* Hopefully the use of ClassReader in this implementation is not too expensive. I suspect it is not * since EmptyVisitor is just a bag of empty methods so shouldn't cost too much. If it turns out to * cost too much, we will want to implement a special purpose ClassReader that only reads out the * APIVersion annotation I think. */ public class AnnotationReader extends EmptyVisitor { - private boolean nextVisitIsVersion = false; - private boolean nextVisitIsMTime = false; + private boolean nextVisitIsVersion; + private boolean nextVisitIsMTime; - private int version = -1; - private long mtime = -1; + private int version; + private long mtime; /** * Reads the classfile bytecode in data and to extract the version. @@ -44,19 +44,19 @@ r.accept(this, 0); } + @Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { nextVisitIsVersion = desc.equals("Lorg/python/compiler/APIVersion;"); nextVisitIsMTime = desc.equals("Lorg/python/compiler/MTime;"); return this; } + @Override public void visit(String name, Object value) { if (nextVisitIsVersion) { version = (Integer)value; - nextVisitIsVersion = false; } else if (nextVisitIsMTime) { mtime = (Long)value; - nextVisitIsVersion = false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |