Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2016-12

Trying to patch TGuid

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Дмитрий Померанцев

I tried to add the comparison operator and the method that returns the empty GUID to the TGuid type, as is done in Delphi. I thought that this would not be any problems, because that type is declared rtl/inc/objpash.inc file which is included in rtl/inc/systemh.inc and the systemh.inc have a {$modeswitch advancedrecords} line.

Unfortunately, it seems to rewrite the system modules is not so easy. After making the changes that are described by this patch:

>>

Index: rtl/inc/objpas.inc
=================================================================== --- rtl/inc/objpas.inc (revision 35175)
+++ rtl/inc/objpas.inc (working copy)
@@ -1000,6 +1000,27 @@

         end;

{****************************************************************************
+ TGUID
+****************************************************************************} +
+
+ class operator TGuid.=(const left, right : TGuid) : boolean;
+ begin
+ result:=IsGUIDEqual(left,right);
+ end;
+
+ class operator TGuid.(const left, right : TGuid) : boolean;
+ begin
+ result:=not(IsGUIDEqual(left,right));
+ end;
+
+ class function TGuid.Empty : TGuid;
+ begin
+ FillChar(result,SizeOf(result),0);
+ end;
+
+
+{**************************************************************************** TINTERFACEDOBJECT
****************************************************************************}

Index: rtl/inc/objpash.inc
=================================================================== --- rtl/inc/objpash.inc (revision 35175)
+++ rtl/inc/objpash.inc (working copy)
@@ -132,6 +132,9 @@

        PGuid = ^TGuid;
        TGuid = packed record

+ class operator =(const left, right : TGuid) : boolean; {$ifdef SYSTEMINLINE} inline; {$endif}
+ class operator (const left, right : TGuid) : boolean; {$ifdef SYSTEMINLINE} inline; {$endif}
+ class function Empty : TGuid; static; {$ifdef SYSTEMINLINE} inline; {$endif}

           case integer of
              1 : (
                   Data1 : DWord;

<<<

I was get the following error (I use the source code from svn, revision #35175):

C:/FPC/3.1.x/source/compiler/ppc1.exe -Ur -Xs -O2 -n -Twin32 -Pi386 -Fi../inc -Fi../i386 -Fi../win -FE. -FUC:/FPC/3.1.x/source/rtl/units/i386-win32 -di386 -dRELEASE -Us -Sg system.pp -Fi../winobjpash.inc(453,70) Error: $ENDIF expected for $IFDEF FPC_HAS_FEATURE_CLASSES defined in objpash.inc line 1550
Fatal: No memory left

Quite a strange message, that it is difficult to understand where that was. But I got it. At the line 453 of file rtl/inc/objpash.inc:

IObjectInstance: TGuid = '{D91C9AF4-3C93-420F-A303-BF5BA82BFD23}';

So the my code is interfere of constant assignment.

And at the in line 1550 of file rtl/inc/systemh.inc we can see:

{$ifdef FPC_HAS_FEATURE_CLASSES}
{$i objpash.inc}
{$endif FPC_HAS_FEATURE_CLASSES}

Here is I stuck. Can anyone suggest what is wrong here? The compiler does not allow include operator overloading or record methods in the system modules? Or is it some kind of a bug?

Dmitriy Pomerantsev.

Reply by email

Jonas Maebe
to Дмитрий Померанцев
Дмитрий Померанцев wrote
Here is I stuck. Can anyone suggest what is wrong here? The compiler does not allow include operator overloading or record methods in the system modules? Or is it some kind of a bug?

It's because the compiler has built-in assumptions regarding the symbols that the tguid type contains and in which order they appear. Adding extra symbols breaks those assumptions.

I'll see tonight whether I can remove those hard-coded assumptions.

Jonas

Reply by email

Jonas Maebe
to Jonas Maebe
Jonas Maebe wrote 10 lines
On 22/12/16 22:07, Дмитрий Померанцев wrote: > Here is I stuck. Can anyone suggest what is wrong here? The compiler > does not allow include operator overloading or record methods in the > system modules? Or is it some kind of a bug? It's because the compiler has built-in assumptions regarding the symbols that the tguid type contains and in which order they appear. Adding extra symbols breaks those assumptions. I'll see tonight whether I can remove those hard-coded assumptions.

Should be fixed in r35190.

Jonas

Reply by email