Book a Demo

Author Topic: create additional files during code gen process  (Read 4387 times)

caspar

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • greetings from europe
    • View Profile
create additional files during code gen process
« on: November 05, 2007, 07:12:15 am »
Hi all,

I intend to perform the following operation: during the code generation process for C++, I like to create two additional files per class. These files should contain method stubs for the CppUnit framework.

Now my question is, wheather it would be possible to create these files, by modifying code templates or something like this.

thank you in anticipation

caspar
« Last Edit: November 05, 2007, 07:12:32 am by caspar »

thomaskilian

  • Guest
Re: create additional files during code gen proces
« Reply #1 on: November 05, 2007, 12:53:41 pm »
AFAIK you can only generate a single file with the templates. I'm generating my files via automation and print statements. A bit more complicated but much more flexible.

caspar

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • greetings from europe
    • View Profile
Re: create additional files during code gen proces
« Reply #2 on: November 06, 2007, 12:38:14 am »
THX

this sounds quite interesting.

can you give me a brief example? I assume such an automation can be implemented be means of a "programming language" like VB?!?
« Last Edit: November 06, 2007, 12:47:59 am by caspar »

TimmyTreeFriends

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: create additional files during code gen proces
« Reply #3 on: November 06, 2007, 03:23:53 am »
Ooooh yes! Automation script can be written in vb, c++, vb.net, c#, java...... Examples can be found in EA help manual - Extending EA - Automation and Scripting.
« Last Edit: November 06, 2007, 03:43:06 am by TimmyTreeFriends »

caspar

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • greetings from europe
    • View Profile
Re: create additional files during code gen proces
« Reply #4 on: November 06, 2007, 05:42:47 am »
developing add-ins is very easy if you know how *lol*

I just downloaded MS Visaual Studio Express for C# and followed the instructions of the EA "tutorial" found here: http://www.sparxsystems.com/resources/developers/autint.html

But now I've got the same problem as before. how can I generate the cppunit files. I know I can run a function to generate the files via a new item under the add-ins menu. but this isn't what I want. I would like to integrate the call of this function into the code gen process (when the user clicks the "generate" button in the "generate package source code" dialog). can something like this be done?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: create additional files during code gen proces
« Reply #5 on: November 06, 2007, 06:50:57 am »
Quote
...I've got the same problem as before. how can I generate the cppunit files. I know I can run a function to generate the files via a new item under the add-ins menu. but this isn't what I want. I would like to integrate the call of this function into the code gen process (when the user clicks the "generate" button in the "generate package source code" dialog). can something like this be done?

Consider trapping the OnPostTransform event. However, this might not work in your case.

Another option is to write an MDG Technology, and trap the appropriate events in your add-in. Note that this works a bit differently, so read the documentation. In particular, you must trap all the MDG events, even if you don't use them.

The ones you are interested in are MDG_PostGenerate, and perhaps also MDG_PreGenerate. You'll find instructions in the EA documentation. Take the time to practice a bit, and you should be fine.

HTH, David

PS: This is an area where Sparx could help us a bit more, but for now we've got to work within the current limits.
No, you can't have it!

thomaskilian

  • Guest
Re: create additional files during code gen proces
« Reply #6 on: November 06, 2007, 12:12:48 pm »
Quote
developing add-ins is very easy if you know how *lol*

I just downloaded MS Visaual Studio Express for C# and followed the instructions of the EA "tutorial" found here: http://www.sparxsystems.com/resources/developers/autint.html

But now I've got the same problem as before. how can I generate the cppunit files. I know I can run a function to generate the files via a new item under the add-ins menu. but this isn't what I want. I would like to integrate the call of this function into the code gen process (when the user clicks the "generate" button in the "generate package source code" dialog). can something like this be done?

You can use the %EXEC_EA_ADDIN function from within the code gen templates. That triggers your add-in. See the help and search the forum on more info about this function.

caspar

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • greetings from europe
    • View Profile
Re: create additional files during code gen proces
« Reply #7 on: November 07, 2007, 12:49:06 am »
thx for the hints, i'll have a try on this today

@thomaskilian I think a function called EXEC_EA_ADDIN does not exist. neither a search on sparx nor on the web returns any results. i just found another post of you. are you sure such a function does exist?
« Last Edit: November 07, 2007, 03:18:53 am by caspar »

thomaskilian

  • Guest
Re: create additional files during code gen proces
« Reply #8 on: November 07, 2007, 03:56:12 am »
sorry: EXEC_ADD_IN