Custom JS code generator

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

Custom JS code generator

Nicolas Cannasse
Hi,

I have just commited in r3592 the ability to write your own custom JS
code generator.

You can see an example on how the default JS code generator was
rewritten in haxe/std/haxe/macro/DefaultJSGenerator.hx

You can try switch to this generator or another one by using the
following compiler commandline option :

   --macro haxe.macro.DefaultJSGenerator.use()

Please note that this is just a first take on this, I'm sure we can
improve it further depending on people requirements. I'm waiting for
your feedback ;)

Best,
Nicolas

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

Re: Custom JS code generator

Heinz Hölzer-2
first test and i have to say it looks amazing :), fantastic work!!

Am 08.01.2011 19:33, schrieb Nicolas Cannasse:

> Hi,
>
> I have just commited in r3592 the ability to write your own custom JS
> code generator.
>
> You can see an example on how the default JS code generator was
> rewritten in haxe/std/haxe/macro/DefaultJSGenerator.hx
>
> You can try switch to this generator or another one by using the
> following compiler commandline option :
>
>   --macro haxe.macro.DefaultJSGenerator.use()
>
> Please note that this is just a first take on this, I'm sure we can
> improve it further depending on people requirements. I'm waiting for
> your feedback ;)
>
> Best,
> Nicolas
>


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

Re: Custom JS code generator

Heinz Hölzer-2
In reply to this post by Nicolas Cannasse
If found a few small bugs for the default generator:

- Main.main() is missing at the end
- It seems that constructors for std classes have problems:

IntIter = ;
List = ;
StringBuf = ;

best,
h

Am 08.01.2011 19:33, schrieb Nicolas Cannasse:

> Hi,
>
> I have just commited in r3592 the ability to write your own custom JS
> code generator.
>
> You can see an example on how the default JS code generator was
> rewritten in haxe/std/haxe/macro/DefaultJSGenerator.hx
>
> You can try switch to this generator or another one by using the
> following compiler commandline option :
>
>   --macro haxe.macro.DefaultJSGenerator.use()
>
> Please note that this is just a first take on this, I'm sure we can
> improve it further depending on people requirements. I'm waiting for
> your feedback ;)
>
> Best,
> Nicolas
>


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

Re: Custom JS code generator

Heinz Hölzer-2
In reply to this post by Nicolas Cannasse
There is one thing that should be fixed,

if you have an expr like

var d = { test : "Foo"};

the generated code is missing the leading semicolon:

var d = { test : "Foo"}

i filled an issue: http://code.google.com/p/haxe/issues/detail?id=297

best,
h

Am 08.01.2011 19:33, schrieb Nicolas Cannasse:

> Hi,
>
> I have just commited in r3592 the ability to write your own custom JS
> code generator.
>
> You can see an example on how the default JS code generator was
> rewritten in haxe/std/haxe/macro/DefaultJSGenerator.hx
>
> You can try switch to this generator or another one by using the
> following compiler commandline option :
>
>   --macro haxe.macro.DefaultJSGenerator.use()
>
> Please note that this is just a first take on this, I'm sure we can
> improve it further depending on people requirements. I'm waiting for
> your feedback ;)
>
> Best,
> Nicolas
>


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

Re: Custom JS code generator

Nicolas Cannasse
In reply to this post by Heinz Hölzer-2
Le 08/01/2011 23:08, Heinz Hölzer a écrit :
> If found a few small bugs for the default generator:
>
> - Main.main() is missing at the end
> - It seems that constructors for std classes have problems:
>
> IntIter = ;
> List = ;
> StringBuf = ;

Both have been fixed on SVN, thanks for the report.


 > the generated code is missing the leading semicolon:
 > var d = { test : "Foo"}

This does not seem like an issue right now, since any JS engine can run
it well.

Nicolas

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

Re: Custom JS code generator

Heinz Hölzer-2
Am 09.01.2011 11:41, schrieb Nicolas Cannasse:

Both have been fixed on SVN, thanks for the report.

great, thx a lot!

This does not seem like an issue right now, since any JS engine can run it well.

yes, not a big thing, i thought that was the cause for a problem with rhino, but i think it's more related to this issue:

http://code.google.com/p/haxe/issues/detail?id=299

best,
h

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

Re: Custom JS code generator

clemos
In reply to this post by Nicolas Cannasse
Hi,

The feature looks great !
Are there plans to provide similar functionnality to PHP target, and
eventually to make it possible to write new target generators using
haXe ?
If so this is really exciting...

Cheers,
Clément

On Sat, Jan 8, 2011 at 6:33 PM, Nicolas Cannasse
<[hidden email]> wrote:

> Hi,
>
> I have just commited in r3592 the ability to write your own custom JS code
> generator.
>
> You can see an example on how the default JS code generator was rewritten in
> haxe/std/haxe/macro/DefaultJSGenerator.hx
>
> You can try switch to this generator or another one by using the following
> compiler commandline option :
>
>  --macro haxe.macro.DefaultJSGenerator.use()
>
> Please note that this is just a first take on this, I'm sure we can improve
> it further depending on people requirements. I'm waiting for your feedback
> ;)
>
> Best,
> Nicolas
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

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