Book a Demo

Author Topic: Change opening brace style in generated code  (Read 4385 times)

EricP

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Change opening brace style in generated code
« on: August 01, 2009, 04:25:50 am »
Using EA 7.1 build 831...

First of all, I have been on here asking a lot of newbie-type questions lately, and I apologize for that... I've been using EA for years but almost always for reverse engineering of existing code; this is the first project on which I am using it for serious system-wide design including code generation, thus I'm coming up against a lot of issues I didn't run into in the past.

Also, before I ask any questions here I always search the forums and the user manual and help facility and have not had much luck in finding things.

On to the questions...

The EA code generator generates code with opening braces in K&R style, i.e. opening brace on the same line as the control statement.  Now, I DO NOT WANT TO START A RELIGIOUS WAR HERE, but I really do prefer the Allman / ANSI style, opening brace on the next line.  Besides, our project's coding standard requires it.

I expect to make heavy use of EA's code generator on this project, and I really do need to change the opening brace to Allman / ANSI style.  I mostly can't make very much sense out of the EA template language, but nonetheless I have gone through all of the C++ code generation templates looking for likely places to change the opening brace style, and found a few likely candidates, but when I changed them in a way that vaguely looked like it made sense, it didn't have any effect.

(THANK YOU!!! for the "Delete" button in the template editor, to put things back the way they were.  That has been a big help in keeping me out of serious trouble.)

So, I'm out of ideas... how do I change the opening brace style for generated code?

Thanks...

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Change opening brace style in generated code
« Reply #1 on: August 01, 2009, 09:05:42 pm »
Check out the PI macro and go from there.

[edit]I'm wrong on this. Check Eric's solution below.[/edit]
« Last Edit: August 03, 2009, 01:50:36 am by Midnight »
No, you can't have it!

EricP

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: Change opening brace style in generated code
« Reply #2 on: August 02, 2009, 09:44:56 pm »
Quote
Check out the PI macro and go from there.

Good morning, Midnight.

I found "PI" in the Help and I guess I can go into the template editor and try changing a few %PI=" "% to something like %PI="\n"% and see what happens.

It doesn't help much that I have absolutely no idea how most of the templates work or what the code in them means.

In a few months I'll be able to take a few days to a week or two off and learn all about the template language, but at this moment I don't have the time to do that just to learn how to do the one single task of moving the opening brace to the next line.

I realize I'm supposed to help myself and not appear to be coming onto this forum looking for someone to do my work for me, and I really don't think I'm doing that but if I am I apologize... but if one of you folks knows off the top of your head how to move the opening brace to the next line and can point that out to me in the template collection I'd really appreciate it.
« Last Edit: August 02, 2009, 09:45:20 pm by rkt-med »

EricP

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: Change opening brace style in generated code
« Reply #3 on: August 02, 2009, 10:34:07 pm »
OK, I found the solution, or at least ONE solution...

On the first line of the Operation Body template, changed "{\n" to "\n{\n".  Didn't change any of the PI's (there aren't any in that template, anyway).

That seems to have done it... remains to be seen what else I broke by doing that...