#1 2015-08-18 19:34:25

sushi
Member
Registered: 2012-05-04
Posts: 3

fpc/lazarus and TDocVariant exception

Hello,

I'm trying to use synMustache to generate web views. I started with the code in the doc :

  mustache := TSynMustache.Parse('Hello {{name}}'#13#10'You have just won {{value}} dollars!');
  TDocVariant.New(doc);
  doc.name := 'Chris';
  doc.value := 10000;
  html := mustache.Render(doc); 

It compiles and it works on Windows. On Linux (Ubuntu), it compiles but the instruction
  doc.name := 'Chris';
raise the exception EVariantBadVarTypeError.

What goes wrong? Thank you.

Offline

#2 2015-08-19 10:50:27

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

Re: fpc/lazarus and TDocVariant exception

Offline

#3 2015-09-04 05:24:59

sushi
Member
Registered: 2012-05-04
Posts: 3

Re: fpc/lazarus and TDocVariant exception

Hello, sorry for the delay.

I think it's the right version, I installed it 2 monhs ago this way: http://www.getlazarus.org/setup/#linux .
Here are the details extracted from Lazarus EDI:

FPC executable:
CompilerDate=30/06/2015 21:51:44
RealCompiler=~/Development/FreePascal/fpc/bin/ppc386
RealCompilerDate=30/06/2015 21:54:09
RealTargetOS=linux
RealTargetCPU=i386
Version=3.1.1

Offline

#4 2015-09-09 06:51:34

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: fpc/lazarus and TDocVariant exception

I can confirm this exception.
I am looking into it !

Offline

#5 2015-09-09 07:45:13

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: fpc/lazarus and TDocVariant exception

Interim report.

Under Windows, the variant type is varOleStr.
Under Linux, the variant type is varustring.

@Ab: any idea already ?

Offline

#6 2015-09-09 07:57:21

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: fpc/lazarus and TDocVariant exception

Ok. Got things working. Not sure if correct, so please check and review.

Inside syncommons.pas, change

if Value.VType=varOleStr then

into

if (Value.VType=varOleStr) OR (Value.VType=varustring) then

and all works under Win and Linux !
But again, please chck if correct !

Offline

#7 2015-09-09 07:57:26

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

Re: fpc/lazarus and TDocVariant exception

String constants are therefore implemented via a BSTR/varOleStr under Windows, whereas it is a varUString (UnicodeString) under Linux.
Very interesting.

Where is the exception triggered?
In mORMot code, or in variants.pas?
Isn't the varUStr type missing in TSynInvokeableVariantType.SetProperty?

Could you check if HASVARUSTRING conditional is enabled in Synopse.inc for your compiler?

Offline

#8 2015-09-09 08:21:06

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

Re: fpc/lazarus and TDocVariant exception

Offline

#9 2015-09-09 08:22:48

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: fpc/lazarus and TDocVariant exception

Well, it breaks here, inside symcommons.pas inside function TSynInvokeableVariantType.SetProperty at:

end else begin
    IntSet(V,Value,PropName); <--

which is to be expected when VType is wrong.
HASVARUSTRING conditional is enabled !

Offline

#10 2015-09-09 08:23:52

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: fpc/lazarus and TDocVariant exception

Sorry, did not see your commit ! Will try now !!

Offline

#11 2015-09-09 08:31:13

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: fpc/lazarus and TDocVariant exception

Your commit works !
Thanks !!

Offline

Board footer

Powered by FluxBB