home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk15 / inttab.pak / TYPINFO.INT < prev    next >
Encoding:
Text File  |  1995-08-24  |  4.1 KB  |  140 lines

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