flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject git commit: update FlexJS emitter to use fully qualified names for 'new classname()'. Now it runs on older versions of Safari. Requires latest FlexJS sources
Date Wed, 03 Apr 2013 04:49:00 GMT
Updated Branches:
  refs/heads/develop 4c3b6d0a9 -> 612357a52


update FlexJS emitter to use fully qualified names for 'new classname()'.  Now it runs on
older versions of Safari.  Requires latest FlexJS sources


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

Branch: refs/heads/develop
Commit: 612357a520faaef1d3ae31abde8d44604d2ee28d
Parents: 4c3b6d0
Author: Alex Harui <aharui@apache.org>
Authored: Tue Apr 2 21:48:24 2013 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Apr 2 21:48:38 2013 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/TestFlexJSClass.java         |    2 +-
 .../codegen/js/flexjs/JSFlexJSEmitter.java         |   14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/612357a5/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
index 6308d27..b36d4b3 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
@@ -45,7 +45,7 @@ public class TestFlexJSClass extends TestGoogClass
     {
         IClassNode node = getClassNode("public class B {public function B() {}; public var
button:Button = new Button(); public function foo():String {return button.label;};}");
         asBlockWalker.visitClass(node);
-        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n/**\n
* @type {spark.components.Button}\n */\norg.apache.flex.B.prototype.button = new Button();\n\n/**\n
* @return {string}\n */\norg.apache.flex.B.prototype.foo = function() {\n\tvar self = this;\n\treturn
self.button.get_label();\n};";
+        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n/**\n
* @type {spark.components.Button}\n */\norg.apache.flex.B.prototype.button = new spark.components.Button();\n\n/**\n
* @return {string}\n */\norg.apache.flex.B.prototype.foo = function() {\n\tvar self = this;\n\treturn
self.button.get_label();\n};";
         assertOut(expected);
     }
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/612357a5/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 4d0b3e9..0c711ce 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -172,7 +172,19 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
                         && !(NativeUtils.isNative(def.getBaseName()));
             }
 
-            if (!isClassCast)
+            if (node.isNewExpression())
+            {
+            	def = node.resolveCalledExpression(getWalker().getProject());
+            	// all new calls to a class should be fully qualified names
+            	if (def instanceof ClassDefinition)
+            		write(def.getQualifiedName());
+            	else // I think we still need this for "new someVarOfTypeClass"
+            		getWalker().walk(node.getNameNode());
+                write(ASEmitterTokens.PAREN_OPEN);
+                walkArguments(node.getArgumentNodes());
+                write(ASEmitterTokens.PAREN_CLOSE);
+            }
+            else if (!isClassCast)
             {
                 getWalker().walk(node.getNameNode());
                 write(ASEmitterTokens.PAREN_OPEN);


Mime
View raw message