#1 2017-08-29 08:53:06

turrican
Member
From: Barcelona
Registered: 2015-06-05
Posts: 94
Website

[FEATURE] System.Generics.Collections implementation on SynCrossPlatf

Hi,

To improve the compatibility with original mORMot, it would be great to implement generics.

For example :

    function RetrieveList(Table: TSQLRecordClass; const FieldNames,
      SQLWhere: string; const BoundsSQLWhere: array of const): TObjectList;

For this :

{$IFDEF NEXTGEN}
    function RetrieveList(Table: TSQLRecordClass; const FieldNames,
      SQLWhere: string; const BoundsSQLWhere: array of const): TObjectList<T>;
{$ELSE}
    function RetrieveList(Table: TSQLRecordClass; const FieldNames,
      SQLWhere: string; const BoundsSQLWhere: array of const): TObjectList;
{$ENDIF}

Offline

#2 2017-08-29 09:02:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: [FEATURE] System.Generics.Collections implementation on SynCrossPlatf

I would rather add something like in the main mORMot.pas unit.

That is, properly using generics for the overloaded version - something like:

    {$ifdef ISDELPHI2010} // Delphi 2009 generics support is buggy :(
    function RetrieveList<T: TSQLRecord>(const FieldNames, SQLWhere: string; const BoundsSQLWhere: array of const): TObjectList<T>; overload;
       {$ifdef HASINLINE}inline;{$endif}
    {$endif}

Your version would be confusing for the compiler.

Offline

#3 2017-08-29 09:13:23

turrican
Member
From: Barcelona
Registered: 2015-06-05
Posts: 94
Website

Re: [FEATURE] System.Generics.Collections implementation on SynCrossPlatf

ab wrote:

I would rather add something like in the main mORMot.pas unit.

That is, properly using generics for the overloaded version - something like:

    {$ifdef ISDELPHI2010} // Delphi 2009 generics support is buggy :(
    function RetrieveList<T: TSQLRecord>(const FieldNames, SQLWhere: string; const BoundsSQLWhere: array of const): TObjectList<T>; overload;
       {$ifdef HASINLINE}inline;{$endif}
    {$endif}

Your version would be confusing for the compiler.

Yes it's much better than mine.

Offline

#4 2017-08-29 13:07:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: [FEATURE] System.Generics.Collections implementation on SynCrossPlatf

I've added TSQLRest.RetrieveList<T> to the cross-platform clients.
See https://synopse.info/fossil/info/1bbe25b1c6

Offline

#5 2017-08-30 07:05:24

turrican
Member
From: Barcelona
Registered: 2015-06-05
Posts: 94
Website

Re: [FEATURE] System.Generics.Collections implementation on SynCrossPlatf

ab wrote:

I've added TSQLRest.RetrieveList<T> to the cross-platform clients.
See https://synopse.info/fossil/info/1bbe25b1c6

Great! Thank you very much!

Offline

#6 2017-08-30 08:25:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: [FEATURE] System.Generics.Collections implementation on SynCrossPlatf

Feedback is welcome: I didn't test it on NextGen/iOS/Android platforms.

Offline

#7 2017-08-30 09:55:26

turrican
Member
From: Barcelona
Registered: 2015-06-05
Posts: 94
Website

Re: [FEATURE] System.Generics.Collections implementation on SynCrossPlatf

ab wrote:

Feedback is welcome: I didn't test it on NextGen/iOS/Android platforms.

I'm currently developing/testing it for a Firemonkey Android client. I will back with updates.

Offline

Board footer

Powered by FluxBB