Re: [fpc-pascal] Is there a way to create a generic pointer to a generic record

2016-11-20 Thread Le Duc Hieu
Is there any entry on Mantis for me to keep track of this bug status?

Thanks.

On Sun, Nov 20, 2016 at 6:03 PM, Sven Barth 
wrote:

> Am 20.11.2016 08:31 schrieb "Le Duc Hieu" :
> >
> > Here is the complete snippet that i wanted to create
> >
> >
> > Type
> >   generic PGList = ^specialize TGList;
> >
> >   generic TGList = record
> > data: T;
> > next: specialize PGList
> >   end;
>
> You'll need to use nested types (they require modeswitch advancedrecords),
> like this:
>
> === code begin ===
>
> type
>   generic TGList = record
>   public type
> TSelf = specialize TGList;
> PGList = ^TSelf;
>   public
> data: T;
> next: PGList;
>   end;
>
> === code end ===
>
> Note: the TSelf construct is currently needed due to a bug in the compiler.
>
> Regards,
> Sven
>
> ___
> 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] Error: Internal error 2014052302

2016-11-20 Thread Sven Barth
Am 20.11.2016 18:21 schrieb "Pierre Free Pascal" :
>
> Hi,
>
>
> > -Message d'origine-
> > De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-
> > boun...@lists.freepascal.org] De la part de Tony Whyman
> > Envoyé : dimanche 20 novembre 2016 15:13
> > À : FPC-Pascal users discussions
> > Objet : [fpc-pascal] Error: Internal error 2014052302
> >
> > Any ideas as to what this means?
>
>   As a general rule, internal errors are consistency checks that
> are made inside the compile.
>   You will need to look into the compiler sources
> themselves to get more precise information.
>
>   Here searching using grep gives:
> in directory fpcbuild-3.0.0/fpcsrc/compiler
> $ grep -n 2014052302 *pas *inc */*pas */*inc
> symdef.pas:1959:  internalerror(2014052302);
>
> symdef.pas-1946-procedure tstoreddef.deref;
> symdef.pas-1947-  var
> symdef.pas-1948-symderef : pderef;
> symdef.pas-1949-i : longint;
> symdef.pas-1950-  begin
> symdef.pas-1951-typesym:=ttypesym(typesymderef.resolve);
> symdef.pas-1952-if df_specialization in defoptions then
> symdef.pas-1953-  genericdef:=tstoreddef(genericdefderef.resolve);
> symdef.pas-1954-if assigned(genconstraintdata) then
> symdef.pas-1955-  genconstraintdata.deref;
> symdef.pas-1956-if assigned(genericparas) then
> symdef.pas-1957-  begin
> symdef.pas-1958-if not assigned(genericparaderefs) then
> symdef.pas:1959:  internalerror(2014052302);
>
> So the problem here is apparently that genericparas
> is assigned but genericparaderefs is not!
>
>   From this, I can assume that your code is using generics feature,
> which is a part of the compiler that I really don't know...
>
> > Seen on FPC 3.0.0 under AMD64 Linux Mint 17
> >
> > The odd thing about this one is that :
> >
> > a) Always on the same blank line just after a constructor
>   This constructor is a specialization of a generic class definition, no?
> > b) Goes away when you recompile clean
>   This might suggest a subtle problem with PPU
> loading versus full recompilation.

That had already been fixed in trunk and I think I also had the fix be
merged to 3.0.1, so it would be in the 3.0.2 release as well.

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

Re: [fpc-pascal] Error: Internal error 2014052302

2016-11-20 Thread Pierre Free Pascal
Hi,


> -Message d'origine-
> De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-
> boun...@lists.freepascal.org] De la part de Tony Whyman
> Envoyé : dimanche 20 novembre 2016 15:13
> À : FPC-Pascal users discussions
> Objet : [fpc-pascal] Error: Internal error 2014052302
> 
> Any ideas as to what this means?

  As a general rule, internal errors are consistency checks that
are made inside the compile.
  You will need to look into the compiler sources
themselves to get more precise information.

  Here searching using grep gives:
in directory fpcbuild-3.0.0/fpcsrc/compiler
$ grep -n 2014052302 *pas *inc */*pas */*inc
symdef.pas:1959:  internalerror(2014052302);
 
