home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 August / VPR9608A.BIN / del20try / install / data.z / TYPINFO.INT < prev    next >
Text File  |  1996-05-08  |  4KB  |  140 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,96 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit TypInfo;
  11.  
  12. interface
  13.  
  14. uses SysUtils;
  15.  
  16. type
  17.  
  18.   TTypeKind = (tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat,
  19.     tkString, tkSet, tkClass, tkMethod, tkWChar, tkLString, tkLWString,
  20.     tkVariant);
  21.   TTypeKinds = set of TTypeKind;
  22.  
  23.   TOrdType = (otSByte, otUByte, otSWord, otUWord, otSLong);
  24.  
  25.   TFloatType = (ftSingle, ftDouble, ftExtended, ftComp, ftCurr);
  26.  
  27.   TMethodKind = (mkProcedure, mkFunction);
  28.   TParamFlags = set of (pfVar, pfConst, pfArray);
  29.  
  30.   PTypeInfo = ^TTypeInfo;
  31.   TTypeInfo = record
  32.     Kind: TTypeKind;
  33.     Name: ShortString;
  34.    {TypeData: TTypeData}
  35.   end;
  36.  
  37.   PTypeData = ^TTypeData;
  38.   TTypeData = packed record
  39.     case TTypeKind of
  40.       tkUnknown, tkLString, tkLWString, tkVariant: ();
  41.       tkInteger, tkChar, tkEnumeration, tkSet, tkWChar: (
  42.         OrdType: TOrdType;
  43.         case TTypeKind of
  44.           tkInteger, tkChar, tkEnumeration, tkWChar: (
  45.             MinValue: Longint;
  46.             MaxValue: Longint;
  47.             case TTypeKind of
  48.               tkInteger, tkChar, tkWChar: ();
  49.               tkEnumeration: (
  50.                 BaseType: PTypeInfo;
  51.                 NameList: ShortString));
  52.           tkSet: (
  53.             CompType: PTypeInfo));
  54.       tkFloat: (
  55.         FloatType: TFloatType);
  56.       tkString: (
  57.         MaxLength: Byte);
  58.       tkClass: (
  59.         ClassType: TClass;
  60.         ParentInfo: PTypeInfo;
  61.         PropCount: SmallInt;
  62.         UnitName: ShortString
  63.        {PropData: TPropData});
  64.       tkMethod: (
  65.         MethodKind: TMethodKind;
  66.         ParamCount: Byte;
  67.         ParamList: array[0..1023] of Char
  68.        {ParamList: array[1..ParamCount] of
  69.           record
  70.             Flags: TParamFlags;
  71.             ParamName: ShortString;
  72.             TypeName: ShortString;
  73.           end;
  74.         ResultType: ShortString});
  75.   end;
  76.  
  77.   TPropData = packed record
  78.     PropCount: Word;
  79.     PropList: record end;
  80.    {PropList: array[1..PropCount] of TPropInfo}
  81.   end;
  82.  
  83.   PPropInfo = ^TPropInfo;
  84.   TPropInfo = packed record
  85.     PropType: PTypeInfo;
  86.     GetProc: Pointer;
  87.     SetProc: Pointer;
  88.     StoredProc: Pointer;
  89.     Index: Integer;
  90.     Default: Longint;
  91.     NameIndex: SmallInt;
  92.     Name: ShortString;
  93.   end;
  94.  
  95.   TPropInfoProc = procedure(PropInfo: PPropInfo) of object;
  96.  
  97.   PPropList = ^TPropList;
  98.   TPropList = array[0..16379] of PPropInfo;
  99.  
  100. const
  101.   tkAny = [Low(TTypeKind)..High(TTypeKind)];
  102.   tkMethods = [tkMethod];
  103.   tkProperties = tkAny - tkMethods - [tkUnknown];
  104.  
  105. { Property access routines }
  106.  
  107. function GetTypeData(TypeInfo: PTypeInfo): PTypeData;
  108.  
  109. function GetEnumName(TypeInfo: PTypeInfo; Value: Integer): string;
  110. function GetEnumValue(TypeInfo: PTypeInfo; const Name: string): Integer;
  111.  
  112. function GetPropInfo(TypeInfo: PTypeInfo; const PropName: string): PPropInfo;
  113. procedure GetPropInfos(TypeInfo: PTypeInfo; PropList: PPropList);
  114. function GetPropList(TypeInfo: PTypeInfo; TypeKinds: TTypeKinds;
  115.   PropList: PPropList): Integer;
  116.  
  117. function IsStoredProp(Instance: TObject; PropInfo: PPropInfo): Boolean;
  118.  
  119. function GetOrdProp(Instance: TObject; PropInfo: PPropInfo): Longint;
  120. procedure SetOrdProp(Instance: TObject; PropInfo: PPropInfo;
  121.   Value: Longint);
  122.  
  123. function GetStrProp(Instance: TObject; PropInfo: PPropInfo): string;
  124. procedure SetStrProp(Instance: TObject; PropInfo: PPropInfo;
  125.   const Value: string);
  126.  
  127. function GetFloatProp(Instance: TObject; PropInfo: PPropInfo): Extended;
  128. procedure SetFloatProp(Instance: TObject; PropInfo: PPropInfo;
  129.   Value: Extended);
  130.  
  131. function GetVariantProp(Instance: TObject; PropInfo: PPropInfo): Variant;
  132. procedure SetVariantProp(Instance: TObject; PropInfo: PPropInfo;
  133.   const Value: Variant);
  134.  
  135. function GetMethodProp(Instance: TObject; PropInfo: PPropInfo): TMethod;
  136. procedure SetMethodProp(Instance: TObject; PropInfo: PPropInfo;
  137.   const Value: TMethod);
  138.  
  139. implementation
  140.