[fpc-pascal] Read Field names from VMT

Michael Van Canneyt michael at freepascal.org
Tue Jan 30 13:42:14 CET 2024



On Mon, 29 Jan 2024, Amir--- via fpc-pascal wrote:

> I am still struggling with this!
>
> for i := 0 to vft^.Count - 1 do
> begin
>        vfe := vft^.Field[i];
>        Name := vfe^.Name;
>
>        ChildTClass := vft^.ClassTab^.ClassRef[vfe^.TypeIndex - 1]^;
>        ChildObj := ChildTClass.Create;
>        TObject(Obj.FieldAddress(Name)^) := ChildObj;
> end;
>
> Looks like "ChildTClass.ClassName" is correct but the constructor of the 
> appropriate class is not being called.

Without more info (declaration of ChildTClass, declaration of the constructor
of that class etc), it is not possible to comment.

We need a complete compilable code sample to provide you with more insight.

Michael.


More information about the fpc-pascal mailing list