[fpc-pascal] Read Field names from VMT
Amir at Aavani.net
Amir at Aavani.net
Tue Jan 30 08:37:45 CET 2024
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.
On 1/22/24 23:05, Michael Van Canneyt via fpc-pascal wrote:
>
>
> On Mon, 22 Jan 2024, Amir--- via fpc-pascal wrote:
>
>> Params := TParams.Create;
>> WriteLn(Params.Int2.IntVal);
>> WriteLn(TInteger(Params.FieldAddress('Int2')).IntVal);
>>
>> The third line does not work (the zipped code is attached).
>
> It should be
>
> WriteLn(TInteger(Params.FieldAddress('Int2')^).IntVal);
>
> Terribly convoluted code, though...
>
> Michael.
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list