Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type helpers #113

Open
gluhow opened this issue Feb 15, 2021 · 2 comments
Open

Type helpers #113

gluhow opened this issue Feb 15, 2021 · 2 comments

Comments

@gluhow
Copy link

gluhow commented Feb 15, 2021

pas file with helpers not supports?

unit test;
{Test}

{$mode objfpc}{$H }
{$MODESWITCH typehelpers}

interface

uses
  Classes, SysUtils;

type

  TTest=(TT1, TT2, TT3);

  { tTestHelper }

  tTestHelper = type helper for TTest
    function ToString: string;
  end;

implementation

{ tTestHelper }

function tTestHelper.ToString: string;
begin
  Result:='ttest';
end;

end.

output:

PasDoc 0.16.0 [2021-02-07|FPC 3.2.0|Linux|64]
Documentation generator for Pascal source

This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Info[1]:    Starting Source File Parsing ...
Info[2]:    Now parsing file ./test.pas...
Warning[2]: Error EPasDoc: ./test.pas(20): Unexpected reserved word "end" while parsing unit test.pas, continuing...
Info[2]:    ... 1 Source File(s) parsed
Fatal Error: EPasDoc: At least one unit must have been successfully parsed to write docs

@michaliskambi michaliskambi changed the title helpers Type helpers Feb 15, 2021
@michaliskambi
Copy link
Collaborator

We support class and record helpers ( https://github.com/pasdoc/pasdoc/blob/master/tests/testcases/ok_class_record_helpers.pas ). Indeed we do not yet parse helpers for simple types with type helper .... Pull requests are welcome :)

@circular17
Copy link
Contributor

Hi @michaliskambi,

Thanks for considering this subject. This is not a priority as @DomingoGP found a workaround, applying sed:

sed -i 's/type helper/class helper/g' bgrabitmaptypes.pas # change depending on you code

The drawback though is that one need to have a mirror of the code to make the change.

This points to a simple solution though in pasdoc, to consider type helper as a synonym of class helper.

The case in BGRABitmap is in generatedcolorspace.inc, which is included in BGRABitmapTypes:

  TColorHelper = type helper for TColor
    class function New(const ARed,AGreen,ABlue:byte): TColor;static;
    class function Colorspace: TColorspaceAny; static;
  private
    function GetRed: byte;
    function GetGreen: byte;
    function GetBlue: byte;
    procedure SetRed(AValue: byte);
    procedure SetGreen(AValue: byte);
    procedure SetBlue(AValue: byte);
  public
    function ToBGRAPixel: TBGRAPixel;overload;
    function ToBGRAPixel(AAlpha: byte): TBGRAPixel;overload;
    function ToFPColor: TFPColor;overload;
    function ToFPColor(AAlpha: word): TFPColor;overload;
    function ToStdRGBA: TStdRGBA;overload;
    function ToStdRGBA(AAlpha: single): TStdRGBA;overload;
    function ToAdobeRGBA: TAdobeRGBA;overload;
    function ToAdobeRGBA(AAlpha: byte): TAdobeRGBA;overload;
    function ToStdHSLA: TStdHSLA;overload;
    function ToStdHSLA(AAlpha: single): TStdHSLA;overload;
    function ToStdHSVA: TStdHSVA;overload;
    function ToStdHSVA(AAlpha: single): TStdHSVA;overload;
    function ToStdCMYK: TStdCMYK;
    function ToByteMask: TByteMask;
    function ToExpandedPixel: TExpandedPixel;overload;
    function ToExpandedPixel(AAlpha: word): TExpandedPixel;overload;
    function ToLinearRGBA: TLinearRGBA;overload;
    function ToLinearRGBA(AAlpha: single): TLinearRGBA;overload;
    function ToHSLAPixel: THSLAPixel;overload;
    function ToHSLAPixel(AAlpha: word): THSLAPixel;overload;
    function ToGSBAPixel: TGSBAPixel;overload;
    function ToGSBAPixel(AAlpha: word): TGSBAPixel;overload;
    function ToYCbCr601: TYCbCr601;
    function ToYCbCr601JPEG: TYCbCr601JPEG;
    function ToYCbCr709: TYCbCr709;
    function ToYCbCr709JPEG: TYCbCr709JPEG;
    function ToXYZA: TXYZA;overload;
    function ToXYZA(AAlpha: single): TXYZA;overload;
    function ToXYZA(const AReferenceWhite: TXYZReferenceWhite): TXYZA;overload;
    function ToWordXYZA: TWordXYZA;overload;
    function ToWordXYZA(AAlpha: word): TWordXYZA;overload;
    function ToWordXYZA(const AReferenceWhite: TXYZReferenceWhite): TWordXYZA;overload;
    function ToLabA: TLabA;overload;
    function ToLabA(AAlpha: single): TLabA;overload;
    function ToLChA: TLChA;overload;
    function ToLChA(AAlpha: single): TLChA;overload;
    procedure FromBGRAPixel(AValue: TBGRAPixel);
    procedure FromFPColor(AValue: TFPColor);
    procedure FromStdRGBA(AValue: TStdRGBA);
    procedure FromAdobeRGBA(AValue: TAdobeRGBA);
    procedure FromStdHSLA(AValue: TStdHSLA);
    procedure FromStdHSVA(AValue: TStdHSVA);
    procedure FromStdCMYK(AValue: TStdCMYK);
    procedure FromByteMask(AValue: TByteMask);
    procedure FromExpandedPixel(AValue: TExpandedPixel);
    procedure FromLinearRGBA(AValue: TLinearRGBA);
    procedure FromHSLAPixel(AValue: THSLAPixel);
    procedure FromGSBAPixel(AValue: TGSBAPixel);
    procedure FromYCbCr601(AValue: TYCbCr601);
    procedure FromYCbCr601JPEG(AValue: TYCbCr601JPEG);
    procedure FromYCbCr709(AValue: TYCbCr709);
    procedure FromYCbCr709JPEG(AValue: TYCbCr709JPEG);
    procedure FromXYZA(AValue: TXYZA); overload;
    procedure FromXYZA(AValue: TXYZA; const AReferenceWhite: TXYZReferenceWhite); overload;
    procedure FromWordXYZA(AValue: TWordXYZA); overload;
    procedure FromWordXYZA(AValue: TWordXYZA; const AReferenceWhite: TXYZReferenceWhite); overload;
    procedure FromLabA(AValue: TLabA);
    procedure FromLChA(AValue: TLChA);
    property red: byte read GetRed write SetRed;
    property green: byte read GetGreen write SetGreen;
    property blue: byte read GetBlue write SetBlue;
  end; 

This is quite a big file, so I don't know how convenient it is for testing.

I appreciate the invitation to propose pull requests. I will consider it as we progress on the documentation, if I take a dive into your great program. I am still discovering its capabilities.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants