Einzelnen Beitrag anzeigen

freimatz

Registriert seit: 20. Mai 2010
1.385 Beiträge
 
Delphi 11 Alexandria
 
#57

AW: Interface-Unterstützung

  Alt 14. Dez 2017, 10:12
Mein Tool ist nicht unviversell brauchbar. Erstmal ist er nur für Transferobjekte da. Weiter wird formatierter Code verlangt so wie es unser Formatter macht. Dann ist das Tool ein Gebastel und mit <duck>VS/C#</duck> erstellt. Neuerdings sollte das Tool auch mit bestehenden units klar kommen.
Zum Verständnis noch ein Beispiel:
Gegeben
Delphi-Quellcode:
  IBlafaselCalculatorSourceData = interface(IBlaCalculatorSourceData)
    ['{FDFBCC49-C16F-4BC1-B6BF-7926EA37113F}']
    property ToleranceZoneGeometry: IToleranceZoneGeometryBase;
    property PreparedPoints: TPreparedPoints;
  end;
Dann wird da draus:
Delphi-Quellcode:
  IBlafaselCalculatorSourceData = interface(IBlaCalculatorSourceData)
    ['{FDFBCC49-C16F-4BC1-B6BF-7926EA37113F}']
    function GetToleranceZoneGeometry(): IToleranceZoneGeometryBase;
    function GetPreparedPoints(): TPreparedPoints;

    property ToleranceZoneGeometry: IToleranceZoneGeometryBase read GetToleranceZoneGeometry;
    property PreparedPoints: TPreparedPoints read GetPreparedPoints;
  end;
...
function CreateBlafaselCalculatorSourceData(
  ... Zeug von Vorfahre
  const p_ToleranceZoneGeometry: IToleranceZoneGeometryBase;
  const p_PreparedPoints : TPreparedPoints): IBlafaselCalculatorSourceData;
...
  TBlafaselCalculatorSourceData = class(TBlaCalculatorSourceData,
    IBlafaselCalculatorSourceData)
  strict private
    FToleranceZoneGeometry: IToleranceZoneGeometryBase;
    FPreparedPoints : TPreparedPoints;
    function GetToleranceZoneGeometry(): IToleranceZoneGeometryBase;
    function GetPreparedPoints(): TPreparedPoints;

  public
    constructor Create(
      ... Zeug von Vorfahre
      const p_ToleranceZoneGeometry: IToleranceZoneGeometryBase;
      const p_PreparedPoints : TPreparedPoints);
    property ToleranceZoneGeometry: IToleranceZoneGeometryBase read GetToleranceZoneGeometry;
    property PreparedPoints: TPreparedPoints read GetPreparedPoints;
  end;
...
constructor TBlafaselCalculatorSourceData.Create(
  ... Zeug von Vorfahre
  const p_ToleranceZoneGeometry: IToleranceZoneGeometryBase;
  const p_PreparedPoints : TPreparedPoints);
begin
  inherited Create(... Zeug von Vorfahre);
  FToleranceZoneGeometry := p_ToleranceZoneGeometry;
  FPreparedPoints := p_PreparedPoints;
end;
...
constructor TBlafaselCalculatorSourceData.Create(
  ... Zeug von Vorfahre
  const p_ToleranceZoneGeometry: IToleranceZoneGeometryBase;
  const p_PreparedPoints : TPreparedPoints);
begin
  inherited Create(... Zeug von Vorfahre);
  FToleranceZoneGeometry := p_ToleranceZoneGeometry;
  FPreparedPoints := p_PreparedPoints;
end;
...
constructor TBlafaselCalculatorSourceData.Create(
  ... Zeug von Vorfahre
  const p_ToleranceZoneGeometry: IToleranceZoneGeometryBase;
  const p_PreparedPoints : TPreparedPoints);
begin
  inherited Create(... Zeug von Vorfahre);
  FToleranceZoneGeometry := p_ToleranceZoneGeometry;
  FPreparedPoints := p_PreparedPoints;
end;

function TBlafaselCalculatorSourceData.GetToleranceZoneGeometry(): IToleranceZoneGeometryBase;
begin
  Result := FToleranceZoneGeometry;
end;

function TBlafaselCalculatorSourceData.GetPreparedPoints(): TPreparedPoints;
begin
  Result := FPreparedPoints;
end;
...
function CreateBlafaselCalculatorSourceData(
  ... Zeug von Vorfahre
  const p_ToleranceZoneGeometry: IToleranceZoneGeometryBase;
  const p_PreparedPoints : TPreparedPoints): IBlafaselCalculatorSourceData;
begin
  Result := TBlafaselCalculatorSourceData.Create(... Zeug von Vorfahre, p_ToleranceZoneGeometry, p_PreparedPoints);
end;
Der Record ist hier noch nicht dabei. Auch etliche REGIONS habe ich weggelassen.
  Mit Zitat antworten Zitat