Hi,

Do you know why this doesn't work?

type
  TGPIO = class
  public
    class function ReadValue: NativeUInt; virtual; abstract;
    class procedure SetValue(AValue: NativeUInt); virtual; abstract;

    class function GetPin(const AIndex: NativeInt): boolean; virtual;
  end;

  generic TStm32GPIO<const Base: integer> = class(TGPIO)
  public
    class function ReadValue: NativeUInt; override;
    class procedure SetValue(AValue: NativeUInt); override;
  end;

class function TGPIO.GetPin(const AIndex: NativeInt): boolean;
begin
  result:=Odd(ReadValue shr AIndex);
end;

class function TStm32GPIO.ReadValue: NativeUInt;
begin
  result:=PNativeUInt(Base)^;
end;

class procedure TStm32GPIO.SetValue(AValue: NativeUInt);
begin
  PNativeUInt(Base)^:=AValue;
end;

type GPIOA = specialize TStm32GPIO<$12400000>;

Best Regards,
Jeppe

On 2/15/19 5:22 PM, Ryan Joseph wrote:
Here’s the latest changes which fixed the constant type checking and includes 
some tests. Are the tests in the correct format? They are named tgenconst*.pp.

https://github.com/genericptr/freepascal/tree/generic_constants

For example:

{%FAIL}
{$mode objfpc}
program tgenconst8;
type
        generic TByte<const U: Byte> = record end;        
var
        a: specialize TByte<300>;
begin
end.


This will now give an error because 300 is a SmallInt. That’s everything I can 
think of for now. Please let me know if this is ready to submit yet.

Regards,
        Ryan Joseph

_______________________________________________
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

Reply via email to