Book a Demo

Author Topic: Code Generation  (Read 3723 times)

Ray Hayes

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I just write code; designers make it pretty.
    • View Profile
Code Generation
« on: November 09, 2009, 06:19:48 pm »
Can I generate multiple output files from a single diagram element? For example, if I designate a class as some special stereotype then I want to generate a set of files around it.

Thanks

Ray

Ray Hayes

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I just write code; designers make it pretty.
    • View Profile
Re: Code Generation
« Reply #1 on: November 11, 2009, 01:49:19 pm »
Figured it out.

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Code Generation
« Reply #2 on: November 12, 2009, 05:55:54 am »
Hi Ray,

Would you like to share with us what you did?

WBR
Günther
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

Ray Hayes

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I just write code; designers make it pretty.
    • View Profile
Re: Code Generation
« Reply #3 on: November 14, 2009, 02:33:52 am »
Sure. I hadn't noticed a section of the documentation on the Automation API so I didn't realize it existed. I ended up using the C#_Sample as the basis for an internal tool that reads the repository and using custom stereotypes and the CodeDom (http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx) to generate entire solutions and projects in Visual Studio 2008. I'm still working on it but so far it's perfect for what I need.

There is probably a better way to do this or should I say a more appropriate one if I needed the roundtrip feature but I'm really designing this for my own use and I really want to separate what I'm calling "standard" behavior which is in the model and fixed versus extra code that is unique to this project so I really don't need the ability to roundtrip my changes from model to code and back.

I looked at writing a domain specific language and using antlr (http://www.antlr.org/)  to parse and generate my code and I looked at the SDK that works with Visual Studio (http://msdn.microsoft.com/en-us/vsx/bb980955.aspx) but found it much more than I needed. There's also a templating engine called T4 but it was a bit expensive. No budget for toys at the moment though using some kind of templating engine would be desireable in the long run. Just don't need it right now.

Let me know if you'd lik any further information.

Ray