Hi all,
I am working with build 726, trying to adapt the C++ code generation templates, and hit some problems. Hope someone can help me out. Specifically:
I declared an interface with a const operation returning, say, an
int. Furthermore, the operation has a fixed inout parameter of type T. In the generated code, I expected something like
virtual int initialize(const T& t) const =0;As far as I understand, this would correspond to the documented behaviour. Alas, the method generated instead is
virtual const int initialize(const T t) =0;[*]In order to make the operation (instead of the return value) constant, I modified the templates
OperationDeclaration and
OperationDeclarationImpl:
%opStatic=="T" ? "static" : ""%
%opConst=="T" ? "const" : ""%
%opReturnType%
[...]
%if opIsQuery=="T" or opStereotype=="const" or opConst=="T"%
const
%endIf%[*] In order to get the reference, I added logic to the templates
Parameter and
ParameterImpl, as follows:
%if paramType != "void"%
%if paramKind == "inout" or paramKind == "out"%
&
%endIf%%paramName%
%endIf%
[/list]
This generates
virtual int initialize(const T &t) const =0;which is fine.
However, on subsequent generations (using method "Synchronize Model and Code"),
the method is appended to the source an additional time, yielding several identical declarations. This seems to happen as soon as I alter the Parameter templates. The error does not occur when only modifying the Operation templates, or when leaving the Parameter templates untouched.
I am stuck and would appreciate if someone can give me a hint.
Many thanks,
Andreas