Re: [fpc-pascal] FPDoc - how to document overloaded functions?

2017-07-12 Thread Graeme Geldenhuys

On 2017-07-12 15:06, Michael Van Canneyt wrote:

You can't. There are no provisions for this.

I usually make the differences clear in the   node.



Thanks Michael. I've been playing around with fpdoc and trying a few 
things and then reviewing the results. Attached is the output I have 
thus far for ovorloaded functions.


NOTE:
  In generates multiple "Arguments" sections, and they seem to appear
  in the same order as what they are in the "Declaration" section.
  I only documented each parameter once in the XML, and fpdoc
  duplicated it to match the Declaration section.

  It kind of works, but there is definitely place for improvement in
  the HTML output (layout of information).


ps #1:
  I haven't tried documenting function results yet, so not sure what 
FPDOC is going to do with that in this output.



ps #2:
  Also not the "Errors" section. There I simply used the  tags to 
document both possible error results. I couldn't see any other way of 
doing it.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Delete and Add for TBytes?

2017-07-12 Thread Sven Barth via fpc-pascal
Am 12.07.2017 16:08 schrieb "Bo Berglund" :
> To remove Count processed bytes from the beginning:
>
> Buffer: AnsiString;
>
> Delete(Buffer, 1, Count)
> or worse:
> Buffer := Copy(Buffer, Count+1, Length(Buffer));

FPC trunk supports Delete() and Insert() on dynamic arrays (TBytes is
merely a dynamic array) and Copy() is supported for longer already. You
merely need to adjust the indices to 0-based instead of 1-based.
Delete() and Insert() are also supported by Delphi XE8 and newer I think.

> For adding new data (c: AnsiChar) to the end:
>
> Buffer := Buffer + c;

The + operator is not yet implemented by default on FPC (neither is
Concat()), but you can easily declare that yourself.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Delete and Add for TBytes?

2017-07-12 Thread Bo Berglund
On Wed, 12 Jul 2017 16:26:31 +0200 (CEST), Michael Van Canneyt
 wrote:

>> Is it possible to overload Delete() so it can be called with TBytes as
>> argument?
>
>It is.
>

OK, then I am doing it erroneously
(Testing in Delphi XE5 at the moment, but trying to write it to be
portable since the unit that needs this is used both in Delphi and
FPC)

This is how I did it:

In a utility unit "CommonFuncs" normally put into the uses clause of
most source files I added this:

interface

// Byte buffer handling 2017-07-12 BB
procedure Delete(var Buf: TBytes; Index, Count: integer); overload;
...
implementation

procedure Delete(var Buf: TBytes, Index, Count: integer); overload;
begin
  Move(Buf[Index+Count], Buf[Index], Length(Buf)-Index - Count);
  SetLength(Buf, Length(Buf) - Count);
end;

Then I did a syntax check and it errored out on a line way up in
CommonFuncs (actually the first use of Delete in the implementation
section):

[dcc32 Error] CommonFuncs.pas(357): E2250 There is no overloaded
version of 'Delete' that can be called with these arguments 

The line looks like this:
Delete(sVal, i, 1);

where sVal is a string, i.e. it should not be affected by the new
Delete since it is not a TBytes variable.

Apparently the System.Delete procedure is missing the "overload"
attribute

So, what steps do I take in order to "overload" Delete in such a way
that strings will still use the System.Delete?


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPDoc - how to document overloaded functions?

2017-07-12 Thread Graeme Geldenhuys

On 2017-07-12 15:19, Graeme Geldenhuys wrote:

ps #1:
   I haven't tried documenting function results yet, so not sure what
FPDOC is going to do with that in this output.



I had a look at documenting function results. There seems to be a bug 
(or place for improvement) in the HTML output. Even worse, the Linear 
output writers don't output Arguments at all! :-/


Back to the HTML output. Using the 4 overloaded FileAge functions, the 
output is as follows:


  Declaration
 // lists all 4 overloaded functions here
  Arguments
 // ...
  Function result
 // ...
  Arguments
 // ...
  Arguments
 // ...
  Arguments
 // ...
  Description
 // ...


As you can see, the "Function result" section only appears once, and 
only after the first "Arguments" section. I'm thinking the best place 
would rather be to list all 4 "Arguments" sections, then followed by the 
"Function results" section.


