Repository: flex-falcon
Updated Branches:
  refs/heads/develop 19140007c -> 177b2f313


NodeBackend: added backend targeting Node.js


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

Branch: refs/heads/develop
Commit: 177b2f31373c246f8eebf43703e9abb45602299e
Parents: 1914000
Author: Josh Tynjala <joshtynj...@apache.org>
Authored: Mon Jan 11 16:33:41 2016 -0800
Committer: Josh Tynjala <joshtynj...@apache.org>
Committed: Mon Jan 11 16:33:41 2016 -0800

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/MXMLJSC.java   |  7 ++-
 .../internal/codegen/js/node/NodePublisher.java | 53 ++++++++++++++++++++
 .../internal/driver/js/node/NodeBackend.java    | 47 +++++++++++++++++
 3 files changed, 106 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/177b2f31/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java 
b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
index 35a9609..ab89e45 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -54,6 +54,7 @@ import 
org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
 import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
 import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
 import org.apache.flex.compiler.internal.driver.js.jsc.JSCBackend;
+import org.apache.flex.compiler.internal.driver.js.node.NodeBackend;
 import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSBackend;
 import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
 import org.apache.flex.compiler.internal.parsing.as.FlexJSASDocDelegate;
@@ -105,7 +106,8 @@ public class MXMLJSC implements JSCompilerEntryPoint, 
ProblemQueryProvider,
         GOOG("goog"),
         VF2JS("vf2js"),
         FLEXJS_DUAL("flexjs_dual"),
-        JSC("jsc");
+        JSC("jsc"),
+        NODE("node");
 
         private String text;
 
@@ -213,6 +215,9 @@ public class MXMLJSC implements JSCompilerEntryPoint, 
ProblemQueryProvider,
         case JSC:
             backend = new JSCBackend();
             break;
+        case NODE:
+            backend = new NodeBackend();
+            break;
         case FLEXJS:
         case FLEXJS_DUAL:
             backend = new MXMLFlexJSBackend();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/177b2f31/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
new file mode 100644
index 0000000..a3f6d1d
--- /dev/null
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
@@ -0,0 +1,53 @@
+/*
+ *
+ *  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.codegen.js.node;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.internal.codegen.js.jsc.JSCPublisher;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+public class NodePublisher extends JSCPublisher
+{
+    public NodePublisher(Configuration config, FlexJSProject project)
+    {
+        super(config, project);
+    }
+
+    @Override
+    protected void writeHTML(String type, String projectName, String dirPath,
+                             String deps, List<String> additionalHTML) throws 
IOException
+    {
+        StringBuilder contents = new StringBuilder();
+        if ("intermediate".equals(type))
+        {
+            
contents.append("require(\"./library/closure/goog/bootstrap/nodejs\");\n");
+            contents.append(deps);
+            contents.append("goog.require(\"");
+            contents.append(projectName);
+            contents.append("\");\n");
+        }
+        contents.append("new " + projectName + "();");
+        writeFile(dirPath + File.separator + "index.js", contents.toString(), 
false);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/177b2f31/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/node/NodeBackend.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/node/NodeBackend.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/node/NodeBackend.java
new file mode 100644
index 0000000..e4d0503
--- /dev/null
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/node/NodeBackend.java
@@ -0,0 +1,47 @@
+/*
+ *
+ *  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.driver.js.node;
+
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.node.NodePublisher;
+import 
org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSPublisher;
+import org.apache.flex.compiler.internal.driver.js.jsc.JSCBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+
+/**
+ * A concrete implementation of the {@link IBackend} API for the 'node' code
+ * production.
+ *
+ * @author Josh Tynjala
+ */
+public class NodeBackend extends JSCBackend
+{
+    @Override
+    public MXMLFlexJSPublisher createPublisher(IASProject project,
+                                               List<ICompilerProblem> errors, 
Configuration config)
+    {
+        return new NodePublisher(config, (FlexJSProject) project);
+    }
+}

Reply via email to