You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/04/14 00:23:42 UTC

svn commit: r1091952 - in /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services: PropertyConduitDelegate.java PropertyConduitSourceImpl.java

Author: hlship
Date: Wed Apr 13 22:23:42 2011
New Revision: 1091952

URL: http://svn.apache.org/viewvc?rev=1091952&view=rev
Log:
TAP5-853: Clean up some casting/boxing/unboxing logic when building parameters to method invocations

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitDelegate.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitDelegate.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitDelegate.java?rev=1091952&r1=1091951&r2=1091952&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitDelegate.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitDelegate.java Wed Apr 13 22:23:42 2011
@@ -70,7 +70,7 @@ public class PropertyConduitDelegate
         return new IntegerRange(from, to);
     }
 
-    protected final <T> T coerce(Object value, Class<T> type)
+    public final <T> T coerce(Object value, Class<T> type)
     {
         return typeCoercer.coerce(value, type);
     }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java?rev=1091952&r1=1091951&r2=1091952&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java Wed Apr 13 22:23:42 2011
@@ -873,7 +873,17 @@ public class PropertyConduitSourceImpl i
                         break;
 
                     case TRUE:
+
+                        builder.loadConstant(1).boxPrimitive("boolean");
+
+                        return Boolean.class;
+
                     case FALSE:
+
+                        builder.loadConstant(0).boxPrimitive("boolean");
+
+                        return Boolean.class;
+
                     case LIST:
                         throw new RuntimeException("Not yet re-implemented.");
 
@@ -1264,10 +1274,18 @@ public class PropertyConduitSourceImpl i
                 if (!parameterType.isAssignableFrom(expressionType))
                 {
                     builder.loadThis().getField(delegateField);
-                    builder.swap().loadTypeConstant(parameterType);
-                    builder.invoke(DelegateMethods.COERCE).checkcast(parameterType);
+                    // TODO: Will this work for wide primitives?
+                    builder.swap().loadTypeConstant(PlasticUtils.toWrapperType(parameterType));
+                    builder.invoke(DelegateMethods.COERCE);
 
-                    // TODO: unboxing if primitive
+                    if (parameterType.isPrimitive())
+                    {
+                        builder.castOrUnbox(parameterType.getName());
+                    }
+                    else
+                    {
+                        builder.checkcast(parameterType);
+                    }
                 }
 
                 // And that should leave an object of the correct type on the stack,