Sign in Join

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

Mailing lists / fpc-pascal / 2014-02

List published properties of a class

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Joao Morais

Hello list. I need to list all published properties declared in a class, iow, removing properties inherited from the parent.

Up to now I am iterating typinfo.GetPropList, starting at:

GetTypeData(PTypeInfo(TheClass.ClassParent.ClassInfo))^.PropCount;

and it works (fpc 2.6.2). TheClass will never receive TObject. Is this the right way? Will such piece of code continue working in future versions of the rtl?

Joao Morais
to Joao Morais
Joao Morais wrote 11 lines
Hello list. I need to list all published properties declared in a class, iow, removing properties inherited from the parent. Up to now I am iterating typinfo.GetPropList, starting at: GetTypeData(PTypeInfo(TheClass.ClassParent.ClassInfo))^.PropCount; and it works (fpc 2.6.2). TheClass will never receive TObject. Is this the right way? Will such piece of code continue working in future versions of the rtl?

Resurrecting this old message. The point is: TObject.ClassInfo is and will always be a TypeInfo pointer? If so, out of curiosity, why declare it as Pointer? What comes to mind is circular reference, layer violation, something like this.

Sven Barth
to Joao Morais
"Joao Morais" wrote 5 lines
Em 09/02/14 18:05, Joao Morais escreveu: > > Hello list. I need to list all published properties declared in a class,

iow, removing properties inherited from the parent.

Show quoted text 6 lines
> > Up to now I am iterating typinfo.GetPropList, starting at: > > GetTypeData(PTypeInfo(TheClass.ClassParent.ClassInfo))^.PropCount; > > and it works (fpc 2.6.2). TheClass will never receive TObject. Is this

the right way? Will such piece of code continue working in future versions of the rtl?

Resurrecting this old message. The point is: TObject.ClassInfo is and

will always be a TypeInfo pointer? If so, out of curiosity, why declare it as Pointer? What comes to mind is circular reference, layer violation, something like this.

Yes, that is the reason. TTypeInfo (and PTypeInfo) is declared in unit typinfo, but TObject and thus ClassInfo is declared in unit system which does not use any other unit.

Also it will stay like this. It would break way too much code if we'd change that.

Regards,
Sven