Author Topic: C++ Code generation inout parameters  (Read 3652 times)

Thomas Ruschival

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
C++ Code generation inout parameters
« on: March 03, 2012, 01:36:42 am »
Hi Forum
At my previous company I used EA already for C++ code generation, now at my new job I made my manager to buy EA (professional 9.2)

Somehow the C++ code generation in 9.2 does not generate pointers in arguments to operations. the Selector "direction" (in,inout,out,return) on the parameter has simply no effect.
In the model it is displayed correctly:
inout and out parameters have a asterisk *

but the generated code looks like this:
Code: [Select]
unsigned char anOp(const unsigned int paramIn, unsigned int paraminOut, unsigned int paramOut);
In C++ code engineering option the "default reference type" is set to Pointer (*)

BTW, C code engineering also does not produce pointers for function parameters.

Pointers however are created for members.

Could it be due to the fact, that I had first installed a 30-day trial version? If so, how can i purge all EA settings?

UPDATE:
- deleted  \AppData\Roaming\Sparx Systems
- re-installed EA (build 922)
--> same thing, no pointers.

Imported classes with methods using pointers generates in EA operations with all parameters direction to "in".
The type of the parameter for this functions is not  e.g. int but int* .

I had a look at the code generation templates, seems there is no code that checks the direction of a parameter.
Can any one with EA 8.xx please check the code generation templates, I am sure it worked a year ago.....

Update 2:
seems I have found a workaround, apparently the "paramKind"is not evaluated in the code templates. I included:
Code: [Select]
%if paramKind != "in"%
*
%endIf%

It now at least generates code what I want to generate but I have still no clue how I could now genererate something that uses references (Type &)

Seems to me somebody at Sparx copied code form Java or other language templates that do not need to specify references/pointes


Best regards
Thomas
« Last Edit: March 03, 2012, 05:32:45 am by truschival »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: C++ Code generation inout parameters
« Reply #1 on: March 05, 2012, 08:25:40 am »
You are correct, C++ code engineering doesn't use the parameter direction and hasn't been made to due to the different ways to represent it in code and the effect of synchronization.

Beware that your workaround will quite possibly cause issues during synchronization.

Thomas Ruschival

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: C++ Code generation inout parameters
« Reply #2 on: March 05, 2012, 11:34:47 pm »
Thanks Simon for the reply.
I am fully aware that my workaround has a plethora of unwanted side-effects. It is a Friday afternoon hack I made being slightly disgruntled after spending half a day reading documentation, trying to fix the behavior in my model.

Neither the Source Code import documentation nor the C or C++ Source Code generation documentation mention that the direction is simply ignored.
The different ways of representing references in C++ is troublesome for code-synchronization. Now the strange thing is that even in plain old C parameter references are ignored - AFAIK there is only one way (pointer) to describe references...

The only workaround that works, is to use references during modeling, making the type of an argument int* or Class& to model inout parameters.

BTW - are there templates I could modify for Code import/ synchronization?

I hope in future versions this will be resolved.

Best regards
Thomas
 



Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: C++ Code generation inout parameters
« Reply #3 on: March 06, 2012, 08:19:19 am »
Sorry, but we don't expose any method of customizing import instructions.