Advertisement
Guest User

Untitled

a guest
Jul 17th, 2015
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.88 KB | None | 0 0
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   TypInfo,
  7.   SysUtils;
  8.  
  9. type
  10.  
  11. {$M+}
  12.  
  13.   { TMyObject }
  14.  
  15.   TMyObject = class(TObject)
  16.   published
  17.     procedure Test(AParamInt: Integer; AParamStr: string);
  18.   end;
  19.  
  20. {$M-}
  21.  
  22.   procedure TMyObject.Test(AParamInt: Integer; AParamStr: string);
  23.   begin
  24.   end;
  25.  
  26. var
  27.   I: Integer;
  28.   J: Integer;
  29.   PNL: Integer;
  30.   CP: Integer;
  31.   TD: PTypeData;
  32.   Flag: Byte;
  33.   Def: string;
  34.   PN: string;
  35.   TN: string;
  36.   Flags: TParamFlags;
  37. begin
  38.   TD := GetTypeData(TypeInfo(@TMyObject.Test));
  39.   if TD <> nil then
  40.   begin
  41.     WriteLn('Method kind: ', TD^.MethodKind);
  42.     WriteLn('Param count: ', TD^.ParamCount);
  43.     CP := 0;
  44.     Def := '(';
  45.     for i := 1 to TD^.ParamCount do
  46.     begin
  47.       Flag := Byte(TD^.ParamList[CP]);
  48.       Flags := TParamFlags(Flag);
  49.       WriteLn('Ord(Flags): ', Ord(TD^.ParamList[CP]));
  50.       //      for i:= 1 to NumI do
  51.       //      begin
  52.       if pfVar in Flags then
  53.         Def += 'var ';
  54.       if pfconst in Flags then
  55.         Def += 'const ';
  56.       if pfArray in Flags then
  57.         Def += 'array of ';
  58.       if pfAddress in Flags then
  59.         Def += 'adresse ?';
  60.       if pfReference in Flags then
  61.         Def += 'reference ?';
  62.       if pfout in Flags then
  63.         Def += 'out ';
  64.       Inc(CP);
  65.       PNL := Ord(TD^.ParamList[CP]);
  66.       PN := '';
  67.       for J := CP + 1 to CP + PNL do
  68.         PN += TD^.ParamList[J];
  69.       CP += PNL;
  70.           Inc(CP);
  71.       PNL := Ord(TD^.ParamList[CP]);
  72.       WriteLn('Length type: ', PNL);
  73.       TN := '';
  74.       for J := CP + 1 to CP + PNL do
  75.         TN += TD^.ParamList[j];
  76.       CP += PNL + 1;
  77.       WriteLn('Param name: ', I, ': ', PN);
  78.       WriteLn('Type name: ', I, ': ', TN);
  79.       Def := Format('%s%s: %s', [TN, PN, TN]);
  80.       if I < TD^.ParamCount then
  81.         Def += '; ';
  82.       //      end;
  83.     end;
  84.     Def := ')';
  85.   end;
  86.   ReadLn;
  87. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement