Author Topic: Generates wrong delphi code  (Read 362 times)

Andi_MC

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Generates wrong delphi code
« on: February 02, 2007, 06:03:18 am »
Hallo

I have following attributes in a UML class diagram

- FConstAttribut: Integer = 10 {readOnly}
- FStaticAttribut: Integer = 10

the generated code looks like

Code: [Select]

unit c_TTest;

interface

type

 TTest = class
 private
   FAttribut: Integer;
   FConstAttribut: Integer;
   class FStaticAttribut: Integer;
 public
   constructor Create; overload;
   destructor Destroy; override;
 end;

implementation
.
.
.


The FConstAttribut is declared as a normal attribute and the FStaticAttribut is also not correct. And where ist the initial Value?  
If I generate Java code, the attributes will be declared correctly.    
Ist that a general problem of the code generator or are there some wrong setting?

Thanks in advance

Andi

Krzysztof Swiatkowski

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
  • Understanding is a three-edged sword
    • View Profile
Re: Generates wrong delphi code
« Reply #1 on: February 06, 2007, 04:14:31 pm »
The problem you are facing may have much deeper background :). First of all you need to specify what Delphi version are you talking about. If it is older Delphi (<=7) than it had neither static fields nor initialization in the interface. You had to initialize fields in the constructor.
New Delphi has new .Net required features like static fields they are declared and referred to as

class var FStaticAttribute : Integer;
TMyClass.FStaticAttribute := 5;

I do not know if there was anything new introduced for setting initial values. Using old ways you could add typed constant and modify it but it is strongly discouraged in new code.
You can use EA Code Generation Templates to modify a way the code is generated. It could be done globally only by introducing Delphi.NET language :)

Regards
Kris
If I put you finger in the eye
then you have finger in the eye
and I have finger in the eye
but it's not the same