typinfo.pp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1998 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { This unit provides the same functionality as the TypInfo Unit }
  13. { of Delphi }
  14. unit typinfo;
  15. interface
  16. uses
  17. sysutils;
  18. type
  19. // FPC uses a Byte because a enumeration type takes always
  20. // 4 bytes which is too much
  21. TTypeKind = Byte;
  22. TOrdType = Byte;
  23. TMethodKind = Byte;
  24. TFloatType = Byte;
  25. TParamFlags;
  26. TTypeKinds = set of TTypeKind;
  27. TTypeInfo = record
  28. Kind : TTypeKind;
  29. Name : ShortString;
  30. end;
  31. PTypeInfo = ^TTypeInfo;
  32. PPTypeInfo = ^PTypeInfo;
  33. PTypeData = ^TTypeData;
  34. TTypeData = packed record
  35. case TTypeKind of
  36. tkUnKnown,tkLString,tkWString,tkAString,tkVariant:
  37. ();
  38. tkInteger,tkChar,tkEnumeration,tkWChar:
  39. ( //!!!!! To be added );
  40. tkFloat:
  41. (FloatType : TFloatType);
  42. tkSString:
  43. (MaxLength : Byte);
  44. tkClass:
  45. (ClassType : TClass);
  46. (ParentInfo : PPTypeInfo);
  47. (PropCount : SmallInt);
  48. (UnitName : ShortString);
  49. end;
  50. const
  51. // if you change one of the following constants,
  52. // you have also to change the compiler in an appropriate way !
  53. tkUnknown = 0;
  54. tkInteger = 1;
  55. tkChar = 2;
  56. tkEnumeration = 3;
  57. tkFloat = 4;
  58. tkSet = 6;
  59. tkMethod = 7;
  60. tkSString = 8;
  61. tkString = tkSString;
  62. tkLString = 9;
  63. tkAString = 10;
  64. tkWString = 11;
  65. tkVariant = 12;
  66. tkArray = 13;
  67. tkRecord = 14;
  68. tkInterface = 15;
  69. tkClass = 16;
  70. tkObject = 17;
  71. tkWChar = 18;
  72. otSByte = 0;
  73. otUByte = 1;
  74. otSWord = 2;
  75. otUWord = 3;
  76. otSLong = 4;
  77. otULong = 5;
  78. ftSingle = 0;
  79. ftDouble = 1;
  80. ftExtended = 2;
  81. ftComp = 3;
  82. ftCurr = 4;
  83. ftFixed16 = 5;
  84. ftFixed32 = 6;
  85. // just skips the id and the name
  86. function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
  87. implementation
  88. function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
  89. begin
  90. GetTypeData:=PTypeData(TypeInfo)+2+PByte(TypeInfo+1)^;
  91. end;
  92. end.
  93. {
  94. $Log$
  95. Revision 1.1 1998-08-25 22:30:00 florian
  96. + initial revision:
  97. o constants
  98. o basic type data record
  99. }