Uses system.typinfo;
Sync with compiler internals
Ttypekind = (Tkunknown, Tkinteger, Tkchar, Tkenumeration, Tkfloat,
Tkstring, Tkset, Tkclass, Tkmethod, Tkwchar, tklstring, tkwstring,
Tkvariant, Tkarray, Tkrecord, Tkinterface, TkInt64, Tkdynarray, tkustring,
Tkclassref, Tkpointer, tkprocedure {, tkmrecord});
Type
{$IFDEF NEXTGEN}
Tsymbolname = Byte;
{$ELSE NEXTGEN}
Tsymbolnamebase = string[255];
Tsymbolname = Type tsymbolnamebase;
{$ENDIF NEXTGEN}
Ttypeinfofieldaccessor = Record
Strict private//static? Private
Fdata:pbyte;
Public
Procedure SetData (const data:pbyte); Inline
Class operator Equal (const left, right:ttypeinfofieldaccessor): Boolean; Inline
function Utf8length:integer; Inline
function tostring:string;
{$IFNDEF NEXTGEN}
function toshortutf8string:shortstring; Inline
{$ENDIF! NEXTGEN}
function tobytearray:tbytes;
function Tail:pbyte; Inline
End
-------------------TypeInfo (T)-------------------
Ptypeinfo = ^ttypeinfo;
Ttypeinfo = Record
Kind:ttypekind;
Name:tsymbolname;
function Namefld:ttypeinfofieldaccessor; Inline
{Typedata:ttypedata}
function Typedata:ptypedata; Inline
End
function Tsampleclass<t>. getdataname:string;
Var
Kind:ttypekind;
Begin
Result: = Gettypename (TypeInfo (T));
Kind: = Ptypeinfo (TypeInfo (T)) ^. Kind;
Case Kind of
Tkinteger:showmessage (' I ');
Tkfloat:showmessage (' F ');
Tkstring,tkustring:showmessage (' S ');
Tkchar:showmessage (' C ');
Tkclass:showmessage (' Class ');
else ShowMessage (Result);
End
End
Type and generic tags