Darron wrote:
>So, when you generate the code, a new AS2CodeGenerator is instantiated 
>and passed the "root" package (containing classes / subpackges, etc).  
>The code generator then loops over everything and write the files (with 
>methods like writePackage, writeClass, writeInterface, writeOperation, 
>writeAttribute, etc).  If you want to generate java code, you would 
>essentially just create a new class - JavaCodeGenerator and just change 
>the "print" and "println" statements that you see in AS2CodeGenerator in> 
>the "write" methods to adjust for the java syntax.  Thus, it's pretty 
>easy to have it generate files for a different syntax (even like 
>ColdFusion - you can write a CFCCodeGenerator if you wanted).

This makes a lot of sense. I like the simplicity of the design here too.
Perhaps, maybe you have already done this, but you could make an interface
(ICodeGenerator) that a developer would have tom implement to create a new
"CodeGenerator".  Then the rest of the code that runs it can treat all code
generators as the interface, and you can have a factory that creates the
different CodeGenerators for each of the languages that you want to generate.
Anyway, this has a lot of possibilities.

>Once Aral can set up the SVN repository, I'll post the code.


I can't wait to take a look!

>If you want to get into using templates and such for code generation, 
>it's probably better to go with one of the many code generators already 
>built.  I'm pretty sure some already exist.. and I probably didn't have 
>to build this by hand at all, it just seemed easier to reinvent the 
>wheel than figure out how to operate someone else's.  I looked at 
>http://sourceforge.net/projects/andromda but it just seemed overly 
>complex for what I wanted to do...

I think keeping it simple is the way to go.  I like the way you have done it
from what I hear so far.  I guess the real advantage of the templates is that
you wouldn't need to recompile to add additional languages.  Perhaps XSLT could
work nicely as templates.  Anyway, I will wait until Aral is back and you have
the code up before trying to speculate further.

Great work!

-Chris





_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to