[Pas2js] Next language feature for pas2js...

Sven Barth pascaldragon at googlemail.com
Sat Apr 28 11:27:18 CEST 2018


Am 28.04.2018 um 00:01 schrieb Michael Van Canneyt:
>
>
> On Fri, 27 Apr 2018, Sven Barth via Pas2js wrote:
>
>> Am 27.04.2018 um 15:11 schrieb Michael Van Canneyt:
>>
>>>
>>>
>>> On Fri, 27 Apr 2018, Ondrej Pokorny wrote:
>>>
>>>> On 27.04.2018 14:49, Michael Van Canneyt wrote:
>>>>> On Fri, 27 Apr 2018, warleyalex via Pas2js wrote:
>>>>>> I'm quite confident our mORMot suits better with the free open 
>>>>>> source Pas2JS
>>>>>> FPC based project.
>>>>>
>>>>> I never was a big fan of mORMot. Way too complicated for 
>>>>> beginners. Not RAD at all.
>>>>>
>>>>> I'm currently converting a big project for a client that uses 
>>>>> mORMot to something else which is less obtuse and fragile. Now I'm 
>>>>> even less of a fan than before.
>>>>
>>>> I have exactly the same experience. In legacy Delphi projects I use 
>>>> SynPDF (which is great) but I abandoned mORMot. Too complicated, 
>>>> too many dirty tricks (e.g. why does it have its own TypInfo?).
>>>
>>> Indeed. The dirty tricks department is what I referred to with my 
>>> 'fragile'.
>>
>> What I *do* like about mORMot and hope to reproduce for fcl-web are 
>> the interface based services for which one merely has an interface on 
>> the client side that one interacts with and an implementation of the 
>> interface on the service side. Between them is the wire protocol like 
>> JSON over HTTP or such.
>
> You can do this in a clean way already. See e.g. Remobjects SDK. Or 
> WST, if you want open source..
 From what I can see Remobjects' Remoting SDK either requires the use of 
attributes or a definition file. WST also requires a definition file.
The idea I want to see (and which is done by mORMot) is to rely on the 
RTTI of interfaces paired with Invoke() to do this without any 
definition files:

=== code begin ===

type
   IMyService = interface
     function ServiceMethod1(aArg1: TUser; const aArg2: String; const 
aArg3: array of LongInt): String;
     procedure ServiceMethod2(aArg1: TUser; aArg2: Boolean);
   end;

=== code end ===

On the client side (at least if it's written in FPC (or Delphi)) there 
would be a TVirtualInterface instance implementing the IMyService 
instance that would convert the given parameters to on-the-wire code 
(e.g. JSON over HTTP). On the server side a web mobule would convert the 
parameters again and then call the correct method of the interface with 
the real parameters.
There would also be classes that would provide a mapping of class, 
method and argument names to their on-the-wire representations (e.g. so 
that the API endpoint would be 
http://host:port/product/my-service/service-method-1 for 
IMyService.ServiceMethod1()) as well as a mapping from user types to 
arguments (e.g. TUser is something that is identified by an ID so what's 
transferred is the ID instead of the whole user). Of course the result, 
var/out parameters as well as exceptions are to be handled accordingly.

Currently missing for this to be done in FPC is the TVirtualInterface 
implementation as well as a working Invoke() for more platforms than 
Linux... (and of course time :P ). And yes, I'm still somewhat missing a 
concept for authorization.

Regards,
Sven


More information about the Pas2js mailing list