#1 2014-12-08 20:28:21

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Problem with nested Records for Interfaces.

XE7 Upd1:

the following Deklaration

  TResultRecord = record
    F : record
      erfolgJN : RawUtf8;
      fehlertext : RawUtf8;
      hinweistext : RawUtf8;
    end;
    FResult1 : RawUtf8;
    FResult2 : RawUtf8;
    FResult3 : RawUtf8;
    FResult4 : RawUtf8;
  end;

results in generated wrapper code:

  TResultRecord = record
    F: :TResultRecord.:1;
    FResult1: string;
    FResult2: string;
    FResult3: string;
    FResult4: string;
  end;

Rad Studio 12.1 Santorini

Offline

#2 2014-12-08 21:46:51

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: Problem with nested Records for Interfaces.

Hi AB i found the solution:

i have to add this at the bottom.

  __TResultRecord =
  'resultRec { erfolgJN RawUtf8 fehlertext RawUtf8 hinweistext RawUtf8} FResult1 RawUtf8 FResult2 RawUtf8 FResult3 RawUtf8 FResult4 RawUtf8';

initialization
  TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TResultRecord),__TResultRecord);

But how can i reuse a record not directly used as Interface function Result ?

   TResult : record
      erfolgJN : RawUtf8;
      fehlertext : RawUtf8;
      hinweistext : RawUtf8;
    end;

 TResultRecord1 = record
    resultRec : TResult;
    FResult1 : RawUtf8;
    FResult2 : RawUtf8;
    FResult3 : RawUtf8;
    FResult4 : RawUtf8;
  end;

 TResultRecord2 = record
    resultRec : TResult;
    FResult1 : RawUtf8;
    FResult2 : RawUtf8;
  end;

in this case TResult is not defined in the Wrapper Client.

Last edited by itSDS (2014-12-08 21:53:58)


Rad Studio 12.1 Santorini

Offline

#3 2014-12-20 11:21:37

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: Problem with nested Records for Interfaces.

Hi AB - great Work - with the new Wrapper my TResult as wished above

itSDS wrote:

But how can i reuse a record not directly used as Interface function Result ?

   TResult : record
      erfolgJN : RawUtf8;
      fehlertext : RawUtf8;
      hinweistext : RawUtf8;
    end;

 TResultRecord1 = record
    resultRec : TResult;
    FResult1 : RawUtf8;
    FResult2 : RawUtf8;
    FResult3 : RawUtf8;
    FResult4 : RawUtf8;
  end;

 TResultRecord2 = record
    resultRec : TResult;
    FResult1 : RawUtf8;
    FResult2 : RawUtf8;
  end;

in this case TResult is not defined in the Wrapper Client.

in this case i have to add 3 TTextWriter- extensions in initializatioin:

const
  __TResult = 'erfolgJN RawUtf8 fehlertext RawUtf8 hinweistext RawUtf8';
  __TResultRecord1 = 'resultRec Tresult FResult1 RawUtf8 FResult2 RawUtf8 FResult3 RawUtf8 FResult4 RawUtf8';
  __TResultRecord2 = 'resultRec Tresult FResult1 RawUtf8 FResult2 RawUtf8';

initialization
  TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TResult),__TResult);
  TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TResultRecord1),__TResultRecord1);
  TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TResultRecord2),__TResultRecord2);

And in my Client i can write some special code for TResult  cool

Last edited by itSDS (2014-12-20 11:29:00)


Rad Studio 12.1 Santorini

Offline

Board footer

Powered by FluxBB