flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [11/18] git commit: [flex-falcon] [refs/heads/develop] - debug version of FlexJSStore now runs. minified version does not due to GCC having problems with the property names in the defineProperties structure.
Date Wed, 08 Apr 2015 23:05:17 GMT
debug version of FlexJSStore now runs.  minified version does not due to GCC having problems
with the property names in the defineProperties structure.


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

Branch: refs/heads/develop
Commit: d9658d627a22861494b0bd4f3c351e72d016ed92
Parents: 7328a52
Author: Alex Harui <aharui@apache.org>
Authored: Fri Apr 3 09:32:19 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Apr 3 09:32:19 2015 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 172 ++++++++++++++-----
 .../codegen/mxml/flexjs/MXMLFlexJSEmitter.java  |  31 ++--
 2 files changed, 144 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d9658d62/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 87a39f2..cbf89b6 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
@@ -121,6 +121,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     }
     
     HashMap<String, PropertyNodes> propertyMap = new HashMap<String, PropertyNodes>();
+    ArrayList<String> bindableVars = new ArrayList<String>();
     
     @Override
     protected String getIndent(int numIndent)
@@ -223,6 +224,13 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
             }
         }
         
+        emitBindableVariables(node.getDefinition());
+        
+        emitASGettersAndSetters(node.getDefinition());
+    }
+    
+    public void emitASGettersAndSetters(IClassDefinition definition)
+    {
         if (!propertyMap.isEmpty())
         {
             write(JSGoogEmitterTokens.OBJECT);
@@ -440,50 +448,82 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         }
         if (node.getNodeID() == ASTNodeID.BindableVariableID)
         {
-            // [Bindable]
-            writeNewline(ASEmitterTokens.SEMICOLON.getToken());
-            writeNewline();
-            writeNewline("/**");
-            writeNewline("@expose");
-            writeNewline(" */");
-            writeNewline(formatQualifiedName(definition.getQualifiedName())
-                    + ASEmitterTokens.MEMBER_ACCESS.getToken() + root
-                    + "get_" + node.getName()
-                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.EQUAL.getToken()
-                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.FUNCTION.getToken()
-                    + ASEmitterTokens.PAREN_OPEN.getToken() + ASEmitterTokens.PAREN_CLOSE.getToken()
-                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.BLOCK_OPEN.getToken());
-            writeNewline(ASEmitterTokens.RETURN.getToken() + ASEmitterTokens.SPACE.getToken()
-                    + ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
-                    + node.getName() + ASEmitterTokens.SEMICOLON.getToken());
-            writeNewline(ASEmitterTokens.BLOCK_CLOSE.getToken() + ASEmitterTokens.SEMICOLON.getToken());
-            writeNewline();
-            writeNewline("/**");
-            writeNewline("@expose");
-            writeNewline(" */");
-            writeNewline(formatQualifiedName(definition.getQualifiedName())
-                    + ASEmitterTokens.MEMBER_ACCESS.getToken() + root
-                    + "set_" + node.getName()
-                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.EQUAL.getToken()
-                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.FUNCTION.getToken()
-                    + ASEmitterTokens.PAREN_OPEN.getToken() + "value" + ASEmitterTokens.PAREN_CLOSE.getToken()
-                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.BLOCK_OPEN.getToken());
-            writeNewline("if (value != " + ASEmitterTokens.THIS.getToken()
-                    + ASEmitterTokens.MEMBER_ACCESS.getToken() + node.getName() + ") {");
-            writeNewline("    var oldValue = "
-                    + ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
-                    + node.getName() + ASEmitterTokens.SEMICOLON.getToken());
-            writeNewline("    " + ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
-                    + node.getName() + " = value;");
-            writeNewline("    this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(");
-            writeNewline("         this, \"" + node.getName() + "\", oldValue, value));");
-            writeNewline("}");
-            write(ASEmitterTokens.BLOCK_CLOSE.getToken());
-            
-            
+        	bindableVars.add(node.getName());            
         }
     }
 
