flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [3/3] git commit: [flex-falcon] [refs/heads/develop] - handle bindings as values of state-specific properties. The value has to get set on the SetProperty, not on the actual property
Date Fri, 17 Oct 2014 05:45:33 GMT
handle bindings as values of state-specific properties.  The value has to get set on the SetProperty,
not on the actual property


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/c932239c
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/c932239c
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/c932239c

Branch: refs/heads/develop
Commit: c932239cf893b78c85667d819950b8ac338fa92f
Parents: cfb9242
Author: Alex Harui <aharui@apache.org>
Authored: Thu Oct 16 22:45:12 2014 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Oct 16 22:45:12 2014 -0700

----------------------------------------------------------------------
 .../as/codegen/MXMLClassDirectiveProcessor.java | 26 ++++++++++++++++++--
 .../codegen/databinding/BindingDatabase.java    |  5 ++--
 .../codegen/databinding/BindingInfo.java        |  8 ++++++
 .../databinding/MXMLBindingDirectiveHelper.java |  5 ++--
 4 files changed, 37 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c932239c/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
b/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
index 8602fdf..50fe14a 100644
--- a/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
+++ b/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
@@ -138,6 +138,7 @@ import org.apache.flex.compiler.definitions.references.ReferenceFactory;
 import org.apache.flex.compiler.exceptions.CodegenInterruptedException;
 import org.apache.flex.compiler.internal.abc.FunctionGeneratorHelper;
 import org.apache.flex.compiler.internal.caches.CSSDocumentCache;
+import org.apache.flex.compiler.internal.codegen.databinding.BindingInfo;
 import org.apache.flex.compiler.internal.codegen.databinding.MXMLBindingDirectiveHelper;
 import org.apache.flex.compiler.internal.css.codegen.CSSCompilationSession;
 import org.apache.flex.compiler.internal.css.codegen.CSSReducer;
@@ -286,6 +287,11 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
     private static final String INSTANCE_INITIALIZER_NAME_BASE = "i";
     
     /**
+     * Autogenerated bindable overrides are named _bo0, _bo1, etc.
+     */
+    private static final String BINDABLE_OVERRIDE_NAME_BASE = "_bo";
+    
+    /**
      * constants used to generate old-style XMLNode's from the XML tag
      */
     private static final Object[] CONSTRUCT_XML_LIST_OPERANDS = new Object[] { ABCGeneratingReducer.xmlListType,
1 };
@@ -476,6 +482,12 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
     
     /**
      * An incrementing counter used to create the names of the
+     * auto-generated bindable overrides.
+     */
+    private int bindableOverrideCounter = 0;
+    
+    /**
+     * An incrementing counter used to create the names of the
      * auto-generated event handler methods.
      */
     private int eventHandlerCounter = 0;
@@ -4403,7 +4415,7 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
             context.addInstruction(OP_getproperty, overrideName);
             
             boolean valueIsDataBound = isDataBindingNode(propertyOrStyleNode.getChild(0));
-            context.pushNumericConstant(valueIsDataBound ? 2 : 3);
+            context.pushNumericConstant(3);
             // Set its 'target' property to the id of the object
             // whose property or style this override will set.
             context.addInstruction(OP_pushstring, "target");
@@ -4424,12 +4436,22 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
                 context.addInstruction(OP_pushstring, "value");
                 processNode(propertyOrStyleValueNode, context); // push value
             }
+            else
+            {
+                String overrideID = BINDABLE_OVERRIDE_NAME_BASE + Integer.toString(bindableOverrideCounter++);
+                context.addInstruction(OP_pushstring, "id");
+                context.addInstruction(OP_pushtrue);
+                context.addInstruction(OP_pushstring, overrideID);
+                addVariableTrait(new Name(overrideID), overrideName);
+                BindingInfo bi = bindingDirectiveHelper.visitNode((IMXMLDataBindingNode)propertyOrStyleNode.getChild(0));
+                bi.setDestinationString(overrideID + ".value");
+            }
             
             context.pushNumericConstant(0); // styles
             context.pushNumericConstant(0); // effects
             context.pushNumericConstant(0); // events
             context.addInstruction(OP_pushnull);
-            context.incrementCounter(IL.MXML_OVERRIDE_PROPERTIES, valueIsDataBound ? 12 :
15);      
+            context.incrementCounter(IL.MXML_OVERRIDE_PROPERTIES, 15);      
 
         }
         else

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c932239c/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingDatabase.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingDatabase.java
b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingDatabase.java
index ff66319..9158b9e 100644
--- a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingDatabase.java
+++ b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingDatabase.java
@@ -117,14 +117,15 @@ public class BindingDatabase
     * May find bindings and watchers already marked for creation by other nodes and re-use
them.
     * 
     */
-   public void analyze(IMXMLDataBindingNode node, Collection<ICompilerProblem> problems,
MXMLClassDirectiveProcessor host)
+   public BindingInfo analyze(IMXMLDataBindingNode node, Collection<ICompilerProblem>
problems, MXMLClassDirectiveProcessor host)
    {
        BindingInfo bindingInfo = BindingAnalyzer.analyze(node, this, problems, this.bindingInfoSet.size(),
host);
        this.bindingInfoSet.add(bindingInfo);
        
        // now watchers
        WatcherAnalyzer watcherAnalyzer = new WatcherAnalyzer(this, problems, bindingInfo,
host.getProject());
-       watcherAnalyzer.analyze();     
+       watcherAnalyzer.analyze();   
+       return bindingInfo;
    }
 
     /**

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c932239c/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java
b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java
index daf1fc6..7267f13 100644
--- a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java
+++ b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java
@@ -228,6 +228,14 @@ public class BindingInfo implements Comparable<BindingInfo>
     }
     
     /**
+     * param the name of the binding destination property
+     */
+    public void setDestinationString(String newDestString)
+    {
+       destinationString = newDestString;
+    }
+    
+    /**
      * just for debugging
      */
     @Override

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c932239c/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
index 9366f25..08573c0 100644
--- a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
+++ b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
@@ -110,11 +110,10 @@ public class MXMLBindingDirectiveHelper
     /**
      * host should visit all the databinding nodes before trying to codegen them
      */
-    public void visitNode(IMXMLDataBindingNode node)
+    public BindingInfo visitNode(IMXMLDataBindingNode node)
     { 
         // analyze the node for later CG
-       bindingDataBase.analyze(node, host.getProblems(), host);
-
+       return bindingDataBase.analyze(node, host.getProblems(), host);
     }
 
     /**


Mime
View raw message