About the author
Given there's a single type declaration,
THDItem
and that I wanted to see the field offsets as well as calculate the total size of the record, using Delphi's RTTI, I can do so with:
var rtype: TRTTIType; fields: TArray<TRTTIField>; LFieldName: string; P: Pointer; LTotalSize: Integer; LHDItem: THDItem; begin rtype := TRTTIContext.Create.GetType(TypeInfo(THDItem)); P := @LHDItem; fields := rtype.GetFields; for i := 0 to High(fields) do begin LFieldName := fields[i].Name; if LFieldName.StartsWith('placeholder', True) then Continue; WriteLn(Format('%-20s: %-10s :: %-30s, Addr: %.8x', [ LFieldName, fields[i].FieldType.ToString, fields[i].GetValue(P).ToString, fields[i].Offset])); LTotalSize := LTotalSize + fields[i].FieldType.TypeSize; end; WriteLn('Size: ', LTotalSize); end;
Continued discussion of undocumented Delphi 8 Property Access Specifiers, and other ways of adding and removing delegates / events handlers, including clearing the list of all the delegates / event handlers.
This article discusses the new Delphi 8 property access specifiers.
A method pointer is now the same as a global procedure, ie, procedure of object = procedure.