mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 11:08:02 +02:00

pgenutil.pas: * parse_generic_parameters & insert_generic_parameter_types: create the type parameter symbols as strict private instead of public (which is the default visiblity) * adjusted two tests which relied on this behavior (that's why I fixed the type aliases previously) + added test git-svn-id: trunk@29486 -
72 lines
1.1 KiB
ObjectPascal
72 lines
1.1 KiB
ObjectPascal
{$mode objfpc}{$h+}
|
|
uses classes, sysutils;
|
|
type
|
|
generic TNode<T> = class
|
|
public
|
|
type
|
|
TAlias = T;
|
|
PT = ^T;
|
|
private
|
|
var
|
|
Data: T;
|
|
public
|
|
constructor Create;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
generic TContainer<T> = class
|
|
public
|
|
type
|
|
TTNode = specialize TNode<T>;
|
|
private
|
|
var
|
|
Data: TTNode;
|
|
public
|
|
constructor Create;
|
|
destructor Destroy; override;
|
|
|
|
function GetAddr: TTNode.PT;
|
|
procedure SetV(v: TTNode.TAlias);
|
|
end;
|
|
|
|
constructor TNode.Create;
|
|
begin
|
|
end;
|
|
|
|
destructor TNode.Destroy;
|
|
begin
|
|
inherited Destroy;
|
|
end;
|
|
|
|
constructor TContainer.Create;
|
|
begin
|
|
Data:=TTNode.Create;
|
|
end;
|
|
|
|
destructor TContainer.Destroy;
|
|
begin
|
|
Data.Free;
|
|
inherited Destroy;
|
|
end;
|
|
|
|
function TContainer.GetAddr: TTNode.PT;
|
|
begin
|
|
result := @Data.Data;
|
|
end;
|
|
|
|
|
|
procedure TContainer.SetV(v: TTNode.TAlias);
|
|
begin
|
|
Data.Data:=v;
|
|
end;
|
|
|
|
type
|
|
TStringContainer=specialize TContainer<String>;
|
|
var
|
|
c : TStringContainer;
|
|
begin
|
|
c:=TStringContainer.Create;
|
|
c.SetV('abc');
|
|
Writeln(HexStr(c.GetAddr));
|
|
end.
|