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:22:57 UTC

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

Author: hlship
Date: Wed Apr 13 22:22:57 2011
New Revision: 1091941

URL: http://svn.apache.org/viewvc?rev=1091941&view=rev
Log:
TAP5-853: Handle access to properties (requiring invocation of a getter method)

Modified:
    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/PropertyConduitSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java?rev=1091941&r1=1091940&r2=1091941&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:22:57 2011
@@ -1309,12 +1309,6 @@ public class PropertyConduitSourceImpl i
 
             final Class termClass = GenericsUtils.asClass(termType);
 
-            final Class wrappedType = ClassFabUtils.getWrapperType(termClass);
-
-            String wrapperTypeName = ClassFabUtils.toJavaClassName(wrappedType);
-
-            final String variableName = nextVariableName(wrappedType);
-
             InstructionBuilderCallback callback = new InstructionBuilderCallback()
             {
                 public void doBuild(InstructionBuilder builder)
@@ -1323,14 +1317,14 @@ public class PropertyConduitSourceImpl i
                     {
                         String typeName = PlasticUtils.toTypeName(termClass);
 
-                        builder.getField(PlasticUtils.toTypeName(info.getField().getDeclaringClass()), info.getField()
-                                .getName(), typeName);
+                        builder.getField(info.getField().getDeclaringClass().getName(), info.getField().getName(),
+                                PlasticUtils.toTypeName(info.getField().getType()));
 
                         builder.unboxPrimitive(typeName);
                     }
                     else
                     {
-                        createPlasticMethodInvocation(term, method);
+                        createPlasticMethodInvocation(builder, term, method, info);
                     }
 
                     builder.dupe(0).ifNull(new InstructionBuilderCallback()
@@ -1350,18 +1344,35 @@ public class PropertyConduitSourceImpl i
 
                                     builder.invokeStatic(PropertyConduitSourceImpl.class, void.class, "nullTerm",
                                             String.class, String.class, Object.class);
+
+                                    // Verifier doesn't realize that the static method throws and exception.
+                                    // Add code, that never executes, to return the null on top of the stack
+
+                                    builder.returnResult();
                             }
                         }
                     }, null);
+
+                    if (info.isCastRequired())
+                    {
+                        builder.checkcast(termClass);
+                    }
                 }
             };
 
             return new PlasticTerm(termType, callback);
         }
 
-        private void createPlasticMethodInvocation(Tree term, Method method)
+        private void createPlasticMethodInvocation(InstructionBuilder builder, Tree node, Method method,
+                ExpressionTermInfo info)
         {
-            // TODO Auto-generated method stub
+            if (method.getParameterTypes().length > 0)
+                throw new RuntimeException("invoking methods with parameters not yet re-implemented");
+
+            // TODO: Get subexpressions, use TypeCoercer to get them to right type.
+
+            builder.invoke(method.getDeclaringClass(), method.getReturnType(), method.getName(),
+                    method.getParameterTypes());
 
         }