program DemoApp;
{$mode objfpc}{$H+}

{ PDR - Demonstrates: string types, enums, sets, class inspect, interface
  inspect, array slicing, locals listing, and live variable assignment. }

uses SysUtils;

type
  TShapeKind = (skRectangle, skTriangle, skCircle);
  TWeekday   = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);

  {.//.$interfaces corba}
  IShape = interface(IUnknown)
    function Area: Double;
    function Perimeter: Double;
    function Description: AnsiString;
  end;
  {$interfaces com}

  TCircle = class
  private
    FName:   AnsiString;
    FKind:   TShapeKind;
    FRadius: Double;
    function GetArea: Double;
    function GetPerimeter: Double;
  public
    constructor Create(const AName: AnsiString; ARadius: Double);
    property Name:      AnsiString read FName;
    property Kind:      TShapeKind read FKind;
    property Radius:    Double     read FRadius;
    property Area:      Double     read GetArea;
    property Perimeter: Double     read GetPerimeter;
  end;

constructor TCircle.Create(const AName: AnsiString; ARadius: Double);
begin
  FName   := AName;
  FKind   := skCircle;
  FRadius := ARadius;
end;

function TCircle.GetArea: Double;
begin
  Result := Pi * FRadius * FRadius;
end;

function TCircle.GetPerimeter: Double;
begin
  Result := 2.0 * Pi * FRadius;
end;

procedure DebugSession(ACircle: TCircle);
var
  Info:     AnsiString;
  Progress: Integer;
begin
  Info     := 'Inspecting: ' + ACircle.Name;
  Progress := 0;
  Progress := Progress + 1;   { *** BREAKPOINT TARGET *** }
end;

var
  { String showcase: a longstanding pain point for FPC debugging }
  ShortLabel: ShortString;
  FullTitle:  AnsiString;
  UniLabel:   UnicodeString;

  { Set of named enum }
  WorkWeek: set of TWeekday;

  { Array for slice demo }
  Radii: array[1..5] of Double;

  { Class and interface }
  MyCircle: TCircle;
  MyShape:  IShape;   { nil — inspect still shows method signatures }

  { Counter for live variable-assignment demo }
  Counter: Integer;

const
  rocketUTF8 = #$F0#$9F#$9A#$80;
  tadaUTF16 = #$D83C#$DF89;

begin
  ShortLabel := 'PDR';
  FullTitle  := 'OPDF version 1 ' + rocketUTF8;
  UniLabel   := 'Unicode: Hello FPC ' + tadaUTF16;

  WorkWeek := [Mon, Tue, Wed, Thu, Fri];

  Radii[1] := 1.5;
  Radii[2] := 2.5;
  Radii[3] := 3.5;
  Radii[4] := 4.5;
  Radii[5] := 5.5;

  MyCircle := TCircle.Create('Alpha', 3.14159);
  MyShape  := nil;
  Counter  := 10;

  DebugSession(MyCircle);

  MyCircle.Free;
end.
