[Lazarus] Thanks to FPC team: Record helper for primitive types!
silvioprog
silvioprog at gmail.com
Sat Nov 29 23:27:53 CET 2014
On Sat, Nov 29, 2014 at 5:55 PM, silvioprog <silvioprog at gmail.com> wrote:
> On Sat, Nov 29, 2014 at 4:54 PM, Michael Van Canneyt <
> michael at freepascal.org> wrote:
>>
>> On Sat, 29 Nov 2014, silvioprog wrote:
>>
>>> On Sat, Nov 29, 2014 at 2:04 PM, Sven Barth <pascaldragon at googlemail.com>
>>> wrote:
>>> On 29.11.2014 16:54, silvioprog wrote:
>>> Hello,
>>>
>>> Today I compiled my FPC from trunk and saw the following
>>> possibility:
>>>
>>>
>>> This feature is available since February 2013 already, you just
>>> had to use {$modeswitch typehelpers}
>>> (I even announced that on fpc-devel, fpc-pascal and fpc-announce
>>> back then). What I committed
>>> yesterday was simply to allow them by default in mode Delphi as
>>> that mode is simply a collection of
>>> features supported by the current Delphi version (in so far they
>>> are already implemented in FPC). You
>>> still have to use the modeswitch in other modes and in all modes
>>> except the Delphi ones it's "type
>>> helper" instead of "record helper".
>>>
>>> Regards,
>>> Sven
>>>
>>>
>>> Awesome. I'll use type helper. =)
>>>
>>> Plans to implement the currently XE helpers? (TIntegerHelper,
>>> TStringHelper etc.)
>>>
>>
>> Definitely, as soon as I find time.
>> But initial patches welcome.
>>
>> Michael.
>
>
> Nice. To implement it we can need to enable the {$modeswitch
> typehelpers}. Can you enable it in SysUtils?
>
Just testing:
unit sysutils;
interface
{$MODE objfpc}
{$MODESWITCH OUT}
{$MODESWITCH TYPEHELPERS}
...
sysutilh.inc
...
function GetModuleName(Module: HMODULE): string;
type
TGuidHelper = type helper for TGuid
// class function Create(const B: TBytes): TGUID; overload; static;
// class function Create(const S: string): TGUID; overload; static;
// class function Create(A: Integer; B: SmallInt; C: SmallInt; const D:
TBytes): TGUID; overload; static;
// class function Create(A: Integer; B: SmallInt; C: SmallInt; D, E, F,
G, H, I, J, K: Byte): TGUID; overload; static;
// class function Create(A: Cardinal; B: Word; C: Word; D, E, F, G, H,
I, J, K: Byte): TGUID; overload; static;
// class function NewGuid: TGUID; static;
// function ToByteArray: TBytes;
// function ToString: string;
end;
...
sysutilh.inc(330,3) Error: Type "TGuid" cannot be extended by a type helper
I'll leave this task to you. =D
--
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20141129/d1730a7f/attachment-0003.html>
More information about the Lazarus
mailing list