Annoucing as3tohaxe : Actionscript 3 to haXe converter

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Annoucing as3tohaxe : Actionscript 3 to haXe converter

Don-Duong Quach
Hey gang,

I've been working on an actionscript 3 to haXe converter in haskell to help spread the haXe love. 

The converter has a ways to go, but it's been pretty useful to me.  And if anyone is looking to convert an as3 code base it should save you the time of rolling your own script for converting datatypes, rewriting loops, etc.

You can check out the git repo here: http://www.github.com/geekrelief/as3tohaxe

For those using Mac OSX, I have an intel binary precompiled for you.  I'll get a windows binary uploaded if there's demand for it.

Feedback or any help testing and hacking on this is appreciated.  I hope this is of use to you.

Cheers,
~Don Q.

P.S. Thanks for working on haXe Nicolas!

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Franco Ponticelli
Very nice. Have you tried some complex conversions like AsWing or Papervision?

Franco

On Mon, Oct 27, 2008 at 7:25 PM, Don-Duong Quach <[hidden email]> wrote:
Hey gang,

I've been working on an actionscript 3 to haXe converter in haskell to help spread the haXe love. 

The converter has a ways to go, but it's been pretty useful to me.  And if anyone is looking to convert an as3 code base it should save you the time of rolling your own script for converting datatypes, rewriting loops, etc.

You can check out the git repo here: http://www.github.com/geekrelief/as3tohaxe

For those using Mac OSX, I have an intel binary precompiled for you.  I'll get a windows binary uploaded if there's demand for it.

Feedback or any help testing and hacking on this is appreciated.  I hope this is of use to you.

Cheers,
~Don Q.

P.S. Thanks for working on haXe Nicolas!

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Don-Duong Quach
AsWing and Papervision are definitely on the TODO list.  Got big plans! :)  Anyways, I'm currently working on flare, http://flare.prefuse.org, which is also a sizeable project.  The conversions aren't perfect, but I hope running as3tohaxe will take a lot of the tedium out of converting.

To give you an idea, here's an example out of flare:

