Re: [fpc-pascal] FPC 3.0.0 and constref default param

2016-04-01 Thread Krzysztof
Anyone? :)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpSelect fails with UDP sockets?

2016-04-01 Thread Mark Morgan Lloyd

Klaus Hartnegg wrote:

Hello,

Does fpSelect not work with UDP sockets?
It always returns 0, which means it did not see a packet.
Is anything wrong with this code?


I don't have time to play with that right now, but test it with a port > 
1024 before trying a lower-numbered one. What OS are you running on- the 
select() semantics vary slightly on Linux compared with e.g. Solaris, 
and I don't know where e.g. BSD stands on this.



Uses
  UnixType, BaseUnix, Sockets;

procedure abort (reason:string);
begin
  writeln (reason);
  halt;
end;

var
  sock: cint;
  adr : {TInet}SockAddr;
  rc  : cint;
  FDS : Tfdset;

begin
  sock := fpSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  if sock = -1 then
 abort ('Error from fpSocket');

  adr.sin_family  := AF_INET;
  adr.sin_addr.s_addr := INADDR_ANY;
  adr.sin_port:= htons(53);
  rc := fpBind (sock, @adr, sizeof(adr));
  if rc <> 0 then
 abort ('Error from fpBind');

  Writeln ('send udp packet in less than 5 seconds');
  Fpfd_zero(FDS);
  FpFd_set (sock,FDS);
  rc := fpSelect (1,@FDS,nil,nil,5000);
  if rc = -1 then
 abort ('Error from fpSelect');
  if rc > 0 then
Writeln ('Thank you !')
  else
Writeln ('Too late !');
end.


--
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


[fpc-pascal] fpSelect fails with UDP sockets?

2016-04-01 Thread Klaus Hartnegg

Hello,

Does fpSelect not work with UDP sockets?
It always returns 0, which means it did not see a packet.
Is anything wrong with this code?

Uses
  UnixType, BaseUnix, Sockets;

procedure abort (reason:string);
begin
  writeln (reason);
  halt;
end;

var
  sock: cint;
  adr : {TInet}SockAddr;
  rc  : cint;
  FDS : Tfdset;

begin
  sock := fpSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  if sock = -1 then
 abort ('Error from fpSocket');

  adr.sin_family  := AF_INET;
  adr.sin_addr.s_addr := INADDR_ANY;
  adr.sin_port:= htons(53);
  rc := fpBind (sock, @adr, sizeof(adr));
  if rc <> 0 then
 abort ('Error from fpBind');

  Writeln ('send udp packet in less than 5 seconds');
  Fpfd_zero(FDS);
  FpFd_set (sock,FDS);
  rc := fpSelect (1,@FDS,nil,nil,5000);
  if rc = -1 then
 abort ('Error from fpSelect');
  if rc > 0 then
Writeln ('Thank you !')
  else
Writeln ('Too late !');
end.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Framework for Objects Serialization / Deserialization

2016-04-01 Thread Dmitry Boyarintsev
On Fri, Apr 1, 2016 at 9:51 AM, Mazola Winstrol 
wrote:

> I can't change the actual hierarchical structure of my classes so i can't
> use TComponent.
>
> Delphi do have an intersting way to do with serialization: they have some
> standard classes (TTypeMashaller, TConverter). If one wants to serialize to
> a new format (e.g binary format), one can extended those base classes and
> implement such serialization. Would be interesting if we create an
> infrastructure like that.
>

That might be handy.

In order to support Xcode project file (.pbx) structures I had to create a
stand-alone (de)serializers from scratch.
It's RTTI dependent, but is not based of TComponent.
It would also not fail, if encounters unrecognized property, instead would
keep it for the later serialization ( .pbx is undocumented and could change
without notice )

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

Re: [fpc-pascal] Framework for Objects Serialization / Deserialization

2016-04-01 Thread Mazola Winstrol
2016-04-01 3:46 GMT-03:00 Michael Van Canneyt :

>
>
> On Fri, 1 Apr 2016, Mazola Winstrol wrote:
>
> Hello list,
>>
>> Is there a fpc framework for or some standard to serialize / deserialize
>> classes and other custom types?
>>
>
> At least two units offer the base for such functionality:
> jsonrtti (fcl-json) and restbase (fcl-web)
>
> And obviously any TComponent can be streamed in the Delphi-native format.
>
>
Thanks for your reply Michael.

I can't change the actual hierarchical structure of my classes so i can't
use TComponent.

I can serialize custom types (e.g records) using fcl-json?

Delphi do have an intersting way to do with serialization: they have some
standard classes (TTypeMashaller, TConverter). If one wants to serialize to
a new format (e.g binary format), one can extended those base classes and
implement such serialization. Would be interesting if we create an
infrastructure like that.

http://docwiki.embarcadero.com/RADStudio/Seattle/en/Serializing_User_Objects
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Write Applet with FPC JVM

2016-04-01 Thread Ingemar Ragnemalm


Hello, FPC list!

Is there anyone who knows how to write a JVM applet with FPC?

I have this minimal Java applet:

import java.applet.*;

import java.awt.*;

public class HelloWorldApplet extends Applet

{

   public void paint (Graphics g)

   {

  g.drawString ("Hello World", 25, 50);

   }

}


AFAIK this translates to:

{$mode objfpc}

// I try to make an Applet. How?

program HelloWorldAppletProgram;

uses

jdk15;

type

HelloWorldApplet = class(JAApplet)

public

procedure paint(g: JAGraphics);override;

end;




procedure HelloWorldApplet.paint(g: JAGraphics);

begin

g.drawString('Hello World (FPC)',25,50);

end;

begin

end.


Compiles, produces HelloWorldAppletProgram.class and HelloWorldApplet.class.

FPC compilation line:

/usr/local/bin/ppcjvm -O2 -g HelloWorldAppletProgram.pas -XP 
-FD/usr/local/bin/


Java compilation line:

/usr/bin/javac HelloWorldApplet.java

Uses this HTML file:

HelloWorldApplet



Should IMHO run with

appletviewer HelloWorldApplet.html

It compiles with both Java and FPC, but the FPC version doesn't run.

Any ideas? Any obvious mistakes of mine?


/Ingemar

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


Re: [fpc-pascal] Framework for Objects Serialization / Deserialization

2016-04-01 Thread Michael Van Canneyt



On Fri, 1 Apr 2016, Mazola Winstrol wrote:


Hello list,

Is there a fpc framework for or some standard to serialize / deserialize
classes and other custom types?


At least two units offer the base for such functionality:
jsonrtti (fcl-json) and restbase (fcl-web)

And obviously any TComponent can be streamed in the Delphi-native format.

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