Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: aram on May 30, 2006, 12:50:25 am

Title: C++ code generation errors
Post by: aram on May 30, 2006, 12:50:25 am
The C++ code generation template introduces simple errors when generating the code. For association classes it generates a pointer variable however in the getters and setters it uses this variable as an value object.

I've tried to modify the template but I got stuck in the following lines:

%if opCode != ""%
%WRAP_LINES(opCode, "-1", "\t", "")%

This opCode produces the getter/setter method implementation. However it is not explained anywhere how is opCode constructed and how could one modify it.
Title: Re: C++ code generation errors
Post by: thomaskilian on May 30, 2006, 04:16:46 am
I'm not very much in C++ but I can't recall any opCode macro. Can you point out in which template you found this. I just browsed through them but could not find it.
Title: Re: C++ code generation errors
Post by: aram on May 30, 2006, 04:41:12 am
its in the C++ Language Operation Body template.

I've tried to remove the lines
%if opCode != ""%
%WRAP_LINES(opCode, "-1", "\t", "")%
then i don't get any getter/setter implementation which means that the whole thing is being done exactly in the opCode macro.

thnx.
Title: Re: C++ code generation errors
Post by: thomaskilian on May 30, 2006, 06:16:27 am
Now this is funny. The help file does not explain opCode while (almost?) all other op* macros are explained. Search the help for "opBehaviour" and you will see the list - except opCode. Sparxian, could you pls. fix that...

However, I remember now that this will return the contents of the "Initial Code:" frame which you will find in Properties/Behaviour of an operation.
Title: Re: C++ code generation errors
Post by: aram on May 30, 2006, 06:23:29 am
So what should I do to have
*variable = newVal
instead of the currently generated
variable = newVal
Title: Re: C++ code generation errors
Post by: thomaskilian on May 30, 2006, 10:09:26 am
You likely have to look into the Attribute Declaration macro. There's a place where "By Reference" is used. This is just a shot in the dark. Maybe someone else has better advice :-/
Title: Re: C++ code generation errors
Post by: Eve on May 30, 2006, 03:11:56 pm
Shortly after the code that you've removed there is the following that generates the code you're interested in.

Code: [Select]
%elseIf opStereotype == "property set" and opTag:"attribute_name" != ""%
\t%opTag:"attribute_name"% = newVal;


If you're removing the first clause of the if-else, make sure you change the next elseIf to an if.
Title: Re: C++ code generation errors
Post by: Eve on June 01, 2006, 03:30:55 pm
The opCode macro is documented in the help file for 791.
Title: Re: C++ code generation errors
Post by: thomaskilian on June 01, 2006, 11:39:31 pm
 :)