[fpc-pascal] Generic (TFPGObjectList) EInvalidCast

2018-12-11 Thread Vojtěch Čihák
Hi,
 
why this code gives EInvalidCast at runtime (but compiles well):w
 
program Project1;
{$mode objfpc}{$H+}
 
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, fgl
  { you can add units after this };
 
{$R *.res}
type
  TMyClass = class
    procedure Output1;
  end;
 
  TMyList = class (specialize TFPGObjectList)
 
  end;
 
  TMyDescClass = class(TMyClass)
    procedure Output2;
  end;
 
var MyList: TMyList;
    MyClass: TMyClass;
 
procedure TMyClass.Output1;
begin
  WriteLn('Output1');
end;
 
procedure TMyDescClass.Output2;
begin
  WriteLn('Output2');
end;
 
begin
  MyList:=TMyList.Create(True);
  MyClass:=TMyClass.Create;
  MyList.Add(MyClass);
  MyList[0].Output1;
  TMyDescClass(MyList[0]);  // EInvalidCast
  MyList.Free;
end.
 
Thanks for help,
 
V.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast

2018-12-11 Thread Vojtěch Čihák

I forgot: FreePascal 3.3.1 r.40507
 
V.
__

Od: "Vojtěch Čihák" 
Komu: "FPC-Pascal users discussions" 
Datum: 11.12.2018 22:19
Předmět: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast


Hi,
 
why this code gives EInvalidCast at runtime (but compiles well):w
 
program Project1;
{$mode objfpc}{$H+}
 
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, fgl
  { you can add units after this };
 
{$R *.res}
type
  TMyClass = class
    procedure Output1;
  end;
 
  TMyList = class (specialize TFPGObjectList)
 
  end;
 
  TMyDescClass = class(TMyClass)
    procedure Output2;
  end;
 
var MyList: TMyList;
    MyClass: TMyClass;
 
procedure TMyClass.Output1;
begin
  WriteLn('Output1');
end;
 
procedure TMyDescClass.Output2;
begin
  WriteLn('Output2');
end;
 
begin
  MyList:=TMyList.Create(True);
  MyClass:=TMyClass.Create;
  MyList.Add(MyClass);
  MyList[0].Output1;
  TMyDescClass(MyList[0]);  // EInvalidCast
  MyList.Free;
end.
 
Thanks for help,
 
V.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 

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

Re: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast

2018-12-11 Thread Vojtěch Čihák

Sorry for noise, this was wrong code and even more it has nothing to do with 
generics.
I can solve it with class helper.
 
V.
 
__

Od: "Vojtěch Čihák" 
Komu: "FPC-Pascal users discussions" 
Datum: 11.12.2018 22:19
Předmět: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast


Hi,
 
why this code gives EInvalidCast at runtime (but compiles well):w
 
program Project1;
{$mode objfpc}{$H+}
 
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, fgl
  { you can add units after this };
 
{$R *.res}
type
  TMyClass = class
    procedure Output1;
  end;
 
  TMyList = class (specialize TFPGObjectList)
 
  end;
 
  TMyDescClass = class(TMyClass)
    procedure Output2;
  end;
 
var MyList: TMyList;
    MyClass: TMyClass;
 
procedure TMyClass.Output1;
begin
  WriteLn('Output1');
end;
 
procedure TMyDescClass.Output2;
begin
  WriteLn('Output2');
end;
 
begin
  MyList:=TMyList.Create(True);
  MyClass:=TMyClass.Create;
  MyList.Add(MyClass);
  MyList[0].Output1;
  TMyDescClass(MyList[0]);  // EInvalidCast
  MyList.Free;
end.
 
Thanks for help,
 
V.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 

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

Re: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast

2018-12-11 Thread Mattias Gaertner via fpc-pascal
On Tue, 11 Dec 2018 22:19:11 +0100
Vojtěch Čihák  wrote:

> Hi,
>  
> why this code gives EInvalidCast at runtime (but compiles well):w
>  
> program Project1;
> {$mode objfpc}{$H+}
>  
> uses
>   {$IFDEF UNIX}{$IFDEF UseCThreads}
>   cthreads,
>   {$ENDIF}{$ENDIF}
>   Classes, fgl
>   { you can add units after this };
>  
> {$R *.res}
> type
>   TMyClass = class
>     procedure Output1;
>   end;
>  
>   TMyList = class (specialize TFPGObjectList)
>  
>   end;
>  
>   TMyDescClass = class(TMyClass)
>     procedure Output2;
>   end;
>  
> var MyList: TMyList;
>     MyClass: TMyClass;
>  
> procedure TMyClass.Output1;
> begin
>   WriteLn('Output1');
> end;
>  
> procedure TMyDescClass.Output2;
> begin
>   WriteLn('Output2');
> end;
>  
> begin
>   MyList:=TMyList.Create(True);
>   MyClass:=TMyClass.Create;
>   MyList.Add(MyClass);
>   MyList[0].Output1;
>   TMyDescClass(MyList[0]);  // EInvalidCast

because MyClass is not TMyDescClass

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

Re: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast

2018-12-11 Thread Vojtěch Čihák

Yes, I see now, it was my mistake.
 
Thanks.
__

Od: "Mattias Gaertner via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 11.12.2018 22:35
Předmět: Re: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast


On Tue, 11 Dec 2018 22:19:11 +0100
Vojtěch Čihák  wrote:

because MyClass is not TMyDescClass

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

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

Re: [fpc-pascal] FPC-based http/s server

2018-12-11 Thread silvioprog
Hello dude,

On Mon, Dec 10, 2018 at 8:09 AM Michael Van Canneyt 
wrote:
[...]

> It does not support https yet, but this is planned for the near future.
> (I expect to work on it between this Christmas and new year)


Please consider support for TLS 1.3  (all
new web servers should use it).

GnuTLS  is a very good library (I've used it about
two years at company). Its API is clean, small, massively documented
, and its ABI is very stable
(about 99.83~100% between 2015-2018).

Cheers

p.s.: I made a X.509 based authentication using OpenSSL. Its API is a
little bit ugly and confuse, so I spent about three weeks working on that.
After, I did the same work using GnuTLS, so I spent just five days because
its API is better and contais this good manual
.

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