flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject svn commit: r1430855 - in /flex/whiteboard/mschmalle/falconjx: compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/ compiler.jx/src/org/apache/flex/compiler/as/codegen/ compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/
Date Wed, 09 Jan 2013 13:44:02 GMT
Author: erikdebruin
Date: Wed Jan  9 13:44:01 2013
New Revision: 1430855

URL: http://svn.apache.org/viewvc?rev=1430855&view=rev
Log:
- refactored a bit to give control over 'interface' handling to the emitter instead of the
walker
- created TestGoogInterface

Added:
    flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java
  (with props)
Modified:
    flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java
    flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java
    flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java
    flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java

Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java?rev=1430855&r1=1430854&r2=1430855&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java
(original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java
Wed Jan  9 13:44:01 2013
@@ -165,7 +165,7 @@ public class TestGoogClass extends TestC
                 "private static const C:Number = 42;" +
                 "foo_bar static const C:String = 'me' + 'you';");
         visitor.visitClass(node);
-        assertOutDebug("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n
* @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n/**\n * @protected\n * @const\n
* @type {number}\n */\norg.apache.flex.A.B = 42;\n\n/**\n * @private\n * @const\n * @type
{number}\n */\norg.apache.flex.A.C = 42;\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C
= 'me' + 'you';\n\n");
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n
* @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n/**\n * @protected\n * @const\n
* @type {number}\n */\norg.apache.flex.A.B = 42;\n\n/**\n * @private\n * @const\n * @type
{number}\n */\norg.apache.flex.A.C = 42;\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C
= 'me' + 'you';\n\n");
     }
     
 	@Ignore

