[fpc-pascal] Common class type

2015-03-20 Thread Torsten Bonde Christiansen

Hi.

Is there method in fpc to find the highest common class-type of two 
derived classes?


Regards,
Torsten Bonde Christiansen.


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

Re: [fpc-pascal] Thoughts on Shell Approach to TCP Sockets

2015-03-20 Thread Michael Schnell

On 03/20/2015 12:18 AM, Coyo Stormcaller wrote:



With a Userspace TCP/IP stack, I can send strange traffic with a raw 
UDP port.


In fact colleagues of mine once in Delphi implemented a TCP - like 
solution that uses UDP transfer to do secure, especially low overhead 
transfers via GPRS.


So I understand that such User-space IP stack extensions might make 
sense in certain cases.


But a User-Space TCP/IP-Stack implementation that sits on naked 
Ethernet does not seem to make any practical sense.


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


Re: [fpc-pascal] Mode Delphi and functions as parameters.

2015-03-20 Thread Michael Schnell

On 03/18/2015 03:49 PM, vfclists . wrote:



Is passing a function as parameter without the '@' symbol accepted in 
Delphi?



Yep.

And to me it looks nicer than using @, even though it is obviously 
sloppy syntax and introduces an ambiguity (what to to if a function has 
no parameter and returns a value that is a pointer to a function of 
exactly this type ?) ;-) .


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


Re: [fpc-pascal] Thoughts on Shell Approach to TCP Sockets

2015-03-20 Thread Mark Morgan Lloyd

Michael Schnell wrote:

On 03/20/2015 12:18 AM, Coyo Stormcaller wrote:



With a Userspace TCP/IP stack, I can send strange traffic with a raw 
UDP port.


In fact colleagues of mine once in Delphi implemented a TCP - like 
solution that uses UDP transfer to do secure, especially low overhead 
transfers via GPRS.


So I understand that such User-space IP stack extensions might make 
sense in certain cases.


But a User-Space TCP/IP-Stack implementation that sits on naked 
Ethernet does not seem to make any practical sense.


It does if the objective is to experiment with variant protocols. Also 
remember that things like nmap already reimplement some parts of IP, so 
there's strong precedent.


I don't know what language implementation would be best for the job. The 
problem is that it's convenient to be able to overlay e.g. an IP packet 
with a predefined type e.g. a record describing the header followed by 
an array encompassing the data, however the actual length of the data is 
unknown at compilation time which means that hardware-supported bounds 
checking is less than useful.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Common class type

2015-03-20 Thread Howard Page-Clark

On 20/03/2015 07:25, Torsten Bonde Christiansen wrote:

Hi.

Is there method in fpc to find the highest common class-type of two
derived classes?


I do not know of such a routine, though there may well be one somewhere.

I would have said that the highest common class would always be TObject, 
because a descendent class is usually spoken of as 'lower' rather than 
'higher' than its ancestor.


I think the following does the job (perhaps rather inefficiently).

function LowestCommonClass(class1, class2: TClass): TClass;
var
  sl: TStringList;
  cp: TClass;

  function FoundClassInList(aClass: TClass; out aCommonClass: TClass): 
boolean;

  var
i: integer;
s: string;
  begin
Result:=False;
aCommonClass:=nil;
s:=aClass.ClassName;
for i:=0 to sl.Count-1 do
  if SameText(sl[i], s) then begin
aCommonClass:=TClass(sl.Objects[i]);
Exit(True);
  end;
  end;

begin
  Result:=nil;
  sl:=TStringList.Create;
  try
sl.AddObject(class1.ClassName, TObject(class1));
cp:=class1.ClassParent;
while (cp  nil) do begin
  sl.AddObject(cp.ClassName, TObject(cp));
  cp:=cp.ClassParent;
end;

cp:=class2;
while (cp  nil) do begin
  if FoundClassInList(cp, Result) then
Exit;
  cp:=cp.ClassParent;
end;

  finally
sl.Free;
  end;
end;



---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

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


[fpc-pascal] fpHttpClient and Https support ?

2015-03-20 Thread fredvs
Hello.

First of all, congratulation for fpHttpClient.pas.
It works directly, like charms, without to install any dependencies. = wow.

I am able to do internet audio streaming with it, perfect. ;-)

Hum, while trying to access Https sites, i get errors. ;-(

In begin of fpHttpClient.pas, there is =

 Todo:
  * Https support.  

Could it be part of the problem ?
Are there plan to enable Https support ?

Thanks.

Fre;D




-
Many thanks ;-)
--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/fpHttpClient-and-Https-support-tp5721435.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpHttpClient and Https support ?

