Book a Demo

Author Topic: Bug with Delphi code  (Read 5289 times)

Jeanluc

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Bug with Delphi code
« on: April 06, 2005, 12:37:45 am »
Hi,

I'll try to explain the problem.

1) Create a class without elements (attributes, operations, etc.)
2) Generate delphi code. In .pas file, you get:
   constructor Create; overload;
   destructor Destroy; override;
3) Return to EA, do a reverse engineering to recreate class in EA diagram. The reverse is ok in diagram.
4) Now, regenerate code and go to Delphi to see generated delphi code. You see:
   constructor Create; overload;
   procedure Destroy; override;

Destroy is totally false ... It's a destructor, not a procedure ...

A good idea to correct this in future version ?

Regards,

Jean-Luc !

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Bug with Delphi code
« Reply #1 on: April 06, 2005, 11:00:45 pm »
Yes, I'd say it would be a good idea to fix it.   ;)

Until it is the fixed templates should look like this.

Edit: I forgot to mention that I will be fixing it.  It should be fixed for build 751, but if not then it will be in the following build.

Operation Declaration
Code: [Select]
%PI=" "%
%if opName == "Create"%
$op_type = "constructor"
%elseIf opName == "Destroy"%
$op_type = "destructor"
%elseIf opReturnType == "" or opReturnType == "void"%
$op_type = "procedure"
%else%
$op_type = "function"
%endIf%

%PI=""%
$params = %list="Parameter" @separator="; "%
%if $params != ""%
$params = "(" + $params + ")"
%endIf%

%PI=" "%
%opStatic == "T" ? "class" : ""%
$op_type

%PI=""%
%opName%$params

%if $op_type == "function"%
: %opReturnType%
%endIf%

%if opPure == "T" or opAbstract == "T"%
; virtual
%endIf%
%opAbstract == "T" ? "; abstract" : ""%
%if opTag:"overload" != "" or $op_type == "constructor"%
; overload
%endIf%
%opTag:"reintroduce" ? "; reintroduce" : ""%
%opTag:"override" == "true" ? "; override" : ""%
;

Operation Declaration Impl
Code: [Select]
%PI=" "%
%if opName == "Create"%
$op_type = "constructor"
%elseIf opName == "Destroy"%
$op_type = "destructor"
%elseIf opReturnType == "" or opReturnType == "void"%
$op_type = "procedure"
%else%
$op_type = "function"
%endIf%

%PI=""%
$params = %list="Parameter" @separator="; "%
%if $params != ""%
$params = "(" + $params + ")"
%endIf%

$op_prefix = $op_type + " " + %className% + "."
%opStatic == "T" ? "class " : ""%
$op_prefix%opName%$params

%if $op_type == "function"%
: %opReturnType%
%endIf%
;\n
« Last Edit: April 06, 2005, 11:31:46 pm by simonm »

Jeanluc

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Bug with Delphi code
« Reply #2 on: April 07, 2005, 02:12:41 am »
Thanks ! The last generated code is correct but format is bad.

type

 Test = class
 public
                  constructor     Create       ; overload    ;
                  destructor     Destroy        ; override ;
 end;

implementation

{implementation of Test}

           constructor Test.Create   ;
 begin

end;

           destructor Test.Destroy   ;
 begin

end;
end.

But it's better than old ..  :D

Jean-Luc
« Last Edit: April 07, 2005, 02:18:17 am by Jeanluc »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Bug with Delphi code
« Reply #3 on: April 07, 2005, 03:12:51 pm »
The problem with the formatting is that when copying the template from here it added an extra space to every line.  Each one was then generated, exactly as it should.

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Bug with Delphi code
« Reply #4 on: April 07, 2005, 04:29:45 pm »
(Sorry Simon - I just want to make this a bit clearer).


When copying code (or any text) from yabb forums, because of the html used you will get an extra blank line between each line.  So you need to go through a clean up step using a text editor (or even word if you want) to remove the extra lines before pasting it into your destination.


bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Bug with Delphi code
« Reply #5 on: April 07, 2005, 06:14:44 pm »
That's fine Bruce.

That's interesting though, I only get an extra space at the end of every line.  (And that's what it looks like Jen-Luc got)

I wonder, is it a browser thing as well?

Simon

Jeanluc

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Bug with Delphi code
« Reply #6 on: April 10, 2005, 11:35:45 pm »
Thanks a lot !  :) I'll clean it !