[Jython-checkins] jython (merge default -> default): Merged upstream

frank.wierzbicki jython-checkins at python.org
Wed Mar 14 04:09:31 CET 2012


http://hg.python.org/jython/rev/6e947ec9b01a
changeset:   6340:6e947ec9b01a
parent:      6339:d7a0bfce8485
parent:      6338:1afee01eac12
user:        Jim Baker <jbaker at zyasoft.com>
date:        Tue Mar 13 13:07:44 2012 -0700
summary:
  Merged upstream

files:
  src/org/python/core/AnnotationReader.java                        |  21 +-
  src/org/python/expose/generate/DescriptorVisitor.java            |   1 +
  src/org/python/expose/generate/ExposedFieldFinder.java           |   2 +-
  src/org/python/expose/generate/RestrictiveAnnotationVisitor.java |   7 +-
  src/org/python/modules/jffi/AsmClassBuilder.java                 |   2 +-
  src/org/python/modules/jffi/EmptyVisitor.java                    |  93 ----------
  src/org/python/modules/jffi/SkinnyMethodAdapter.java             |  23 +-
  7 files changed, 24 insertions(+), 125 deletions(-)


diff --git a/src/org/python/core/AnnotationReader.java b/src/org/python/core/AnnotationReader.java
--- a/src/org/python/core/AnnotationReader.java
+++ b/src/org/python/core/AnnotationReader.java
@@ -50,17 +50,18 @@
     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
         nextVisitIsVersion = desc.equals("Lorg/python/compiler/APIVersion;");
         nextVisitIsMTime = desc.equals("Lorg/python/compiler/MTime;");
