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 2016/05/06 18:00:44 UTC

[2/4] git commit: [flex-falcon] [refs/heads/develop] - externc: typedefs for function signatures are now recognized, and Function is emitted in ActionScript

externc: typedefs for function signatures are now recognized, and Function is emitted in ActionScript


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

Branch: refs/heads/develop
Commit: 84b7e80e5c7a823ba25f6ba537568f1e3ebf2a72
Parents: c492dcc
Author: Josh Tynjala <jo...@gmail.com>
Authored: Fri May 6 10:28:35 2016 -0700
Committer: Josh Tynjala <jo...@gmail.com>
Committed: Fri May 6 10:28:35 2016 -0700

----------------------------------------------------------------------
 .../codegen/externals/utils/JSTypeUtils.java    | 32 +++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/84b7e80e/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java
index c14ddb8..217c61b 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java
@@ -98,8 +98,20 @@ public class JSTypeUtils
 
     public static String transformType(String type)
     {
+        // a comment in the type might contain |, so strip the comment first
+        String typeWithoutComment = type;
+        int startIndex = typeWithoutComment.indexOf(" /*");
+        if (startIndex != -1)
+        {
+            int endIndex = typeWithoutComment.indexOf("*/", startIndex);
+            if (endIndex != -1)
+            {
+                typeWithoutComment = typeWithoutComment.substring(0, startIndex) +
+                        typeWithoutComment.substring(endIndex + 2);
+            }
+        }
         // XXX This is an error but, needs to be reduced in @param union
-        if (type.indexOf("|") != -1)
+        if (typeWithoutComment.indexOf("|") != -1)
             return "Object";
 
         HashMap<String, String> map = new HashMap<String, String>();
@@ -164,6 +176,24 @@ public class JSTypeUtils
                 jsType = jsType2;
         }
 
+        ClassReference typeDef = model.getTypeDefReference(jsType.getDisplayName());
+        if (typeDef != null)
+        {
+            JSTypeExpression typeDefTypeExpression = typeDef.getComment().getTypedefType();
+            if (typeDefTypeExpression != null)
+            {
+                JSType typeDefJSType = getJsType(model, typeDefTypeExpression);
+                if (typeDefJSType.isFunctionType())
+                {
+                    // I'm not sure what the implications would be when
+                    // returning the JSType for any typedef, so I'm limiting it
+                    // to function typedefs for now. this should be
+                    // revisited eventually. -JT
+                    jsType = typeDefJSType;
+                }
+            }
+        }
+
         return jsType;
     }
 }