23.1 Constants, Types and variables

Constants

The following constants are used in the implementation section of the unit.
 BooleanIdents: array[Boolean] of String = ('False', 'True');
 DotSep: String = '.';
The following constants determine the access method for the Stored identifier of a property as used in the PropProcs field of the TPropInfo record:
 ptField = 0;
 ptStatic = 1;
 ptVirtual = 2;
 ptConst = 3;
The following typed constants are used for easy selection of property types.
 tkAny = [Low(TTypeKind)..High(TTypeKind)];
 tkMethods = [tkMethod];
 tkProperties = tkAny-tkMethods-[tkUnknown];

types

The following pointer types are defined:
 PShortString =^ShortString;
 PByte        =^Byte;
 PWord        =^Word;
 PLongint     =^Longint;
 PBoolean     =^Boolean;
 PSingle      =^Single;
 PDouble      =^Double;
 PExtended    =^Extended;
 PComp        =^Comp;
 PFixed16     =^Fixed16;
 Variant      = Pointer;

The TTypeKind determines the type of a property:

 TTypeKind = (tkUnknown,tkInteger,tkChar,tkEnumeration,
              tkFloat,tkSet,tkMethod,tkSString,tkLString,tkAString,
              tkWString,tkVariant,tkArray,tkRecord,tkInterface,
              tkClass,tkObject,tkWChar,tkBool,tkInt64,tkQWord,
              tkDynArray,tkInterfaceRaw);
 tkString = tkSString;
tkString is an alias that is introduced for Delphi compatibility.

If the property is and ordinal type, then TTOrdType determines the size and sign of the ordinal type:

 TTOrdType = (otSByte,otUByte,otSWord,otUWord,otSLong,otULong);
The size of a float type is determined by TFloatType:
 TFloatType = (ftSingle,ftDouble,ftExtended,ftComp,ftCurr,
               ftFixed16,ftFixed32);
A method property (e.g. an event) can have one of several types:
 TMethodKind = (mkProcedure,mkFunction,mkConstructor,mkDestructor,
                mkClassProcedure, mkClassFunction);
The kind of parameter to a method is determined by TParamFlags:
 TParamFlags = set of (pfVar,pfConst,pfArray,pfAddress,pfReference,pfOut);
Interfaces are described further with TntfFlags:
 TIntfFlags = set of (ifHasGuid,ifDispInterface,ifDispatch);
The following defines a set of TTypeKind:
 TTypeKinds = set of TTypeKind;
The TypeInfo function returns a pointer to a TTypeInfo record:
 TTypeInfo = record
   Kind : TTypeKind;
   Name : ShortString;
 end;
 PTypeInfo = ^TTypeInfo;
 PPTypeInfo = ^PTypeInfo;
Note that the Name is stored with as much bytes as needed to store the name, it is not padded to 255 characters. The type data immediatly follows the TTypeInfo record as a TTypeData record:
 PTypeData = ^TTypeData;
 TTypeData = packed record
 case TTypeKind of
   tkUnKnown,tkLString,tkWString,tkAString,tkVariant:
     ();
   tkInteger,tkChar,tkEnumeration,tkWChar:
     (OrdType : TTOrdType;
      case TTypeKind of
        tkInteger,tkChar,tkEnumeration,tkBool,tkWChar : (
          MinValue,MaxValue : Longint;
          case TTypeKind of
            tkEnumeration: (
              BaseType : PTypeInfo;
              NameList : ShortString
            )
          );
        tkSet: (
              CompType : PTypeInfo
          )
      );
   tkFloat: (
     FloatType : TFloatType
     );
   tkSString:
     (MaxLength : Byte);
   tkClass:
     (ClassType : TClass;
      ParentInfo : PTypeInfo;
      PropCount : SmallInt;
      UnitName : ShortString
      );
   tkMethod:
     (MethodKind : TMethodKind;
      ParamCount : Byte;
      ParamList : array[0..1023] of Char
      {in reality ParamList is a array[1..ParamCount] of:
   record
     Flags : TParamFlags;
     ParamName : ShortString;
     TypeName : ShortString;
   end;
 followed by
   ResultType : ShortString}
     );
   tkInt64:
    (MinInt64Value, MaxInt64Value: Int64);
   tkQWord:
    (MinQWordValue, MaxQWordValue: QWord);
   tkInterface:
 ();
                                                                            

                                                                            
 end;
If the typeinfo kind is tkClass, then the property information follows the UnitName string, as an array of TPropInfo records.

The TPropData record is not used, but is provided for completeness and compatibility with Delphi.

 TPropData = packed record
   PropCount : Word;
   PropList : record end;
 end;
The TPropInfo record describes one published property of a class:
 PPropInfo = ^TPropInfo;
 TPropInfo = packed record
   PropType : PTypeInfo;
   GetProc : Pointer;
   SetProc : Pointer;
   StoredProc : Pointer;
   Index : Integer;
   Default : Longint;
   NameIndex : SmallInt;
   PropProcs : Byte;
   Name : ShortString;
 end;
The Name field is stored not with 255 characters, but with just as many characters as required to store the name.
 TProcInfoProc = procedure(PropInfo : PPropInfo) of object;
The following pointer and array types are used for typecasts:
 PPropList = ^TPropList;
 TPropList = array[0..65535] of PPropInfo;