DataSchema.as:
package flare.data
{
    import flare.util.Arrays;
   
    /**
     * A data schema represents a set of data variables and their associated
     * types. A schema maintains a collection of <code>DataField</code>
     * objects.
     * @see flare.data.DataField
     */
    public class DataSchema
    {
        public var dataRoot:String = null;
        public var hasHeader:Boolean = false;
       
        private var _fields:/*DataField*/Array = [];
        private var _nameLookup:/*String->DataField*/Object = {};
        private var _idLookup:/*String->DataField*/Object = {};
       
        /** An array containing the data fields in this schema. */
        public function get fields():Array { return Arrays.copy(_fields); }
        /** The number of data fields in this schema. */
        public function get numFields():int { return _fields.length; }
       
        /**
         * Creates a new DataSchema.
         * @param fields an ordered list of data fields to include in the
         * schema
         */
        public function DataSchema(...fields)
        {
            for each (var f:DataField in fields) {
                addField(f);
            }
        }
       
        /**
         * Adds a field to this schema.
         * @param field the data field to add
         */
        public function addField(field:DataField):void
        {
            _fields.push(field);
            _nameLookup[field.name] = field;
            _idLookup[field.id] = field;
        }
       
        /**
         * Retrieves a data field by name.
         * @param name the data field name
         * @return the corresponding data field, or null if no data field is
         *  found matching the name
         */
        public function getFieldByName(name:String):DataField
        {
            return _nameLookup[name];
        }
       
        /**
         * Retrieves a data field by id.
         * @param name the data field id
         * @return the corresponding data field, or null if no data field is
         *  found matching the id
         */
        public function getFieldById(id:String):DataField
        {
            return _idLookup[id];
        }
       
        /**
         * Retrieves a data field by its index in this schema.
         * @param idx the index of the data field in this schema
         * @return the corresponding data field
         */
        public function getFieldAt(idx:int):DataField
        {
            return _fields[idx];
        }
       
    } // end of class DataSchema


to DataSchema.hx:
package flare.data;

    import flare.util.Arrays;
   
    /**
     * A data schema represents a set of data variables and their associated
     * types. A schema maintains a collection of <code>DataField</code>
     * objects.
     * @see flare.data.DataField
     */
    class DataSchema
    {
        public var fields(getFields, null) : Array<Dynamic> ;
        public var numFields(getNumFields, null) : Int ;
        public var dataRoot:String ;
        public var hasHeader:Bool ;
       
        private var _fields:/*DataField*/Array<Dynamic> ;
        private var _nameLookup:/*String->DataField*/Dynamic ;
        private var _idLookup:/*String->DataField*/Dynamic ;
       
        /** An array containing the data fields in this schema. */
        public function getFields():Array<Dynamic> { return Arrays.copy(_fields); }
        /** The number of data fields in this schema. */
        public function getNumFields():Int { return _fields.length; }
       
        /**
         * Creates a new DataSchema.
         * @param fields an ordered list of data fields to include in the
         * schema
         */
        public function new(fields:Array<Dynamic>)
        {
           
            dataRoot = null;
            hasHeader = false;
            _fields = [];
            _nameLookup = {};
            _idLookup = {};
            for each (var f:DataField in fields) {
                addField(f);
            }
        }
       
        /**
         * Adds a field to this schema.
         * @param field the data field to add
         */
        public function addField(field:DataField):Void
        {
            _fields.push(field);
            _nameLookup[field.name] = field;
            _idLookup[field.id] = field;
        }
       
        /**
         * Retrieves a data field by name.
         * @param name the data field name
         * @return the corresponding data field, or null if no data field is
         *  found matching the name
         */
        public function getFieldByName(name:String):DataField
        {
            return _nameLookup[name];
        }
       
        /**
         * Retrieves a data field by id.
         * @param name the data field id
         * @return the corresponding data field, or null if no data field is
         *  found matching the id
         */
        public function getFieldById(id:String):DataField
        {
            return _idLookup[id];
        }
       
        /**
         * Retrieves a data field by its index in this schema.
         * @param idx the index of the data field in this schema
         * @return the corresponding data field
         */
        public function getFieldAt(idx:Int):DataField
        {
            return _fields[idx];
        }
       
    } // end of class DataSchema

This doesn't showcase everything it can do so far, but I hope add more to it as time goes on.  I have a partial list of things it can translate up on the wiki: http://github.com/geekrelief/as3tohaxe/wikis  I've created a google group, http://groups.google.com/group/as3tohaxe, for anyone having issues, and I'll follow this up with a blog post, http://geekrelief.wordpress.com.

Thanks for taking a look.
-Don Q. 

On Tue, Oct 28, 2008 at 4:30 AM, Franco Ponticelli <[hidden email]> wrote:
Very nice. Have you tried some complex conversions like AsWing or Papervision?

Franco

On Mon, Oct 27, 2008 at 7:25 PM, Don-Duong Quach <[hidden email]> wrote:
Hey gang,

I've been working on an actionscript 3 to haXe converter in haskell to help spread the haXe love. 

The converter has a ways to go, but it's been pretty useful to me.  And if anyone is looking to convert an as3 code base it should save you the time of rolling your own script for converting datatypes, rewriting loops, etc.

You can check out the git repo here: http://www.github.com/geekrelief/as3tohaxe

For those using Mac OSX, I have an intel binary precompiled for you.  I'll get a windows binary uploaded if there's demand for it.

Feedback or any help testing and hacking on this is appreciated.  I hope this is of use to you.

Cheers,
~Don Q.

P.S. Thanks for working on haXe Nicolas!

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Franco Ponticelli
Flare for haXe ... sounds very interesting!
RSS added to my Google Reader.

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Trevor Burton
I'm just waiting for my new macbook to arrive - then i'll definately be checking this out - will be VERY useful for me!

nice work...

T

On Tue, Oct 28, 2008 at 6:24 PM, Franco Ponticelli <[hidden email]> wrote:
Flare for haXe ... sounds very interesting!
RSS added to my Google Reader.

Franco

--
haXe - an open source web programming language
http://haxe.org



--
Trevor Burton
http://www.paperworld3d.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Franco Ponticelli
I forgot ... a Windows version would be appreciated.

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Don-Duong Quach
In reply to this post by Trevor Burton
Thanks, let me know how it works out for you.

On Tue, Oct 28, 2008 at 11:37 AM, Trevor Burton <[hidden email]> wrote:
I'm just waiting for my new macbook to arrive - then i'll definately be checking this out - will be VERY useful for me!

nice work...

T

On Tue, Oct 28, 2008 at 6:24 PM, Franco Ponticelli <[hidden email]> wrote:
Flare for haXe ... sounds very interesting!
RSS added to my Google Reader.

Franco

--
haXe - an open source web programming language
http://haxe.org



--
Trevor Burton
http://www.paperworld3d.com

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Don-Duong Quach
In reply to this post by Franco Ponticelli
Sure thing, I'll post to the google group as soon as I can get it together.

-Don Q.

On Tue, Oct 28, 2008 at 12:26 PM, Franco Ponticelli <[hidden email]> wrote:
I forgot ... a Windows version would be appreciated.

Franco

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Nicolas Cannasse
In reply to this post by Don-Duong Quach
Don-Duong Quach a écrit :
> Thanks, let me know how it works out for you.

Useful tool !

Few things to fix :

- remove keywords such as "public" "final" "internal" or "protected"
before "class" , "function" and "var" declarations.

- translate "Number" to "Float"

- translate for each ( t in E )
        and for each ( var t : T in E )
        into for( t in E )

- translate delete E1[E2] into Reflect.deleteField(E1,E2)

- add a comma between several extends or implements

- if possible, translate  public var x : T1, y : T2;  into :
        public var x : T1;
        public var y : T2;

- translate for(init; cond; incr) E; into :
     init;
     while( cond ) {
        E;
        incr;
     }

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Ian Thomas
On Sat, Nov 1, 2008 at 12:18 PM, Nicolas Cannasse
<[hidden email]> wrote:

> - translate for(init; cond; incr) E; into :
>    init;
>    while( cond ) {
>        E;
>        incr;
>    }

Won't that last one trip up if continue is called? Might need to be:

init;
while (cont) {
    E;  // and if E contains 'continue', make it incr;continue;
    incr;
}

Ian

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Don-Duong Quach
In reply to this post by Nicolas Cannasse
Glad you like it.  Number to Float (or Int with a command line option), commas between extends and implements, and the basic for loop implemented in the latest revision.  But I'm wondering if you encountered an issue with the for loop conversion.

I'll look into getting the fixes in place.  Thanks for the suggestions!

-Don Q.

On Sat, Nov 1, 2008 at 4:18 AM, Nicolas Cannasse <[hidden email]> wrote:
Don-Duong Quach a écrit :

Thanks, let me know how it works out for you.

Useful tool !

Few things to fix :

- remove keywords such as "public" "final" "internal" or "protected" before "class" , "function" and "var" declarations.

- translate "Number" to "Float"

- translate for each ( t in E )
       and for each ( var t : T in E )
       into for( t in E )

- translate delete E1[E2] into Reflect.deleteField(E1,E2)

- add a comma between several extends or implements

- if possible, translate  public var x : T1, y : T2;  into :
       public var x : T1;
       public var y : T2;

- translate for(init; cond; incr) E; into :
   init;
   while( cond ) {
       E;
       incr;
   }

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Annoucing as3tohaxe : Actionscript 3 to haXe converter

Don-Duong Quach
In reply to this post by Ian Thomas
Yeah that does look like an issue.  I'll put that on the todo list.

Thanks.
-Don Q.

On Sat, Nov 1, 2008 at 4:32 AM, Ian Thomas <[hidden email]> wrote:
On Sat, Nov 1, 2008 at 12:18 PM, Nicolas Cannasse
<[hidden email]> wrote:

> - translate for(init; cond; incr) E; into :
>    init;
>    while( cond ) {
>        E;
>        incr;
>    }

Won't that last one trip up if continue is called? Might need to be:

init;
while (cont) {
   E;  // and if E contains 'continue', make it incr;continue;
   incr;
}

Ian

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org