home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vp21beta.zip / ARTLSRC.RAR / TYPINFO.PAS < prev    next >
Pascal/Delphi Source File  |  2000-08-15  |  4KB  |  144 lines

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