Book a Demo

Author Topic: Looking for help/info on Code Generation Templates  (Read 5994 times)

buosc

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Looking for help/info on Code Generation Templates
« on: April 16, 2004, 02:31:05 pm »
I'm struggling with code generation and using the templates.  I've read the help file but am wondering if there are any other source of information on the code generation templates out there?

Help appreciated,
Jon

Gaiiden

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #1 on: April 19, 2004, 11:05:44 pm »
I'd like to second that motion. It seems to me that modifying the code generation templates is somewhat an involved process. Specifically I was wondering if there are any resources out there like a site with a bunch of templates that output various code/comment styles I could choose from. Second to that wonderful scenario, if anyone could share examples of what they did to customize their code generation would probably help immensly :)

AdamHearn

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #2 on: April 20, 2004, 02:36:23 am »
The process of updating the code templates is indeed involved. However, consider that you spend a day or two on this and how much effort this saves in the long term - though only if you habitually use code generation!

I don't think you'll find a 'resource' of templates as anyone going to the trouble of setting it up will [probably] be doing so in order to support the company/user convention.

I spent a day sorting out code generation templates to meet our standards and when we upgraded to V4, they all broke :( I still need to sort them out ::)

I found it's best to start off with a basic model. Include an interface with methods and properties, a class with the same and some members. Some inheritance, etc. etc. Hit the top level stuff 1st like the company/personal headers, then pick on a UML element going through the file from top to bottom - class definition, attribute declaration, comment styles for them, method declaration, etc. etc. It's not 'hard' but then it's not 'easy' either, merely time consuming to get everything just so - especially if your required format wants to move the braces around a bit :)

buosc

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #3 on: April 20, 2004, 09:32:22 am »
I've got the basic operation of the templates down such that I can basically generate code that matches our pre-existing (and somewhat rigid) code standards.  There are a few niggling areas though that seem to be completely under documented.  

Specifically, I am having trouble with the following:

- XML comment being generated from the operation notes.  It is not formatted very well and if there are @ keywords (such as @remark) in the notes then it appears as though the XML_COMMENT function macro parses those out and creates xml comments as well.  This is all completely undocumented and I'd like to understand it better in addition to having a little more control over formatting of the output.  

- In the body of my operation I'd like to generate some code that conditionally logs the input parameters at the start of the method and the output parameters at the end of the method.  I see there are field substitution macros such as paramName, paramKind, etc thus making me believe this should be a feasible undertaking, however, it isn't documented how to iterate over the parameters for an operation.  Mind that I'm not looking for just the List macro to create a comma delimited list of parameters, I want to process each parameter individually.

Any and all help is appreciated,
Jon

Barry_Pearce

  • EA User
  • **
  • Posts: 70
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #4 on: June 24, 2004, 04:36:27 pm »
Indeed, it is indeed a failing that the code generation templates are a little 'dumb' and do not have access to the full object model....it would solve ALL of my code-gen issues If I had that access - we too have made extensive change to c++ generation 1. to fix many faults in the codegen templates and 2. for our own very strict coding standards (hey adam - casting our minds back to previous projects.....I get to use my standard with s/w engineers - theres no 'artists' here!!! LOL)

AdamHearn

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #5 on: June 25, 2004, 04:37:53 am »
Just watch your 'tabs' Barry :)

I posted a feature request a couple of weeks ago. I've not heard anything on it as yet :-[ Within it I asked for more code generation functions and in particular those for basic string manipulation. The code generation templates are on the cusp of being extremely powerful, they just need a little opening up and we'd all be very happy designer/developers ;)

fluxtah

  • EA User
  • **
  • Posts: 144
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #6 on: June 25, 2004, 04:49:34 am »
Hopefully soon this might happen, qoute from ea future plans:

Quote
Code Generation templates: User customizable templates for all in-built languages, plus the ability to create new language definitions and templates for code generation. Ties in with the UML Profile support to provide extensible code generation (anything generation?) supportin a model independent way. Due out in July 2003.

AdamHearn

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #7 on: June 25, 2004, 04:33:38 pm »
This feature is *already* here! You really don't want to know how it was before the way it is now ;)

fluxtah

  • EA User
  • **
  • Posts: 144
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #8 on: June 26, 2004, 08:49:36 am »
but it states we should be able to create new  language definitions, i havent found this option yet :(

looking now :)

regards

fluxtah

AdamHearn

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #9 on: June 28, 2004, 05:25:20 am »
Under Configuration, you have a few menu options:
Language Datatypes
Language Macros
Code Generation Templates


Using Language Datatypes first, you can add a 'New Product' into the Langauge DataTypes dialog. You can add the datatypes specific to that language.

When selected the "Code Generation Templates" dialog will list out the new product thus allowing you to style the output to your requirement.

I've not used this is anger (don't need to add new language support) but it looks to be in place.

Barry_Pearce

  • EA User
  • **
  • Posts: 70
  • Karma: +0/-0
    • View Profile
Re: Looking for help/info on Code Generation Templ
« Reply #10 on: June 28, 2004, 08:00:13 am »
Depends on what was meant by new language definitions - but you can also override the templates using stereotypes - we use this to take the effort out of coding implementation code for abstract factories.

Another way of extending to include more of a specific language is tagged values - these are very useful.

If you are working on C++ and need things like mutable the tagged values are an excellent way to progress - however EA's C++ support is lacking - even with tagged values - I am working on a document now which will be sent to sparx in the next couple of days which should highlight all the problems (currently running at approx 85 issues) - after which full C++ support should be more forthcoming (fingers crossed).

AFAIK reading other threads the language support for a new language - the features required are 95% there - but there are one or two niggles about one or two of the drop-downs not updating to support the new user-defined language.

« Last Edit: June 28, 2004, 08:00:38 am by Barry_Pearce »