Updated Branches: refs/heads/develop 026a53c72 -> dc0c5fe49
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/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 2bebadd..5ef10ba 100644 --- a/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js +++ b/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js @@ -21,157 +21,157 @@ goog.require('org.apache.flex.utils.Timer'); * @extends {org.apache.flex.core.ViewBase} */ MyInitialView = function() { - goog.base(this); - - /** - * @private - * @type {org.apache.flex.html.staticControls.Label} - */ - this.lbl; - - /** - * @private - * @type {org.apache.flex.binding.SimpleBinding} - */ - this.$ID0; - - /** - * @private - * @type {org.apache.flex.html.staticControls.TextButton} - */ - this.$ID1; - - /** - * @private - * @type {org.apache.flex.html.staticControls.TextButton} - */ - this.$ID2; - - /** - * @private - * @type {org.apache.flex.html.staticControls.Label} - */ - this.timerLabel; - - /** - * @private - * @type {org.apache.flex.html.staticControls.List} - */ - this.cityList; - - /** - * @private - * @type {org.apache.flex.binding.ConstantBinding} - */ - this.$ID3; - - /** - * @private - * @type {org.apache.flex.html.staticControls.TextArea} - */ - this.$ID5; - - /** - * @private - * @type {org.apache.flex.binding.SimpleBinding} - */ - this.$ID4; - - /** - * @private - * @type {org.apache.flex.html.staticControls.TextInput} - */ - this.input; - - /** - * @private - * @type {org.apache.flex.html.staticControls.TextButton} - */ - this.$ID6; - - /** - * @private - * @type {org.apache.flex.html.staticControls.CheckBox} - */ - this.checkbox; - - /** - * @private - * @type {org.apache.flex.html.staticControls.RadioButton} - */ - this.$ID7; - - /** - * @private - * @type {org.apache.flex.html.staticControls.RadioButton} - */ - this.$ID8; - - /** - * @private - * @type {org.apache.flex.html.staticControls.RadioButton} - */ - this.$ID9; - - /** - * @private - * @type {org.apache.flex.html.staticControls.RadioButton} - */ - this.$ID10; - - /** - * @private - * @type {org.apache.flex.html.staticControls.RadioButton} - */ - this.$ID11; - - /** - * @private - * @type {org.apache.flex.html.staticControls.RadioButton} - */ - this.$ID12; - - /** - * @private - * @type {org.apache.flex.html.staticControls.DropDownList} - */ - this.list; - - /** - * @private - * @type {org.apache.flex.binding.ConstantBinding} - */ - this.$ID13; - - /** - * @private - * @type {org.apache.flex.html.staticControls.TextButton} - */ - this.$ID14; - - /** - * @private - * @type {org.apache.flex.html.staticControls.ComboBox} - */ - this.comboBox; - - /** - * @private - * @type {org.apache.flex.binding.ConstantBinding} - */ - this.$ID15; - - /** - * @private - * @type {Array} - */ - this.mxmldd; - - /** - * @private - * @type {Array} - */ - this.mxmldp; + goog.base(this); + + /** + * @private + * @type {org.apache.flex.html.staticControls.Label} + */ + this.lbl; + + /** + * @private + * @type {org.apache.flex.binding.SimpleBinding} + */ + this.$ID0; + + /** + * @private + * @type {org.apache.flex.html.staticControls.TextButton} + */ + this.$ID1; + + /** + * @private + * @type {org.apache.flex.html.staticControls.TextButton} + */ + this.$ID2; + + /** + * @private + * @type {org.apache.flex.html.staticControls.Label} + */ + this.timerLabel; + + /** + * @private + * @type {org.apache.flex.html.staticControls.List} + */ + this.cityList; + + /** + * @private + * @type {org.apache.flex.binding.ConstantBinding} + */ + this.$ID3; + + /** + * @private + * @type {org.apache.flex.html.staticControls.TextArea} + */ + this.$ID5; + + /** + * @private + * @type {org.apache.flex.binding.SimpleBinding} + */ + this.$ID4; + + /** + * @private + * @type {org.apache.flex.html.staticControls.TextInput} + */ + this.input; + + /** + * @private + * @type {org.apache.flex.html.staticControls.TextButton} + */ + this.$ID6; + + /** + * @private + * @type {org.apache.flex.html.staticControls.CheckBox} + */ + this.checkbox; + + /** + * @private + * @type {org.apache.flex.html.staticControls.RadioButton} + */ + this.$ID7; + + /** + * @private + * @type {org.apache.flex.html.staticControls.RadioButton} + */ + this.$ID8; + + /** + * @private + * @type {org.apache.flex.html.staticControls.RadioButton} + */ + this.$ID9; + + /** + * @private + * @type {org.apache.flex.html.staticControls.RadioButton} + */ + this.$ID10; + + /** + * @private + * @type {org.apache.flex.html.staticControls.RadioButton} + */ + this.$ID11; + + /** + * @private + * @type {org.apache.flex.html.staticControls.RadioButton} + */ + this.$ID12; + + /** + * @private + * @type {org.apache.flex.html.staticControls.DropDownList} + */ + this.list; + + /** + * @private + * @type {org.apache.flex.binding.ConstantBinding} + */ + this.$ID13; + + /** + * @private + * @type {org.apache.flex.html.staticControls.TextButton} + */ + this.$ID14; + + /** + * @private + * @type {org.apache.flex.html.staticControls.ComboBox} + */ + this.comboBox; + + /** + * @private + * @type {org.apache.flex.binding.ConstantBinding} + */ + this.$ID15; + + /** + * @private + * @type {Array} + */ + this.mxmldd; + + /** + * @private + * @type {Array} + */ + this.mxmldp; }; goog.inherits(MyInitialView, org.apache.flex.core.ViewBase); @@ -186,7 +186,7 @@ MyInitialView.prototype.timer; * @return {string} */ MyInitialView.prototype.get_symbol = function() { - return org.apache.flex.utils.Language.as(this.get_list().get_selectedItem(), String); + return org.apache.flex.utils.Language.as(this.get_list().get_selectedItem(), String); }; /** @@ -194,7 +194,7 @@ MyInitialView.prototype.get_symbol = function() { * @return {string} */ MyInitialView.prototype.get_city = function() { - return org.apache.flex.utils.Language.as(this.get_cityList().get_selectedItem(), String); + return org.apache.flex.utils.Language.as(this.get_cityList().get_selectedItem(), String); }; /** @@ -202,7 +202,7 @@ MyInitialView.prototype.get_city = function() { * @return {string} */ MyInitialView.prototype.get_inputText = function() { - return this.get_input().get_text(); + return this.get_input().get_text(); }; /** @@ -210,7 +210,7 @@ MyInitialView.prototype.get_inputText = function() { * @return {string} */ MyInitialView.prototype.get_comboBoxValue = function() { - return String(this.get_comboBox().get_selectedItem()); + return String(this.get_comboBox().get_selectedItem()); }; /** @@ -218,9 +218,9 @@ MyInitialView.prototype.get_comboBoxValue = function() { * @param {org.apache.flex.events.org.apache.flex.events.Event} event */ MyInitialView.prototype.startTimer = function(event) { - this.timer = new org.apache.flex.utils.Timer(1000); - this.timer.addEventListener('timer', goog.bind(this.timerHandler, this)); - this.timer.start(); + this.timer = new org.apache.flex.utils.Timer(1000); + this.timer.addEventListener('timer', goog.bind(this.timerHandler, this)); + this.timer.start(); }; /** @@ -228,7 +228,7 @@ MyInitialView.prototype.startTimer = function(event) { * @param {org.apache.flex.events.org.apache.flex.events.Event} event */ MyInitialView.prototype.timerHandler = function(event) { - this.get_timerLabel().set_text(this.timer.get_currentCount().toString()); + this.get_timerLabel().set_text(this.timer.get_currentCount().toString()); }; /** @@ -238,7 +238,7 @@ MyInitialView.prototype.timerHandler = function(event) { */ MyInitialView.prototype.$EH0 = function(event) { - this.startTimer(event); + this.startTimer(event); }; /** @@ -248,8 +248,8 @@ MyInitialView.prototype.$EH0 = function(event) */ MyInitialView.prototype.$EH1 = function(event) { - this.timer.removeEventListener('timer', goog.bind(this.timerHandler, this)); - this.timer.stop(); + this.timer.removeEventListener('timer', goog.bind(this.timerHandler, this)); + this.timer.stop(); }; /** @@ -259,7 +259,7 @@ MyInitialView.prototype.$EH1 = function(event) */ MyInitialView.prototype.$EH2 = function(event) { - this.dispatchEvent(new org.apache.flex.events.CustomEvent('cityListChanged')); + this.dispatchEvent(new org.apache.flex.events.CustomEvent('cityListChanged')); }; /** @@ -269,7 +269,7 @@ MyInitialView.prototype.$EH2 = function(event) */ MyInitialView.prototype.$EH3 = function(event) { - this.dispatchEvent(new org.apache.flex.events.CustomEvent('transferClicked')); + this.dispatchEvent(new org.apache.flex.events.CustomEvent('transferClicked')); }; /** @@ -279,7 +279,7 @@ MyInitialView.prototype.$EH3 = function(event) */ MyInitialView.prototype.$EH4 = function(event) { - this.dispatchEvent(new org.apache.flex.events.CustomEvent('listChanged')); + this.dispatchEvent(new org.apache.flex.events.CustomEvent('listChanged')); }; /** @@ -289,7 +289,7 @@ MyInitialView.prototype.$EH4 = function(event) */ MyInitialView.prototype.$EH5 = function(event) { - this.dispatchEvent(new org.apache.flex.events.CustomEvent('buttonClicked')); + this.dispatchEvent(new org.apache.flex.events.CustomEvent('buttonClicked')); }; /** @@ -299,7 +299,7 @@ MyInitialView.prototype.$EH5 = function(event) */ MyInitialView.prototype.$EH6 = function(event) { - this.dispatchEvent(new org.apache.flex.events.CustomEvent('comboBoxChanged')); + this.dispatchEvent(new org.apache.flex.events.CustomEvent('comboBoxChanged')); }; /** @@ -309,7 +309,7 @@ MyInitialView.prototype.$EH6 = function(event) */ MyInitialView.prototype.get_lbl = function() { - return this.lbl; + return this.lbl; }; /** @@ -319,8 +319,8 @@ MyInitialView.prototype.get_lbl = function() */ MyInitialView.prototype.set_lbl = function(value) { - if (value != this.lbl) - this.lbl = value; + if (value != this.lbl) + this.lbl = value; }; /** @@ -330,7 +330,7 @@ MyInitialView.prototype.set_lbl = function(value) */ MyInitialView.prototype.get_timerLabel = function() { - return this.timerLabel; + return this.timerLabel; }; /** @@ -340,8 +340,8 @@ MyInitialView.prototype.get_timerLabel = function() */ MyInitialView.prototype.set_timerLabel = function(value) { - if (value != this.timerLabel) - this.timerLabel = value; + if (value != this.timerLabel) + this.timerLabel = value; }; /** @@ -351,7 +351,7 @@ MyInitialView.prototype.set_timerLabel = function(value) */ MyInitialView.prototype.get_cityList = function() { - return this.cityList; + return this.cityList; }; /** @@ -361,8 +361,8 @@ MyInitialView.prototype.get_cityList = function() */ MyInitialView.prototype.set_cityList = function(value) { - if (value != this.cityList) - this.cityList = value; + if (value != this.cityList) + this.cityList = value; }; /** @@ -372,7 +372,7 @@ MyInitialView.prototype.set_cityList = function(value) */ MyInitialView.prototype.get_input = function() { - return this.input; + return this.input; }; /** @@ -382,8 +382,8 @@ MyInitialView.prototype.get_input = function() */ MyInitialView.prototype.set_input = function(value) { - if (value != this.input) - this.input = value; + if (value != this.input) + this.input = value; }; /** @@ -393,7 +393,7 @@ MyInitialView.prototype.set_input = function(value) */ MyInitialView.prototype.get_checkbox = function() { - return this.checkbox; + return this.checkbox; }; /** @@ -403,8 +403,8 @@ MyInitialView.prototype.get_checkbox = function() */ MyInitialView.prototype.set_checkbox = function(value) { - if (value != this.checkbox) - this.checkbox = value; + if (value != this.checkbox) + this.checkbox = value; }; /** @@ -414,7 +414,7 @@ MyInitialView.prototype.set_checkbox = function(value) */ MyInitialView.prototype.get_list = function() { - return this.list; + return this.list; }; /** @@ -424,8 +424,8 @@ MyInitialView.prototype.get_list = function() */ MyInitialView.prototype.set_list = function(value) { - if (value != this.list) - this.list = value; + if (value != this.list) + this.list = value; }; /** @@ -435,7 +435,7 @@ MyInitialView.prototype.set_list = function(value) */ MyInitialView.prototype.get_comboBox = function() { - return this.comboBox; + return this.comboBox; }; /** @@ -445,8 +445,8 @@ MyInitialView.prototype.get_comboBox = function() */ MyInitialView.prototype.set_comboBox = function(value) { - if (value != this.comboBox) - this.comboBox = value; + if (value != this.comboBox) + this.comboBox = value; }; /** @@ -456,12 +456,12 @@ MyInitialView.prototype.set_comboBox = function(value) */ MyInitialView.prototype.get_MXMLDescriptor = function() { - if (this.mxmldd == undefined) - { - /** @type {Array} */ - var arr = goog.base(this, 'get_MXMLDescriptor'); - /** @type {Array} */ - var data = [ + if (this.mxmldd == undefined) + { + /** @type {Array} */ + var arr = goog.base(this, 'get_MXMLDescriptor'); + /** @type {Array} */ + var data = [ org.apache.flex.html.staticControls.Label, 4, 'id', @@ -835,13 +835,13 @@ null, [org.apache.flex.binding.ConstantBinding, 4, '_id', true, '$ID15', 'source 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; }; http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/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 c80f220..36d2f14 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 @@ -1,110 +1,124 @@ goog.provide('controllers.MyController'); + + /** * @constructor * @implements {org.apache.flex.core.IDocument} * @param {org.apache.flex.core.Application=} app */ controllers.MyController = function(app) { - app = typeof app !== 'undefined' ? app : null; - if (app) { - this.app = org.apache.flex.utils.Language.as(app, FlexJSTest_again); - app.addEventListener("viewChanged", goog.bind(this.viewChangeHandler, this)); - } + app = typeof app !== 'undefined' ? app : null; + if (app) { + this.app = org.apache.flex.utils.Language.as(app, FlexJSTest_again); + app.addEventListener("viewChanged", goog.bind(this.viewChangeHandler, this)); + } }; + /** * @private * @type {string} */ controllers.MyController.prototype.queryBegin = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22"; + /** * @private * @type {string} */ controllers.MyController.prototype.queryEnd = "%22)%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json"; + /** * @private * @type {FlexJSTest_again} */ controllers.MyController.prototype.app; + /** * @private * @param {org.apache.flex.events.Event} event */ controllers.MyController.prototype.viewChangeHandler = function(event) { - this.app.initialView.addEventListener("buttonClicked", goog.bind(this.buttonClickHandler, this)); - this.app.initialView.addEventListener("listChanged", goog.bind(this.listChangedHandler, this)); - this.app.initialView.addEventListener("cityListChanged", goog.bind(this.cityListChangeHandler, this)); - this.app.initialView.addEventListener("transferClicked", goog.bind(this.transferClickHandler, this)); - this.app.initialView.addEventListener("comboBoxChanged", goog.bind(this.comboBoxChangeHandler, this)); + this.app.initialView.addEventListener("buttonClicked", goog.bind(this.buttonClickHandler, this)); + this.app.initialView.addEventListener("listChanged", goog.bind(this.listChangedHandler, this)); + this.app.initialView.addEventListener("cityListChanged", goog.bind(this.cityListChangeHandler, this)); + this.app.initialView.addEventListener("transferClicked", goog.bind(this.transferClickHandler, this)); + this.app.initialView.addEventListener("comboBoxChanged", goog.bind(this.comboBoxChangeHandler, this)); }; + /** * @private * @param {org.apache.flex.events.Event} event */ controllers.MyController.prototype.buttonClickHandler = function(event) { - var /** @type {string} */ sym = this.app.initialView/** Cast to MyInitialView */.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 = this.app.initialView/** Cast to MyInitialView */.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)); }; + /** * @private * @param {org.apache.flex.events.Event} event */ controllers.MyController.prototype.completeHandler = function(event) { - this.app.model/** Cast to models.MyModel */.set_labelText(org.apache.flex.utils.Language.as(this.app.get_collection().getItemAt(0), String)); + this.app.model/** Cast to models.MyModel */.set_labelText(org.apache.flex.utils.Language.as(this.app.get_collection().getItemAt(0), String)); }; + /** * @private * @param {org.apache.flex.events.Event} event */ controllers.MyController.prototype.listChangedHandler = function(event) { - this.app.model/** Cast to models.MyModel */.set_labelText(this.app.initialView/** Cast to MyInitialView */.get_symbol()); + this.app.model/** Cast to models.MyModel */.set_labelText(this.app.initialView/** Cast to MyInitialView */.get_symbol()); }; + /** * @private * @param {org.apache.flex.events.Event} event */ controllers.MyController.prototype.cityListChangeHandler = function(event) { - this.app.model/** Cast to models.MyModel */.set_labelText(this.app.initialView/** Cast to MyInitialView */.get_city()); + this.app.model/** Cast to models.MyModel */.set_labelText(this.app.initialView/** Cast to MyInitialView */.get_city()); }; + /** * @private * @param {org.apache.flex.events.Event} event */ controllers.MyController.prototype.transferClickHandler = function(event) { - this.app.model/** Cast to models.MyModel */.set_labelText(this.app.initialView/** Cast to MyInitialView */.get_inputText()); + this.app.model/** Cast to models.MyModel */.set_labelText(this.app.initialView/** Cast to MyInitialView */.get_inputText()); }; + /** * @private * @param {org.apache.flex.events.Event} event */ controllers.MyController.prototype.comboBoxChangeHandler = function(event) { - this.app.model/** Cast to models.MyModel */.set_labelText(this.app.initialView/** Cast to MyInitialView */.get_comboBoxValue()); + this.app.model/** Cast to models.MyModel */.set_labelText(this.app.initialView/** Cast to MyInitialView */.get_comboBoxValue()); }; + /** * @expose * @param {Object} document * @param {string=} id */ controllers.MyController.prototype.setDocument = function(document, id) { - id = typeof id !== 'undefined' ? id : null; - this.app = org.apache.flex.utils.Language.as(document, FlexJSTest_again); - this.app.addEventListener("viewChanged", goog.bind(this.viewChangeHandler, this)); + id = typeof id !== 'undefined' ? id : null; + this.app = org.apache.flex.utils.Language.as(document, FlexJSTest_again); + this.app.addEventListener("viewChanged", goog.bind(this.viewChangeHandler, this)); }; + /** * @const */ http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/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 38422d6..eb9c7a2 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 @@ -1,63 +1,72 @@ goog.provide('models.MyModel'); + + /** * @constructor * @extends {org.apache.flex.events.EventDispatcher} */ models.MyModel = function() { - goog.base(this); + goog.base(this); } goog.inherits(models.MyModel, org.apache.flex.events.EventDispatcher); + /** * @private * @type {string} */ models.MyModel.prototype._labelText; + /** * @expose * @return {string} */ models.MyModel.prototype.get_labelText = function() { - return this._labelText; + return this._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")); - } + if (value != this._labelText) { + this._labelText = value; + this.dispatchEvent(new org.apache.flex.events.Event("labelTextChanged")); + } }; + /** * @private * @type {Array} */ models.MyModel.prototype._strings = ["AAPL", "ADBE", "GOOG", "MSFT", "YHOO"]; + /** * @expose * @return {Array} */ models.MyModel.prototype.get_strings = function() { - return this._strings; + return this._strings; }; + /** * @private * @type {Array} */ models.MyModel.prototype._cities = ["London", "Miami", "Paris", "Sydney", "Tokyo"]; + /** * @expose * @return {Array} */ models.MyModel.prototype.get_cities = function() { - return this._cities; -}; \ No newline at end of file + return this._cities; +}; http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js b/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js index 6923f67..3edfc62 100644 --- a/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js +++ b/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js @@ -3,33 +3,34 @@ goog.provide('wildcard_import'); goog.require('org.apache.flex.core.Application'); goog.require('org.apache.flex.html.staticControls.Button'); + + /** * @constructor * @extends {org.apache.flex.core.Application} */ wildcard_import = function() { - goog.base(this); - - /** - * @private - * @type {Array} - */ - this.mxmldd; - - /** - * @private - * @type {Array} - */ - this.mxmldp; + goog.base(this); + + /** + * @private + * @type {Array} + */ + this.mxmldd; + + /** + * @private + * @type {Array} + */ + this.mxmldp; }; goog.inherits(wildcard_import, org.apache.flex.core.Application); + /** * @private */ wildcard_import.prototype.tmp = function() { - var /** @type {Button} */ myButton; - myButton = new org.apache.flex.html.staticControls.Button(); + var /** @type {Button} */ myButton; + myButton = new org.apache.flex.html.staticControls.Button(); }; - - http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test_result.js b/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test_result.js index 3168e0c..ace15bb 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test_result.js @@ -1,12 +1,12 @@ goog.provide('Test'); goog.require('classes.A'); - goog.require('interfaces.IA'); goog.require('interfaces.IE'); - goog.require('org.apache.flex.utils.Language'); + + /** * @constructor * @extends {classes.A} @@ -14,10 +14,11 @@ goog.require('org.apache.flex.utils.Language'); * @implements {interfaces.IE} */ Test = function() { - goog.base(this); -} + goog.base(this); +}; goog.inherits(Test, classes.A); + /** * @const */ http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A_result.js b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A_result.js index 48c2497..1df9f5d 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A_result.js @@ -2,11 +2,13 @@ goog.provide('classes.A'); goog.require('classes.C'); + + /** * @constructor * @extends {classes.C} */ classes.A = function() { - goog.base(this); -} -goog.inherits(classes.A, classes.C); \ No newline at end of file + goog.base(this); +}; +goog.inherits(classes.A, classes.C); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B_result.js b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B_result.js index d1fe335..3dd8adb 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B_result.js @@ -1,8 +1,9 @@ goog.provide('classes.B'); + /** * @constructor */ classes.B = function() { -}; \ No newline at end of file +}; http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C_result.js b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C_result.js index 7aa37e6..9c7bb13 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C_result.js @@ -1,8 +1,9 @@ goog.provide('classes.C'); + /** * @constructor */ classes.C = function() { -}; \ No newline at end of file +}; http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA_result.js b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA_result.js index 97b7e18..360c807 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA_result.js @@ -2,6 +2,8 @@ goog.provide('interfaces.IA'); goog.require('interfaces.IC'); + + /** * @interface * @extends {interfaces.IC} @@ -9,6 +11,7 @@ goog.require('interfaces.IC'); interfaces.IA = function() { }; + /** * @const */ http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB_result.js b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB_result.js index e50057d..611cfb6 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB_result.js @@ -1,5 +1,7 @@ goog.provide('interfaces.IB'); + + /** * @interface */ http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC_result.js b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC_result.js index db01166..35f794d 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC_result.js @@ -2,6 +2,8 @@ goog.provide('interfaces.IC'); goog.require('interfaces.ID'); + + /** * @interface * @extends {interfaces.ID} @@ -9,6 +11,7 @@ goog.require('interfaces.ID'); interfaces.IC = function() { }; + /** * @const */ http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID_result.js b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID_result.js index d25c4a4..dfa6505 100644 --- a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID_result.js +++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID_result.js @@ -1,6 +1,7 @@ goog.provide('interfaces.ID'); + /** * @interface */ http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/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 bb526de..c91f544 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 @@ -1,6 +1,7 @@ goog.provide('interfaces.IE'); + /** * @interface */ http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/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 5edb70b..e8a2e62 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 @@ -24,6 +24,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants; @@ -31,6 +33,7 @@ import org.apache.flex.compiler.codegen.IDocEmitter; import org.apache.flex.compiler.codegen.js.flexjs.IJSFlexJSEmitter; import org.apache.flex.compiler.common.ASModifier; import org.apache.flex.compiler.common.ModifiersSet; +import org.apache.flex.compiler.definitions.IClassDefinition; import org.apache.flex.compiler.definitions.IDefinition; import org.apache.flex.compiler.definitions.IFunctionDefinition; import org.apache.flex.compiler.definitions.IFunctionDefinition.FunctionClassification; @@ -75,6 +78,7 @@ import org.apache.flex.compiler.tree.as.IInterfaceNode; import org.apache.flex.compiler.tree.as.ILanguageIdentifierNode; import org.apache.flex.compiler.tree.as.ILiteralNode; import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode; +import org.apache.flex.compiler.tree.as.IParameterNode; import org.apache.flex.compiler.tree.as.ISetterNode; import org.apache.flex.compiler.tree.as.ITypeNode; import org.apache.flex.compiler.tree.as.ITypedExpressionNode; @@ -103,6 +107,15 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter private ICompilerProject project; @Override + protected String getIndent(int numIndent) + { + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < numIndent; i++) + sb.append(JSFlexJSEmitterTokens.INDENT.getToken()); + return sb.toString(); + } + + @Override protected void emitMemberName(IDefinitionNode node) { write(node.getName()); @@ -115,7 +128,72 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter project = getWalker().getProject(); - super.emitClass(node); + IClassDefinition definition = node.getDefinition(); + + IFunctionDefinition ctorDefinition = definition.getConstructor(); + + // Static-only (Singleton) classes may not have a constructor + if (ctorDefinition != null) + { + IFunctionNode ctorNode = (IFunctionNode) ctorDefinition.getNode(); + if (ctorNode != null) + { + // constructor + emitMethod(ctorNode); + write(ASEmitterTokens.SEMICOLON); + } + else + { + String qname = definition.getQualifiedName(); + if (qname != null && !qname.equals("")) + { + write(qname); + write(ASEmitterTokens.SPACE); + writeToken(ASEmitterTokens.EQUAL); + write(ASEmitterTokens.FUNCTION); + write(ASEmitterTokens.PAREN_OPEN); + write(ASEmitterTokens.PAREN_CLOSE); + write(ASEmitterTokens.SPACE); + write(ASEmitterTokens.BLOCK_OPEN); + writeNewline(); + write(ASEmitterTokens.BLOCK_CLOSE); + write(ASEmitterTokens.SEMICOLON); + } + } + } + + IDefinitionNode[] dnodes = node.getAllMemberNodes(); + for (IDefinitionNode dnode : dnodes) + { + if (dnode.getNodeID() == ASTNodeID.VariableID) + { + writeNewline(); + writeNewline(); + writeNewline(); + emitField((IVariableNode) dnode); + write(ASEmitterTokens.SEMICOLON); + } + else if (dnode.getNodeID() == ASTNodeID.FunctionID) + { + if (!((IFunctionNode) dnode).isConstructor()) + { + writeNewline(); + writeNewline(); + writeNewline(); + emitMethod((IFunctionNode) dnode); + write(ASEmitterTokens.SEMICOLON); + } + } + else if (dnode.getNodeID() == ASTNodeID.GetterID + || dnode.getNodeID() == ASTNodeID.SetterID) + { + writeNewline(); + writeNewline(); + writeNewline(); + emitAccessors((IAccessorNode) dnode); + write(ASEmitterTokens.SEMICOLON); + } + } } @Override @@ -681,6 +759,71 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter } @Override + protected void emitDefaultParameterCodeBlock(IFunctionNode node) + { + IParameterNode[] pnodes = node.getParameterNodes(); + if (pnodes.length == 0) + return; + + Map<Integer, IParameterNode> defaults = getDefaults(pnodes); + + if (defaults != null) + { + final StringBuilder code = new StringBuilder(); + + if (!hasBody(node)) + { + indentPush(); + write(JSFlexJSEmitterTokens.INDENT); + } + + List<IParameterNode> parameters = new ArrayList<IParameterNode>( + defaults.values()); + + for (int i = 0, n = parameters.size(); i < n; i++) + { + IParameterNode pnode = parameters.get(i); + + if (pnode != null) + { + code.setLength(0); + + /* x = typeof y !== 'undefined' ? y : z;\n */ + code.append(pnode.getName()); + code.append(ASEmitterTokens.SPACE.getToken()); + code.append(ASEmitterTokens.EQUAL.getToken()); + code.append(ASEmitterTokens.SPACE.getToken()); + code.append(ASEmitterTokens.TYPEOF.getToken()); + code.append(ASEmitterTokens.SPACE.getToken()); + code.append(pnode.getName()); + code.append(ASEmitterTokens.SPACE.getToken()); + code.append(ASEmitterTokens.STRICT_NOT_EQUAL.getToken()); + code.append(ASEmitterTokens.SPACE.getToken()); + code.append(ASEmitterTokens.SINGLE_QUOTE.getToken()); + code.append(ASEmitterTokens.UNDEFINED.getToken()); + code.append(ASEmitterTokens.SINGLE_QUOTE.getToken()); + code.append(ASEmitterTokens.SPACE.getToken()); + code.append(ASEmitterTokens.TERNARY.getToken()); + code.append(ASEmitterTokens.SPACE.getToken()); + code.append(pnode.getName()); + code.append(ASEmitterTokens.SPACE.getToken()); + code.append(ASEmitterTokens.COLON.getToken()); + code.append(ASEmitterTokens.SPACE.getToken()); + code.append(pnode.getDefaultValue()); + code.append(ASEmitterTokens.SEMICOLON.getToken()); + + write(code.toString()); + + if (i == n - 1 && !hasBody(node)) + indentPop(); + + writeNewline(); + } + } + } + } + + @Override public void emitBinaryOperator(IBinaryOperatorNode node) { ASTNodeID id = node.getNodeID(); @@ -889,6 +1032,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter ArrayList<String> writtenInstances = new ArrayList<String>(); writtenInstances.add(cname); // make sure we don't add ourselves + boolean emitsRequires = false; if (requiresList != null) { for (String imp : requiresList) @@ -913,18 +1057,15 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter write(ASEmitterTokens.SINGLE_QUOTE); write(ASEmitterTokens.PAREN_CLOSE); writeNewline(ASEmitterTokens.SEMICOLON); + writtenInstances.add(imp); + + emitsRequires = true; } } - - if (requiresList.size() > 1 - || (requiresList.size() == 1 && requiresList.get(0).indexOf( - JSGoogEmitterTokens.AS3.getToken()) == -1)) - { - writeNewline(); - } } + boolean emitsInterfaces = false; if (interfacesList != null) { for (String imp : interfacesList) @@ -936,11 +1077,8 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter write(ASEmitterTokens.SINGLE_QUOTE); write(ASEmitterTokens.PAREN_CLOSE); writeNewline(ASEmitterTokens.SEMICOLON); - } - - if (interfacesList.size() > 0) - { - writeNewline(); + + emitsInterfaces = true; } } @@ -948,8 +1086,9 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter // 'as' operators. We don't need to worry about requiring // this in every project: ADVANCED_OPTIMISATIONS will NOT // include any of the code if it is not used in the project. - if (flexProject.mainCU != null && - cu.getName().equals(flexProject.mainCU.getName())) + boolean isMainCU = flexProject.mainCU != null && + cu.getName().equals(flexProject.mainCU.getName()); + if (isMainCU) { write(JSGoogEmitterTokens.GOOG_REQUIRE); write(ASEmitterTokens.PAREN_OPEN); @@ -958,8 +1097,15 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter write(ASEmitterTokens.SINGLE_QUOTE); write(ASEmitterTokens.PAREN_CLOSE); writeNewline(ASEmitterTokens.SEMICOLON); + } + + if (emitsRequires || emitsInterfaces || isMainCU) + { writeNewline(); } + + writeNewline(); + writeNewline(); } @Override @@ -983,6 +1129,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter { writeNewline(); writeNewline(); + writeNewline(); getDoc().begin(); getDoc().emitConst(null); getDoc().end(); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java index 10ff880..53110c1 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java @@ -27,6 +27,7 @@ import org.apache.flex.compiler.codegen.IEmitterTokens; public enum JSFlexJSEmitterTokens implements IEmitterTokens { FLEXJS_CLASS_INFO("FLEXJS_CLASS_INFO"), + INDENT(" "), INTERFACES("interfaces"), LANGUAGE_QNAME("org.apache.flex.utils.Language"), UNDERSCORE("_"), http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/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 30e70bb..dc039a9 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 @@ -704,7 +704,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter } } - private void emitDefaultParameterCodeBlock(IFunctionNode node) + protected void emitDefaultParameterCodeBlock(IFunctionNode node) { IParameterNode[] pnodes = node.getParameterNodes(); if (pnodes.length == 0) @@ -869,7 +869,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter super(out); } - private Map<Integer, IParameterNode> getDefaults(IParameterNode[] nodes) + protected Map<Integer, IParameterNode> getDefaults(IParameterNode[] nodes) { Map<Integer, IParameterNode> result = new HashMap<Integer, IParameterNode>(); int i = 0; @@ -953,7 +953,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter return false; } - private static boolean hasBody(IFunctionNode node) + protected static boolean hasBody(IFunctionNode node) { IScopedNode scope = node.getScopedNode(); return scope.getChildCount() > 0; http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4bdbf59/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java index 444b26a..cd7aad7 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java @@ -103,6 +103,15 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements super(out); } + @Override + protected String getIndent(int numIndent) + { + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < numIndent; i++) + sb.append(JSFlexJSEmitterTokens.INDENT.getToken()); + return sb.toString(); + } + //-------------------------------------------------------------------------- @Override @@ -1386,15 +1395,11 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements if (project.mainCU != null && cu.getName().equals(project.mainCU.getName())) { - write(JSGoogEmitterTokens.GOOG_REQUIRE); - write(ASEmitterTokens.PAREN_OPEN); - write(ASEmitterTokens.SINGLE_QUOTE); - write(JSFlexJSEmitterTokens.LANGUAGE_QNAME); - write(ASEmitterTokens.SINGLE_QUOTE); - write(ASEmitterTokens.PAREN_CLOSE); - writeNewline(ASEmitterTokens.SEMICOLON); - writeNewline(); + emitHeaderLine(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken()); } + + writeNewline(); + writeNewline(); } private void emitHeaderLine(String qname)