2015-03-20 Thread silvioprog
On Fri, Mar 20, 2015 at 11:54 PM, fredvs fi...@hotmail.com wrote:

 Hello.

 First of all, congratulation for fpHttpClient.pas.
 It works directly, like charms, without to install any dependencies. =
 wow.

 I am able to do internet audio streaming with it, perfect. ;-)

 Hum, while trying to access Https sites, i get errors. ;-(

 In begin of fpHttpClient.pas, there is =

  Todo:
   * Https support.

 Could it be part of the problem ?
 Are there plan to enable Https support ?

 Thanks.

 Fre;D

 -
 Many thanks ;-)


It is already implemented in trunk. So you just:

program project1;

{$mode objfpc}{$H+}

uses
  fphttpclient;

begin
  WriteLn(TFPHTTPClient.SimpleGet('https://www.google.com/humans.txt'));
end.

-- 
Silvio Clécio
My public projects - github.com/silvioprog
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Where is the 'write' function defined and how is it different from 'writeln'?

2015-03-20 Thread Sven Barth

On 20.03.2015 21:18, vfclists . wrote:



On 20 March 2015 at 19:34, Sven Barth pascaldra...@googlemail.com
mailto:pascaldra...@googlemail.com wrote:

Am 20.03.2015 19:19 schrieb vfclists . vfcli...@gmail.com
mailto:vfcli...@gmail.com:


 
 
 
  On 20 March 2015 at 18:01, leledumbo leledumbo_c...@yahoo.co.id
mailto:leledumbo_c...@yahoo.co.id wrote:
 
   Where is the 'write'  function defined and how is it different
from
  'writeln'?
  
   I can see a lot of fpc_writeXXX and other Write functions,
but no
   'write' itself
 
  those fpc_writeXXX ARE the actual write. Write(Ln) is NOT a
function as like
  others whose implementation you can clearly see. It's rather a
command for
  the compiler to translate to the correct fpc_writeXXX call. So,
if you:
 
  WriteLn(123,' is an integer');
 
  the compiler will translate it to:
 
  fpc_write_text_shortint(123);
  fpc_write_text_shortstring('is an integer');
  fpc_writeln_end;
 
  The same case applies to Read(Ln). AFAIK Pascal's I/O is part of the
  language, not the RTL.
 
 
 
  Where does the output go? Is it for stdout, strderr  or the console?

It depends.

Write('foobar');

Will write to whatever Textfile is contained in Output and

Write(xyz, 'foobar');

