#1 2017-07-03 11:24:47

JD
Member
Registered: 2015-08-20
Posts: 118

SOA Interface based services in Lazarus - GEORGE's Third Party demo

Hi there everyone,

I'm trying to adapt the third party example by George to get a feeling for creating interface SOA in Lazarus. The example compiles and works in Lazarus and that is why I'm interested in studying it. Inside George's example, there is a pascal file mORMotRESTFPCInterfaces.pas with the following header

/// SOA interface methods definition to circumvent FPC missing RTTI
// - generated at 2016-07-27 09:30:40
unit mORMotRESTFPCInterfaces;

{
  WARNING:
    This unit has been generated by a mORMot 1.18.2797 server.
    Any manual modification of this file may be lost after regeneration.

  Synopse mORMot framework. Copyright (C) 2017 Arnaud Bouchez
    Synopse Informatique - https://synopse.info

  This unit is released under a MPL/GPL/LGPL tri-license,
  and therefore may be freely included in any application.

  This unit is intended to work on older FPC compilers, which lack of RTTI
  for interfaces - see http://bugs.freepascal.org/view.php?id=26774
  
  USAGE:

  Add this mORMotRESTFPCInterfaces unit to your uses clause, so that the following
  interfaces would be defined as expected by mORMot under FPC:

   - IRestMethods
  
}

It says this file was generated automatically BUT it does not say how it was done. Can anyone please tell me what I need to do to generate a file such as this for my test project.

Thanks a lot for your help.

JD

Last edited by JD (2017-07-03 11:25:47)

Offline

#2 2017-07-03 12:31:28

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

Re: SOA Interface based services in Lazarus - GEORGE's Third Party demo

Check the documentation about this.
https://synopse.info/files/html/Synopse … #TITLE_669

Note that if you use NewPascal fork of FPC, the needed RTTI will be there, so no need to generate such a unit.

Offline

#3 2017-07-03 14:37:28

JD
Member
Registered: 2015-08-20
Posts: 118

Re: SOA Interface based services in Lazarus - GEORGE's Third Party demo

Thanks a million ab. And thanks for the wonderful work you all are doing with mORMot. I haven't totally adopted NewPascal because my old work uses client side components that don't work in NewPascal.

If I understand what is written in the manual, it means I must compile at least the server code using Delphi to generate the XXXFPCInterface.pas file and then I can transfer it to my client & server projects in Lazarus.

Offline

#4 2017-07-03 15:12:21

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

Re: SOA Interface based services in Lazarus - GEORGE's Third Party demo

Yes, a Delphi is needed somewhere... just to compile the unit with the RTTI.
But a old Delphi 6 or 7 is enough for the purpose!

Or you may use a NewPascal setup for this, even if you don't use it for your project.
NewPascal FPC compiler has the RTTI, so you could be able to generate the unit.

Offline

#5 2017-09-05 20:01:24

JD
Member
Registered: 2015-08-20
Posts: 118

Re: SOA Interface based services in Lazarus - GEORGE's Third Party demo

Hi there AB,

I've been struggling with this RTTI problem for a while. I tried a NewPascal version that I downloaded a week ago and for some reason it gave me an error in line 18247 of SynCommons.pas saying Unknown Codepage; "1200".

I then reverted to Delphi 2010 to try to generate the missing unit.

The program dpr file is as shown below (it is a short file):

program BasicCalculatorClientDelphi;

{$define COMPUTEFPCINTERFACES}

uses
  {$I SynDprUses.inc} // use FastMM4 on older Delphi, or set FPC threads
  mORMotWrappers,
  //
  SysUtils,           // for ExtractFilePath
  //
  Forms,
  uClientForm in 'uClientForm.pas' {frmBasicCalculator},
  ucalculatorinterface in '..\ucalculatorinterface.pas',
  ucalculatorinterfacemethods in '..\ucalculatorinterfacemethods.pas';

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TfrmBasicCalculator, frmBasicCalculator);
  Application.Run;
  {$ifdef COMPUTEFPCINTERFACES}
  ChDir(ExtractFilePath(ParamStr(0)));
  ComputeFPCInterfacesUnit(
    ['..\CrossPlatform\templates','..\..\CrossPlatform\templates'],
     '..\CalculatorFPCInterface.pas');
  {$endif}
end.

The problem is CalculatorFPCInterface.pas is not being generated by Delphi 2010. What am I missing? Thanks for your assistance.

JD

Offline

#6 2017-09-06 06:06:42

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

Re: SOA Interface based services in Lazarus - GEORGE's Third Party demo

Change the relative path "..\" by using an absolute path on your local computer, to find the templates.

Offline

#7 2017-09-06 14:10:11

JD
Member
Registered: 2015-08-20
Posts: 118

Re: SOA Interface based services in Lazarus - GEORGE's Third Party demo

Merci infiniment AB,

It worked! I've even created a template from it that I can use for different projects. mORMot is like an onion; it has many layers and peeling away each layer reveals something new.

JD

Offline

Board footer

Powered by FluxBB