#1 Re: mORMot 1 » Out parameters in Interface based services » 2018-01-18 12:27:25

Ok, I understood this, but how to solve the problem with "out" parameters with TStringList and TObjectList classes that are not initialized in the procedure call by webservice?

Thanks!

#2 mORMot 1 » Out parameters in Interface based services » 2018-01-17 16:47:03

anmendes
Replies: 3

Hello,

I am using Mormot with Interface based services.

In my interface implementation, have the lines bellow:

procedure CarregaPedidoDisk(Filtro : string; out Pedido : TPedidoDisk);
procedure CarregaImpressoesPedido(PedidoGeral : integer; out Lista : TListaImpressaoPedido);

TPedidoDisk is a TPersistent class descendant and Lista is a TStringList class descendant.

The "Pedido" and "Lista" parameter have the "out" modifier. This modifier tells delphi/freepascal that the parameter is only for output.

But in implementation of "CarregaPedidoDisk" the "Pedido" parameter is initialized (automatic object create) and Lista is not initialized (The correct, in my opinion, the "out" modifier was used).


Searching in the Mormot code ("mormot.pas", TServiceMethodExecute.BeforeExecute procedure) this code is used for automatic creation:

case ValueType of
      smvObject:
        fObjects[IndexVar] := ArgTypeInfo^.ClassCreate
      smvRecord:
        if fAlreadyExecuted then
          FillcharFast(fRecords[IndexVar],ArgTypeInfo^.RecordType^.Size,0);



I suggest change the code for :


case ValueType of
      smvObject:
        if ValueDirection <> smdOut then
           fObjects[IndexVar] := ArgTypeInfo^.ClassCreate
        else
           fObjects[IndexVar] := nil;
      smvRecord:
        if fAlreadyExecuted then
          FillcharFast(fRecords[IndexVar],ArgTypeInfo^.RecordType^.Size,0);


Antonio Mendes

Board footer

Powered by FluxBB