[Lazarus] Challenge of converting a Delphi project

Mattias Gärtner nc-gaertnma at netcologne.de
Wed May 5 13:30:35 CEST 2010


Zitat von Juha Manninen <juha.manninen at phnet.fi>:

> Mattias Gaertner wrote:
>> Yes, because you enabled 'verify method calls' -CR.
>> Disabling this gives a class diagram under gtk2.
>> Looks promising.
>
> Wow, I guessed it is some small thing and then I would feel stupid. :-)
>
> Now I need to understand this. What does 'verify method calls' option do?
> There was a typecast, not a method call.

Yes, the description is misleading. Original is "Verify object method  
call validity", which is longer without being more clear.
AFAIK it only checks class typecasts.


> Is it by design that this option creates RunError and other errors  
> and crashes
> the program when there is a typecast, or is it a bug?

It works like range checking. It raises an exception. If you don't  
catch it the default handler will stop the program.


> Doesn't look very useful option to me.

It is very useful. It correctly found the invalid type cast.
For these rare cases you normally disable checks. I don't know the  
flags for -CR, but here is an example for range checks:

   {$IFOPT R+}{$DEFINE RangeChecking}{$ENDIF}
   {$R-}
   while AString[p]<>#0 do inc(p);
   {$IFDEF RangeChecking}{$R+}{$UNDEF RangeChecking}{$ENDIF}

or you could use push and pop.


> Anyway, this was not the original main problem with EssModel (fortunately
> because then I would feel very stupid). First it didn't draw anything. I
> changed the project settings later.
> I still think the complex interface system was the problem for both  
> Delphi2009
> and for FPC. EssModel used also delegated interfaced methods. There must have
> been some change in Delphi regarding interfaces.

The code uses some dirty tricks that are doomed to fail with newer  
Delphi versions, and even more to port to FPC and other platforms. I  
think it is a bad example for testing the converter.


> The interfaces were used to make some kind of model-view system between the
> model and the visual controls showing it. I replaced interfaces with Listener
> classes. How do other Delphi / Lazarus programs do such things?

see for example tiopf.


> Mattias mentioned at forum a need for a class diagram component. What kind of
> component? Would it be integrated in Lazarus IDE?

Well, the codetools provide a lot of data. I would like to show class  
diagrams of units, packages and projects. I need a control to show  
graphs with hundreds (or even thousands) of nodes. Later we can add  
editing abilities.
The EssModel looks promising, but I have some doubts about the code quality.


> A (more or less) working version can be found in my GitHub repo. Anybody is
> welcome to look at it.


Mattias







More information about the Lazarus mailing list