anchor.diff:    {$MODESWITCH ADVANCEDRECORDS}
   {$ENDIF}
   
  +{$I ./../../config.inc}
   interface
   
   type
  
positive.code: class procedure TDisposables.Finalize(var ADisposables: TDisposables);
  var
    FirstException: Pointer;
    i: Integer;
  begin
    FirstException := nil;
  
    for i := ADisposables.FLastIndex downto 0 do
    try
      case ADisposables.FPointers[i].DisposePolicy of
  
negative.code: constructor TDisposables.TGuard.Create(ADisposablesRec: PDisposables);
  begin
    FDispoablesRec := ADisposablesRec;
    {$IFNDEF DELPHI_SYDNEY_PLUS}
    TDisposables.Initialize(FDispoablesRec^);
    {$ENDIF}
  end;
  
  destructor TDisposables.TGuard.Destroy;
  begin
    inherited;
    try
      {$IFNDEF DELPHI_SYDNEY_PLUS}
      TDisposables.Finalize(FDispoablesRec^);
      {$ENDIF}
    except
      FreeInstance;
      raise;
    end;
  end;
  
  {$IFDEF DELPHI_SYDNEY_PLUS}
  class operator TDisposables.Initialize (out Dest: TDisposables);
  begin
    Dest.FLastIndex := -1;
    SetLength(Dest.FPointers, 16);
  end;
  
  class operator TDisposables.Finalize (var Dest: TDisposables);
  var
    FirstException: Pointer;
    i, x: Integer;
  begin
    FirstException := nil;
    for i := Dest.FLastIndex downto 0 do
    try
      case Dest.FPointers[i].DisposePolicy of
        idpNone: ;
        idpNil: Dest.FPointers[i].Ptr := nil;
        idpFree, idpFreeAndNil: if Assigned(Dest.FPointers[i].Ptr) then begin
          FreeAndNil(Dest.FPointers[i].Ptr);
          Dest.FPointers[i].Ptr := nil;
        end;
        idpRelease: begin
          raise ENotSupportedException.Create('Dispose policy idoRelease not supported');
        end;
        idpFreeMem: if Assigned(Dest.FPointers[i].Ptr) then System.FreeMem(Dest.FPointers[i].Ptr);
        else raise ENotSupportedException.Create('Dispose policy not supported');
      end;
    except
      if not Assigned(FirstException) then
        FirstException := AcquireExceptionObject;
    end;
  
    if Assigned(FirstException) then
    begin
      SetLength(Dest.FPointers, 0);
      raise TObject(FirstException);
    end;
  end;
  {$ELSE}
  class procedure TDisposables.Initialize(var ADisposables: TDisposables);
  begin
    ADisposables.FLastIndex := -1;
  