-        return super.visitAnnotation(desc, visible);
-    }
+        return new AnnotationVisitor(Opcodes.ASM4) {
 
-    public void visit(String name, Object value) {
-        if (nextVisitIsVersion) {
-            version = (Integer)value;
-            nextVisitIsVersion = false;
-        } else if (nextVisitIsMTime) {
-            mtime = (Long)value;
-            nextVisitIsVersion = false;
-        }
+        	public void visit(String name, Object value) {
+        		if (nextVisitIsVersion) {
+        			version = (Integer)value;
+        			nextVisitIsVersion = false;
+        		} else if (nextVisitIsMTime) {
+        			mtime = (Long)value;
+        			nextVisitIsVersion = false;
+        		}
+        	}
+		};
     }
 
     public int getVersion() {
diff --git a/src/org/python/expose/generate/DescriptorVisitor.java b/src/org/python/expose/generate/DescriptorVisitor.java
--- a/src/org/python/expose/generate/DescriptorVisitor.java
+++ b/src/org/python/expose/generate/DescriptorVisitor.java
@@ -12,6 +12,7 @@
 
     @Override
     public void visit(String name, Object value) {
+    	System.err.println("DescriptorVisitor::visit:: " + name + " value: " + value);
         if (name.equals("name")) {
             val = (String)value;
         } else if (name.equals("doc")) {
diff --git a/src/org/python/expose/generate/ExposedFieldFinder.java b/src/org/python/expose/generate/ExposedFieldFinder.java
--- a/src/org/python/expose/generate/ExposedFieldFinder.java
+++ b/src/org/python/expose/generate/ExposedFieldFinder.java
@@ -14,7 +14,7 @@
     private String doc;
 
     public ExposedFieldFinder(String name, FieldVisitor delegate) {
-        super(Opcodes.ASM4, delegate);
+        super(Opcodes.ASM4);
         fieldName = name;
         this.delegate = delegate;
     }
diff --git a/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java b/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java
--- a/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java
+++ b/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java
@@ -9,12 +9,9 @@
  */
 public class RestrictiveAnnotationVisitor extends AnnotationVisitor {
 
-    public RestrictiveAnnotationVisitor(int arg0) {
-        super(arg0);
-    }
-
     public RestrictiveAnnotationVisitor() {
-        this(Opcodes.ASM4);
+        super(Opcodes.ASM4);
+        System.err.println("RestrictiveAnnotationVisitor:: constructed ");
     }
 
     public AnnotationVisitor visitAnnotation(String name, String desc) {
diff --git a/src/org/python/modules/jffi/AsmClassBuilder.java b/src/org/python/modules/jffi/AsmClassBuilder.java
--- a/src/org/python/modules/jffi/AsmClassBuilder.java
+++ b/src/org/python/modules/jffi/AsmClassBuilder.java
@@ -142,7 +142,7 @@
             Constructor<? extends ClassVisitor> c = tmvClass.getDeclaredConstructor(PrintWriter.class);
             return c.newInstance(out);
         } catch (Throwable t) {
-            return new EmptyVisitor();
+            return null;
         }
     }
 
diff --git a/src/org/python/modules/jffi/EmptyVisitor.java b/src/org/python/modules/jffi/EmptyVisitor.java
deleted file mode 100644
--- a/src/org/python/modules/jffi/EmptyVisitor.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.python.modules.jffi;
-
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-
-public class EmptyVisitor extends ClassVisitor {
-
-    AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM4) {
-
-        @Override
-        public AnnotationVisitor visitAnnotation(
-            String name,
-            String desc)
-        {
-            return this;
-        }
-
-        @Override
-        public AnnotationVisitor visitArray(String name) {
-            return this;
-        }
-    };
-
-    public EmptyVisitor() {
-        super(Opcodes.ASM4);
-    }
-
-    @Override
-    public AnnotationVisitor visitAnnotation(
-        String desc,
-        boolean visible)
-    {
-        return av;
-    }
-
-    @Override
-    public FieldVisitor visitField(
-        int access,
-        String name,
-        String desc,
-        String signature,
-        Object value)
-    {
-        return new FieldVisitor(Opcodes.ASM4) {
-
-            @Override
-            public AnnotationVisitor visitAnnotation(
-                String desc,
-                boolean visible)
-            {
-                return av;
-            }
-        };
-    }
-
-    @Override
-    public MethodVisitor visitMethod(
-        int access,
-        String name,
-        String desc,
-        String signature,
-        String[] exceptions)
-    {
-        return new MethodVisitor(Opcodes.ASM4) {
-
-            @Override
-            public AnnotationVisitor visitAnnotationDefault() {
-                return av;
-            }
-
-            @Override
-            public AnnotationVisitor visitAnnotation(
-                String desc,
-                boolean visible)
-            {
-                return av;
-            }
-
-            @Override
-            public AnnotationVisitor visitParameterAnnotation(
-                int parameter,
-                String desc,
-                boolean visible)
-            {
-                return av;
-            }
-        };
-    }
-}
\ No newline at end of file
diff --git a/src/org/python/modules/jffi/SkinnyMethodAdapter.java b/src/org/python/modules/jffi/SkinnyMethodAdapter.java
--- a/src/org/python/modules/jffi/SkinnyMethodAdapter.java
+++ b/src/org/python/modules/jffi/SkinnyMethodAdapter.java
@@ -10,7 +10,8 @@
 package org.python.modules.jffi;
 
 import org.objectweb.asm.*;
-import org.objectweb.asm.util.ASMifier;
+import org.objectweb.asm.util.Printer;
+import org.objectweb.asm.util.Textifier;
 import org.objectweb.asm.util.TraceMethodVisitor;
 
 import java.io.PrintStream;
@@ -25,33 +26,25 @@
 public class SkinnyMethodAdapter extends MethodVisitor implements Opcodes {
     private final static boolean DEBUG = Boolean.getBoolean("jython.compile.dump");
     private MethodVisitor method;
+    private Printer printer;
     private String name;
     private ClassVisitor cv;
     
-    /** Creates a new instance of SkinnyMethodAdapter */
-    public SkinnyMethodAdapter(MethodVisitor method) {
-    	super(Opcodes.ASM4);
-        setMethodVisitor(method);
-    }
-
     public SkinnyMethodAdapter(ClassVisitor cv, int flags, String name, String signature, String something, String[] exceptions) {
-    	super(Opcodes.ASM4);
+    	super(ASM4);
         setMethodVisitor(cv.visitMethod(flags, name, signature, something, exceptions));
         this.cv = cv;
         this.name = name;
     }
     
-    public SkinnyMethodAdapter() {
-    	super(Opcodes.ASM4);
-    }
-    
     public MethodVisitor getMethodVisitor() {
         return method;
     }
     
     public void setMethodVisitor(MethodVisitor mv) {
         if (DEBUG) {
-            this.method = new TraceMethodVisitor(mv, new ASMifier());
+        	this.printer = new Textifier();
+            this.method = new TraceMethodVisitor(mv, printer);
         } else {
             this.method = mv;
         }
@@ -533,7 +526,7 @@
             } else {
                 pw.write("*** Dumping ***\n");
             }
-            ((TraceMethodVisitor)getMethodVisitor()).p.print(pw);
+            printer.print(pw);
             pw.flush();
         }
         getMethodVisitor().visitMaxs(1, 1);
@@ -898,7 +891,7 @@
         if (DEBUG) {
             PrintWriter pw = new PrintWriter(System.out);
             pw.write("*** Dumping ***\n");
-            ((TraceMethodVisitor)getMethodVisitor()).p.print(pw);
+            printer.print(pw);
             pw.flush();
         }
         getMethodVisitor().visitMaxs(arg0, arg1);

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list