For simple types, the rules are pretty much the same as for records, plus there are some extra requirements:
{$modeswitch typehelpers}
This modeswitch is enabled by default only in mode Delphi and DelphiUnicode.
TTestHelper = type helper for TObject
end;
This of course means that all other simple types are supported.
The following gives an idea of the possibilities:
{$mode objfpc}
{$modeswitch typehelpers}
type
TLongIntHelper = type helper for LongInt
constructor create(AValue: LongInt);
class procedure Test; static;
procedure DoPrint;
end;
constructor TLongIntHelper.create(AValue: LongInt);
begin
Self:=Avalue;
DoPrint;
end;
class procedure TLongIntHelper.Test;
begin
Writeln('Test');
end;
procedure TLongIntHelper.DoPrint;
begin
Writeln('Value :',Self);
end;
var
i: LongInt;
begin
I:=123;
i.Test;
$12345678.Test;
LongInt.Test;
I:=123;
i.DoPrint;
$12345678.DoPrint;
end.