Book a Demo

Author Topic: Code generation (newbie)  (Read 4117 times)

PaoloR

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Code generation (newbie)
« on: August 07, 2009, 10:35:23 am »
Is it possible to change the formatting of generated code? I'm thinking specifically of C++ and the placement of { and }.

I've looked at the Code Generation templates and left in a hurry  :exclamation

and I don't want to change stuff I don't understand.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Code generation (newbie)
« Reply #1 on: August 07, 2009, 06:51:25 pm »
Hi,

I am afraid, if you want to change it you need to get familiar with the code generation templates. You cannot control formatting with any options, its only possible to select general options what should be generated (e.g. constructors).

WBR
Günther

PaoloR

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Code generation (newbie)
« Reply #2 on: August 07, 2009, 07:17:57 pm »
OK, in the short term I'll stick with the default.

Thanks

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Code generation (newbie)
« Reply #3 on: August 08, 2009, 12:22:22 am »
Hi Paolo, and welcome to the forum.

You were in the right place, the code generation templates are what you have to fiddle with if you want to change things like code formatting.

It is a little involved, especially if you're working in a multi-user environment since you then need to think about how to deploy your updated templates so the same code gets generated regardless of who does it.

My advice to a newbie is to leave it alone. In all likelihood you will need to make additional changes to the generated code (like actual method implementations) and if so you might as well run it through a separate code-formatter.

Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

PaoloR

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Code generation (newbie)
« Reply #4 on: August 08, 2009, 09:39:24 am »
Thanks Uffe. I had more or less decided to do what you suggest - a bit of 'after generation' tinkering/tidying!  :)

EricP

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: Code generation (newbie)
« Reply #5 on: August 09, 2009, 02:38:46 am »
Quote
Is it possible to change the formatting of generated code? I'm thinking specifically of C++ and the placement of { and }.

I've looked at the Code Generation templates and left in a hurry

Good afternoon, Paolo.

I don't blame you, I'm pretty intimidated by the Code Generation templates myself.

I have managed to figure out a few things, with the help of the folks on this forum.

You mentioned specifically the placement of { and }.  I had the same problem, in that our coding standard requires the Allman / ANSI style (opening brace on the next line) whereas EA by default supports the K&R style (opening brace on the same line as the controlling statement).

I fixed that by going to the Operation Body code generation template.  On the very first line is the following:

{\n

I changed that by adding a "\n" at the beginning, i.e. "\n{\n" and that moved the opening brace to where I needed it.

I'm pretty sure that there is a safeguard against irretrievably messing up the code generation templates.  SOMEBODY PLEASE CORRECT ME IF I'M WRONG ON THIS, but I believe the "Delete" button at the bottom deletes ONLY YOUR CHANGES and restores the template to its default contents.  Like I said, I hope someone will correct me if I'm wrong on that... it seems like "Delete" is a bit of a misnomer in that case.

I'm still using version 7.1 (I don't like to change versions of my tools in the middle of a project unless there is a good reason to do it), and I don't know if what I described above is directly applicable to 7.5.

Hope this is helpful...

PaoloR

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Code generation (newbie)
« Reply #6 on: August 09, 2009, 05:49:55 pm »
Eric: thx for your reply. I've decide to focus my efforts on learning how to use EA productively rather than worrying about {} at the moment. As I said earlier, I can always 'beautify' their placement later.