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/03/21 23:10:51 UTC
[14/50] git commit: [flex-falcon] [refs/heads/master] - fix
initializing complex values in [Bindable]
fix initializing complex values in [Bindable]
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/5e482df9
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/5e482df9
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/5e482df9
Branch: refs/heads/master
Commit: 5e482df9d9812e06aec19ae3b5f2fe22574a1314
Parents: a6c4530
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jan 13 13:13:01 2017 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jan 13 13:13:01 2017 -0800
----------------------------------------------------------------------
.../internal/codegen/js/jx/ClassEmitter.java | 6 +-
.../codegen/js/flexjs/TestFlexJSClass.java | 90 ++++++++++++++++++++
2 files changed, 95 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5e482df9/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
index 1717a64..573ff54 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
@@ -213,7 +213,7 @@ public class ClassEmitter extends JSSubEmitter implements
IDefinitionNode[] dnodes = node.getAllMemberNodes();
for (IDefinitionNode dnode : dnodes)
{
- if (dnode.getNodeID() == ASTNodeID.VariableID)
+ if (dnode.getNodeID() == ASTNodeID.VariableID || dnode.getNodeID() == ASTNodeID.BindableVariableID)
{
IVariableNode varnode = ((IVariableNode)dnode);
IExpressionNode vnode = varnode.getAssignedValueNode();
@@ -223,6 +223,10 @@ public class ClassEmitter extends JSSubEmitter implements
write(ASEmitterTokens.THIS);
write(ASEmitterTokens.MEMBER_ACCESS);
write(dnode.getName());
+ if (dnode.getNodeID() == ASTNodeID.BindableVariableID)
+ {
+ write("_");
+ }
write(ASEmitterTokens.SPACE);
writeToken(ASEmitterTokens.EQUAL);
getEmitter().getWalker().walk(vnode);
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5e482df9/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
index bb03418..07c8000 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
@@ -311,6 +311,96 @@ public class TestFlexJSClass extends TestGoogClass
}
@Test
+ public void testBindableFieldsWithInitialComplexValue()
+ {
+ IClassNode node = getClassNode("public class A {[Bindable] public var a:Object = { foo: 1 };[Bindable] protected var b:String; "
+ + "[Bindable] private var c:int; internal var d:uint; var e:Number}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n" +
+ " */\norg.apache.flex.A = function() {\n\n" +
+ "this.a_ = {foo:1};\n" +
+ "};\n\n\n" +
+ "/**\n" +
+ " * @export\n" +
+ " * @type {Object}\n" +
+ " */\n" +
+ "org.apache.flex.A.prototype.a_;\n\n\n" +
+ "/**\n" +
+ " * @protected\n" +
+ " * @type {string}\n" +
+ " */\n" +
+ "org.apache.flex.A.prototype.b_;\n\n\n" +
+ "/**\n" +
+ " * @private\n" +
+ " * @type {number}\n" +
+ " */\n" +
+ "org.apache.flex.A.prototype.c_ = 0;\n\n\n" +
+ "/**\n" +
+ " * @export\n" +
+ " * @type {number}\n" +
+ " */\n" +
+ "org.apache.flex.A.prototype.d = 0;\n\n\n" +
+ "/**\n" +
+ " * @export\n" +
+ " * @type {number}\n" +
+ " */\n" +
+ "org.apache.flex.A.prototype.e;Object.defineProperties(org.apache.flex.A.prototype, /** @lends {org.apache.flex.A.prototype} */ {\n" +
+ "/** @export\n" +
+ " * @type {Object} */\n" +
+ "a: {\n" +
+ "/** @this {org.apache.flex.A} */\n" +
+ " get: function() {\n" +
+ " return this.a_;\n" +
+ " },\n" +
+ "\n" +
+ "/** @this {org.apache.flex.A} */\n" +
+ "set: function(value) {\n" +
+ "if (value != this.a_) {\n" +
+ " var oldValue = this.a_;\n" +
+ " this.a_ = value;\n" +
+ " this.dispatchEvent(org.apache.flex.events.ValueChangeEvent.createUpdateEvent(\n" +
+ " this, \"a\", oldValue, value));\n" +
+ "}\n" +
+ "}}," +
+ "/** @export\n" +
+ " * @private\n" +
+ " * @type {string} */\n" +
+ "b: {\n" +
+ "/** @this {org.apache.flex.A} */\n" +
+ " get: function() {\n" +
+ " return this.b_;\n" +
+ " },\n" +
+ "\n" +
+ "/** @this {org.apache.flex.A} */\n" +
+ "set: function(value) {\n" +
+ "if (value != this.b_) {\n" +
+ " var oldValue = this.b_;\n" +
+ " this.b_ = value;\n" +
+ " this.dispatchEvent(org.apache.flex.events.ValueChangeEvent.createUpdateEvent(\n" +
+ " this, \"b\", oldValue, value));\n" +
+ "}\n" +
+ "}},/** @export\n" +
+ " * @private\n" +
+ " * @type {number} */\n" +
+ "c: {\n" +
+ "/** @this {org.apache.flex.A} */\n" +
+ " get: function() {\n" +
+ " return this.c_;\n" +
+ " },\n" +
+ "\n" +
+ "/** @this {org.apache.flex.A} */\n" +
+ "set: function(value) {\n" +
+ "if (value != this.c_) {\n" +
+ " var oldValue = this.c_;\n" +
+ " this.c_ = value;\n" +
+ " this.dispatchEvent(org.apache.flex.events.ValueChangeEvent.createUpdateEvent(\n" +
+ " this, \"c\", oldValue, value));\n" +
+ "}\n" +
+ "}}}\n" +
+ ");");
+ }
+
+ @Test
public void testBindableClass()
{
IClassNode node = getClassNode("[Bindable] public class A {public var a:Object;protected var b:String; "