mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-22 16:39:34 +01:00
+ pgenutil.pas:
add a procedure which adds a type symbol to a non-Delphi-mode generic class or record which has the same name as the unit global dummy symbol for that generic. I don't know why I had that idea earlier as this will simplify some of the conditions in the parser again (I haven't changed these yet, but I hope to do that at least when I start working on generic functions).
* pgenutil.pas, generate_specialization:
correctly handle "specialize TSomeGeneric<T>" as method parameter in a generic with the newly added rename symbol
* pdecobj.pas, object_dec & ptype.pas, record_dec:
call the procedure to add the rename symbol (the procedure checks whether the mode is correct)
* ppu.pas:
increase PPU version so that we don't use non-Delphi mode units with generics, but without the rename symbol
+ added tests:
the one in webtbs are for classes/objects and those in test are for records
git-svn-id: trunk@21603 -
46 lines
708 B
ObjectPascal
46 lines
708 B
ObjectPascal
{$mode delphi}
|
|
|
|
unit tgeneric76;
|
|
|
|
interface
|
|
|
|
type
|
|
|
|
{ TPointEx }
|
|
|
|
TPointEx<T> = record
|
|
X, Y: T;
|
|
function Create(const AX, AY: T): TPointEx<T>;
|
|
class procedure Swap(var A, B: TPointEx<T>); static;
|
|
class procedure OrderByY(var A, B: TPointEx<T>); static;
|
|
end;
|
|
|
|
TPoint = TPointEx<integer>;
|
|
TPointF = TPointEx<single>;
|
|
|
|
implementation
|
|
|
|
function TPointEx<T>.Create(const AX, AY: T): TPointEx<T>;
|
|
begin
|
|
result.X:=AX;
|
|
result.Y:=AY;
|
|
end;
|
|
|
|
class procedure TPointEx<T>.Swap(var A, B: TPointEx<T>);
|
|
var
|
|
tmp: TPointEx<T>;
|
|
begin
|
|
tmp:=A;
|
|
A:=B;
|
|
B:=tmp;
|
|
end;
|
|
|
|
class procedure TPointEx<T>.OrderByY(var A, B: TPointEx<T>);
|
|
begin
|
|
if A.Y > B.Y then
|
|
TPointEx<T>.Swap(A,B);
|
|
end;
|
|
|
|
|
|
end.
|