home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vp11demo.zip / rtlsrc.rar / rtl / TYPINFO.PAS < prev    next >
Pascal/Delphi Source File  |  1996-10-08  |  4KB  |  152 lines

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