symdef.pas-1946-procedure tstoreddef.deref;
symdef.pas-1947-  var
symdef.pas-1948-symderef : pderef;
symdef.pas-1949-i : longint;
symdef.pas-1950-  begin
symdef.pas-1951-typesym:=ttypesym(typesymderef.resolve);
symdef.pas-1952-if df_specialization in defoptions then
symdef.pas-1953-  genericdef:=tstoreddef(genericdefderef.resolve);
symdef.pas-1954-if assigned(genconstraintdata) then
symdef.pas-1955-  genconstraintdata.deref;
symdef.pas-1956-if assigned(genericparas) then
symdef.pas-1957-  begin
symdef.pas-1958-if not assigned(genericparaderefs) then
symdef.pas:1959:  internalerror(2014052302);

So the problem here is apparently that genericparas
is assigned but genericparaderefs is not!

  From this, I can assume that your code is using generics feature,
which is a part of the compiler that I really don't know...

> Seen on FPC 3.0.0 under AMD64 Linux Mint 17
> 
> The odd thing about this one is that :
> 
> a) Always on the same blank line just after a constructor
  This constructor is a specialization of a generic class definition, no? 
> b) Goes away when you recompile clean
  This might suggest a subtle problem with PPU
loading versus full recompilation.
  


  Without a full ensemble of source files that 
is able to reproduce the described behavior fully,
it will be difficult to help you out.

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


[fpc-pascal] Error: Internal error 2014052302

2016-11-20 Thread Tony Whyman

Any ideas as to what this means?

Seen on FPC 3.0.0 under AMD64 Linux Mint 17

The odd thing about this one is that :

a) Always on the same blank line just after a constructor

b) Goes away when you recompile clean

c) Seems to be fixed by just moving the constructor to the end of the unit.

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


Re: [fpc-pascal] HIDAPI Bindings for FPC (on Linux)

2016-11-20 Thread Bernd
I found and fixed a few minor problems while writing the demo and
added a simple demo program that will enumerate and print all devices
and then tries to open a certain device by vid/pid, I have just hard
coded the vid/pid of a popular cheap Logitech joystick because that
was the only HID device that would make sense trying to demonstrate it
with, my other HID device is just a self built USB device implemented
on a Freescale evaluation board and I don't just want to open the
first device on the list and maybe pull the keyboard driver away from
under their hands.

The user using this will most likely be interested in testing this
with his own hardware and use different vid/pid anyways.

The demo program will produce output like this:

--($)-- sudo ./demo
[sudo] Passwort für bernd:
will now enumerate all USB HID devices.
Note that it will list more info if you run with sudo,
you might want to add an udev rule for your device.

Found: Logitech Extreme 3D (046D:C215) at: 0006:0003:00
Found: Demo Device (DEAD:BEEF) at: 0005:0002:00
Found: USB Keyboard (1A2C:0C21) at: 0003:0002:00
Found: USB Keyboard (1A2C:0C21) at: 0003:0002:01

Will now try to open device 046D:C215

device is open, now going to read data from it
Manufacturer: Logitech
Product: Logitech Extreme 3D
08 A2 87 80 00 88 00
closing device

2016-11-19 23:46 GMT+01:00 Michael Van Canneyt :
>
>
> On Sat, 19 Nov 2016, Bernd wrote:
>
>> Hello list,
>>
>> I have made a binding for libhidapi because i needed one and I could
>> not find any.
>>
>> https://github.com/prof7bit/HIDAPI.pas
>> (LGPL + static linking)
>>
>> It is not just an automated header translation, instead I have made it
>> using the good old Pascal objects (and pointers to them) to cast the
>> device handles into, attached Methods with Pascal-ish names to the
>> objects which not only wrap the original c functions but also do some
>> conversion of ugly wchar_t* stuff on the fly if needed and make it
>> much more fun to use this C API.
>>
>> I hope someone might find it useful, its license compatible with other
>> FPC units.
>
>
> Nice work.
>
> I will add it to the FPC packages if that is OK with you. Would it be
> possible to provide a sample program which e.g. lists the available devices
> ?
>
> Michael.
> ___
> 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] Is there a way to create a generic pointer to a generic record

2016-11-20 Thread Sven Barth
Am 20.11.2016 08:31 schrieb "Le Duc Hieu" :
>
> Here is the complete snippet that i wanted to create
>
>
> Type
>   generic PGList = ^specialize TGList;
>
>   generic TGList = record
> data: T;
> next: specialize PGList
>   end;

You'll need to use nested types (they require modeswitch advancedrecords),
like this:

=== code begin ===

type
  generic TGList = record
  public type
TSelf = specialize TGList;
PGList = ^TSelf;
  public
data: T;
next: PGList;
  end;

=== code end ===

Note: the TSelf construct is currently needed due to a bug in the compiler.

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