Added: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java?rev=1430855&view=auto
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java
(added)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java
Wed Jan  9 13:44:01 2013
@@ -0,0 +1,124 @@
+/*
+ *
+ *  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.compiler.internal.js.codegen.goog;
+
+import org.apache.flex.compiler.clients.IBackend;
+import org.apache.flex.compiler.internal.as.codegen.TestInterface;
+import org.apache.flex.compiler.internal.js.driver.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This class tests the production of valid 'goog' JS code for Interface production.
+ * 
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class TestGoogInterface extends TestInterface
+{
+    //--------------------------------------------------------------------------
+    // Interface
+    //--------------------------------------------------------------------------
+
+	@Ignore
+	@Override
+    @Test
+    public void testSimple()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA{}");
+        visitor.visitInterface(node);
+        assertOut("");
+    }
+
+	@Ignore
+	@Override
+    @Test
+    public void testSimpleExtends()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA extends IB{}");
+        visitor.visitInterface(node);
+        assertOut("");
+    }
+
+	@Ignore
+	@Override
+    @Test
+    public void testSimpleExtendsMultiple()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA extends IB, IC, ID {}");
+        visitor.visitInterface(node);
+        assertOut("");
+    }
+
+	@Ignore
+	@Override
+    @Test
+    public void testQualifiedExtendsMultiple()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA extends foo.bar.IB, baz.goo.IC,
foo.ID {}");
+        visitor.visitInterface(node);
+        assertOut("");
+    }
+
+	@Ignore
+	@Override
+    @Test
+    public void testAccessors()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA {"
+                + "function get foo1():Object;"
+                + "function set foo1(value:Object):void;}");
+        visitor.visitInterface(node);
+        assertOut("");
+    }
+
+	@Ignore
+	@Override
+    @Test
+    public void testMethods()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA {"
+                + "function foo1():Object;"
+                + "function foo1(value:Object):void;}");
+        visitor.visitInterface(node);
+        assertOut("");
+    }
+
+	@Ignore
+	@Override
+    @Test
+    public void testAccessorsMethods()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA {"
+                + "function get foo1():Object;"
+                + "function set foo1(value:Object):void;"
+                + "function baz1():Object;"
+                + "function baz2(value:Object):void;}");
+        visitor.visitInterface(node);
+        assertOut("");
+    }
+
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+
+}

Propchange: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java?rev=1430855&r1=1430854&r2=1430855&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java
(original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java
Wed Jan  9 13:44:01 2013
@@ -27,6 +27,7 @@ import org.apache.flex.compiler.tree.as.
 import org.apache.flex.compiler.tree.as.IExpressionNode;
 import org.apache.flex.compiler.tree.as.IFunctionNode;
 import org.apache.flex.compiler.tree.as.IGetterNode;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
 import org.apache.flex.compiler.tree.as.IPackageNode;
 import org.apache.flex.compiler.tree.as.IParameterNode;
 import org.apache.flex.compiler.tree.as.ISetterNode;
@@ -90,6 +91,13 @@ public interface IASEmitter
     void emitClass(IClassNode node);
 
     /**
+     * Emit an Interface.
+     * 
+     * @param node The {@link IInterfaceNode} class.
+     */
+    void emitInterface(IInterfaceNode node);
+
+    /**
      * Emit a documentation comment for a Class field or constant
      * {@link IVariableNode}.
      * 

Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java?rev=1430855&r1=1430854&r2=1430855&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java
(original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java
Wed Jan  9 13:44:01 2013
@@ -286,61 +286,8 @@ 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
-            final int len = members.length;
-            int i = 0;
-            for (IDefinitionNode mnode : members)
-            {
-                walk(mnode);
-                emitter.write(";");
-                if (i < len - 1)
-                    emitter.write("\n");
-                i++;
-            }
-
-            emitter.indentPop();
-        }
-
-        emitter.write("\n");
-        emitter.write("}");
-
-        typeDefinition = null;
+        
+        emitter.emitInterface(node);
     }
 
     @Override

Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java?rev=1430855&r1=1430854&r2=1430855&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
(original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
Wed Jan  9 13:44:01 2013
@@ -44,6 +44,7 @@ import org.apache.flex.compiler.tree.as.
 import org.apache.flex.compiler.tree.as.IExpressionNode;
 import org.apache.flex.compiler.tree.as.IFunctionNode;
 import org.apache.flex.compiler.tree.as.IGetterNode;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
 import org.apache.flex.compiler.tree.as.IKeywordNode;
 import org.apache.flex.compiler.tree.as.IPackageNode;
 import org.apache.flex.compiler.tree.as.IParameterNode;
@@ -318,6 +319,62 @@ public class ASEmitter implements IASEmi
         write("}");
     }
     
+    @Override
+    public void emitInterface(IInterfaceNode node)
+    {
+        write(node.getNamespace());
+        write(" ");
+
+        write("interface");
+        write(" ");
+        getWalker().walk(node.getNameExpressionNode());
+        write(" ");
+
+        IExpressionNode[] inodes = node.getExtendedInterfaceNodes();
+        final int ilen = inodes.length;
+        if (ilen != 0)
+        {
+            write("extends");
+            write(" ");
+            for (int i = 0; i < ilen; i++)
+            {
+            	getWalker().walk(inodes[i]);
+                if (i < ilen - 1)
+                {
+                    write(",");
+                    write(" ");
+                }
+            }
+            write(" ");
+        }
+
+        write("{");
+
+        final IDefinitionNode[] members = node.getAllMemberDefinitionNodes();
+        if (members.length > 0)
+        {
+            indentPush();
+            write("\n");
+
+            // TODO (mschmalle) Check to see if the node order is the order of member parsed
+            final int len = members.length;
+            int i = 0;
+            for (IDefinitionNode mnode : members)
+            {
+            	getWalker().walk(mnode);
+                write(";");
+                if (i < len - 1)
+                    write("\n");
+                i++;
+            }
+
+            indentPop();
+        }
+
+        write("\n");
+        write("}");
+    }
+    
     //--------------------------------------------------------------------------
     // 
     //--------------------------------------------------------------------------



Mime
View raw message