Book a Demo

Author Topic: Delphi property Get generation flaw  (Read 2632 times)

sftweng

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Delphi property Get generation flaw
« on: June 16, 2004, 10:00:43 pm »
I've been using UML with various tools since the pre-release version of UML (0.9). As a result of my evaluation over the past month, we decided to proceed to a full "Pro" licence and did so yesterday. You guys deserve kudos for producing a wonderful tool.

Not surprisingly, though, it has a few startup warts and I think I've found another two, closely related.

The first is pretty easy to deal with, I think. When Getxxx and Putxxx methods are generated for an attribute of a class which is marked as a property, the Getxxx method should be a Pascal "function" that returns a value of the desired class, rather than a "procedure" which returns no value. In "C" terms, a procedure returns a void while a function returns something non-void.

The second is more gnarly and I bumped into it yesterday. A property which is indexed in Delphi Pascal appears to cause grief on round-trip engineering. I'll try to document this better later today (it's now just past midnight), but the problem comes with trying to handle properties that look something like this, the result of a round trip (forward & reverse) and some code tweaking:

type

 TRSExtentList = class (TObjectlist)
 private
   fExtents: TRSExtent;
 public
   function  GetExtents(Index: Integer): TRSExtent;
   procedure SetExtents(Index: Integer; NewVal: TRSExtent);
   constructor Create; overload;
   procedure Destroy; virtual;
   property GetExtents:TRSExtent read GetGetExtents write SetGetExtents;
 published
   property Extents[Index : Integer]:TRSExtent read GetExtents write SetExtents;
 end;

The wierdness (IMHO) is in the GetGetExtents and SetGetExtents code generation, which appears to be non-reversible and doesn't produce procedure skeletons.

I can find a workaround so this isn't a show-stopper for me and I'd be happy to help to diagnose this further but I'd like to see a solution eventually.

Alan
Alan

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Delphi property Get generation flaw
« Reply #1 on: June 17, 2004, 04:10:18 pm »
Hi Alan,

Quote
The first is pretty easy to deal with, I think. When Getxxx and Putxxx methods are generated for an attribute of a class which is marked as a property, the Getxxx method should be a Pascal "function" that returns a value of the desired class, rather than a "procedure" which returns no value. In "C" terms, a procedure returns a void while a function returns something non-void.


Yes, it is easy to fix and it's already waiting to be released in the next build.  In fact, it's so easy to fix that you can fix it yourself before then by editing the code generation templates.  See http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.cgi?board=general;action=display;num=1085411421.

As for your other problem.  I'm not exactly sure what you are describing, but I tried importing the code you put up.  Doing a fresh generate from that resulted in exactly the same thing.  So as far as I can tell it does round trip.  Just it brings the two property bits in as tagged values.

Simon
« Last Edit: June 17, 2004, 04:19:49 pm by simonm »