mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-06 20:28:14 +02:00

ptype.pas, read_named_type: * array_dec & procvar_dec: set df_generic of the array/procvar if parse_generic was originally set + added test git-svn-id: trunk@27874 -
55 lines
1.1 KiB
ObjectPascal
55 lines
1.1 KiB
ObjectPascal
unit tw26288;
|
|
|
|
{$mode objfpc}{$h+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils;
|
|
|
|
type
|
|
{ TGenVector }
|
|
generic TGenVector<_TItem_> = class
|
|
public type
|
|
TItemToString = function (const Item: _TItem_) : String of object;
|
|
|
|
strict private
|
|
fOnItemToString: TItemToString;
|
|
|
|
procedure SetOnItemToString(AValue: TItemToString);
|
|
|
|
public
|
|
constructor Create;
|
|
|
|
function DefaultItemToString(const Item: _TItem_) : String; virtual;
|
|
|
|
property OnItemToString : TItemToString read fOnItemToString
|
|
write SetOnItemToString;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{--- TGenVector.Create ---}
|
|
constructor TGenVector.Create;
|
|
begin
|
|
SetOnItemToString(nil);
|
|
end;
|
|
|
|
{--- TGenVector.DefaultItemToString ---}
|
|
function TGenVector.DefaultItemToString(const Item: _TItem_): String;
|
|
begin
|
|
raise Exception.Create('Method not redefined');
|
|
Result := '';
|
|
end;
|
|
|
|
{--- TGenVector.SetOnItemToString ---}
|
|
procedure TGenVector.SetOnItemToString(AValue: TItemToString);
|
|
begin
|
|
if AValue = nil then
|
|
fOnItemToString := @DefaultItemToString
|
|
else
|
|
fOnItemToString := AValue;
|
|
end;
|
|
|
|
end.
|