Alternatively, I can try listing one "Argument", then one "Function 
result", repeat. I'm not sure if this is possible though, and what 
happens if one of the overloads don't actually have a result.


Your thoughts?

ps:
  I can send you a screenshot in private if that will help visualise
  things better. The FPC mailing list doesn't seem to like attachments
  at all.



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Delete and Add for TBytes?

2017-07-12 Thread Michael Van Canneyt



On Wed, 12 Jul 2017, Bo Berglund wrote:


I would like to replace a buffer handling scheme in an old application
(written in Delphi) where the buffer was originally of type string and
later when unicode appeared changed to AnsiString.

But AnsiString also causes potential headaches so I would like to get
rid of it altogether by using a TBytes container instead.
The problem is that the code utilizes heavily a few string oriented
functions like:

To remove Count processed bytes from the beginning:

Buffer: AnsiString;

Delete(Buffer, 1, Count)
or worse:
Buffer := Copy(Buffer, Count+1, Length(Buffer));

For adding new data (c: AnsiChar) to the end:

Buffer := Buffer + c;

I would like to instead use TBytes as container but then I would not
like to rewrite all of the code so I would like to be able to do
something like:

Buf: TBytes;
b: byte;

Delete(Buf, Index, Count);  //Removes Count bytes at Index 


BufAdd(Buf, b); //Extends size of Buf and puts b last

Is it possible to overload Delete() so it can be called with TBytes as
argument?


It is.



For adding data the + operator would have been fine but I have no idea
how one could do that...


Just define an operator.  Plenty of examples.

uses sysutils;

operator + (a : TBytes; B : Char) c : TBytes;

begin
  SetLength(C,Length(A)+1);
  Move(A[0],C[0],Length(A));
  C[Length(A)]:=Ord(B);
end;

Procedure Dump(a : TBytes);

Var
  B : byte;

begin
  For B in A do
Write(char(B));
  Writeln;
end;

Var
  A : TBytes;

begin
  A:=A+'c';
  Dump(A);
end.

outputs 'c' for me.



Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Delete and Add for TBytes?

2017-07-12 Thread Bo Berglund
I would like to replace a buffer handling scheme in an old application
(written in Delphi) where the buffer was originally of type string and
later when unicode appeared changed to AnsiString.

But AnsiString also causes potential headaches so I would like to get
rid of it altogether by using a TBytes container instead.
The problem is that the code utilizes heavily a few string oriented
functions like:

To remove Count processed bytes from the beginning:

Buffer: AnsiString;

Delete(Buffer, 1, Count)
or worse:
Buffer := Copy(Buffer, Count+1, Length(Buffer));

For adding new data (c: AnsiChar) to the end:

Buffer := Buffer + c;

I would like to instead use TBytes as container but then I would not
like to rewrite all of the code so I would like to be able to do
something like:

Buf: TBytes;
b: byte;

Delete(Buf, Index, Count);  //Removes Count bytes at Index 

BufAdd(Buf, b); //Extends size of Buf and puts b last

Is it possible to overload Delete() so it can be called with TBytes as
argument?
For adding data the + operator would have been fine but I have no idea
how one could do that...


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPDoc - how to document overloaded functions?

2017-07-12 Thread Michael Van Canneyt



On Wed, 12 Jul 2017, Graeme Geldenhuys wrote:


Hi,

How do you document overloaded functions? In this case I have overloaded 
functions that have different parameters (obviously), but also different 
result types.


You can't. There are no provisions for this.

I usually make the differences clear in the   node.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPDoc - how to document a function result?

2017-07-12 Thread Michael Van Canneyt



On Wed, 12 Jul 2017, Graeme Geldenhuys wrote:

As the subject line says. Do I simply create a ELEMENT take with the 
function name and ".Result"?  For example:




This is the function result documentation.



Or is there some other syntax?


This is the correct syntax.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] FPDoc - how to document overloaded functions?

2017-07-12 Thread Graeme Geldenhuys

Hi,

How do you document overloaded functions? In this case I have overloaded 
functions that have different parameters (obviously), but also different 
result types.



I've been looking through the FPDoc PDF manual, but there is no explicit 
information on this subject. But then, I could be overlooking something 
(it happens).


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] FPDoc - how to document a function result?

2017-07-12 Thread Graeme Geldenhuys
As the subject line says. Do I simply create a ELEMENT take with the 
function name and ".Result"?  For example:




This is the function result documentation.



Or is there some other syntax?


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal