You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ms...@apache.org on 2012/12/21 20:08:06 UTC

svn commit: r1425097 - in /incubator/flex/whiteboard/mschmalle/falconjx: compiler.jx.tests/src/org/apache/flex/js/internal/driver/ compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/

Author: mschmalle
Date: Fri Dec 21 19:08:06 2012
New Revision: 1425097

URL: http://svn.apache.org/viewvc?rev=1425097&view=rev
Log:
Flex:FalconJx
- added TestInterface implemented interface and extends production

Added:
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java   (with props)
Modified:
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestClass.java
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestClass.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestClass.java?rev=1425097&r1=1425096&r2=1425097&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestClass.java (original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestClass.java Fri Dec 21 19:08:06 2012
@@ -32,7 +32,7 @@ import org.junit.Test;
 public class TestClass extends TestWalkerBase
 {
     //--------------------------------------------------------------------------
-    // Accessor
+    // Class
     //--------------------------------------------------------------------------
 
     @Test

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java?rev=1425097&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java Fri Dec 21 19:08:06 2012
@@ -0,0 +1,78 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.js.internal.driver;
+
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
+import org.junit.Test;
+
+/**
+ * This class tests the production of valid ActionScript3 code for Interface
+ * production.
+ * 
+ * @author Michael Schmalle
+ */
+public class TestInterface extends TestWalkerBase
+{
+    //--------------------------------------------------------------------------
+    // Interface
+    //--------------------------------------------------------------------------
+
+    @Test
+    public void testSimple()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA{}");
+        visitor.visitInterface(node);
+        assertOut("public interface IA {\n}");
+    }
+
+    @Test
+    public void testSimpleExtends()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA extends IB{}");
+        visitor.visitInterface(node);
+        assertOut("public interface IA extends IB {\n}");
+    }
+
+    @Test
+    public void testSimpleExtendsMultiple()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA extends IB, IC, ID {}");
+        visitor.visitInterface(node);
+        assertOut("public interface IA extends IB, IC, ID {\n}");
+    }
+
+    @Test
+    public void testQualifiedExtendsMultiple()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA extends foo.bar.IB, baz.goo.IC, foo.ID {}");
+        visitor.visitInterface(node);
+        assertOut("public interface IA extends foo.bar.IB, baz.goo.IC, foo.ID {\n}");
+    }
+    
+    protected IInterfaceNode getInterfaceNode(String code)
+    {
+        String source = "package {" + code + "}";
+        IFileNode node = getFileNode(source);
+        IInterfaceNode child = (IInterfaceNode) findFirstDescendantOfType(node,
+                IInterfaceNode.class);
+        return child;
+    }
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java?rev=1425097&r1=1425096&r2=1425097&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java (original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java Fri Dec 21 19:08:06 2012
@@ -366,6 +366,55 @@ public class ASBlockWalker implements IA
     public void visitInterface(IInterfaceNode node)
     {
         debug("visitInterface()");
+        typeDefinition = node.getDefinition();
+        
+        emitter.write(node.getNamespace());
+        emitter.write(" ");
+        
+        emitter.write("interface");
+        emitter.write(" ");
+        walk(node.getNameExpressionNode());
+        emitter.write(" ");
+        
+        IExpressionNode[] inodes = node.getExtendedInterfaceNodes();
+        final int ilen = inodes.length;
+        if (ilen != 0)
+        {
+            emitter.write("extends");
+            emitter.write(" ");
+            for (int i = 0; i < ilen; i++)
+            {
+                walk(inodes[i]);
+                if (i < ilen - 1)
+                {
+                    emitter.write(",");
+                    emitter.write(" ");
+                }
+            }
+            emitter.write(" ");
+        }
+        
+        emitter.write("{");
+        
+        final IDefinitionNode[] members = node.getAllMemberDefinitionNodes();
+        if (members.length > 0)
+        {
+            emitter.indentPush();
+            emitter.write("\n");
+            
+            // TODO (mschmalle) Check to see if the node order is the order of member parsed
+            for (IDefinitionNode mnode : members)
+            {
+                walk(mnode);
+            }
+
+            emitter.indentPop();
+        }
+        
+        emitter.write("\n");
+        emitter.write("}");
+        
+        typeDefinition = null;
     }
 
     public void visitConstructor(IFunctionNode node)