Hi,

What are the rules regarding the order of a unsorted list of published properties using the GetPropList method, when inheritance has been used.
I had unit tests from a Delphi app that detected this difference.

Below is the results from Delphi and FPC. The first set has been compiled with Delphi 7 and the second set of results from a exectable compiled with FPC 2.0.1

As you can see, Delphi lists the properties from the root object out, and FPC lists them from the outer object in. Which one is doing it correctly, or is there no set rule?


[Delphi 7]
C:\Programming\Tests\GetPropList\D7_2>Project1.exe
Total property Count: 4
Property 1: Caption
Property 2: IntProp
Property 3: StrProp
Property 4: AnotherStrProp
---------------

[FPC 2.0.1]
C:\Programming\Tests\GetPropList\D7_2>Project1.exe
Total property Count: 4
Property 1: AnotherStrProp
Property 2: IntProp
Property 3: StrProp
Property 4: Caption
---------------


Here is the full source of the application
-------------------------------------------------
program project1;

{$IFDEF FPC}
  {$mode objfpc}{$H+}
{$ELSE}
  {$APPTYPE CONSOLE}
{$ENDIF}

uses
  SysUtils,
  TypInfo,
  Classes;

type
  TAObject = class(TPersistent)
  private
    FCaption: string;
  published
    property Caption: string read FCaption write FCaption;
  end;

  TBObject = class(TAObject)
  private
    FIntProp: Integer;
    FStrProp: String;
  published
    property IntProp: Integer read FIntProp write FIntProp;
    property StrProp: String read FStrProp write FStrProp;
  end;


  TCObject = class(TBObject)
  private
     FAStrProp: String;
  published
    property AnotherStrProp: String read FAStrProp write FAStrProp;
  end;

procedure ShowProperties;
var
  Obj: TCObject;
  i: Longint;
  lPropFilter: TTypeKinds;
  lCount: Longint;
  lSize: Integer;
  lList: PPropList;
begin
  Obj := TCObject.Create;
  lPropFilter := [tkInteger, tkLString {$ifdef FPC}, tkAString{$endif}];

  lCount  := GetPropList(Obj.ClassInfo, lPropFilter, nil, false);
  lSize   := lCount * SizeOf(Pointer);
  GetMem(lList, lSize);

  Writeln('Total property Count: ' + IntToStr(lCount));
  lCount := GetPropList(Obj.ClassInfo, lPropFilter, lList, false);
  for i := 0 to lCount-1 do
  begin
    Writeln('Property '+IntToStr(i+1)+': ' + lList^[i]^.Name);
  end;

  FreeMem(lList);
  Obj.Free;
  Writeln('---------------');
end;


begin
  ShowProperties;
end.

-------------------------------------------------

I'm running FPC 2.0.1 that came with Lazarus 0.9.10 on Windows 2000.

Regards,
  - Graeme -


_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to