Book a Demo

Author Topic: typedef for C++ templates code generation defect  (Read 3588 times)

Xentrax

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
typedef for C++ templates code generation defect
« on: April 22, 2006, 07:35:36 am »
I tried to reverse engineer some of my classes and after adding of some macros EA could do rather well.

But when I tried to generate code back EA produced incorrect code.

Initially I had such code:
class TToolsRegion : public TToolsGeoObject
{
// ...
typedef std::map<string, TArrOfProjections> TMapOfSystems;

TMapOfSystems systems_;
// ...
}


After generation i've got this:
typedef std::map<string TMapOfSystems;
TMapOfSystems systems_;
And it's not ok.


Does EA support C++ templates?


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: typedef for C++ templates code generation defe
« Reply #1 on: April 23, 2006, 03:23:03 pm »
What build are you using?

I just tested this and it worked properly.  After reverse engineering, if you look at the class "TMapOfSystems" it should have a parent of "std::map" and on the Detail page of the properties dialog the Templates Type should be "Instantiated" with arguments of "string, TArrOfProjections".

Is this what you see?

Xentrax

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: typedef for C++ templates code generation defe
« Reply #2 on: May 05, 2006, 12:43:24 am »
Build 787 (Trial)

Yes. It has std::map in upper-right corner of the rectangle and stereotype is "typedef" and template has "instantiated" in Details page with correct parameters (string, TArrOfProjections). It has link to TToolsRegion in Links page.

But the code generated is incorrect "typedef std::map<string TMapOfSystems; "

I even deleted the diagram and regenerated it again but it did not help.

Xentrax

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: typedef for C++ templates code generation defe
« Reply #3 on: May 06, 2006, 09:48:56 am »
I am reproducing it on build 790. I am still getting "typedef std::map<string TMapOfSystems;" after a roundtrip.

I isolated all the code in a separate file and created separate eap project.


#pragma once

namespace TT2TSBridge
{

class TToolsGeoObject
{
};

class TToolsSystem
: public TToolsGeoObject
{
public:

TToolsSystem(const string& name)
: TToolsGeoObject(name, string())
{
}
};


class TToolsRegion : public TToolsGeoObject
{
public:
struct TPrjDescription
{
string display_name_;
string prj_id_;
bool isUser_;
};

typedef std::vector<TPrjDescription> TArrOfProjections;
typedef std::map<string, TArrOfProjections> TMapOfSystems; // ***
TMapOfSystems systems_;

};
}

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: typedef for C++ templates code generation defe
« Reply #4 on: May 07, 2006, 04:58:03 pm »
Ok,

I found the problem.  We'll put a fix into a future build, but until then you can modify the template yourself.

Class Declaration template: typedef override
Code: [Select]
$parent=%list="ClassBase" @separator="#ENDPARENT#"%
$breakPos = %FIND($parent, "#ENDPARENT#")%
%if $breakPos != "-1"%
$parent = %LEFT($parent, $breakPos)%
%endIf%
%if $parent == ""%
%endTemplate%
%PI=" "%
typedef
%opTag:"type"%
$parent
%className%;