+    private void emitBindableVariables(IClassDefinition cdef)
+    {
+    	if (bindableVars.size() > 0)
+    	{
+            write(JSGoogEmitterTokens.OBJECT);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSEmitterTokens.DEFINE_PROPERTIES);
+            write(ASEmitterTokens.PAREN_OPEN);
+            String qname = cdef.getQualifiedName();
+            write(formatQualifiedName(qname));
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSEmitterTokens.PROTOTYPE);        	
+            write(ASEmitterTokens.COMMA);
+            write(ASEmitterTokens.SPACE);
+            writeNewline(ASEmitterTokens.BLOCK_OPEN);
+            
+	        boolean firstTime = true;
+	        for (String varName : bindableVars)
+	        {
+	        	if (firstTime)
+	        		firstTime = false;
+	        	else
+	                write(ASEmitterTokens.COMMA);
+	            
+	        	emitBindableVarDefineProperty(varName, cdef);
+	        }
+            writeNewline(ASEmitterTokens.BLOCK_CLOSE);
+            write(ASEmitterTokens.PAREN_CLOSE);
+            write(ASEmitterTokens.SEMICOLON);
+
+    	}
+    }
+    
+    private void emitBindableVarDefineProperty(String name, IClassDefinition cdef)
+    {
+	    // 'PropName': {
+	    writeNewline(ASEmitterTokens.SINGLE_QUOTE.getToken() + name + 
+	    				ASEmitterTokens.SINGLE_QUOTE.getToken() + 
+	    				ASEmitterTokens.COLON.getToken() +
+	    				ASEmitterTokens.SPACE.getToken() +
+	    				ASEmitterTokens.BLOCK_OPEN.getToken());
+	    indentPush();
+	    writeNewline("/** @this {" + formatQualifiedName(cdef.getQualifiedName()) + "} */");
+	    writeNewline(ASEmitterTokens.GET.getToken() + ASEmitterTokens.COLON.getToken()
+	            + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.FUNCTION.getToken()
+	            + ASEmitterTokens.PAREN_OPEN.getToken() + ASEmitterTokens.PAREN_CLOSE.getToken()
+	            + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.BLOCK_OPEN.getToken());
+	    writeNewline(ASEmitterTokens.RETURN.getToken() + ASEmitterTokens.SPACE.getToken()
+	            + ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
+	            + name + "_" + ASEmitterTokens.SEMICOLON.getToken());
+	    indentPop();
+	    writeNewline(ASEmitterTokens.BLOCK_CLOSE.getToken() + ASEmitterTokens.COMMA.getToken());
+	    writeNewline();
+	    writeNewline("/** @this {" + formatQualifiedName(cdef.getQualifiedName()) + "} */");
+	    writeNewline(ASEmitterTokens.SET.getToken() + ASEmitterTokens.COLON.getToken()
+	            + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.FUNCTION.getToken()
+	            + ASEmitterTokens.PAREN_OPEN.getToken() + "value" + ASEmitterTokens.PAREN_CLOSE.getToken()
+	            + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.BLOCK_OPEN.getToken());
+	    writeNewline("if (value != " + ASEmitterTokens.THIS.getToken()
+	            + ASEmitterTokens.MEMBER_ACCESS.getToken() + name + "_) {");
+	    writeNewline("    var oldValue = "
+	            + ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
+	            + name + "_" + ASEmitterTokens.SEMICOLON.getToken());
+	    writeNewline("    " + ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
+	            + name + "_ = value;");
+	    writeNewline("    this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(");
+	    writeNewline("         this, \"" + name + "_\", oldValue, value));");
+	    writeNewline("}");
+	    write(ASEmitterTokens.BLOCK_CLOSE.getToken());
+	    write(ASEmitterTokens.BLOCK_CLOSE.getToken());
+    }
+
     /*
     @Override
     protected void emitAccessors(IAccessorNode node)
@@ -1364,11 +1404,49 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         FunctionNode fn = (FunctionNode) node;
         fn.parseFunctionBody(getProblems());
         
+        boolean isBindableSetter = false;
+        if (node instanceof SetterNode)
+        {
+	        IMetaInfo[] metaInfos = null;
+	        metaInfos = node.getMetaInfos();
+	        for (IMetaInfo metaInfo : metaInfos)
+	        {
+	            name = metaInfo.getTagName();
+	            if (name.equals("Bindable") && metaInfo.getAllAttributes().length ==
0)
+	            {
+	                isBindableSetter = true;
+	                break;
+	            }
+	        }
+        }
+        if (isBindableSetter)
+        {
+            IFunctionDefinition definition = node.getDefinition();
+            ITypeDefinition type = (ITypeDefinition) definition.getParent();
+            getDoc().emitMethodDoc(fn, project);
+            write(formatQualifiedName(type.getQualifiedName()));
+            if (!node.hasModifier(ASModifier.STATIC))
+            {
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                write(JSEmitterTokens.PROTOTYPE);
+            }
+
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write("__bindingWrappedSetter__");
+            writeToken(node.getName());
+            writeToken(ASEmitterTokens.EQUAL);
+            write(ASEmitterTokens.FUNCTION);
+            emitParameters(node.getParameterNodes());
+            //writeNewline();
+            emitMethodScope(node.getScopedNode());
+        }
     }
    
     @Override
     protected void emitObjectDefineProperty(IAccessorNode node)
     {
+    	//TODO: ajh  is this method needed anymore?
+    	
         FunctionNode fn = (FunctionNode) node;
         fn.parseFunctionBody(getProblems());
 
@@ -1436,8 +1514,8 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         }
         if (isBindableSetter)
         {
-            write(ASEmitterTokens.FUNCTION);
-            emitParameters(node.getParameterNodes());
+            //write(ASEmitterTokens.FUNCTION);
+            //emitParameters(node.getParameterNodes());
             write(ASEmitterTokens.SPACE);
             writeNewline(ASEmitterTokens.BLOCK_OPEN);
 
@@ -1449,9 +1527,9 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
             write(ASEmitterTokens.SPACE);
             write(ASEmitterTokens.THIS);
             write(ASEmitterTokens.MEMBER_ACCESS);
-            write("get_" + node.getName());
-            write(ASEmitterTokens.PAREN_OPEN);
-            write(ASEmitterTokens.PAREN_CLOSE);
+            write(node.getName());
+            //write(ASEmitterTokens.PAREN_OPEN);
+            //write(ASEmitterTokens.PAREN_CLOSE);
             writeNewline(ASEmitterTokens.SEMICOLON);
             
             // add change check
@@ -1481,7 +1559,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
             writeNewline("    this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(");
             writeNewline("         this, \"" + node.getName() + "\", oldValue, " + params[0].getName()
+ "));");
             write(ASEmitterTokens.BLOCK_CLOSE);
-            writeNewline(ASEmitterTokens.SEMICOLON);
+            //writeNewline(ASEmitterTokens.SEMICOLON);
             writeNewline();
             writeNewline();
         }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d9658d62/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 ef8ccfc..cf5d3df 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
@@ -210,6 +210,8 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
 
         emitScripts();
 
+        ((JSFlexJSEmitter)asEmitter).emitASGettersAndSetters(cdef);
+        
         emitEvents(cname);
 
         emitPropertyGetterSetters(cname);
@@ -844,7 +846,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
             	n++;
             }
         }
-    	if (n == 0)
+    	if (n == 0 && descriptorTree.size() == 0)
     		return;
     	
     	String formattedCName = formatQualifiedName(cname);
@@ -880,7 +882,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
                 writeNewline("}");
                 indentPop();
                 writeNewline("}");
-                if (i < n - 1)
+                if (i < n - 1 || descriptorTree.size() > 0)
                 	writeNewline("},");
                 else
                 {
@@ -890,7 +892,8 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
                 i++;
             }
         }
-        writeNewline("});");
+        if (descriptorTree.size() == 0)
+        	writeNewline("});");
     }
 
     //--------------------------------------------------------------------------    
@@ -903,18 +906,18 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
             MXMLDescriptorSpecifier root = descriptorTree.get(0);
             root.isTopNode = false;
     
-            writeNewline("/**");
-            writeNewline(" * @override");
-            writeNewline(" * @return {Array} the Array of UI element descriptors.");
-            writeNewline(" */");
-            writeNewline(formatQualifiedName(cname) + ".prototype.get_MXMLDescriptor = function()");
+            indentPush();
+            writeNewline("'MXMLDescriptor': {");
+            writeNewline("/** @this {" + formatQualifiedName(cname) + "} */");
+            indentPush();
+            writeNewline("get: function() {");
             indentPush();
             writeNewline("{");
             writeNewline("if (this.mxmldd == undefined)");
             indentPush();
             writeNewline("{");
             writeNewline("/** @type {Array} */");
-            writeNewline("var arr = " + formatQualifiedName(cname) + ".base(this, 'get_MXMLDescriptor');");
+            writeNewline("var arr = org_apache_flex_utils_Language.superGetter(" + formatQualifiedName(cname)
+ ",this, 'MXMLDescriptor');");
             writeNewline("/** @type {Array} */");
             indentPop();
             indentPop();
@@ -938,10 +941,14 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
             writeNewline("}");
             indentPop();
             writeNewline("return this.mxmldd;");
-            writeNewline("};");
-            writeNewline();
+            writeNewline("}");
+            indentPop();
+            writeNewline("}");
+            indentPop();
+            writeNewline("}");
+        	writeNewline("});");
         }
-        
+   
     }
 
     //--------------------------------------------------------------------------    


Mime
View raw message