Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: stegeto22 on February 22, 2006, 06:50:38 am

Title: C++ code generation and roundtrip engineering
Post by: stegeto22 on February 22, 2006, 06:50:38 am
Hi,

I've defined this class:

Code: [Select]

class MyClass
{
public:

typedef int tMyType;

void MyFunction(tMyType myParam);
};


If I now reverse engineer this code to EA and then generate code from it again, the MyFunction has changed to this:
Code: [Select]

void MyFunction(MyClass::tMyType myParam);


Everytime I do these two steps I get another MyClass:: prefix:
Code: [Select]

void MyFunction(MyClass::MyClass::tMyType myParam);


But I don't want the 'MyClass::' prefix.
Is this the correct behavior? Could I prevent this somehow?

Thanks
Title: Re: C++ code generation and roundtrip engineering
Post by: Eve on February 22, 2006, 01:10:06 pm
This is a bug that we're currently in the process of fixing.

The only work around that I know of is removing the namespace qualifier code from the code templates.

You can do this yourself by replacing the following in the Attribute Declaration template, and similar changes in the Linked Attribute Declaration, Linked Class Base, Operation Declaration and Parameter templates.

Code: [Select]
$type=%attQualType? value : "int"%
$type=%REPLACE($type,".","::")%
$qualType=%packagePath% + "::" + %attType%
%if genOptCPPGenNamespace == "T" and $type == $qualType%
$type=%attType%
%endIf%
$type

Code: [Select]
%attType=="" ? "int" : value%
Or, you can send an email in to Sparx support briefly mentioning the problem and asking for the templates to fix it and I can email you a file to import into EA.
Title: Re: C++ code generation and roundtrip engineering
Post by: stegeto22 on March 10, 2006, 01:02:38 am
I have tried it now with the new build 788 again. But the problem is going worse.

Code: [Select]

class MyClass
{
public:
void MyFunction(tMyType myParam);
typedef int tMyType;
};


I reverse engineer this code to EA and generate code from it. But now I get this output:

Code: [Select]

class MyClass
{
public:
void MyFunction(tMyType myParam);

Attribute VB_Name = "tMyType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" , "Yes"
Attribute VB_Ext_KEY = "Top_Level" , "Yes"
Option Explicit
};


What's going wrong?

Thanks
Title: Re: C++ code generation and roundtrip engineering
Post by: Eve on March 13, 2006, 04:46:54 pm
EA appears to be trying to generate the type tMyType as Visual Basic.

My current investigations suggest that it is only happening to inner classes on synchronisation.  If you generate the file from scratch it doesn't appear to be hapenning.
Title: Re: C++ code generation and roundtrip engineering
Post by: stegeto22 on March 13, 2006, 11:12:31 pm
That's right, when I generate it the first time from scratch, it's ok. But once I synchronize it, it'll be generated as Visual Basic.
Title: Re: C++ code generation and roundtrip engineering
Post by: Eve on March 14, 2006, 01:09:29 pm
This problem should be fixed in our next patch release.
Title: Re: C++ code generation and roundtrip engineering
Post by: mikewhit on March 15, 2006, 01:04:20 am
VB instead of C++ ?
Yikes ! Let's hope it doesn't start generating Michael Jackson JSP structure diagrams instead of UML !
Title: Re: C++ code generation and roundtrip engineering
Post by: SnowMan on April 07, 2006, 02:07:40 am
Is this problem resolved in 4th Apr version of Sparx EA?..
Title: Re: C++ code generation and roundtrip engineering
Post by: stegeto22 on April 07, 2006, 09:29:09 am
Yes, it's fixed now.