Repository: flex-falcon
Updated Branches:
  refs/heads/develop 0c648e511 -> f35f69840


Updated a few things to accommidate jQuery.
- Base JQuery test, ignored until the source is in the correct place.
- Starting a d3 extern file.


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

Branch: refs/heads/develop
Commit: f35f6984016185291cf1d24ba6b86b5fe0dbdedd
Parents: 0c648e5
Author: Michael Schmalle <[email protected]>
Authored: Thu Jun 18 17:29:06 2015 -0400
Committer: Michael Schmalle <[email protected]>
Committed: Thu Jun 18 17:29:41 2015 -0400

----------------------------------------------------------------------
 .../codegen/externals/TestExternJQuery.java     | 69 ++++++++++++++++++++
 compiler.jx.tests/test-files/externals/d3.js    | 52 +++++++++++++++
 .../compiler/clients/ExternCConfiguration.java  | 11 ++++
 .../externals/reference/ClassReference.java     |  2 +-
 .../externals/reference/FieldReference.java     |  4 ++
 .../externals/reference/MethodReference.java    |  5 ++
 .../externals/reference/ReferenceModel.java     |  6 ++
 .../codegen/externals/utils/JSTypeUtils.java    | 16 +++++
 8 files changed, 164 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f35f6984/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJQuery.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJQuery.java
 
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJQuery.java
new file mode 100644
index 0000000..bbb41f9
--- /dev/null
+++ 
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJQuery.java
@@ -0,0 +1,69 @@
+/*
+ *
+ *  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.externals;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.apache.flex.compiler.clients.ExternCConfiguration;
+import 
org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.google.javascript.jscomp.Result;
+
+@Ignore
+public class TestExternJQuery extends ExternalsTestBase
+{
+    @SuppressWarnings("unused")
+    @Test
+    public void test_classes() throws IOException
+    {
+        Result result = compile();
+        assertTrue(result.success);
+
+        //        String[] classes = {};
+        //
+        //        assertEquals(17, model.getClasses().size());
+        //        for (String className : classes)
+        //        {
+        //            assertTrue(model.hasClass(className));
+        //        }
+
+        ClassReference jQuery_Promise = 
model.getInterfaceReference("jQuery.Promise");
+        assertNotNull(jQuery_Promise);
+
+        StringBuilder sb = new StringBuilder();
+        jQuery_Promise.emit(sb);
+        String r = sb.toString();
+    }
+
+    @Override
+    protected void configure(ExternCConfiguration config) throws IOException
+    {
+        config.setASRoot(ExternalsTestUtils.AS_ROOT_DIR);
+
+        String coreRoot = ExternalsTestUtils.EXTERNAL_JS_DIR.getAbsolutePath();
+        config.addExternal(coreRoot + "/jquery-1.9.js");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f35f6984/compiler.jx.tests/test-files/externals/d3.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/externals/d3.js 
b/compiler.jx.tests/test-files/externals/d3.js
new file mode 100644
index 0000000..965aad0
--- /dev/null
+++ b/compiler.jx.tests/test-files/externals/d3.js
@@ -0,0 +1,52 @@
+/*
+ *
+ *  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.
+ *
+ */
+
+/**
+ * @const
+ */
+var d3 = {};
+
+/**
+ * Stores the current event, if any. 
+ * 
+ * @type {!Event}
+ */
+d3.event;
+
+/**
+ * Stores the current event, if any.
+ *
+ * @param {!Element} container The container may be an HTML or SVG container 
element.
+ */
+d3.mouse = function (container) {};
+
+
+d3.touch = function (container, opt_touches, opt_identifier) {};
+
+
+d3.touches  = function (container, opt_touches) {};
+
+
+selection.transition([name])
+
+
+
+
+
+

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f35f6984/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java 
b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
index 6242d3a..44d27f4 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@ -43,6 +43,7 @@ public class ExternCConfiguration
 
     private List<ExternalFile> externals = new ArrayList<ExternalFile>();
 
+    private List<String> classToFunctions = new ArrayList<String>();
     private List<ExcludedMemeber> excludesClass = new 
ArrayList<ExcludedMemeber>();
     private List<ExcludedMemeber> excludesField = new 
ArrayList<ExcludedMemeber>();
     private List<ExcludedMemeber> excludes = new ArrayList<ExcludedMemeber>();
@@ -102,6 +103,16 @@ public class ExternCConfiguration
         return externals;
     }
 
+    public boolean isClassToFunctions(String className)
+    {
+        return classToFunctions.contains(className);
+    }
+
+    public void addClassToFunction(String className)
+    {
+        classToFunctions.add(className);
+    }
+
     public void addExternal(File file) throws IOException
     {
         if (!file.exists())

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f35f6984/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
index 7cc595d..696b2d0 100644
--- 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
@@ -671,7 +671,7 @@ public class ClassReference extends BaseReference
     {
         sb.append("public interface ");
 
-        sb.append(getQualifiedName() + " ");
+        sb.append(getBaseName() + " ");
 
         List<JSTypeExpression> extendedInterfaces = 
getComment().getExtendedInterfaces();
         int len = extendedInterfaces.size();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f35f6984/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
index 060421e..f91290b 100644
--- 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
@@ -81,6 +81,10 @@ public class FieldReference extends MemberReference
     @Override
     public void emit(StringBuilder sb)
     {
+        // XXX HACK TEMP!
+        if (getComment().isConstructor())
+            return;
+
         // Window has a global var Window that conflicts with the constructor.
         if (getQualifiedName().equals(getClassReference().getQualifiedName()))
             return;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f35f6984/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
index fac8260..fa5dda2 100644
--- 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
@@ -80,6 +80,11 @@ public class MethodReference extends MemberReference
     @Override
     public void emit(StringBuilder sb)
     {
+        // XXX HACK TEMP!
+        if (getComment().isConstructor()
+                && !getBaseName().equals(getClassReference().getBaseName()))
+            return;
+
         if (isConstructor())
         {
             emitConstructor(sb);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f35f6984/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
index 52b64d6..099a3f8 100644
--- 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
@@ -125,6 +125,12 @@ public class ReferenceModel
 
     public void addClass(Node node, String qualifiedName)
     {
+        if (getConfiguration().isClassToFunctions(qualifiedName))
+        {
+            addFunction(node, qualifiedName);
+            return;
+        }
+
         if (classes.containsKey(qualifiedName))
         {
             err("Duplicate class [" + qualifiedName + "]");

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f35f6984/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java
index ddd8fe1..70ee50d 100644
--- 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java
@@ -61,6 +61,10 @@ public class JSTypeUtils
                     {
                         return "Array";
                     }
+                    else if (type.indexOf("Object<") == 0)
+                    {
+                        return "Object";
+                    }
                 }
 
             }
@@ -110,18 +114,26 @@ public class JSTypeUtils
         JSTypeExpression returnType = reference.getComment().getReturnType();
         if (returnType != null)
         {
+
             JSType jsType = JSTypeUtils.toReturnJsType(reference.getModel(),
                     returnType);
             //System.err.println(jsType);
 
             if (jsType != null)
             {
+                if (jsType.isRecordType())
+                    return "Object";
+
                 type = jsType.toString();
 
                 if (type.indexOf("Array<") == 0)
                 {
                     return "Array";
                 }
+                else if (type.indexOf("Object<") == 0)
+                {
+                    return "Object";
+                }
             }
             else
             {
@@ -186,6 +198,10 @@ public class JSTypeUtils
                     {
                         return "Array";
                     }
+                    else if (type.indexOf("Object<") == 0)
+                    {
+                        return "Object";
+                    }
                 }
             }
             else

Reply via email to