Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-02

Any way to find all descendants of a class?

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Craig Peterson

In Delphi I can use the new extended RTTI support to build a list of all TForm descendants in my application (TRttiContext.GetTypes). Is there any way to do the same thing in Free Pascal without having to explicitly add each class to a list?

I do have an intermediate class that all of our other forms descend from, so I can add something there if necessary, and I don't need it to be compatible with Delphi.

Craig Peterson Scooter Software

Reply by email

Sven Barth
to Craig Peterson
Craig Peterson wrote 5 lines
In Delphi I can use the new extended RTTI support to build a list of all TForm descendants in my application (TRttiContext.GetTypes). Is there any way to do the same thing in Free Pascal without having to explicitly add each class to a list?

Free Pascal does not yet support the extended RTTI, so the answer is: No.

I do have an intermediate class that all of our other forms descend from, so I can add something there if necessary, and I don't need it to be compatible with Delphi.

In theory all classes that can be read from e.g. an LFM file are registered with the RTL's streaming system. So please check whether the corresponding functions can help you. You can find them in $fpcdir/rtl/objpas/classes/classesh.inc around line 1938 (look for "RegisterClass").

Regards,
Sven

Reply by email