You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by er...@apache.org on 2013/04/20 12:54:16 UTC

[1/5] git commit: [flex-falcon] - [FalconJX] add test for local function call

Updated Branches:
  refs/heads/develop 0cf1d9c72 -> eba24a91f


[FalconJX] add test for local function call

Added a test file for the 'local function call' output using 'goog.bind'; aharui already provided handling in JSFlexJSEmitter.

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/develop
Commit: 305038ff56a4c99210b9897e7e346712b724d9a9
Parents: 0cf1d9c
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Sat Apr 20 10:28:12 2013 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Sat Apr 20 10:28:12 2013 +0200

----------------------------------------------------------------------
 .../internal/codegen/js/flexjs/TestFlexJSFile.java |   18 ++++++++
 .../test-files/flexjs/files/LocalFunction.as       |   26 ++++++++++++
 .../flexjs/files/LocalFunction_result.js           |   31 +++++++++++++++
 .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java   |    7 +++
 4 files changed, 82 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/305038ff/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
index 187e747..8c66c4f 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
@@ -36,6 +36,24 @@ import org.junit.Test;
 public class TestFlexJSFile extends FlexJSTestBase
 {
     @Test
+    public void testLocalFunction()
+    {
+        String fileName = "LocalFunction";
+
+        IFileNode node = compileAS(fileName, true,
+                "test-files"
+                        + File.separator + "flexjs" + File.separator + "files",
+                false);
+        
+        asBlockWalker.visitFile(node);
+        
+        writeResultToFile(writer.toString(), fileName);
+        
+        assertOut(getCodeFromFile(fileName + "_result", true,
+                "flexjs" + File.separator + "files"));
+    }
+
+    @Test
     public void testFlexJSMyController()
     {
         String fileName = "MyController";

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/305038ff/compiler.jx.tests/test-files/flexjs/files/LocalFunction.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/LocalFunction.as b/compiler.jx.tests/test-files/flexjs/files/LocalFunction.as
new file mode 100644
index 0000000..e7e9b70
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/files/LocalFunction.as
@@ -0,0 +1,26 @@
+package
+{
+	
+	public class LocalFunction
+	{
+		public function LocalFunction() {}
+		
+		private var myMemberProperty:String = "got it: ";
+		
+		private function myMemberMethod(value:int):void
+		{
+			function myLocalFunction(value:int):String
+			{
+				return myMemberProperty + value;
+			}
+			
+			trace("WOW! :: " + myLocalFunction(value + 42));
+		}
+		
+		public function doIt():void
+		{
+			myMemberMethod(624);
+		}
+	}
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/305038ff/compiler.jx.tests/test-files/flexjs/files/LocalFunction_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/LocalFunction_result.js b/compiler.jx.tests/test-files/flexjs/files/LocalFunction_result.js
new file mode 100644
index 0000000..f416447
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/files/LocalFunction_result.js
@@ -0,0 +1,31 @@
+goog.provide('LocalFunction');
+
+/**
+ * @constructor
+ */
+LocalFunction = function() {
+};
+
+/**
+ * @private
+ * @type {string}
+ */
+LocalFunction.prototype.myMemberProperty = "got it: ";
+
+/**
+ * @private
+ * @param {number} value
+ */
+LocalFunction.prototype.myMemberMethod = function(value) {
+	function myLocalFunction(value) {
+		return this.myMemberProperty + value;
+	};
+	trace("WOW! :: " + goog.bind(myLocalFunction, this)(value + 42));
+};
+
+/**
+ * @expose
+ */
+LocalFunction.prototype.doIt = function() {
+	this.myMemberMethod(624);
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/305038ff/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index c22ff1f..f6b358a 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -279,10 +279,17 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         htmlFile.append("\t<script type=\"text/javascript\">\n");
 
         // TODO (erikdebruin) the utility methods should have their own place...
+        // is()
         htmlFile.append("\t\tfunction is(object, type) {\n");
         htmlFile.append("\t\t\treturn true;\n");
         htmlFile.append("\t\t};\n");
         htmlFile.append("\t\t\n");
+        // trace()
+        htmlFile.append("\t\tfunction trace(value) {\n");
+        htmlFile.append("\t\t\tif (console && console.log)\n");
+        htmlFile.append("\t\t\t\tconsole.log(value);\n");
+        htmlFile.append("\t\t};\n");
+        htmlFile.append("\t\t\n");
 
         htmlFile.append("\t\tnew ");
         htmlFile.append(projectName);


[3/5] git commit: [flex-falcon] - [FalconJX] another update

Posted by er...@apache.org.
[FalconJX] another update

That should teach me not to commit before having at least 2 coffees ;-)

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/develop
Commit: 0420b98d44ce067e3cbc28773c21a9fe94c3834a
Parents: ac67e4e
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Sat Apr 20 10:37:05 2013 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Sat Apr 20 10:37:05 2013 +0200

----------------------------------------------------------------------
 .../internal/codegen/js/flexjs/TestFlexJSFile.java |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0420b98d/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
index e6a1fbb..9e2fae4 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
@@ -65,7 +65,7 @@ public class TestFlexJSFile extends FlexJSTestBase
         
         asBlockWalker.visitFile(node);
         
-        writeResultToFile(writer.toString(), fileName);
+        //writeResultToFile(writer.toString(), fileName);
         
         assertOut(getCodeFromFile(fileName + "_result", true,
                 "flexjs" + File.separator + "files"));
@@ -81,7 +81,7 @@ public class TestFlexJSFile extends FlexJSTestBase
 
         asBlockWalker.visitFile(node);
         
-        writeResultToFile(writer.toString(), fileName);
+        //writeResultToFile(writer.toString(), fileName);
         
         assertOut(getCodeFromFile(fileName + "_result", true,
                 "flexjs" + File.separator + "files"));


Re: [4/5] git commit: [flex-falcon] - [FalconJX] updated NativeUtils and support/tests

Posted by Erik de Bruin <er...@ixsoftware.nl>.
That would be one option. Maybe use the 'fragments' collection theme
that i saw in use in FalconJS. I think that having a global state runs
a bit counter to the idea behind FalconJX. But whatever works :-)

Another option would be to provide a 'global utils' class in FlexJS
and have FalconJX emit the correct code translation.

EdB



On Sat, Apr 20, 2013 at 3:13 PM, Alex Harui <ah...@adobe.com> wrote:
> What do you think of the idea of moving these helper functions out of the
> html template and have the compiler codegen them on-demand somehow.  IMO, it
> is a slippery slope to keep adding code to the html template that might not
> actually be used by the app, and it is one more thing that can be screwed up
> as the user customizes the html file.
>
>
> On 4/20/13 3:54 AM, "erikdebruin@apache.org" <er...@apache.org> wrote:
>
>> [FalconJX] updated NativeUtils and support/tests
>>
>> I've updated NativeUtils to more closely match the desired state of JS
>> 'native' support for AS global objects and functions. Updated the tests for
>> Object, int and uint again, together with the addition of support methods in
>> the Publisher.
>>
>> Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/6f8e8f9e
>> Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/6f8e8f9e
>> Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/6f8e8f9e
>>
>> Branch: refs/heads/develop
>> Commit: 6f8e8f9e4a315213a13f935dcf4084477abe41e8
>> Parents: 0420b98
>> Author: Erik de Bruin <er...@ixsoftware.nl>
>> Authored: Sat Apr 20 12:48:58 2013 +0200
>> Committer: Erik de Bruin <er...@ixsoftware.nl>
>> Committed: Sat Apr 20 12:48:58 2013 +0200
>>
>> ----------------------------------------------------------------------
>>  .../js/flexjs/TestFlexJSGlobalFunctions.java       |   35 +++-----------
>>  .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java   |   21 ++++++++-
>>  .../apache/flex/compiler/utils/NativeUtils.java    |   27 ++++++++++-
>>  3 files changed, 50 insertions(+), 33 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6f8e8f9e/compiler.jx.t
>> ests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalF
>> unctions.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/Te
>> stFlexJSGlobalFunctions.java
>> b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/Te
>> stFlexJSGlobalFunctions.java
>> index a3f6207..7cdeebc 100644
>> ---
>> a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/Te
>> stFlexJSGlobalFunctions.java
>> +++
>> b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/Te
>> stFlexJSGlobalFunctions.java
>> @@ -48,33 +48,6 @@ public class TestFlexJSGlobalFunctions extends
>> TestGoogGlobalFunctions
>>
>>      @Override
>>      @Test
>> -    public void testInt()
>> -    {
>> -        IVariableNode node = getVariable("var a:int = int(1.8);");
>> -        asBlockWalker.visitVariable(node);
>> -        assertOut("var /** @type {number} */ a = 1.8/** Cast to int */");
>> -    }
>> -
>> -    @Override
>> -    @Test
>> -    public void testObject()
>> -    {
>> -        IVariableNode node = getVariable("var a:Object = Object(\"1\");");
>> -        asBlockWalker.visitVariable(node);
>> -        assertOut("var /** @type {Object} */ a = \"1\"/** Cast to Object
>> */");
>> -    }
>> -
>> -    @Override
>> -    @Test
>> -    public void testUint()
>> -    {
>> -        IVariableNode node = getVariable("var a:uint = uint(-100);");
>> -        asBlockWalker.visitVariable(node);
>> -        assertOut("var /** @type {number} */ a = -100/** Cast to uint */");
>> -    }
>> -
>> -    @Override
>> -    @Test
>>      public void testVector()
>>      {
>>          IVariableNode node = getVariable("var a:Vector.<String> =
>> Vector.<String>(['Hello', 'World']);");
>> @@ -93,6 +66,10 @@ public class TestFlexJSGlobalFunctions extends
>> TestGoogGlobalFunctions
>>          //     <@/>  or something like that?
>>          // I cannot find any reference to creating an XML object via a
>>          // global function
>> +
>> +        // (erikdebruin) E4X in Javascript is obsolete.
>> +        //               Ref.: https://developer.mozilla.org/en-US/docs/E4X
>> +
>>          assertOut("var /** @type {XML} */ a = XML('@')");
>>      }
>>
>> @@ -107,6 +84,10 @@ public class TestFlexJSGlobalFunctions extends
>> TestGoogGlobalFunctions
>>          //     <@/>  or something like that?
>>          // I cannot find any reference to creating an XML object via a
>>          // global function
>> +
>> +        // (erikdebruin) E4X in Javascript is obsolete.
>> +        //               Ref.: https://developer.mozilla.org/en-US/docs/E4X
>> +
>>          assertOut("var /** @type {XMLList} */ a = XMLList('<!-- comment
>> -->')");
>>      }
>>
>>
>> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6f8e8f9e/compiler.jx/s
>> rc/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.j
>> ava
>> ----------------------------------------------------------------------
>> diff --git
>> a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFl
>> exJSPublisher.java
>> b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFl
>> exJSPublisher.java
>> index f6b358a..137dd61 100644
>> ---
>> a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFl
>> exJSPublisher.java
>> +++
>> b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFl
>> exJSPublisher.java
>> @@ -284,13 +284,28 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher
>> implements
>>          htmlFile.append("\t\t\treturn true;\n");
>>          htmlFile.append("\t\t};\n");
>>          htmlFile.append("\t\t\n");
>> +        // int()
>> +        htmlFile.append("\t\tfunction int(value) {\n");
>> +        htmlFile.append("\t\t\treturn value >> 0;\n");
>> +        htmlFile.append("\t\t};\n");
>> +        htmlFile.append("\t\t\n");
>>          // trace()
>>          htmlFile.append("\t\tfunction trace(value) {\n");
>> -        htmlFile.append("\t\t\tif (console && console.log)\n");
>> -        htmlFile.append("\t\t\t\tconsole.log(value);\n");
>> +        htmlFile.append("\t\t\ttry {\n");
>> +        htmlFile.append("\t\t\t\tif (console && console.log) {\n");
>> +        htmlFile.append("\t\t\t\t\tconsole.log(value);\n");
>> +        htmlFile.append("\t\t\t\t}\n");
>> +        htmlFile.append("\t\t\t} catch (e) {\n");
>> +        htmlFile.append("\t\t\t\t// ignore; at least we tried ;-)\n");
>> +        htmlFile.append("\t\t\t}\n");
>>          htmlFile.append("\t\t};\n");
>>          htmlFile.append("\t\t\n");
>> -
>> +        // uint()
>> +        htmlFile.append("\t\tfunction uint(value) {\n");
>> +        htmlFile.append("\t\t\treturn value >>> 0;\n");
>> +        htmlFile.append("\t\t};\n");
>> +        htmlFile.append("\t\t\n");
>> +
>>          htmlFile.append("\t\tnew ");
>>          htmlFile.append(projectName);
>>          htmlFile.append("()");
>>
>> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6f8e8f9e/compiler.jx/s
>> rc/org/apache/flex/compiler/utils/NativeUtils.java
>> ----------------------------------------------------------------------
>> diff --git a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
>> b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
>> index 361f178..4f53496 100644
>> --- a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
>> +++ b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
>> @@ -86,9 +86,10 @@ public class NativeUtils
>>
>>      public enum NativeJSType
>>      {
>> +        // (erikdebruin) Ref.:
>> https://cwiki.apache.org/confluence/display/FLEX/Full+Table
>> +
>> +        Array("Array"),
>>          Boolean("Boolean"),
>> -        Number("Number"),
>> -        String("String"),
>>          decodeURI("decodeURI"),
>>          decodeURIComponent("decodeURIComponent"),
>>          encodeURI("encodeURI"),
>> @@ -96,10 +97,30 @@ public class NativeUtils
>>          escape("escape"),
>>          isFinite("isFinite"),
>>          isNaN("isNaN"),
>> +        Number("Number"),
>> +        Object("Object"),
>>          parseFloat("parseFloat"),
>>          parseInt("parseInt"),
>> -        unescape("unescape");
>> +        String("String"),
>> +        unescape("unescape"),
>> +
>> +        // (erikdebruin) These aren't strictly 'native' to JS, but the
>> +        //               Publisher provides global functions, so, for all
>> +        //               intends and purposes they behave like they are.
>> +        _int("int"),
>> +        trace("trace"),
>> +        uint("uint"),
>> +
>> +        // (erikdebruin) These are left out, but should, at some point, be
>> +        //               treated as if they actually are 'native'.
>> +        /*
>> +        isXMLName("isXMLName"),
>> +        Vector("Vector"),
>> +        XML("XML"),
>> +        XMLList("XMLList"),
>> +        */
>>
>> +        ;
>>          private final String value;
>>
>>          NativeJSType(String value)
>>
>
> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>



-- 
Ix Multimedia Software

Jan Luykenstraat 27
3521 VB Utrecht

T. 06-51952295
I. www.ixsoftware.nl

Re: [4/5] git commit: [flex-falcon] - [FalconJX] updated NativeUtils and support/tests

Posted by Alex Harui <ah...@adobe.com>.
What do you think of the idea of moving these helper functions out of the
html template and have the compiler codegen them on-demand somehow.  IMO, it
is a slippery slope to keep adding code to the html template that might not
actually be used by the app, and it is one more thing that can be screwed up
as the user customizes the html file.


On 4/20/13 3:54 AM, "erikdebruin@apache.org" <er...@apache.org> wrote:

> [FalconJX] updated NativeUtils and support/tests
> 
> I've updated NativeUtils to more closely match the desired state of JS
> 'native' support for AS global objects and functions. Updated the tests for
> Object, int and uint again, together with the addition of support methods in
> the Publisher.
> 
> Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/6f8e8f9e
> Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/6f8e8f9e
> Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/6f8e8f9e
> 
> Branch: refs/heads/develop
> Commit: 6f8e8f9e4a315213a13f935dcf4084477abe41e8
> Parents: 0420b98
> Author: Erik de Bruin <er...@ixsoftware.nl>
> Authored: Sat Apr 20 12:48:58 2013 +0200
> Committer: Erik de Bruin <er...@ixsoftware.nl>
> Committed: Sat Apr 20 12:48:58 2013 +0200
> 
> ----------------------------------------------------------------------
>  .../js/flexjs/TestFlexJSGlobalFunctions.java       |   35 +++-----------
>  .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java   |   21 ++++++++-
>  .../apache/flex/compiler/utils/NativeUtils.java    |   27 ++++++++++-
>  3 files changed, 50 insertions(+), 33 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6f8e8f9e/compiler.jx.t
> ests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalF
> unctions.java
> ----------------------------------------------------------------------
> diff --git 
> a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/Te
> stFlexJSGlobalFunctions.java
> b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/Te
> stFlexJSGlobalFunctions.java
> index a3f6207..7cdeebc 100644
> --- 
> a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/Te
> stFlexJSGlobalFunctions.java
> +++ 
> b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/Te
> stFlexJSGlobalFunctions.java
> @@ -48,33 +48,6 @@ public class TestFlexJSGlobalFunctions extends
> TestGoogGlobalFunctions
>  
>      @Override
>      @Test
> -    public void testInt()
> -    {
> -        IVariableNode node = getVariable("var a:int = int(1.8);");
> -        asBlockWalker.visitVariable(node);
> -        assertOut("var /** @type {number} */ a = 1.8/** Cast to int */");
> -    }
> -
> -    @Override
> -    @Test
> -    public void testObject()
> -    {
> -        IVariableNode node = getVariable("var a:Object = Object(\"1\");");
> -        asBlockWalker.visitVariable(node);
> -        assertOut("var /** @type {Object} */ a = \"1\"/** Cast to Object
> */");
> -    }
> -
> -    @Override
> -    @Test
> -    public void testUint()
> -    {
> -        IVariableNode node = getVariable("var a:uint = uint(-100);");
> -        asBlockWalker.visitVariable(node);
> -        assertOut("var /** @type {number} */ a = -100/** Cast to uint */");
> -    }
> -
> -    @Override
> -    @Test
>      public void testVector()
>      {
>          IVariableNode node = getVariable("var a:Vector.<String> =
> Vector.<String>(['Hello', 'World']);");
> @@ -93,6 +66,10 @@ public class TestFlexJSGlobalFunctions extends
> TestGoogGlobalFunctions
>          //     <@/>  or something like that?
>          // I cannot find any reference to creating an XML object via a
>          // global function
> +        
> +        // (erikdebruin) E4X in Javascript is obsolete.
> +        //               Ref.: https://developer.mozilla.org/en-US/docs/E4X
> +        
>          assertOut("var /** @type {XML} */ a = XML('@')");
>      }
>  
> @@ -107,6 +84,10 @@ public class TestFlexJSGlobalFunctions extends
> TestGoogGlobalFunctions
>          //     <@/>  or something like that?
>          // I cannot find any reference to creating an XML object via a
>          // global function
> +
> +        // (erikdebruin) E4X in Javascript is obsolete.
> +        //               Ref.: https://developer.mozilla.org/en-US/docs/E4X
> +        
>          assertOut("var /** @type {XMLList} */ a = XMLList('<!-- comment
> -->')");
>      }
>  
> 
> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6f8e8f9e/compiler.jx/s
> rc/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.j
> ava
> ----------------------------------------------------------------------
> diff --git 
> a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFl
> exJSPublisher.java
> b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFl
> exJSPublisher.java
> index f6b358a..137dd61 100644
> --- 
> a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFl
> exJSPublisher.java
> +++ 
> b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFl
> exJSPublisher.java
> @@ -284,13 +284,28 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher
> implements
>          htmlFile.append("\t\t\treturn true;\n");
>          htmlFile.append("\t\t};\n");
>          htmlFile.append("\t\t\n");
> +        // int()
> +        htmlFile.append("\t\tfunction int(value) {\n");
> +        htmlFile.append("\t\t\treturn value >> 0;\n");
> +        htmlFile.append("\t\t};\n");
> +        htmlFile.append("\t\t\n");
>          // trace()
>          htmlFile.append("\t\tfunction trace(value) {\n");
> -        htmlFile.append("\t\t\tif (console && console.log)\n");
> -        htmlFile.append("\t\t\t\tconsole.log(value);\n");
> +        htmlFile.append("\t\t\ttry {\n");
> +        htmlFile.append("\t\t\t\tif (console && console.log) {\n");
> +        htmlFile.append("\t\t\t\t\tconsole.log(value);\n");
> +        htmlFile.append("\t\t\t\t}\n");
> +        htmlFile.append("\t\t\t} catch (e) {\n");
> +        htmlFile.append("\t\t\t\t// ignore; at least we tried ;-)\n");
> +        htmlFile.append("\t\t\t}\n");
>          htmlFile.append("\t\t};\n");
>          htmlFile.append("\t\t\n");
> -
> +        // uint()
> +        htmlFile.append("\t\tfunction uint(value) {\n");
> +        htmlFile.append("\t\t\treturn value >>> 0;\n");
> +        htmlFile.append("\t\t};\n");
> +        htmlFile.append("\t\t\n");
> +        
>          htmlFile.append("\t\tnew ");
>          htmlFile.append(projectName);
>          htmlFile.append("()");
> 
> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6f8e8f9e/compiler.jx/s
> rc/org/apache/flex/compiler/utils/NativeUtils.java
> ----------------------------------------------------------------------
> diff --git a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
> b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
> index 361f178..4f53496 100644
> --- a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
> +++ b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
> @@ -86,9 +86,10 @@ public class NativeUtils
>  
>      public enum NativeJSType
>      {
> +        // (erikdebruin) Ref.:
> https://cwiki.apache.org/confluence/display/FLEX/Full+Table
> +        
> +        Array("Array"),
>          Boolean("Boolean"),
> -        Number("Number"),
> -        String("String"),
>          decodeURI("decodeURI"),
>          decodeURIComponent("decodeURIComponent"),
>          encodeURI("encodeURI"),
> @@ -96,10 +97,30 @@ public class NativeUtils
>          escape("escape"),
>          isFinite("isFinite"),
>          isNaN("isNaN"),
> +        Number("Number"),
> +        Object("Object"),
>          parseFloat("parseFloat"),
>          parseInt("parseInt"),
> -        unescape("unescape");
> +        String("String"),
> +        unescape("unescape"),
> +
> +        // (erikdebruin) These aren't strictly 'native' to JS, but the
> +        //               Publisher provides global functions, so, for all
> +        //               intends and purposes they behave like they are.
> +        _int("int"),
> +        trace("trace"),
> +        uint("uint"),
> +        
> +        // (erikdebruin) These are left out, but should, at some point, be
> +        //               treated as if they actually are 'native'.
> +        /*
> +        isXMLName("isXMLName"),
> +        Vector("Vector"),
> +        XML("XML"),
> +        XMLList("XMLList"),
> +        */
>          
> +        ;
>          private final String value;
>  
>          NativeJSType(String value)
> 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


[4/5] git commit: [flex-falcon] - [FalconJX] updated NativeUtils and support/tests

Posted by er...@apache.org.
[FalconJX] updated NativeUtils and support/tests

I've updated NativeUtils to more closely match the desired state of JS 'native' support for AS global objects and functions. Updated the tests for Object, int and uint again, together with the addition of support methods in the Publisher.

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/develop
Commit: 6f8e8f9e4a315213a13f935dcf4084477abe41e8
Parents: 0420b98
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Sat Apr 20 12:48:58 2013 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Sat Apr 20 12:48:58 2013 +0200

----------------------------------------------------------------------
 .../js/flexjs/TestFlexJSGlobalFunctions.java       |   35 +++-----------
 .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java   |   21 ++++++++-
 .../apache/flex/compiler/utils/NativeUtils.java    |   27 ++++++++++-
 3 files changed, 50 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6f8e8f9e/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
index a3f6207..7cdeebc 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
@@ -48,33 +48,6 @@ public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
 
     @Override
     @Test
-    public void testInt()
-    {
-        IVariableNode node = getVariable("var a:int = int(1.8);");
-        asBlockWalker.visitVariable(node);
-        assertOut("var /** @type {number} */ a = 1.8/** Cast to int */");
-    }
-
-    @Override
-    @Test
-    public void testObject()
-    {
-        IVariableNode node = getVariable("var a:Object = Object(\"1\");");
-        asBlockWalker.visitVariable(node);
-        assertOut("var /** @type {Object} */ a = \"1\"/** Cast to Object */");
-    }
-
-    @Override
-    @Test
-    public void testUint()
-    {
-        IVariableNode node = getVariable("var a:uint = uint(-100);");
-        asBlockWalker.visitVariable(node);
-        assertOut("var /** @type {number} */ a = -100/** Cast to uint */");
-    }
-
-    @Override
-    @Test
     public void testVector()
     {
         IVariableNode node = getVariable("var a:Vector.<String> = Vector.<String>(['Hello', 'World']);");
@@ -93,6 +66,10 @@ public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
         //     <@/>  or something like that?
         // I cannot find any reference to creating an XML object via a
         // global function
+        
+        // (erikdebruin) E4X in Javascript is obsolete.
+        //               Ref.: https://developer.mozilla.org/en-US/docs/E4X
+        
         assertOut("var /** @type {XML} */ a = XML('@')");
     }
 
@@ -107,6 +84,10 @@ public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
         //     <@/>  or something like that?
         // I cannot find any reference to creating an XML object via a
         // global function
+
+        // (erikdebruin) E4X in Javascript is obsolete.
+        //               Ref.: https://developer.mozilla.org/en-US/docs/E4X
+        
         assertOut("var /** @type {XMLList} */ a = XMLList('<!-- comment -->')");
     }
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6f8e8f9e/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index f6b358a..137dd61 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -284,13 +284,28 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         htmlFile.append("\t\t\treturn true;\n");
         htmlFile.append("\t\t};\n");
         htmlFile.append("\t\t\n");
+        // int()
+        htmlFile.append("\t\tfunction int(value) {\n");
+        htmlFile.append("\t\t\treturn value >> 0;\n");
+        htmlFile.append("\t\t};\n");
+        htmlFile.append("\t\t\n");
         // trace()
         htmlFile.append("\t\tfunction trace(value) {\n");
-        htmlFile.append("\t\t\tif (console && console.log)\n");
-        htmlFile.append("\t\t\t\tconsole.log(value);\n");
+        htmlFile.append("\t\t\ttry {\n");
+        htmlFile.append("\t\t\t\tif (console && console.log) {\n");
+        htmlFile.append("\t\t\t\t\tconsole.log(value);\n");
+        htmlFile.append("\t\t\t\t}\n");
+        htmlFile.append("\t\t\t} catch (e) {\n");
+        htmlFile.append("\t\t\t\t// ignore; at least we tried ;-)\n");
+        htmlFile.append("\t\t\t}\n");
         htmlFile.append("\t\t};\n");
         htmlFile.append("\t\t\n");
-
+        // uint()
+        htmlFile.append("\t\tfunction uint(value) {\n");
+        htmlFile.append("\t\t\treturn value >>> 0;\n");
+        htmlFile.append("\t\t};\n");
+        htmlFile.append("\t\t\n");
+        
         htmlFile.append("\t\tnew ");
         htmlFile.append(projectName);
         htmlFile.append("()");

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6f8e8f9e/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
index 361f178..4f53496 100644
--- a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
+++ b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
@@ -86,9 +86,10 @@ public class NativeUtils
 
     public enum NativeJSType
     {
+        // (erikdebruin) Ref.: https://cwiki.apache.org/confluence/display/FLEX/Full+Table
+        
+        Array("Array"),
         Boolean("Boolean"),
-        Number("Number"),
-        String("String"),
         decodeURI("decodeURI"),
         decodeURIComponent("decodeURIComponent"),
         encodeURI("encodeURI"),
@@ -96,10 +97,30 @@ public class NativeUtils
         escape("escape"),
         isFinite("isFinite"),
         isNaN("isNaN"),
+        Number("Number"),
+        Object("Object"),
         parseFloat("parseFloat"),
         parseInt("parseInt"),
-        unescape("unescape");
+        String("String"),
+        unescape("unescape"),
+
+        // (erikdebruin) These aren't strictly 'native' to JS, but the 
+        //               Publisher provides global functions, so, for all 
+        //               intends and purposes they behave like they are.
+        _int("int"),
+        trace("trace"),
+        uint("uint"),
+        
+        // (erikdebruin) These are left out, but should, at some point, be
+        //               treated as if they actually are 'native'.
+        /*
+        isXMLName("isXMLName"),
+        Vector("Vector"),
+        XML("XML"),
+        XMLList("XMLList"),
+        */
         
+        ;
         private final String value;
 
         NativeJSType(String value)


[2/5] git commit: [flex-falcon] - [FalconJX] little update to previous commit

Posted by er...@apache.org.
[FalconJX] little update to previous commit

Commented out the writing to an external file. That shouldn't be part of a regular test run.

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/develop
Commit: ac67e4eb9796c593987bedb363f956ec1876953d
Parents: 305038f
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Sat Apr 20 10:32:08 2013 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Sat Apr 20 10:32:08 2013 +0200

----------------------------------------------------------------------
 .../internal/codegen/js/flexjs/TestFlexJSFile.java |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ac67e4eb/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
index 8c66c4f..e6a1fbb 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
@@ -47,7 +47,7 @@ public class TestFlexJSFile extends FlexJSTestBase
         
         asBlockWalker.visitFile(node);
         
-        writeResultToFile(writer.toString(), fileName);
+        //writeResultToFile(writer.toString(), fileName);
         
         assertOut(getCodeFromFile(fileName + "_result", true,
                 "flexjs" + File.separator + "files"));


[5/5] git commit: [flex-falcon] - [FalconJX] resolved warnings

Posted by er...@apache.org.
[FalconJX] resolved warnings

Removed some unused imports + vars.

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/develop
Commit: eba24a91fd53799de4015d0955729669b1d451e4
Parents: 6f8e8f9
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Sat Apr 20 12:50:50 2013 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Sat Apr 20 12:50:50 2013 +0200

----------------------------------------------------------------------
 .../org/apache/flex/compiler/clients/MXMLJSC.java  |    1 -
 .../compiler/internal/codegen/as/ASEmitter.java    |    1 -
 .../compiler/internal/targets/FlexJSTarget.java    |   17 ---------------
 3 files changed, 0 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/eba24a91/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 35b539f..d4d6bc3 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -443,7 +443,6 @@ public class MXMLJSC
     {
         final List<ICompilerProblem> problemsBuildingSWF = new ArrayList<ICompilerProblem>();
 
-        String qname = config.getMainDefinition();
         ((FlexJSProject)project).mainCU = mainCU;
         final IJSApplication app = buildApplication(project,
                 config.getMainDefinition(), mainCU, problemsBuildingSWF);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/eba24a91/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
index 621105e..3db6b55 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
@@ -42,7 +42,6 @@ import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
 import org.apache.flex.compiler.internal.tree.as.ContainerNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
 import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
-import org.apache.flex.compiler.internal.tree.as.NamespaceAccessExpressionNode;
 import org.apache.flex.compiler.internal.tree.as.TernaryOperatorNode;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.tree.ASTNodeID;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/eba24a91/compiler.jx/src/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/targets/FlexJSTarget.java b/compiler.jx/src/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
index adb0a44..a4fc149 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
@@ -19,27 +19,10 @@
 
 package org.apache.flex.compiler.internal.targets;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.flex.compiler.driver.js.IJSApplication;
-import org.apache.flex.compiler.exceptions.BuildCanceledException;
-import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
-import org.apache.flex.compiler.internal.driver.js.JSApplication;
-import org.apache.flex.compiler.internal.projects.CompilerProject;
-import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.projects.IASProject;
 import org.apache.flex.compiler.targets.IJSTarget;
 import org.apache.flex.compiler.targets.ITargetProgressMonitor;
-import org.apache.flex.compiler.targets.ITargetReport;
 import org.apache.flex.compiler.targets.ITargetSettings;
-import org.apache.flex.compiler.units.ICompilationUnit;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
 
 public class FlexJSTarget extends JSTarget implements IJSTarget
 {