incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik de Bruin <e...@ixsoftware.nl>
Subject [ASJS] Adjusting FalconJS output (no general discussion in this thread, please)
Date Fri, 07 Dec 2012 09:12:37 GMT
Mike, I'm not sure what will work best for this process, but for now
I'll try inlining my comments (in square brackets, BELOW the line
they're about) into "your" output and see if that makes sense.

//=================================================================
// JS CODE

/** @preserve CROSS-COMPILED BY MXMLJSC (329449.1) ON 2012-12-06 12:55:52
 */
[#Remove '@preserve', it is not needed and will litter the Closure
Compiler (CC) output]
/**
 * CROSS-COMPILED BY MXMLJSC (329449.1) ON 2012-12-06 12:52:19
[#Remove line, duplicate information (low priority)]
 *
 * Class: com.example.components.MyTextButton
[Remove line, information obvious (low priority)]
 * @constructor
 * @extends flash.display.Sprite
 */

// Constructor
[#Remove line, duplicate information (low priority)]

[#Insert 'goog.provides()' call to set up namespace]

[#Insert 'goog.requires()'; the equivalent of 'import' in AS]

/**
 * Constructor: com.example.components.MyTextButton()
 * @constructor
 * @this {com.example.components}
 */
[#Remove entire comment block, duplicate/unneeded information that
confuses CC (high priority)]
com.example.components.MyTextButton = function()
{
        var self = this;
                self.publicProperty /* : Number */ = 100;
                goog.base(this);
                return self;
}
[#Changes:
- no need for the 'self = this' workaround, this is only needed when a
'this' reference is passed into a closure;
- I don't see the need to 'return' anything from a constructor...
]

goog.inherits(com.example.components.MyTextButton, flash.display.Sprite);

/**
 * Member: com.example.components.MyTextButton.prototype._CLASS
 * @const
 * @type {com.example.components.MyTextButton}
 */
com.example.components.MyTextButton.prototype._CLASS =
com.example.components.MyTextButton;
;
[#Remove entire block, obsolete]

/**
 * Member: com.example.components.MyTextButton._privateVar
[#Remove 'Member' comment line, redundant information]
 * @private
 * @type {string}
 */
com.example.components.MyTextButton.prototype._privateVar /* : String
*/ = "do ";
[#Changes:
- don't create private vars on the prototype, instead 'create' them in
the constructor (as this._privateVar), as shown in the example
- remove type hint, CC uses the '@type' annotation]
;
[#Remove extra semi-colon]

/**
 * Member: com.example.components.MyTextButton.publicProperty
[#Remove 'Member' comment line, redundant information]
 * @type {number}
 */
com.example.components.MyTextButton.prototype.publicProperty /* :
Number */ = 100;
[#Remove type hint, CC uses the '@type' annotation]
;
[#Remove extra semi-colon]


/**
 * Method: com.example.components.MyTextButton.myFunction()
[#Remove 'Method' comment line, redundant information]
 * @this {com.example.components.MyTextButton}
 * @param {string} value
 * @return {string}
 */
com.example.components.MyTextButton.prototype.myFunction =
function(value /* : String */) /* : String */
{
                /** @type {com.example.components.MyTextButton} */
                var self = this;
                return (("Don't " + self._privateVar) + value);
}
[#Changes:
- remove type hints from function declaration, CC uses the '@param'
and '@return' annotations
- no need for the 'self = this' workaround, this is only needed when a
'this' reference is passed into a closure;
]
[#Insert semi-colon]

/**
 * Member: com.example.components.MyTextButton._PACKAGE
 * @const
 * @type {com.example.components}
 */
com.example.components.MyTextButton._PACKAGE = com.example.components;
[#Remove entire block, obsolete]


/**
 * Member: com.example.components.MyTextButton._NAME
 * @const
 * @type {string}
 */
com.example.components.MyTextButton._NAME = "MyTextButton";
[#Remove entire block, obsolete]

/**
 * Member: com.example.components.MyTextButton._FULLNAME
 * @const
 * @type {string}
 */
com.example.components.MyTextButton._FULLNAME =
"com.example.components.MyTextButton";
[#Remove entire block, obsolete]

/**
 * Member: com.example.components.MyTextButton._SUPER
 * @const
 * @type {flash.display.Sprite}
 */
com.example.components.MyTextButton._SUPER = flash.display.Sprite;
[#Remove entire block, obsolete]

/**
 * Member: com.example.components.MyTextButton._NAMESPACES
 * @const
 * @type {Object}
 */
com.example.components.MyTextButton._NAMESPACES = {
        "_privateVar::7:com.example.components.MyTextButton" : true,
        "publicProperty::2" : true,
        "myFunction::2" : true
}
[#Remove entire block, obsolete]

adobe.classes["com.example.components.MyTextButton"]  =
com.example.components.MyTextButton;
[#Remove line, obsolete]

// CODE
//=================================================================

Let's see if we can 'please' the Closure Linter (not easy, it's very
strict; it is however a very nice benchmark, so we should try). A
happy Linter means a happy Compiler, which means highly optimized code
and fewer errors.

Thanks for working with me on this,

EdB



--
Ix Multimedia Software

Jan Luykenstraat 27
3521 VB Utrecht

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

Mime
View raw message