flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject git commit: [flex-falcon] [refs/heads/develop] - compiler.jx: JSCPublisher differentitates between a main class that is ActionScript versus one that is MXML, and does not call start() on an ActionScript main class
Date Wed, 05 Oct 2016 21:38:04 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop 078fe695a -> 386112843


compiler.jx: JSCPublisher differentitates between a main class that is ActionScript versus
one that is MXML, and does not call start() on an ActionScript main class


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

Branch: refs/heads/develop
Commit: 386112843968b120cb91ee8118cee010886e6f28
Parents: 078fe69
Author: Josh Tynjala <joshtynjala@gmail.com>
Authored: Wed Oct 5 14:37:55 2016 -0700
Committer: Josh Tynjala <joshtynjala@gmail.com>
Committed: Wed Oct 5 14:37:55 2016 -0700

----------------------------------------------------------------------
 .../internal/codegen/js/jsc/JSCPublisher.java   | 27 ++++++++++++++++++++
 1 file changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/38611284/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
index fd29f85..21c456c 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
@@ -24,14 +24,41 @@ import java.io.IOException;
 import java.util.List;
 
 import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSPublisher;
 import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.tree.as.IDefinitionNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
 
 public class JSCPublisher extends MXMLFlexJSPublisher
 {
     public JSCPublisher(Configuration config, FlexJSProject project)
     {
         super(config, project);
+        this.project = project;
+    }
+
+    private FlexJSProject project;
+
+    @Override
+    protected String getTemplateBody(String projectName)
+    {
+        IDefinition def = project.resolveQNameToDefinition(projectName);
+        IDefinitionNode node = def.getNode();
+        if (node instanceof IMXMLDocumentNode)
+        {
+            //we should probably customize MXML too, but for now, pass it to the
+            //default implementation -JT
+            return super.getTemplateBody(projectName);
+        }
+        //for ActionScript classes, simply call the constructor by default
+        StringBuilder bodyHTML = new StringBuilder();
+        bodyHTML.append("\t<script type=\"text/javascript\">\n");
+        bodyHTML.append("\t\tnew ");
+        bodyHTML.append(projectName);
+        bodyHTML.append("();\n");
+        bodyHTML.append("\t</script>\n");
+        return bodyHTML.toString();
     }
 
     @Override


Mime
View raw message