Will write to the xyz Textfile. And these Textfiles can basically be
anything. By default Output simply writes to StdOut (there's also a
variable for StdErr, but I have forgotten how it's called...), but
you could also use an implementation that writes to a TStream or one
which uses sockets. It's quite flexible...

Regards,
Sven


How do you ensure own implementation overrides the system's
implementation, does the compiler take care of that automatically, or
will you have to name your function differently?


There is no need to ensure that. Here is an example:

=== code begin ===

var
  f, oldout: TextFile;
begin
  Writeln('Hello Output as StdOut');

  oldout := Output;

  Assign(Output, 'test.txt');
  Rewrite(Output);

  Writeln('Hello Output as file');

  Close(f);

  Output := oldout;

  Writeln('Hello Output as StdOut again');
end.

=== code end ===

To see how such a TextFile is implemented you can take a look at unit 
StreamIO which is part of FPC's units.


(Though I wonder why Assign(f, 'test.txt'); Output := f; Writeln('Hello 
Output as file'); does not work :/ )


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


Re: [fpc-pascal] Where is the 'write' function defined and how is it different from 'writeln'?

2015-03-20 Thread vfclists .
On 20 March 2015 at 18:01, leledumbo leledumbo_c...@yahoo.co.id wrote:

  Where is the 'write'  function defined and how is it different from
 'writeln'?
 
  I can see a lot of fpc_writeXXX and other Write functions, but no
  'write' itself

 those fpc_writeXXX ARE the actual write. Write(Ln) is NOT a function as
 like
 others whose implementation you can clearly see. It's rather a command for
 the compiler to translate to the correct fpc_writeXXX call. So, if you:

 WriteLn(123,' is an integer');

 the compiler will translate it to:

 fpc_write_text_shortint(123);
 fpc_write_text_shortstring('is an integer');
 fpc_writeln_end;

 The same case applies to Read(Ln). AFAIK Pascal's I/O is part of the
 language, not the RTL.



Where does the output go? Is it for stdout, strderr  or the console?

-- 
Frank Church

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

[fpc-pascal] Where is the 'write' function defined and how is it different from 'writeln'?

2015-03-20 Thread vfclists .
Where is the 'write'  function defined and how is it different from
'writeln'?

I can see a lot of fpc_writeXXX and other Write functions, but no
'write' itself

-- 
Frank Church

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

Re: [fpc-pascal] Where is the 'write' function defined and how is it different from 'writeln'?

2015-03-20 Thread leledumbo
 Where is the 'write'  function defined and how is it different from
'writeln'?

 I can see a lot of fpc_writeXXX and other Write functions, but no
 'write' itself

those fpc_writeXXX ARE the actual write. Write(Ln) is NOT a function as like
others whose implementation you can clearly see. It's rather a command for
the compiler to translate to the correct fpc_writeXXX call. So, if you:

WriteLn(123,' is an integer');

the compiler will translate it to:

fpc_write_text_shortint(123);
fpc_write_text_shortstring('is an integer');
fpc_writeln_end;

The same case applies to Read(Ln). AFAIK Pascal's I/O is part of the
language, not the RTL.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Where-is-the-write-function-defined-and-how-is-it-different-from-writeln-tp5721427p5721428.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is the 'write' function defined and how is it different from 'writeln'?

2015-03-20 Thread Sven Barth
Am 20.03.2015 19:19 schrieb vfclists . vfcli...@gmail.com:



 On 20 March 2015 at 18:01, leledumbo leledumbo_c...@yahoo.co.id wrote:

  Where is the 'write'  function defined and how is it different from
 'writeln'?
 
  I can see a lot of fpc_writeXXX and other Write functions, but no
  'write' itself

 those fpc_writeXXX ARE the actual write. Write(Ln) is NOT a function as
like
 others whose implementation you can clearly see. It's rather a command
for
 the compiler to translate to the correct fpc_writeXXX call. So, if you:

 WriteLn(123,' is an integer');

 the compiler will translate it to:

 fpc_write_text_shortint(123);
 fpc_write_text_shortstring('is an integer');
 fpc_writeln_end;

 The same case applies to Read(Ln). AFAIK Pascal's I/O is part of the
 language, not the RTL.



 Where does the output go? Is it for stdout, strderr  or the console?

It depends.

Write('foobar');

Will write to whatever Textfile is contained in Output and

Write(xyz, 'foobar');

Will write to the xyz Textfile. And these Textfiles can basically be
anything. By default Output simply writes to StdOut (there's also a
variable for StdErr, but I have forgotten how it's called...), but you
could also use an implementation that writes to a TStream or one which uses
sockets. It's quite flexible...

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

Re: [fpc-pascal] Where is the 'write' function defined and how is it different from 'writeln'?

2015-03-20 Thread vfclists .
On 20 March 2015 at 19:34, Sven Barth pascaldra...@googlemail.com wrote:

 Am 20.03.2015 19:19 schrieb vfclists . vfcli...@gmail.com:

 
 
 
  On 20 March 2015 at 18:01, leledumbo leledumbo_c...@yahoo.co.id wrote:
 
   Where is the 'write'  function defined and how is it different from
  'writeln'?
  
   I can see a lot of fpc_writeXXX and other Write functions, but no
   'write' itself
 
  those fpc_writeXXX ARE the actual write. Write(Ln) is NOT a function as
 like
  others whose implementation you can clearly see. It's rather a command
 for
  the compiler to translate to the correct fpc_writeXXX call. So, if you:
 
  WriteLn(123,' is an integer');
 
  the compiler will translate it to:
 
  fpc_write_text_shortint(123);
  fpc_write_text_shortstring('is an integer');
  fpc_writeln_end;
 
  The same case applies to Read(Ln). AFAIK Pascal's I/O is part of the
  language, not the RTL.
 
 
 
  Where does the output go? Is it for stdout, strderr  or the console?

 It depends.

 Write('foobar');

 Will write to whatever Textfile is contained in Output and

 Write(xyz, 'foobar');

 Will write to the xyz Textfile. And these Textfiles can basically be
 anything. By default Output simply writes to StdOut (there's also a
 variable for StdErr, but I have forgotten how it's called...), but you
 could also use an implementation that writes to a TStream or one which uses
 sockets. It's quite flexible...

 Regards,
 Sven

 How do you ensure own implementation overrides the system's
implementation, does the compiler take care of that automatically, or will
you have to name your function differently?

-- 
Frank Church

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

Re: [fpc-pascal] PtrInt - possible candidate to be marked as deprecated

2015-03-20 Thread Michael Schnell

On 03/18/2015 05:36 PM, Tony Whyman wrote:



TDataEvent = procedure (Data: PtrInt) of object;


To me PtrUInt seems more appropriate.

-Michael


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


[fpc-pascal] Portable coroutines

2015-03-20 Thread Mark Morgan Lloyd
Efficient implementation of coroutines requires CPU-specific code in the 
RTL and possibly the compiler. However 
http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html suggests a 
way that coroutines can be implemented in a portable fashion in C, how 
can this be done in Object Pascal?


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal