flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/2] git commit: [flex-falcon] [refs/heads/develop] - handle state dependent nodes that specify an attribute more than once
Date Mon, 05 Jan 2015 23:20:32 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop d1c44a4dd -> 2591c553c


handle state dependent nodes that specify an attribute more than once


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

Branch: refs/heads/develop
Commit: 5cfc750735604afd401f2094c7d7046c6349f598
Parents: d1c44a4
Author: Alex Harui <aharui@apache.org>
Authored: Wed Dec 31 08:30:56 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Dec 31 08:30:56 2014 -0800

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 10 +++++++
 .../codegen/mxml/flexjs/MXMLEventSpecifier.java | 15 ++++++++++
 .../codegen/mxml/flexjs/MXMLFlexJSEmitter.java  |  9 ++++++
 .../tree/mxml/MXMLClassReferenceNodeBase.java   | 30 +++++++++++++++++---
 4 files changed, 60 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5cfc7507/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 2a970c3..d1afba4 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -76,6 +76,7 @@ import org.apache.flex.compiler.tree.as.IAccessorNode;
 import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
 import org.apache.flex.compiler.tree.as.IClassNode;
 import org.apache.flex.compiler.tree.as.IDefinitionNode;
+import org.apache.flex.compiler.tree.as.IDynamicAccessNode;
 import org.apache.flex.compiler.tree.as.IExpressionNode;
 import org.apache.flex.compiler.tree.as.IForLoopNode;
 import org.apache.flex.compiler.tree.as.IFunctionCallNode;
@@ -784,6 +785,15 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
                                 break;
                             }
                         }
+                        if (pnode instanceof IDynamicAccessNode)
+                        {
+                            if (thisNode != pnode.getChild(1))
+                            {
+                                // can't be an assignment because 
+                                // we're on the left side of a DynamicAccessNode
+                                break;
+                            }
+                        }
                         if (pnode == leftNode)
                         {
                             isAssignment = true;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5cfc7507/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLEventSpecifier.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLEventSpecifier.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLEventSpecifier.java
index 44c04c3..b3d8c04 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLEventSpecifier.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLEventSpecifier.java
@@ -19,6 +19,9 @@
 
 package org.apache.flex.compiler.internal.codegen.mxml.flexjs;
 
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
 
 /**
@@ -44,6 +47,16 @@ public class MXMLEventSpecifier extends MXMLNodeSpecifier
     //
     //--------------------------------------------------------------------------
 
+    List<String> nameMap = Arrays.asList(
+    		"rollOver",
+    		"rollOut",
+    		"mouseDown",
+    		"mouseMove",
+    		"mouseOver",
+    		"mouseOut",
+    		"mouseUp"
+    );
+    
     //---------------------------------
     //    eventHandler
     //---------------------------------
@@ -70,6 +83,8 @@ public class MXMLEventSpecifier extends MXMLNodeSpecifier
     {
         String handler = ASEmitterTokens.THIS.getToken()
                 + ASEmitterTokens.MEMBER_ACCESS.getToken() + eventHandler;
+        if (nameMap.contains(name))
+        	name = name.toLowerCase();
         writeSimpleDescriptor(name, null, handler, writeNewline);
 
         return sb.toString();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5cfc7507/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
index ee62cdc..f052173 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
@@ -935,6 +935,9 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     @Override
     public void emitEventSpecifier(IMXMLEventSpecifierNode node)
     {
+    	if (isStateDependent(node) && !inStatesOverride)
+    		return;
+    	
         IDefinition cdef = node.getDefinition();
 
         MXMLDescriptorSpecifier currentDescriptor = getCurrentDescriptor("i");
@@ -1204,6 +1207,8 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
      */
     void emitEventOverride(IMXMLEventSpecifierNode eventNode)
     {
+        inStatesOverride = true;
+        
         MXMLDescriptorSpecifier currentInstance = getCurrentDescriptor("ps");
         FlexProject project = (FlexProject) getMXMLWalker().getProject();
         Name eventOverride = project.getEventOverrideClassName();
@@ -1252,6 +1257,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         handler.value = ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
+ eventHandler;
         setEvent.propertySpecifiers.add(handler);
         
+        inStatesOverride = false;
     }
 
     public void emitInstanceOverride(IMXMLInstanceNode instanceNode)
@@ -1460,6 +1466,9 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         if (isDataboundProp(node))
             return;
         
+        if (isStateDependent(node))
+            return;
+        
         IDefinition cdef = node.getDefinition();
 
         IASNode cnode = node.getChild(0);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5cfc7507/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
b/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
index bc4ef24..43c8ac3 100644
--- a/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
+++ b/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
@@ -118,6 +118,13 @@ abstract class MXMLClassReferenceNodeBase extends MXMLNodeBase implements
IMXMLC
      * be null.
      */
     private Map<String, IMXMLPropertySpecifierNode> propertyNodeMap;
+    
+    /**
+     * All child property nodes.  The propertyNodeMap only has the last value
+     * specified for a property name.  There can be more than one value
+     * specified if there is different values for different states.
+     */
+    private List<IMXMLPropertySpecifierNode> allPropertyNodes;
 
     /**
      * A map of child nodes of this node which specify events. The keys are the
@@ -126,6 +133,13 @@ abstract class MXMLClassReferenceNodeBase extends MXMLNodeBase implements
IMXMLC
     private Map<String, IMXMLEventSpecifierNode> eventNodeMap;
 
     /**
+     * All child event nodes.  The eventNodeMap only has the last value
+     * specified for a event name.  There can be more than one value
+     * specified if there is different values for different states.
+     */
+    private List<IMXMLEventSpecifierNode> allEventNodes;
+    
+    /**
      * A map of suffix (specifying a state or state group) to the child nodes
      * with this suffix.
      */
@@ -297,16 +311,24 @@ abstract class MXMLClassReferenceNodeBase extends MXMLNodeBase implements
IMXMLC
                 if (child instanceof IMXMLPropertySpecifierNode)
                 {
                     if (propertyNodeMap == null)
+                    {
                         propertyNodeMap = new HashMap<String, IMXMLPropertySpecifierNode>();
+                        allPropertyNodes = new ArrayList<IMXMLPropertySpecifierNode>();
+                    }
 
                     propertyNodeMap.put(child.getName(), (IMXMLPropertySpecifierNode)child);
+                    allPropertyNodes.add((IMXMLPropertySpecifierNode)child);
                 }
                 else if (child instanceof IMXMLEventSpecifierNode)
                 {
                     if (eventNodeMap == null)
+                    {
                         eventNodeMap = new HashMap<String, IMXMLEventSpecifierNode>();
+                        allEventNodes = new ArrayList<IMXMLEventSpecifierNode>();
+                    }
 
                     eventNodeMap.put(child.getName(), (IMXMLEventSpecifierNode)child);
+                    allEventNodes.add((IMXMLEventSpecifierNode)child);
                 }
 
                 if (child instanceof IMXMLSpecifierNode)
@@ -330,8 +352,8 @@ abstract class MXMLClassReferenceNodeBase extends MXMLNodeBase implements
IMXMLC
     @Override
     public IMXMLPropertySpecifierNode[] getPropertySpecifierNodes()
     {
-        return propertyNodeMap != null ?
-                propertyNodeMap.values().toArray(new IMXMLPropertySpecifierNode[0]) :
+        return allPropertyNodes != null ?
+        		allPropertyNodes.toArray(new IMXMLPropertySpecifierNode[0]) :
                 null;
     }
 
@@ -344,8 +366,8 @@ abstract class MXMLClassReferenceNodeBase extends MXMLNodeBase implements
IMXMLC
     @Override
     public IMXMLEventSpecifierNode[] getEventSpecifierNodes()
     {
-        return eventNodeMap != null ?
-                eventNodeMap.values().toArray(new IMXMLEventSpecifierNode[0]) :
+        return allEventNodes != null ?
+                allEventNodes.toArray(new IMXMLEventSpecifierNode[0]) :
                 null;
     }
 


Mime
View raw message