adjust the tests for defineProp
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/b974c9aa Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/b974c9aa Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/b974c9aa Branch: refs/heads/develop Commit: b974c9aa4c8ce0337500e2036a369e217375dc47 Parents: 8eefb00 Author: Alex Harui <aha...@apache.org> Authored: Tue Apr 7 21:12:03 2015 -0700 Committer: Alex Harui <aha...@apache.org> Committed: Tue Apr 7 21:12:03 2015 -0700 ---------------------------------------------------------------------- .../js/flexjs/TestFlexJSAccessorMembers.java | 71 ++-- .../codegen/js/flexjs/TestFlexJSAccessors.java | 8 +- .../codegen/js/flexjs/TestFlexJSClass.java | 8 +- .../js/flexjs/TestFlexJSExpressions.java | 50 +-- .../codegen/js/flexjs/TestFlexJSInterface.java | 6 +- .../internal/codegen/js/goog/TestGoogClass.java | 14 +- .../codegen/js/goog/TestGoogEmiter.java | 2 +- .../flexjs/files/FlexJSTest_again_result.js | 92 ++--- .../flexjs/files/MyInitialView_result.js | 411 ++++++++----------- .../files/controllers/MyController_result.js | 18 +- .../flexjs/files/models/MyModel_result.js | 55 ++- .../projects/interfaces/interfaces/IE_result.js | 20 +- .../flexjs/projects/super/Base_result.js | 29 +- .../flexjs/projects/super/Super_result.js | 25 +- .../test-files/goog/files/call-super_result.js | 4 +- .../test-files/goog/files/output.js | 2 +- .../test-files/goog/files/poc_result.js | 2 +- .../goog/files/qualify-new-object_result.js | 2 +- .../codegen/js/flexjs/JSFlexJSEmitter.java | 78 +++- .../internal/codegen/js/goog/JSGoogEmitter.java | 9 +- 20 files changed, 458 insertions(+), 448 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessorMembers.java ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessorMembers.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessorMembers.java index 0d40229..09bf25c 100644 --- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessorMembers.java +++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessorMembers.java @@ -22,6 +22,7 @@ package org.apache.flex.compiler.internal.codegen.js.flexjs; import org.apache.flex.compiler.driver.IBackend; import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogAccessorMembers; import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend; +import org.apache.flex.compiler.tree.as.IClassNode; import org.apache.flex.compiler.tree.as.IGetterNode; import org.apache.flex.compiler.tree.as.ISetterNode; import org.junit.Test; @@ -35,90 +36,100 @@ public class TestFlexJSAccessorMembers extends TestGoogAccessorMembers @Test public void testGetAccessor() { - IGetterNode node = (IGetterNode) getAccessor("function get foo():int{}"); - asBlockWalker.visitGetter(node); - assertOut("/**\n * @return {number}\n */\nFalconTest_A.prototype.get_foo = function() {\n}"); + IClassNode node = (IClassNode) getNode("function get foo():int{}", + IClassNode.class, WRAP_LEVEL_CLASS); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo;\n\n;Object.defineProperties(FalconTest_A.prototype, /** @lends {FalconTest_A.prototype} */ {\n/** @expose */\nfoo: {\nget: /** @this {FalconTest_A} */ function() {\n}}}\n);"); } @Override @Test public void testGetAccessor_withBody() { - IGetterNode node = (IGetterNode) getAccessor("function get foo():int{return -1;}"); - asBlockWalker.visitGetter(node); - assertOut("/**\n * @return {number}\n */\nFalconTest_A.prototype.get_foo = function() {\n return -1;\n}"); + IClassNode node = (IClassNode) getNode("function get foo():int{return -1;}", + IClassNode.class, WRAP_LEVEL_CLASS); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo;\n\n;Object.defineProperties(FalconTest_A.prototype, /** @lends {FalconTest_A.prototype} */ {\n/** @expose */\nfoo: {\nget: /** @this {FalconTest_A} */ function() {\n return -1;\n}}}\n);"); } @Override @Test public void testGetAccessor_withNamespace() { - IGetterNode node = (IGetterNode) getAccessor("public function get foo():int{return -1;}"); - asBlockWalker.visitGetter(node); - assertOut("/**\n * @expose\n * @return {number}\n */\nFalconTest_A.prototype.get_foo = function() {\n return -1;\n}"); + IClassNode node = (IClassNode) getNode("public function get foo():int{return -1;}", + IClassNode.class, WRAP_LEVEL_CLASS); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo;\n\n;Object.defineProperties(FalconTest_A.prototype, /** @lends {FalconTest_A.prototype} */ {\n/** @expose */\nfoo: {\nget: /** @this {FalconTest_A} */ function() {\n return -1;\n}}}\n);"); } @Override @Test public void testGetAccessor_withNamespaceOverride() { - IGetterNode node = (IGetterNode) getAccessor("public override function get foo():int{super.foo(); return -1;}"); - asBlockWalker.visitGetter(node); - assertOut("/**\n * @expose\n * @return {number}\n * @override\n */\nFalconTest_A.prototype.get_foo = function() {\n FalconTest_A.base(this, 'get_foo');\n return -1;\n}"); + IClassNode node = (IClassNode) getNode("public override function get foo():int{super.foo(); return -1;}", + IClassNode.class, WRAP_LEVEL_CLASS); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo;\n\n;Object.defineProperties(FalconTest_A.prototype, /** @lends {FalconTest_A.prototype} */ {\n/** @expose */\nfoo: {\nget: /** @this {FalconTest_A} */ function() {\n org_apache_flex_utils_Language.superGetter(FalconTest_A, this, 'foo');\n return -1;\n}}}\n);"); } @Override @Test public void testGetAccessor_withStatic() { - IGetterNode node = (IGetterNode) getAccessor("public static function get foo():int{return -1;}"); - asBlockWalker.visitGetter(node); - assertOut("/**\n * @expose\n * @return {number}\n */\nFalconTest_A.get_foo = function() {\n return -1;\n}"); + IClassNode node = (IClassNode) getNode("public static function get foo():int{return -1;}", + IClassNode.class, WRAP_LEVEL_CLASS); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n * @type {number}\n */\nFalconTest_A.foo;\n\n;Object.defineProperties(FalconTest_A, /** @lends {FalconTest_A} */ {\n/** @expose */\nfoo: {\nget: function() {\n return -1;\n}}}\n);"); } @Override @Test public void testSetAccessor() { - ISetterNode node = (ISetterNode) getAccessor("function set foo(value:int):void{}"); - asBlockWalker.visitSetter(node); - assertOut("/**\n * @param {number} value\n */\nFalconTest_A.prototype.set_foo = function(value) {\n}"); + IClassNode node = (IClassNode) getNode("function set foo(value:int):void{}", + IClassNode.class, WRAP_LEVEL_CLASS); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo;\n\n;Object.defineProperties(FalconTest_A.prototype, /** @lends {FalconTest_A.prototype} */ {\n/** @expose */\nfoo: {\nset: /** @this {FalconTest_A} */ function(value) {\n}}}\n);"); } @Override @Test public void testSetAccessor_withBody() { - ISetterNode node = (ISetterNode) getAccessor("function set foo(value:int):void{fetch('haai');}"); - asBlockWalker.visitSetter(node); - assertOut("/**\n * @param {number} value\n */\nFalconTest_A.prototype.set_foo = function(value) {\n fetch('haai');\n}"); + IClassNode node = (IClassNode) getNode("function set foo(value:int):void{fetch('haai');}", + IClassNode.class, WRAP_LEVEL_CLASS); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo;\n\n;Object.defineProperties(FalconTest_A.prototype, /** @lends {FalconTest_A.prototype} */ {\n/** @expose */\nfoo: {\nset: /** @this {FalconTest_A} */ function(value) {\n fetch('haai');\n}}}\n);"); } @Override @Test public void testSetAccessor_withNamespace() { - ISetterNode node = (ISetterNode) getAccessor("public function set foo(value:int):void{}"); - asBlockWalker.visitSetter(node); - assertOut("/**\n * @expose\n * @param {number} value\n */\nFalconTest_A.prototype.set_foo = function(value) {\n}"); + IClassNode node = (IClassNode) getNode("public function set foo(value:int):void{}", + IClassNode.class, WRAP_LEVEL_CLASS); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo;\n\n;Object.defineProperties(FalconTest_A.prototype, /** @lends {FalconTest_A.prototype} */ {\n/** @expose */\nfoo: {\nset: /** @this {FalconTest_A} */ function(value) {\n}}}\n);"); } @Override @Test public void testSetAccessor_withNamespaceOverride() { - ISetterNode node = (ISetterNode) getAccessor("public override function set foo(value:int):void{super.foo();}"); - asBlockWalker.visitSetter(node); - assertOut("/**\n * @expose\n * @param {number} value\n * @override\n */\nFalconTest_A.prototype.set_foo = function(value) {\n FalconTest_A.base(this, 'set_foo');\n}"); + IClassNode node = (IClassNode) getNode("public class B extends A { public override function set foo(value:int):void {super.foo = value;} }; public class A extends B { public override set foo(value:int):void{}}", + IClassNode.class, WRAP_LEVEL_PACKAGE); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n * @extends {A}\n */\nB = function() {\n B.base(this, 'constructor');\n};\ngoog.inherits(B, A);\n\n\n/**\n * @expose\n * @type {number}\n */\nB.prototype.foo;\n\n;Object.defineProperties(B.prototype, /** @lends {B.prototype} */ {\n/** @expose */\nfoo: {\nset: /** @this {B} */ function(value) {\n org_apache_flex_utils_Language.superSetter(B, this, 'foo', value);\n}}}\n);"); } @Override @Test public void testSetAccessor_withStatic() { - ISetterNode node = (ISetterNode) getAccessor("public static function set foo(value:int):void{}"); - asBlockWalker.visitSetter(node); - assertOut("/**\n * @expose\n * @param {number} value\n */\nFalconTest_A.set_foo = function(value) {\n}"); + IClassNode node = (IClassNode) getNode("public static function set foo(value:int):void{}", + IClassNode.class, WRAP_LEVEL_CLASS); + asBlockWalker.visitClass(node); + assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n * @type {number}\n */\nFalconTest_A.foo;\n\n;Object.defineProperties(FalconTest_A, /** @lends {FalconTest_A} */ {\n/** @expose */\nfoo: {\nset: function(value) {\n}}}\n);"); } @Override http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessors.java ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessors.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessors.java index d6e6a28..2844dcc 100644 --- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessors.java +++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSAccessors.java @@ -38,7 +38,7 @@ public class TestFlexJSAccessors extends ASTestBase "public function doStuff():void {label = 'hello, bye'; var theLabel:String = label;}; private var _label:String; public function get label():String {return _label}; public function set label(value:String):void {_label = value}; ", IClassNode.class, WRAP_LEVEL_CLASS); asBlockWalker.visitClass(node); - String expected = "/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n */\nFalconTest_A.prototype.doStuff = function() {\n this.set_label('hello, bye');\n var /** @type {string} */ theLabel = this.get_label();\n};\n\n\n/**\n * @private\n * @type {string}\n */\nFalconTest_A.prototype._label;\n\n\n/**\n * @expose\n * @return {string}\n */\nFalconTest_A.prototype.get_label = function() {\n return this._label;\n};\n\n\n/**\n * @expose\n * @param {string} value\n */\nFalconTest_A.prototype.set_label = function(value) {\n this._label = value;\n};"; + String expected = "/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n */\nFalconTest_A.prototype.doStuff = function() {\n this.label = 'hello, bye';\n var /** @type {string} */ theLabel = this.label;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nFalconTest_A.prototype._label;\n\n\n/**\n * @expose\n * @type {string}\n */\nFalconTest_A.prototype.label;\n\n;\n\n\n;Object.defineProperties(FalconTest_A.prototype, /** @lends {FalconTest_A.prototype} */ {\n/** @expose */\nlabel: {\nget: /** @this {FalconTest_A} */ function() {\n return this._label;\n},\nset: /** @this {FalconTest_A} */ function(value) {\n this._label = value;\n}}}\n);"; assertOut(expected); } @@ -49,7 +49,7 @@ public class TestFlexJSAccessors extends ASTestBase "public class B { public function B() {}; public function doStuff():void {this.label = label + 'bye'; var theLabel:String = label;}; private var _label:String; public function get label():String {return _label}; public function set label(value:String):void {_label = value};}", IClassNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitClass(node); - String expected = "/**\n * @constructor\n */\nB = function() {\n};\n\n\n/**\n * @expose\n */\nB.prototype.doStuff = function() {\n this.set_label(this.get_label() + 'bye');\n var /** @type {string} */ theLabel = this.get_label();\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB.prototype._label;\n\n\n/**\n * @expose\n * @return {string}\n */\nB.prototype.get_label = function() {\n return this._label;\n};\n\n\n/**\n * @expose\n * @param {string} value\n */\nB.prototype.set_label = function(value) {\n this._label = value;\n};"; + String expected = "/**\n * @constructor\n */\nB = function() {\n};\n\n\n/**\n * @expose\n */\nB.prototype.doStuff = function() {\n this.label = this.label + 'bye';\n var /** @type {string} */ theLabel = this.label;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB.prototype._label;\n\n\n/**\n * @expose\n * @type {string}\n */\nB.prototype.label;\n\n;\n\n\n;Object.defineProperties(B.prototype, /** @lends {B.prototype} */ {\n/** @expose */\nlabel: {\nget: /** @this {B} */ function() {\n return this._label;\n},\nset: /** @this {B} */ function(value) {\n this._label = value;\n}}}\n);"; assertOut(expected); } @@ -60,7 +60,7 @@ public class TestFlexJSAccessors extends ASTestBase "public function doStuff():void {label = label + 'bye'; var theLabel:String = label;}; private var _label:String; public function get label():String {return _label}; public function set label(value:String):void {_label = value}; ", IClassNode.class, WRAP_LEVEL_CLASS); asBlockWalker.visitClass(node); - String expected = "/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n */\nFalconTest_A.prototype.doStuff = function() {\n this.set_label(this.get_label() + 'bye');\n var /** @type {string} */ theLabel = this.get_label();\n};\n\n\n/**\n * @private\n * @type {string}\n */\nFalconTest_A.prototype._label;\n\n\n/**\n * @expose\n * @return {string}\n */\nFalconTest_A.prototype.get_label = function() {\n return this._label;\n};\n\n\n/**\n * @expose\n * @param {string} value\n */\nFalconTest_A.prototype.set_label = function(value) {\n this._label = value;\n};"; + String expected = "/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n * @expose\n */\nFalconTest_A.prototype.doStuff = function() {\n this.label = this.label + 'bye';\n var /** @type {string} */ theLabel = this.label;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nFalconTest_A.prototype._label;\n\n\n/**\n * @expose\n * @type {string}\n */\nFalconTest_A.prototype.label;\n\n;\n\n\n;Object.defineProperties(FalconTest_A.prototype, /** @lends {FalconTest_A.prototype} */ {\n/** @expose */\nlabel: {\nget: /** @this {FalconTest_A} */ function() {\n return this._label;\n},\nset: /** @this {FalconTest_A} */ function(value) {\n this._label = value;\n}}}\n);"; assertOut(expected); } @@ -71,7 +71,7 @@ public class TestFlexJSAccessors extends ASTestBase "public class B { public function B() {}; public function doStuff():void {label = this.label; var theLabel:String = label;}; private var _label:String; public function get label():String {return _label}; public function set label(value:String):void {_label = value};}", IClassNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitClass(node); - String expected = "/**\n * @constructor\n */\nB = function() {\n};\n\n\n/**\n * @expose\n */\nB.prototype.doStuff = function() {\n this.set_label(this.get_label());\n var /** @type {string} */ theLabel = this.get_label();\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB.prototype._label;\n\n\n/**\n * @expose\n * @return {string}\n */\nB.prototype.get_label = function() {\n return this._label;\n};\n\n\n/**\n * @expose\n * @param {string} value\n */\nB.prototype.set_label = function(value) {\n this._label = value;\n};"; + String expected = "/**\n * @constructor\n */\nB = function() {\n};\n\n\n/**\n * @expose\n */\nB.prototype.doStuff = function() {\n this.label = this.label;\n var /** @type {string} */ theLabel = this.label;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB.prototype._label;\n\n\n/**\n * @expose\n * @type {string}\n */\nB.prototype.label;\n\n;\n\n\n;Object.defineProperties(B.prototype, /** @lends {B.prototype} */ {\n/** @expose */\nlabel: {\nget: /** @this {B} */ function() {\n return this._label;\n},\nset: /** @this {B} */ function(value) {\n this._label = value;\n}}}\n);"; assertOut(expected); } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/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 fd121ea..1eb5434 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 @@ -108,7 +108,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/**\n * @expose\n * @type {spark_components_Button}\n */\norg_apache_flex_B.prototype.button = new spark_components_Button();\n\n\n/**\n * @expose\n * @return {string}\n */\norg_apache_flex_B.prototype.foo = function() {\n return this.button.get_label();\n};"; + String expected = "/**\n * @constructor\n */\norg_apache_flex_B = function() {\n};\n\n\n/**\n * @expose\n * @type {spark_components_Button}\n */\norg_apache_flex_B.prototype.button = new spark_components_Button();\n\n\n/**\n * @expose\n * @return {string}\n */\norg_apache_flex_B.prototype.foo = function() {\n return this.button.label;\n};"; assertOut(expected); } @@ -153,7 +153,7 @@ public class TestFlexJSClass extends TestGoogClass { IClassNode node = getClassNode("public class B {public function B() {}; public function set baz(value:Object):void {}; public function set foo(value:Object):void {baz = value;};}"); asBlockWalker.visitClass(node); - String expected = "/**\n * @constructor\n */\norg_apache_flex_B = function() {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg_apache_flex_B.prototype.set_baz = function(value) {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg_apache_flex_B.prototype.set_foo = function(value) {\n this.set_baz(value);\n};"; + String expected = "/**\n * @constructor\n */\norg_apache_flex_B = function() {\n};\n\n\n/**\n * @expose\n * @type {Object}\n */\norg_apache_flex_B.prototype.baz;\n\n;\n\n\n/**\n * @expose\n * @type {Object}\n */\norg_apache_flex_B.prototype.foo;\n\n;Object.defineProperties(org_apache_flex_B.prototype, /** @lends {org_apache_flex_B.prototype} */ {\n/** @expose */\nbaz: {\nset: /** @this {org_apache_flex_B} */ function(value) {\n}},\n/** @expose */\nfoo: {\nset: /** @this {org_apache_flex_B} */ function(value) {\n this.baz = value;\n}}}\n);"; assertOut(expected); } @@ -162,7 +162,7 @@ public class TestFlexJSClass extends TestGoogClass { IClassNode node = getClassNode("public class B {public function B() {}; override public function set foo(value:Object):void {super.foo = value;};}"); asBlockWalker.visitClass(node); - String expected = "/**\n * @constructor\n */\norg_apache_flex_B = function() {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n * @override\n */\norg_apache_flex_B.prototype.set_foo = function(value) {\n org_apache_flex_B.base(this, 'set_foo', value);\n};"; + String expected = "/**\n * @constructor\n */\norg_apache_flex_B = function() {\n};\n\n\n/**\n * @expose\n * @type {Object}\n */\norg_apache_flex_B.prototype.foo;\n\n;Object.defineProperties(org_apache_flex_B.prototype, /** @lends {org_apache_flex_B.prototype} */ {\n/** @expose */\nfoo: {\nset: /** @this {org_apache_flex_B} */ function(value) {\n foo = value;\n}}}\n);"; assertOut(expected); } @@ -214,7 +214,7 @@ public class TestFlexJSClass extends TestGoogClass + "foo_bar function get foo6():Object{return null;}" + "foo_bar function set foo6(value:Object):void{}" + "}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n */\norg_apache_flex_A = function() {\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg_apache_flex_A.prototype.get_foo1 = function() {\n return null;\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg_apache_flex_A.prototype.set_foo1 = function(value) {\n};\n\n\n/**\n * @protected\n * @return {Object}\n */\norg_apache_flex_A.prototype.get_foo2 = function() {\n return null;\n};\n\n\n/**\n * @protected\n * @param {Object} value\n */\norg_apache_flex_A.prototype.set_foo2 = function(value) {\n};\n\n\n/**\n * @private\n * @return {Object}\n */\norg_apache_flex_A.prototype.get_foo3 = function() {\n return null;\n};\n\n\n/**\n * @private\n * @param {Object} value\n */\norg_apache_flex_A.prototype.set_foo3 = function(value) {\n};\n\n\n/**\n * @return {Object}\n */\norg_apache_flex_A.prototype.get_foo5 = function() {\n return null;\n};\n\n\n/**\n * @param {Object} value\n */\norg_apache_flex_A.prototype.set_foo5 = function(value) {\n};\n\n\n/**\n * @return {Object}\n */\norg_apache_flex_A.prototype.get_foo6 = function() {\n return null;\n};\n\n\n/**\n * @param {Object} value\n */\norg_apache_flex_A.prototype.set_foo6 = function(value) {\n};"); + assertOut("/**\n * @constructor\n */\norg_apache_flex_A = function() {\n};\n\n\n/**\n * @expose\n * @type {Object}\n */\norg_apache_flex_A.prototype.foo1;\n\n;\n\n\n;\n\n\n/**\n * @protected\n * @type {Object}\n */\norg_apache_flex_A.prototype.foo2;\n\n;\n\n\n;\n\n\n/**\n * @private\n * @type {Object}\n */\norg_apache_flex_A.prototype.foo3;\n\n;\n\n\n;\n\n\n/**\n * @expose\n * @type {Object}\n */\norg_apache_flex_A.prototype.foo5;\n\n;\n\n\n;\n\n\n/**\n * @expose\n * @type {Object}\n */\norg_apache_flex_A.prototype.foo6;\n\n;\n\n\n;Object.defineProperties(org_apache_flex_A.prototype, /** @lends {org_apache_flex_A.prototype} */ {\n/** @expose */\nfoo5: {\nget: /** @this {org_apache_flex_A} */ function() {\n return null;\n},\nset: /** @this {org_apache_flex_A} */ function(value) {\n}},\n/** @expose */\nfoo3: {\nget: /** @this {org_apache_flex_A} */ function() {\n return null;\n},\nset: /** @this {org_apache_flex_A} */ function(value) {\n}},\n/** @expose */\nfoo2: {\nget: /** @this {org_apache_flex_A} */ function() {\n return null;\n},\nset: /** @this {org_apache_flex_A} */ function(value) {\n}},\n/** @expose */\nfoo1: {\nget: /** @this {org_apache_flex_A} */ function() {\n return null;\n},\nset: /** @this {org_apache_flex_A} */ function(value) {\n}},\n/** @expose */\nfoo6: {\nget: /** @this {org_apache_flex_A} */ function() {\n return null;\n},\nset: /** @this {org_apache_flex_A} */ function(value) {\n}}}\n);"); } @Override http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java index 84ddd03..9691b70 100644 --- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java +++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java @@ -104,7 +104,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {public function b(s:String):Boolean {return this.c + 10; } public function get c():int { return 0; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.get_c() + 10"); + assertOut("this.c + 10"); } @Test @@ -134,7 +134,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {public function set b(value:int):void {}; public function c() { b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.set_b(1)"); + assertOut("this.b = 1"); } @Test @@ -144,7 +144,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {public function set b(value:int):void {}; public function c() { this.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.set_b(1)"); + assertOut("this.b = 1"); } @Test @@ -168,7 +168,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions ((JSFlexJSEmitter)asEmitter).thisClass = def; asBlockWalker.visitBinaryOperator(bnode); - assertOut("this.set_b(1)"); + assertOut("this.b = 1"); } @Test @@ -192,7 +192,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions ((JSFlexJSEmitter)asEmitter).thisClass = def; asBlockWalker.visitBinaryOperator(bnode); - assertOut("this.set_b(1)"); + assertOut("this.b = 1"); } @Test @@ -202,7 +202,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {public function set b(value:int):void {}; public function c(other:B) { other.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("other.set_b(1)"); + assertOut("other.b = 1"); } @Test @@ -212,7 +212,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {public function set b(value:int):void {}; public function get d():B {}; public function c(other:B) { d.d.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.get_d().get_d().set_b(1)"); + assertOut("this.d.d.b = 1"); } @Test @@ -222,7 +222,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {public function set b(value:int):void {}; public function get d():B {}; public function c(other:B) { other.d.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("other.get_d().set_b(1)"); + assertOut("other.d.b = 1"); } @Test @@ -232,7 +232,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {public function set b(value:int):void {}; public function c() { b = b + 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.set_b(this.get_b() + 1)"); + assertOut("this.b = this.b + 1"); } @Test @@ -262,7 +262,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {[Bindable] public var b:int; public function c() { b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.set_b(1)"); + assertOut("this.b = 1"); } @Test @@ -272,7 +272,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {[Bindable] public var b:int; public function c() { this.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.set_b(1)"); + assertOut("this.b = 1"); } @Test @@ -282,7 +282,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {[Bindable] public var b:int; public function c(other:B) { other.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("other.set_b(1)"); + assertOut("other.b = 1"); } @Test @@ -292,7 +292,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {[Bindable] public var b:int; [Bindable] public var d:B; public function c(other:B) { d.d.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.get_d().get_d().set_b(1)"); + assertOut("this.d.d.b = 1"); } @Test @@ -302,7 +302,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {[Bindable] public var b:int; [Bindable] public var d:B; public function c(other:B) { other.d.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("other.get_d().set_b(1)"); + assertOut("other.d.b = 1"); } @Test @@ -312,7 +312,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {[Bindable] public var b:int; public function c() { b = b + 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.set_b(this.get_b() + 1)"); + assertOut("this.b = this.b + 1"); } @Test @@ -372,7 +372,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {[Bindable] public var b:int; public var d:B; public function c(other:B) { d.d.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("this.d.d.set_b(1)"); + assertOut("this.d.d.b = 1"); } @Test @@ -392,7 +392,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions "public class B {[Bindable] public var b:int; public var d:B; public function c(other:B) { other.d.b = 1; }}", IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitBinaryOperator(node); - assertOut("other.d.set_b(1)"); + assertOut("other.d.b = 1"); } @Test @@ -434,7 +434,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType( node, IBinaryOperatorNode.class); asBlockWalker.visitBinaryOperator(bnode); - assertOut("foo_bar_B.set_b(1)"); + assertOut("foo_bar_B.b = 1"); } @Test @@ -446,7 +446,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType( node, IBinaryOperatorNode.class); asBlockWalker.visitBinaryOperator(bnode); - assertOut("foo_bar_B.set_b(1)"); + assertOut("foo_bar_B.b = 1"); } @Test @@ -458,7 +458,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType( node, IBinaryOperatorNode.class); asBlockWalker.visitBinaryOperator(bnode); - assertOut("foo_bar_B.get_d().set_b(1)"); + assertOut("foo_bar_B.d.b = 1"); } @Test @@ -482,7 +482,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions ((JSFlexJSEmitter)asEmitter).thisClass = def; asBlockWalker.visitBinaryOperator(bnode); - assertOut("foo_bar_B.get_d().set_b(1)"); + assertOut("foo_bar_B.d.b = 1"); } @Test @@ -494,7 +494,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType( node, IBinaryOperatorNode.class); asBlockWalker.visitBinaryOperator(bnode); - assertOut("foo_bar_B.set_b(foo_bar_B.get_b() + 1)"); + assertOut("foo_bar_B.b = foo_bar_B.b + 1"); } @Test @@ -542,7 +542,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions ((JSFlexJSEmitter)asEmitter).thisClass = def; asBlockWalker.visitBinaryOperator(bnode); - assertOut("org_apache_flex_utils_Language.as(this.model, foo_bar_E, true).set_labelText(null)"); + assertOut("org_apache_flex_utils_Language.as(this.model, foo_bar_E, true).labelText = null"); } @Test @@ -636,7 +636,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions { IClassNode node = (IClassNode) getNode("import spark.components.Button; public class B implements Button { public function B() { Button(b).label = ''; } }", ClassNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n * @implements {spark_components_Button}\n */\nB = function() {\n org_apache_flex_utils_Language.as(b, spark_components_Button, true).set_label('');\n};"); + assertOut("/**\n * @constructor\n * @implements {spark_components_Button}\n */\nB = function() {\n org_apache_flex_utils_Language.as(b, spark_components_Button, true).label = '';\n};"); } @Test @@ -644,7 +644,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions { IFunctionNode node = getMethod("function foo(){var foo:Object = FalconTest_A(bar).bar = '';}; public function get bar():Object { return this; };"); asBlockWalker.visitFunction(node); - assertOut("FalconTest_A.prototype.foo = function() {\n var /** @type {Object} */ foo = org_apache_flex_utils_Language.as(this.get_bar(), FalconTest_A, true).set_bar('');\n}"); + assertOut("FalconTest_A.prototype.foo = function() {\n var /** @type {Object} */ foo = org_apache_flex_utils_Language.as(this.bar, FalconTest_A, true).bar = '';\n}"); } @Test http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSInterface.java ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSInterface.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSInterface.java index 1bc10f4..5d1028b 100644 --- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSInterface.java +++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSInterface.java @@ -43,7 +43,7 @@ public class TestFlexJSInterface extends TestGoogInterface + "function get foo1():Object;" + "function set foo1(value:Object):void;}"); asBlockWalker.visitInterface(node); - assertOut("/**\n * @interface\n */\nIA = function() {\n};\n\n\n/**\n * @return {Object}\n */\nIA.prototype.get_foo1 = function() {};\n\n\n/**\n * @param {Object} value\n */\nIA.prototype.set_foo1 = function(value) {};"); + assertOut("/**\n * @interface\n */\nIA = function() {\n};\nIA.prototype.foo1;"); } @Override @@ -54,7 +54,7 @@ public class TestFlexJSInterface extends TestGoogInterface + "function baz1():Object;" + "function baz2(value:Object):void;}"); asBlockWalker.visitInterface(node); - assertOut("/**\n * @interface\n */\nIA = function() {\n};\n\n\n/**\n * @return {Object}\n */\nIA.prototype.baz1 = function() {};\n\n\n/**\n * @param {Object} value\n */\nIA.prototype.baz2 = function(value) {};"); + assertOut("/**\n * @interface\n */\nIA = function() {\n};\nIA.prototype.baz1 = function() {\n};\nIA.prototype.baz2 = function(value) {\n};"); } @Override @@ -67,7 +67,7 @@ public class TestFlexJSInterface extends TestGoogInterface + "function baz1():Object;" + "function baz2(value:Object):void;}"); asBlockWalker.visitInterface(node); - assertOut("/**\n * @interface\n */\nIA = function() {\n};\n\n\n/**\n * @return {Object}\n */\nIA.prototype.get_foo1 = function() {};\n\n\n/**\n * @param {Object} value\n */\nIA.prototype.set_foo1 = function(value) {};\n\n\n/**\n * @return {Object}\n */\nIA.prototype.baz1 = function() {};\n\n\n/**\n * @param {Object} value\n */\nIA.prototype.baz2 = function(value) {};"); + assertOut("/**\n * @interface\n */\nIA = function() {\n};\nIA.prototype.foo1;\nIA.prototype.baz1 = function() {\n};\nIA.prototype.baz2 = function(value) {\n};"); } protected IBackend createBackend() http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java index 791e7d4..bbe0720 100644 --- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java +++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java @@ -81,7 +81,7 @@ public class TestGoogClass extends TestClass { IClassNode node = getClassNode("public class A extends Button {public function A() {}}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); + assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); } @Override @@ -108,7 +108,7 @@ public class TestGoogClass extends TestClass { IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher {public function A() {}}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); + assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); } @Override @@ -117,7 +117,7 @@ public class TestGoogClass extends TestClass { IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher, ILogger {public function A() {}}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); + assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); } @Override @@ -126,7 +126,7 @@ public class TestGoogClass extends TestClass { IClassNode node = getClassNode("public final class A extends Button implements IEventDispatcher, ILogger {public function A() {}}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); + assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); } @Override @@ -135,7 +135,7 @@ public class TestGoogClass extends TestClass { IClassNode node = getClassNode("public class A extends spark.components.Button implements flash.events.IEventDispatcher, mx.logging.ILogger {public function A() {}}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); + assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n\torg.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); } @Override @@ -160,7 +160,7 @@ public class TestGoogClass extends TestClass { IClassNode node = getClassNode("public class A extends spark.components.Button { public function A() { super('foo', 42);}}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n\tvar self = this;\n\torg.apache.flex.A.base(this, 'constructor', 'foo', 42);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); + assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n\tvar self = this;\n\torg.apache.flex.A.base(this, 'constructor', 'foo', 42);\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); } @Override @@ -178,7 +178,7 @@ public class TestGoogClass extends TestClass { IClassNode node = getClassNode("public class A extends spark.components.Button {public function A(arg1:String, arg2:int) {}}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.flex.A = function(arg1, arg2) {\n\torg.apache.flex.A.base(this, 'constructor', arg1, arg2);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); + assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.flex.A = function(arg1, arg2) {\n\torg.apache.flex.A.base(this, 'constructor', arg1, arg2);\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);"); } @Override http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java index ac460d2..e1f1278 100644 --- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java +++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java @@ -50,7 +50,7 @@ public class TestGoogEmiter extends ASTestBase + "return \"Don't \" + _privateVar + value; }"; IFileNode node = compileAS(code); asBlockWalker.visitFile(node); - assertOut("goog.provide('com.example.components.MyTextButton');\n\ngoog.require('spark.components.Button');\n\n/**\n * @constructor\n * @extends {spark.components.Button}\n */\ncom.example.components.MyTextButton = function() {\n\tvar self = this;\n\tcom.example.components.MyTextButton.base(this, 'constructor');\n\tif (foo() != 42) {\n\t\tbar();\n\t}\n}\ngoog.inherits(com.example.components.MyTextButton, spark.components.Button);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyTextButton.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyTextButton.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\tvar self = this;\n\treturn \"Don't \" + self._privateVar + value;\n};"); + assertOut("goog.provide('com.example.components.MyTextButton');\n\ngoog.require('spark.components.Button');\n\n/**\n * @constructor\n * @extends {spark.components.Button}\n */\ncom.example.components.MyTextButton = function() {\n\tvar self = this;\n\tcom.example.components.MyTextButton.base(this, 'constructor');\n\tif (foo() != 42) {\n\t\tbar();\n\t}\n};\ngoog.inherits(com.example.components.MyTextButton, spark.components.Button);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyTextButton.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyTextButton.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\tvar self = this;\n\treturn \"Don't \" + self._privateVar + value;\n};"); } @Test http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js b/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js index 5d6a1ca..5460952 100644 --- a/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js +++ b/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js @@ -46,49 +46,49 @@ FlexJSTest_again = function() { * @private * @type {org_apache_flex_core_SimpleCSSValuesImpl} */ - this.$ID0; + this.$ID0_; /** * @private * @type {MyInitialView} */ - this.$ID1; + this.$ID1_; /** * @private * @type {models_MyModel} */ - this.$ID2; + this.$ID2_; /** * @private * @type {controllers_MyController} */ - this.$ID3; + this.$ID3_; /** * @private * @type {org_apache_flex_net_HTTPService} */ - this.service; + this.service_; /** * @private * @type {org_apache_flex_net_dataConverters_LazyCollection} */ - this.collection; + this.collection_; /** * @private * @type {org_apache_flex_net_JSONInputParser} */ - this.$ID4; + this.$ID4_; /** * @private * @type {StockDataJSONItemConverter} */ - this.$ID5; + this.$ID5_; /** * @private @@ -142,54 +142,38 @@ FlexJSTest_again.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'FlexJSTest_aga */ FlexJSTest_again.prototype.$EH0 = function(event) { - org_apache_flex_utils_Language.as(this.model, models_MyModel, true).set_labelText('Hello World'); + org_apache_flex_utils_Language.as(this.model, models_MyModel, true).labelText = 'Hello World'; }; -/** - * @expose - * @return {org_apache_flex_net_HTTPService} - */ -FlexJSTest_again.prototype.get_service = function() -{ - return this.service; -}; - - -/** - * @expose - * @param {org_apache_flex_net_HTTPService} value - */ -FlexJSTest_again.prototype.set_service = function(value) -{ - if (value != this.service) { - this.service = value; - this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'service', null, value)); +Object.defineProperties(FlexJSTest_again.prototype, /** @lends {FlexJSTest_again.prototype} */ { +/** @expose */ + service: { + /** @this {FlexJSTest_again} */ + get: function() { + return this.service_; + }, + /** @this {FlexJSTest_again} */ + set: function(value) { + if (value != this.service_) { + this.service_ = value; + this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'service', null, value)); + } + } + }, + /** @expose */ + collection: { + /** @this {FlexJSTest_again} */ + get: function() { + return this.collection_; + }, + /** @this {FlexJSTest_again} */ + set: function(value) { + if (value != this.collection_) { + this.collection_ = value; + this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'collection', null, value)); + } + } } -}; - - -/** - * @expose - * @return {org_apache_flex_net_dataConverters_LazyCollection} - */ -FlexJSTest_again.prototype.get_collection = function() -{ - return this.collection; -}; - - -/** - * @expose - * @param {org_apache_flex_net_dataConverters_LazyCollection} value - */ -FlexJSTest_again.prototype.set_collection = function(value) -{ - if (value != this.collection) { - this.collection = value; - this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'collection', null, value)); - } -}; - - +}); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js b/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js index 5f38962..6062278 100644 --- a/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js +++ b/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js @@ -51,139 +51,139 @@ MyInitialView = function() { * @private * @type {org_apache_flex_html_Label} */ - this.lbl; + this.lbl_; /** * @private * @type {org_apache_flex_binding_SimpleBinding} */ - this.$ID0; + this.$ID0_; /** * @private * @type {org_apache_flex_html_TextButton} */ - this.$ID1; + this.$ID1_; /** * @private * @type {org_apache_flex_html_TextButton} */ - this.$ID2; + this.$ID2_; /** * @private * @type {org_apache_flex_html_Label} */ - this.timerLabel; + this.timerLabel_; /** * @private * @type {org_apache_flex_html_List} */ - this.cityList; + this.cityList_; /** * @private * @type {org_apache_flex_binding_ConstantBinding} */ - this.$ID3; + this.$ID3_; /** * @private * @type {org_apache_flex_html_TextArea} */ - this.$ID5; + this.$ID5_; /** * @private * @type {org_apache_flex_binding_SimpleBinding} */ - this.$ID4; + this.$ID4_; /** * @private * @type {org_apache_flex_html_TextInput} */ - this.input; + this.input_; /** * @private * @type {org_apache_flex_html_TextButton} */ - this.$ID6; + this.$ID6_; /** * @private * @type {org_apache_flex_html_CheckBox} */ - this.checkbox; + this.checkbox_; /** * @private * @type {org_apache_flex_html_RadioButton} */ - this.$ID7; + this.$ID7_; /** * @private * @type {org_apache_flex_html_RadioButton} */ - this.$ID8; + this.$ID8_; /** * @private * @type {org_apache_flex_html_RadioButton} */ - this.$ID9; + this.$ID9_; /** * @private * @type {org_apache_flex_html_RadioButton} */ - this.$ID10; + this.$ID10_; /** * @private * @type {org_apache_flex_html_RadioButton} */ - this.$ID11; + this.$ID11_; /** * @private * @type {org_apache_flex_html_RadioButton} */ - this.$ID12; + this.$ID12_; /** * @private * @type {org_apache_flex_html_DropDownList} */ - this.list; + this.list_; /** * @private * @type {org_apache_flex_binding_ConstantBinding} */ - this.$ID13; + this.$ID13_; /** * @private * @type {org_apache_flex_html_TextButton} */ - this.$ID14; + this.$ID14_; /** * @private * @type {org_apache_flex_html_ComboBox} */ - this.comboBox; + this.comboBox_; /** * @private * @type {org_apache_flex_binding_ConstantBinding} */ - this.$ID15; + this.$ID15_; /** * @private @@ -215,40 +215,16 @@ MyInitialView.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'MyInitialView', q MyInitialView.prototype.timer; -/** - * @expose - * @return {string} - */ -MyInitialView.prototype.get_symbol = function() { - return org_apache_flex_utils_Language.as(this.get_list().get_selectedItem(), String); -}; +; -/** - * @expose - * @return {string} - */ -MyInitialView.prototype.get_city = function() { - return org_apache_flex_utils_Language.as(this.get_cityList().get_selectedItem(), String); -}; +; -/** - * @expose - * @return {string} - */ -MyInitialView.prototype.get_inputText = function() { - return this.get_input().get_text(); -}; +; -/** - * @expose - * @return {string} - */ -MyInitialView.prototype.get_comboBoxValue = function() { - return String(this.get_comboBox().get_selectedItem()); -}; +; /** @@ -267,11 +243,32 @@ MyInitialView.prototype.startTimer = function(event) { * @param {org_apache_flex_events_Event} event */ MyInitialView.prototype.timerHandler = function(event) { - this.get_timerLabel().set_text(this.timer.get_currentCount().toString()); + this.timerLabel.text = this.timer.currentCount.toString(); }; -/** +Object.defineProperties(MyInitialView.prototype, /** @lends {MyInitialView.prototype} */ { +/** @expose */ +comboBoxValue: { +get: /** @this {MyInitialView} */ function() { + return String(this.comboBox.selectedItem); +}}, +/** @expose */ +inputText: { +get: /** @this {MyInitialView} */ function() { + return this.input.text; +}}, +/** @expose */ +symbol: { +get: /** @this {MyInitialView} */ function() { + return org_apache_flex_utils_Language.as(this.list.selectedItem, String); +}}, +/** @expose */ +city: { +get: /** @this {MyInitialView} */ function() { + return org_apache_flex_utils_Language.as(this.cityList.selectedItem, String); +}}} +);/** * @expose * @param {org_apache_flex_events_Event} event */ @@ -342,180 +339,116 @@ MyInitialView.prototype.$EH6 = function(event) }; -/** - * @expose - * @return {org_apache_flex_html_Label} - */ -MyInitialView.prototype.get_lbl = function() -{ - return this.lbl; -}; - - -/** - * @expose - * @param {org_apache_flex_html_Label} value - */ -MyInitialView.prototype.set_lbl = function(value) -{ - if (value != this.lbl) { - this.lbl = value; - this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'lbl', null, value)); - } -}; - - -/** - * @expose - * @return {org_apache_flex_html_Label} - */ -MyInitialView.prototype.get_timerLabel = function() -{ - return this.timerLabel; -}; - - -/** - * @expose - * @param {org_apache_flex_html_Label} value - */ -MyInitialView.prototype.set_timerLabel = function(value) -{ - if (value != this.timerLabel) { - this.timerLabel = value; - this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'timerLabel', null, value)); - } -}; - - -/** - * @expose - * @return {org_apache_flex_html_List} - */ -MyInitialView.prototype.get_cityList = function() -{ - return this.cityList; -}; - - -/** - * @expose - * @param {org_apache_flex_html_List} value - */ -MyInitialView.prototype.set_cityList = function(value) -{ - if (value != this.cityList) { - this.cityList = value; - this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'cityList', null, value)); - } -}; - - -/** - * @expose - * @return {org_apache_flex_html_TextInput} - */ -MyInitialView.prototype.get_input = function() -{ - return this.input; -}; - - -/** - * @expose - * @param {org_apache_flex_html_TextInput} value - */ -MyInitialView.prototype.set_input = function(value) -{ - if (value != this.input) { - this.input = value; - this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'input', null, value)); - } -}; - - -/** - * @expose - * @return {org_apache_flex_html_CheckBox} - */ -MyInitialView.prototype.get_checkbox = function() -{ - return this.checkbox; -}; - - -/** - * @expose - * @param {org_apache_flex_html_CheckBox} value - */ -MyInitialView.prototype.set_checkbox = function(value) -{ - if (value != this.checkbox) { - this.checkbox = value; - this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'checkbox', null, value)); - } -}; - - -/** - * @expose - * @return {org_apache_flex_html_DropDownList} - */ -MyInitialView.prototype.get_list = function() -{ - return this.list; -}; - - -/** - * @expose - * @param {org_apache_flex_html_DropDownList} value - */ -MyInitialView.prototype.set_list = function(value) -{ - if (value != this.list) { - this.list = value; - this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'list', null, value)); - } -}; - - -/** - * @expose - * @return {org_apache_flex_html_ComboBox} - */ -MyInitialView.prototype.get_comboBox = function() -{ - return this.comboBox; -}; - - -/** - * @expose - * @param {org_apache_flex_html_ComboBox} value - */ -MyInitialView.prototype.set_comboBox = function(value) -{ - if (value != this.comboBox) { - this.comboBox = value; - this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'comboBox', null, value)); - } -}; - - -/** - * @override - * @return {Array} the Array of UI element descriptors. - */ -MyInitialView.prototype.get_MXMLDescriptor = function() -{ - if (this.mxmldd == undefined) - { - /** @type {Array} */ - var arr = MyInitialView.base(this, 'get_MXMLDescriptor'); - /** @type {Array} */ - var data = [ -org_apache_flex_html_Label, +Object.defineProperties(MyInitialView.prototype, /** @lends {MyInitialView.prototype} */ { +/** @expose */ + lbl: { + /** @this {MyInitialView} */ + get: function() { + return this.lbl_; + }, + /** @this {MyInitialView} */ + set: function(value) { + if (value != this.lbl_) { + this.lbl_ = value; + this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'lbl', null, value)); + } + } + }, + /** @expose */ + timerLabel: { + /** @this {MyInitialView} */ + get: function() { + return this.timerLabel_; + }, + /** @this {MyInitialView} */ + set: function(value) { + if (value != this.timerLabel_) { + this.timerLabel_ = value; + this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'timerLabel', null, value)); + } + } + }, + /** @expose */ + cityList: { + /** @this {MyInitialView} */ + get: function() { + return this.cityList_; + }, + /** @this {MyInitialView} */ + set: function(value) { + if (value != this.cityList_) { + this.cityList_ = value; + this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'cityList', null, value)); + } + } + }, + /** @expose */ + input: { + /** @this {MyInitialView} */ + get: function() { + return this.input_; + }, + /** @this {MyInitialView} */ + set: function(value) { + if (value != this.input_) { + this.input_ = value; + this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'input', null, value)); + } + } + }, + /** @expose */ + checkbox: { + /** @this {MyInitialView} */ + get: function() { + return this.checkbox_; + }, + /** @this {MyInitialView} */ + set: function(value) { + if (value != this.checkbox_) { + this.checkbox_ = value; + this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'checkbox', null, value)); + } + } + }, + /** @expose */ + list: { + /** @this {MyInitialView} */ + get: function() { + return this.list_; + }, + /** @this {MyInitialView} */ + set: function(value) { + if (value != this.list_) { + this.list_ = value; + this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'list', null, value)); + } + } + }, + /** @expose */ + comboBox: { + /** @this {MyInitialView} */ + get: function() { + return this.comboBox_; + }, + /** @this {MyInitialView} */ + set: function(value) { + if (value != this.comboBox_) { + this.comboBox_ = value; + this.dispatchEvent(org_apache_flex_events_ValueChangeEvent.createUpdateEvent(this, 'comboBox', null, value)); + } + } + }, + 'MXMLDescriptor': { + /** @this {MyInitialView} */ + get: function() { + { + if (this.mxmldd == undefined) + { + /** @type {Array} */ + var arr = org_apache_flex_utils_Language.superGetter(MyInitialView,this, 'MXMLDescriptor'); + /** @type {Array} */ + var data = [ + org_apache_flex_html_Label, 4, 'id', true, @@ -887,14 +820,16 @@ null, [org_apache_flex_binding_ConstantBinding, 4, '_id', true, '$ID15', 'source 'change', this.$EH6, null -]; - - if (arr) - this.mxmldd = arr.concat(data); - else - this.mxmldd = data; - } - return this.mxmldd; -}; - - + ]; + + if (arr) + this.mxmldd = arr.concat(data); + else + this.mxmldd = data; + } + return this.mxmldd; + } + } + } + }); + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/flexjs/files/controllers/MyController_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/files/controllers/MyController_result.js b/compiler.jx.tests/test-files/flexjs/files/controllers/MyController_result.js index 27d163b..128b5e6 100644 --- a/compiler.jx.tests/test-files/flexjs/files/controllers/MyController_result.js +++ b/compiler.jx.tests/test-files/flexjs/files/controllers/MyController_result.js @@ -76,10 +76,10 @@ controllers_MyController.prototype.viewChangeHandler = function(event) { * @param {org_apache_flex_events_Event} event */ controllers_MyController.prototype.buttonClickHandler = function(event) { - var /** @type {string} */ sym = org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).get_symbol(); - this.app.get_service().set_url(this.queryBegin + sym + this.queryEnd); - this.app.get_service().send(); - this.app.get_service().addEventListener("complete", goog.bind(this.completeHandler, this)); + var /** @type {string} */ sym = org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).symbol; + this.app.service.url = this.queryBegin + sym + this.queryEnd; + this.app.service.send(); + this.app.service.addEventListener("complete", goog.bind(this.completeHandler, this)); }; @@ -88,7 +88,7 @@ controllers_MyController.prototype.buttonClickHandler = function(event) { * @param {org_apache_flex_events_Event} event */ controllers_MyController.prototype.completeHandler = function(event) { - org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).set_labelText(org_apache_flex_utils_Language.as(this.app.get_collection().getItemAt(0), String)); + org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).labelText = org_apache_flex_utils_Language.as(this.app.collection.getItemAt(0), String); }; @@ -97,7 +97,7 @@ controllers_MyController.prototype.completeHandler = function(event) { * @param {org_apache_flex_events_Event} event */ controllers_MyController.prototype.listChangedHandler = function(event) { - org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).set_labelText(org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).get_symbol()); + org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).labelText = org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).symbol; }; @@ -106,7 +106,7 @@ controllers_MyController.prototype.listChangedHandler = function(event) { * @param {org_apache_flex_events_Event} event */ controllers_MyController.prototype.cityListChangeHandler = function(event) { - org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).set_labelText(org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).get_city()); + org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).labelText = org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).city; }; @@ -115,7 +115,7 @@ controllers_MyController.prototype.cityListChangeHandler = function(event) { * @param {org_apache_flex_events_Event} event */ controllers_MyController.prototype.transferClickHandler = function(event) { - org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).set_labelText(org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).get_inputText()); + org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).labelText = org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).inputText; }; @@ -124,7 +124,7 @@ controllers_MyController.prototype.transferClickHandler = function(event) { * @param {org_apache_flex_events_Event} event */ controllers_MyController.prototype.comboBoxChangeHandler = function(event) { - org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).set_labelText(org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).get_comboBoxValue()); + org_apache_flex_utils_Language.as(this.app.model, models_MyModel, true).labelText = org_apache_flex_utils_Language.as(this.app.initialView, MyInitialView, true).comboBoxValue; }; http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/flexjs/files/models/MyModel_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/files/models/MyModel_result.js b/compiler.jx.tests/test-files/flexjs/files/models/MyModel_result.js index 4f73cf3..5921236 100644 --- a/compiler.jx.tests/test-files/flexjs/files/models/MyModel_result.js +++ b/compiler.jx.tests/test-files/flexjs/files/models/MyModel_result.js @@ -42,23 +42,14 @@ models_MyModel.prototype._labelText; /** * @expose - * @return {string} + * @type {string} */ -models_MyModel.prototype.get_labelText = function() { - return this._labelText; -}; +models_MyModel.prototype.labelText; +; -/** - * @expose - * @param {string} value - */ -models_MyModel.prototype.set_labelText = function(value) { - if (value != this._labelText) { - this._labelText = value; - this.dispatchEvent(new org_apache_flex_events_Event("labelTextChanged")); - } -}; + +; /** @@ -70,11 +61,11 @@ models_MyModel.prototype._strings = ["AAPL", "ADBE", "GOOG", "MSFT", "YHOO"]; /** * @expose - * @return {Array} + * @type {Array} */ -models_MyModel.prototype.get_strings = function() { - return this._strings; -}; +models_MyModel.prototype.strings; + +; /** @@ -86,11 +77,33 @@ models_MyModel.prototype._cities = ["London", "Miami", "Paris", "Sydney", "Tokyo /** * @expose - * @return {Array} + * @type {Array} */ -models_MyModel.prototype.get_cities = function() { +models_MyModel.prototype.cities; + +;Object.defineProperties(models_MyModel.prototype, /** @lends {models_MyModel.prototype} */ { +/** @expose */ +labelText: { +get: /** @this {models_MyModel} */ function() { + return this._labelText; +}, +set: /** @this {models_MyModel} */ function(value) { + if (value != this._labelText) { + this._labelText = value; + this.dispatchEvent(new org_apache_flex_events_Event("labelTextChanged")); + } +}}, +/** @expose */ +cities: { +get: /** @this {models_MyModel} */ function() { return this._cities; -}; +}}, +/** @expose */ +strings: { +get: /** @this {models_MyModel} */ function() { + return this._strings; +}}} +); /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE_result.js b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE_result.js index 19275b0..78e3f86 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE_result.js @@ -28,21 +28,9 @@ goog.provide('interfaces_IE'); */ interfaces_IE = function() { }; - - -interfaces_IE.prototype.myMethod = function() {}; - - -/** - * @return {string} - */ -interfaces_IE.prototype.get_myProp = function() {}; - - -/** - * @param {string} value - */ -interfaces_IE.prototype.set_myProp = function(value) {}; +interfaces_IE.prototype.myMethod = function() { +}; +interfaces_IE.prototype.myProp; /** @@ -50,4 +38,4 @@ interfaces_IE.prototype.set_myProp = function(value) {}; * * @type {Object.<string, Array.<Object>>} */ -interfaces_IE.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IE', qName: 'interfaces_IE'}] }; +interfaces_IE.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IE', qName: 'interfaces_IE'}] }; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/flexjs/projects/super/Base_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/super/Base_result.js b/compiler.jx.tests/test-files/flexjs/projects/super/Base_result.js index e482ccc..e9f3263 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/super/Base_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/super/Base_result.js @@ -38,24 +38,25 @@ goog.inherits(Base, Super); /** * @expose - * @return {string} - * @override + * @type {string} */ -Base.prototype.get_text = function() { - return "A" + Base.base(this, 'get_text'); -}; +Base.prototype.text; +; -/** - * @expose - * @param {string} value - * @override - */ -Base.prototype.set_text = function(value) { - if (value != Base.base(this, 'get_text')) { - Base.base(this, 'set_text', "B" + value); + +;Object.defineProperties(Base.prototype, /** @lends {Base.prototype} */ { +/** @expose */ +text: { +get: /** @this {Base} */ function() { + return "A" + text; +}, +set: /** @this {Base} */ function(value) { + if (value != text) { + org_apache_flex_utils_Language.superSetter(Base, this, 'text', "B" + value); } -}; +}}} +); /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/flexjs/projects/super/Super_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/super/Super_result.js b/compiler.jx.tests/test-files/flexjs/projects/super/Super_result.js index 5a11768..d35c1e0 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/super/Super_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/super/Super_result.js @@ -39,22 +39,25 @@ Super.prototype._text = ''; /** * @expose - * @return {string} + * @type {string} */ -Super.prototype.get_text = function() { - return this._text; -}; +Super.prototype.text; +; -/** - * @expose - * @param {string} value - */ -Super.prototype.set_text = function(value) { + +;Object.defineProperties(Super.prototype, /** @lends {Super.prototype} */ { +/** @expose */ +text: { +get: /** @this {Super} */ function() { + return this._text; +}, +set: /** @this {Super} */ function(value) { if (value != this._text) { this._text = value; } -}; +}}} +); /** @@ -62,4 +65,4 @@ Super.prototype.set_text = function(value) { * * @type {Object.<string, Array.<Object>>} */ -Super.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Super', qName: 'Super'}] }; +Super.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Super', qName: 'Super'}] }; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/goog/files/call-super_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/goog/files/call-super_result.js b/compiler.jx.tests/test-files/goog/files/call-super_result.js index 6b751fb..d877c86 100644 --- a/compiler.jx.tests/test-files/goog/files/call-super_result.js +++ b/compiler.jx.tests/test-files/goog/files/call-super_result.js @@ -25,7 +25,7 @@ goog.require('spark.components.Button'); org.apache.flex.A = function(z) { var self = this; org.apache.flex.A.base(this, 'constructor', z); -} +}; goog.inherits(org.apache.flex.A, spark.components.Button); /** @@ -38,4 +38,4 @@ org.apache.flex.A.prototype.hasSuperCall = function(a, b) { org.apache.flex.A.base(this, 'hasSuperCall', a, b, 100); var /** @type {string} */ result = myRegularFunctionCall(-1); return result; -}; +}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/goog/files/output.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/goog/files/output.js b/compiler.jx.tests/test-files/goog/files/output.js index a2d00e5..af542a3 100644 --- a/compiler.jx.tests/test-files/goog/files/output.js +++ b/compiler.jx.tests/test-files/goog/files/output.js @@ -25,7 +25,7 @@ org.apache.flex.A = function() { var self = this; org.apache.flex.A.base(this, 'constructor'); self.trace(typeof("a")); -} +}; goog.inherits(org.apache.flex.A, spark.components.Button); /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/goog/files/poc_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/goog/files/poc_result.js b/compiler.jx.tests/test-files/goog/files/poc_result.js index 3b983ef..e9d176a 100644 --- a/compiler.jx.tests/test-files/goog/files/poc_result.js +++ b/compiler.jx.tests/test-files/goog/files/poc_result.js @@ -26,7 +26,7 @@ Example = function() { var self = this; Example.base(this, 'constructor'); self.init(); -} +}; goog.inherits(Example, spark.components.Group); /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx.tests/test-files/goog/files/qualify-new-object_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/goog/files/qualify-new-object_result.js b/compiler.jx.tests/test-files/goog/files/qualify-new-object_result.js index b5821e4..e10f9fd 100644 --- a/compiler.jx.tests/test-files/goog/files/qualify-new-object_result.js +++ b/compiler.jx.tests/test-files/goog/files/qualify-new-object_result.js @@ -24,7 +24,7 @@ org.apache.flex.A = function() { var self = this; org.apache.flex.A.base(this, 'constructor'); self.init(); -} +}; goog.inherits(org.apache.flex.A, flash.events.EventDispatcher); /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/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 46a4da9..51a3510 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 @@ -121,9 +121,16 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter } HashMap<String, PropertyNodes> propertyMap = new HashMap<String, PropertyNodes>(); + HashMap<String, PropertyNodes> staticPropertyMap = new HashMap<String, PropertyNodes>(); ArrayList<String> bindableVars = new ArrayList<String>(); @Override + protected void writeIndent() + { + write(JSFlexJSEmitterTokens.INDENT); + } + + @Override protected String getIndent(int numIndent) { final StringBuilder sb = new StringBuilder(); @@ -312,6 +319,63 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter write(ASEmitterTokens.PAREN_CLOSE); write(ASEmitterTokens.SEMICOLON); } + if (!staticPropertyMap.isEmpty()) + { + write(JSGoogEmitterTokens.OBJECT); + write(ASEmitterTokens.MEMBER_ACCESS); + write(JSEmitterTokens.DEFINE_PROPERTIES); + write(ASEmitterTokens.PAREN_OPEN); + String qname = definition.getQualifiedName(); + write(formatQualifiedName(qname)); + write(ASEmitterTokens.COMMA); + write(ASEmitterTokens.SPACE); + write("/** @lends {" + formatQualifiedName(qname) + "} */ "); + writeNewline(ASEmitterTokens.BLOCK_OPEN); + + Set<String> propertyNames = staticPropertyMap.keySet(); + boolean firstTime = true; + for (String propName : propertyNames) + { + if (firstTime) + firstTime = false; + else + writeNewline(ASEmitterTokens.COMMA); + + PropertyNodes p = staticPropertyMap.get(propName); + writeNewline("/** @expose */"); + write(propName); + write(ASEmitterTokens.COLON); + write(ASEmitterTokens.SPACE); + writeNewline(ASEmitterTokens.BLOCK_OPEN); + if (p.getter != null) + { + write(ASEmitterTokens.GET); + write(ASEmitterTokens.COLON); + write(ASEmitterTokens.SPACE); + write(ASEmitterTokens.FUNCTION); + emitParameters(p.getter.getParameterNodes()); + + emitDefinePropertyFunction(p.getter); + } + if (p.setter != null) + { + if (p.getter != null) + writeNewline(ASEmitterTokens.COMMA); + + write(ASEmitterTokens.SET); + write(ASEmitterTokens.COLON); + write(ASEmitterTokens.SPACE); + write(ASEmitterTokens.FUNCTION); + emitParameters(p.setter.getParameterNodes()); + + emitDefinePropertyFunction(p.setter); + } + write(ASEmitterTokens.BLOCK_CLOSE); + } + writeNewline(ASEmitterTokens.BLOCK_CLOSE); + write(ASEmitterTokens.PAREN_CLOSE); + write(ASEmitterTokens.SEMICOLON); + } } private void loadImportIgnores(String doc) @@ -1379,12 +1443,15 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter @Override public void emitGetAccessor(IGetterNode node) { + ModifiersSet modifierSet = node.getDefinition().getModifiers(); + boolean isStatic = (modifierSet != null && modifierSet.hasModifier(ASModifier.STATIC)); + HashMap<String, PropertyNodes> map = isStatic ? staticPropertyMap : propertyMap; String name = node.getName(); - PropertyNodes p = propertyMap.get(name); + PropertyNodes p = map.get(name); if (p == null) { p = new PropertyNodes(); - propertyMap.put(name, p); + map.put(name, p); } p.getter = node; FunctionNode fn = (FunctionNode) node; @@ -1394,12 +1461,15 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter @Override public void emitSetAccessor(ISetterNode node) { + ModifiersSet modifierSet = node.getDefinition().getModifiers(); + boolean isStatic = (modifierSet != null && modifierSet.hasModifier(ASModifier.STATIC)); + HashMap<String, PropertyNodes> map = isStatic ? staticPropertyMap : propertyMap; String name = node.getName(); - PropertyNodes p = propertyMap.get(name); + PropertyNodes p = map.get(name); if (p == null) { p = new PropertyNodes(); - propertyMap.put(name, p); + map.put(name, p); } p.setter = node; FunctionNode fn = (FunctionNode) node; http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b974c9aa/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java index 58cc59f..b253fbc 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java @@ -101,6 +101,11 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter return new JSGoogDocEmitter(this); } + protected void writeIndent() + { + write(ASEmitterTokens.INDENT); + } + //-------------------------------------------------------------------------- // //-------------------------------------------------------------------------- @@ -493,7 +498,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter if (isConstructor && hasSuperClass) { - writeNewline(); + writeNewline(ASEmitterTokens.SEMICOLON); write(JSGoogEmitterTokens.GOOG_INHERITS); write(ASEmitterTokens.PAREN_OPEN); write(formatQualifiedName(qname)); @@ -736,7 +741,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter if (!hasBody(node)) { indentPush(); - write(ASEmitterTokens.INDENT); + writeIndent(); } List<IParameterNode> parameters = new ArrayList<IParameterNode>(