You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jo...@apache.org on 2017/05/26 22:01:24 UTC

[1/2] git commit: [flex-falcon] [refs/heads/release0.8.0] - compiler-jx: moved conversion of node module names with dashes to camel case from ExternCConfiguration into a utility class so that it may be used elsewhere

Repository: flex-falcon
Updated Branches:
  refs/heads/release0.8.0 80990a86b -> 5a32df89d


compiler-jx: moved conversion of node module names with dashes to camel case from ExternCConfiguration into a utility class so that it may be used elsewhere


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

Branch: refs/heads/release0.8.0
Commit: 693af591303e6b514d4eee042fb76abed6487fda
Parents: 80990a8
Author: Josh Tynjala <jo...@apache.org>
Authored: Fri May 26 14:58:56 2017 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Fri May 26 14:58:56 2017 -0700

----------------------------------------------------------------------
 .../compiler/clients/ExternCConfiguration.java  | 11 +-----
 .../apache/flex/compiler/utils/NodeJSUtils.java | 41 ++++++++++++++++++++
 2 files changed, 43 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/693af591/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
index d3118e9..67bc814 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@ -38,6 +38,7 @@ import org.apache.flex.compiler.internal.config.annotations.Arguments;
 import org.apache.flex.compiler.internal.config.annotations.Config;
 import org.apache.flex.compiler.internal.config.annotations.InfiniteArguments;
 import org.apache.flex.compiler.internal.config.annotations.Mapping;
+import org.apache.flex.compiler.utils.NodeJSUtils;
 import org.apache.flex.utils.FilenameNormalization;
 
 public class ExternCConfiguration extends Configuration
@@ -324,15 +325,7 @@ public class ExternCConfiguration extends Configuration
         for (String module : namedModules)
         {
             //convert to camel case
-            String camelCaseModule = module;
-            int moduleIndex = camelCaseModule.indexOf("-");
-            while (moduleIndex != -1 && moduleIndex < camelCaseModule.length() - 1)
-            {
-                camelCaseModule = camelCaseModule.substring(0, moduleIndex)
-                        + camelCaseModule.substring(moduleIndex + 1, moduleIndex + 2).toUpperCase()
-                        + camelCaseModule.substring(moduleIndex + 2);
-                moduleIndex = camelCaseModule.indexOf("-");
-            }
+            String camelCaseModule = NodeJSUtils.convertFromDashesToCamelCase(module);
             if(basePackageName.length() == 0)
             {
                 if (classReference.getBaseName().equals(camelCaseModule))

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/693af591/compiler-jx/src/main/java/org/apache/flex/compiler/utils/NodeJSUtils.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/utils/NodeJSUtils.java b/compiler-jx/src/main/java/org/apache/flex/compiler/utils/NodeJSUtils.java
new file mode 100644
index 0000000..608b3ac
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/utils/NodeJSUtils.java
@@ -0,0 +1,41 @@
+/*
+ *
+ *  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.utils;
+
+public class NodeJSUtils
+{
+    /**
+     * Converts the name of a node module with dashes into a version in camel
+     * case so that it can be a valid identifier.
+     */
+    public static String convertFromDashesToCamelCase(String moduleNameWithDashes)
+    {
+        String camelCaseModule = moduleNameWithDashes;
+        int moduleIndex = camelCaseModule.indexOf("-");
+        while (moduleIndex != -1 && moduleIndex < camelCaseModule.length() - 1)
+        {
+            camelCaseModule = camelCaseModule.substring(0, moduleIndex)
+                    + camelCaseModule.substring(moduleIndex + 1, moduleIndex + 2).toUpperCase()
+                    + camelCaseModule.substring(moduleIndex + 2);
+            moduleIndex = camelCaseModule.indexOf("-");
+        }
+        return camelCaseModule;
+    }
+}


[2/2] git commit: [flex-falcon] [refs/heads/release0.8.0] - compiler-jx: fixed issue where require() calls generated by PackageHeaderEmitter for Node.js modules would create invalid variable names because it didn't convert from dashes to camel case

Posted by jo...@apache.org.
compiler-jx: fixed issue where require() calls generated by PackageHeaderEmitter for Node.js modules would create invalid variable names because it didn't convert from dashes to camel case


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

Branch: refs/heads/release0.8.0
Commit: 5a32df89de60f93f3da9dddbbd60788654eda875
Parents: 693af59
Author: Josh Tynjala <jo...@apache.org>
Authored: Fri May 26 15:01:17 2017 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Fri May 26 15:01:17 2017 -0700

----------------------------------------------------------------------
 .../internal/codegen/js/jx/PackageHeaderEmitter.java   | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5a32df89/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
index 0f1d0cd..5d2c413 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
@@ -51,6 +51,7 @@ import org.apache.flex.compiler.targets.ITarget.TargetType;
 import org.apache.flex.compiler.tree.as.ITypeNode;
 import org.apache.flex.compiler.units.ICompilationUnit;
 import org.apache.flex.compiler.utils.NativeUtils;
+import org.apache.flex.compiler.utils.NodeJSUtils;
 
 public class PackageHeaderEmitter extends JSSubEmitter implements
         ISubEmitter<IPackageDefinition>
@@ -402,26 +403,28 @@ public class PackageHeaderEmitter extends JSSubEmitter implements
         if (externalRequiresList != null)
         {
             Collections.sort(externalRequiresList);
-            for (String imp : externalRequiresList)
+            for (String nodeJSModuleName : externalRequiresList)
             {
-                if (writtenRequires.indexOf(imp) == -1)
+                if (writtenRequires.indexOf(nodeJSModuleName) == -1)
                 {
+                    String moduleVariableName = NodeJSUtils.convertFromDashesToCamelCase(nodeJSModuleName);
                     /* var x = require('x');\n */
+                    /* var someModule = require('some-module');\n */
                     write(ASEmitterTokens.VAR);
                     write(ASEmitterTokens.SPACE);
-                    write(imp);
+                    write(moduleVariableName);
                     write(ASEmitterTokens.SPACE);
                     write(ASEmitterTokens.EQUAL);
                     write(ASEmitterTokens.SPACE);
                     write(NodeEmitterTokens.REQUIRE);
                     write(ASEmitterTokens.PAREN_OPEN);
                     write(ASEmitterTokens.SINGLE_QUOTE);
-                    write(imp);
+                    write(nodeJSModuleName);
                     write(ASEmitterTokens.SINGLE_QUOTE);
                     write(ASEmitterTokens.PAREN_CLOSE);
                     writeNewline(ASEmitterTokens.SEMICOLON);
 
-                    writtenRequires.add(imp);
+                    writtenRequires.add(nodeJSModuleName);
 
                     emitsExternalRequires = true;
                 }