incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Schmalle <apa...@teotigraphix.com>
Subject Re: [FalconJx] Prototype ActionScript -> JavaScript compiler code up in svn
Date Fri, 14 Dec 2012 14:00:16 GMT
Right,

 From my experience with compilers, I guessed that is what Google did.  
And it turns out that is what they did.

So keep on your course Erik, nothing to worry about. Let's just get  
this thing rolling so #ApacheFlex #FalconJx tags are swimming in the  
Twitter atmosphere. ;-)

I'm not that arrogant, just know that unit tests prove software and  
also why I waited to commit code that had them, proving what we  
already know, this is a doable project.

Mike

Quoting Erik de Bruin <erik@ixsoftware.nl>:

>> Ok, then not to worry, we can even tests this sooner than later to see
>> exactly what the closure compiler does with our namespaces.
>
> Taking the example AS -> JS we worked with last week, let me show you:
>
> //============================**==============================**=======
>
> AS CODE
>
>
> package com.example.components
> {
>
> import flash.display.Sprite;
>
> public class MyTextButton extends Sprite
> {
>     public function MyTextButton()
>
>     {
>         super();
>      }
>
>     private var _privateVar:String = "do ";
>
>     public var publicProperty:Number = 100;
>
>     public function myFunction(value: String): String
>     {
>         return "Don't " + _privateVar + value;
>     }
> }
> }
>
>
>
> //============================**==============================**=======
>
> JS CODE (intended, maybe even current, output of FalconJx)
>
> /**
>  * CROSS-COMPILED BY MXMLJSC (329449.1) ON 2012-12-07 08:11:27
>  */
>
> goog.provide("com.example.components.MyTextButton");
>
> goog.require("flash.display.Sprite");
>
> /**
>  * @constructor
>  * @extends flash.display.Sprite
>  */
> com.example.components.MyTextButton = function()
> {
>     goog.base(this);
>
>     /**
>      * @private
>      * @type {string}
>      */
>      this._privateVar = "do ";
> }
> goog.inherits(com.example.components.MyTextButton, flash.display.Sprite);
>
> /**
>  * @type {number}
>  */
> com.example.components.MyTextButton.prototype.publicProperty = 100;
>
> /**
>  * @this {com.example.components.MyTextButton}
>  * @param {string} value
>  * @return {string}
>  */
> com.example.components.MyTextButton.prototype.myFunction = function(value)
> {
>     return (("Don't " + this._privateVar) + value);
> }
>
> // Ensures the symbol will be visible after compiler renaming (needed
> only for "application" level class)
> goog.exportSymbol('com.example.components.MyTextButton',
> com.example.components.MyTextButton);
>
>
>
> //============================**==============================**=======
>
> JS CODE (run through the Closure Builder)
>
> function a(){this.a="do "}function b(){}function
> c(){}c.prototype=b.prototype;a.b=b.prototype;a.prototype=new c;var
> d=["com","example","components","MyTextButton"],e=this;!(d[0]in
> e)&&e.execScript&&e.execScript("var "+d[0]);for(var
> f;d.length&&(f=d.shift());)!d.length&&void
> 0!==a?e[f]=a:e=e[f]?e[f]:e[f]={};
>
>
>
> Now, although we use stuff from the "goog" library ('provides',
> 'requires', 'base' and 'inherits'), the Closure Builder output is ALL
> THAT'S NEEDED for our JS to run in the browser. This means that all
> dependencies have been resolved and the code is compiled such that
> doesn't need the "goog" library to run... Pretty efficient and highly
> optimised, I'd say ;-)
>
> EdB
>
>
>
> --
> Ix Multimedia Software
>
> Jan Luykenstraat 27
> 3521 VB Utrecht
>
> T. 06-51952295
> I. www.ixsoftware.nl
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Mime
View raw message