[fpc-pascal] All methods vitrual ?

Adriaan van Os adriaan at adriaan.biz
Tue Oct 10 11:18:15 CEST 2023


Michael Van Canneyt via fpc-pascal wrote:
> 
> 
> On Mon, 9 Oct 2023, Adriaan van Os via fpc-pascal wrote:
> 
>> Is there a trick to make (in mode macpas) all class methods 
>> implicitely virtual ? I mean, without adding the virtual keyword to 
>> all of them ? The reason is that I want to create a tree view of the 
>> class hierarchy with all the method names (not just those that are 
>> normally in the VMT because they are overridden).
>>
>> Any other ideas ?
> 
> If you need this tree at run-time:
> 
> - The "extended RTTI" branch of fpc allows you to list all methods,
>   regardless of their visibility

Interesting ! If I am correct, the docs referred to at 
<https://gitlab.com/freepascal.org/fpc/source/-/issues/38964> say

; visibility-clause:
; METHODS|PROPERTIES|FIELDS (visibility-expression)

Does that mean that the "extended RTTI" branch supports RTTI for fields ?

> 
> - In the released compiler, if you remove all visibility specifiers, you 
> can
>   get a list by specifying {$M+} on your base object and then list all
>   published methods using the RTTI.

My understanding is that I have to explicitely specify public for class fields, otherwise the 
compiler will issue an error.

> 
> If you simply need this tree:
> 
> - You can simply use fcl-passrc to analyse your source tree and create 
> the complete
>   list. No changes to code needed. I have several programs that do this.

Will try that out, thanks.

Regards,

Adriaan van Os



More information about the fpc-pascal mailing list