[fpc-pascal] SetPropValue: value as string does not work for Chars and Booleans

silvioprog silvioprog at gmail.com
Sat Jun 13 08:47:23 CEST 2015


On Thu, Jun 11, 2015 at 2:26 AM, silvioprog <silvioprog at gmail.com> wrote:

> Hello,
>
> Trying to set the value 'a' to a property Char and a 'True' to a Boolean
> property, I got some errors (logs in attached) in function
> 'TypInfo.SetPropValue'. But I did the same test in Delphi XE 7 and also in
> Delphi 7 (after some changes in my demo, shure), and it worked fine. So I
> decided to test other property types looking for more errors.
>
> I attached a small project simulating a test-case, testing the function
> 'TypInfo.SetPropValue' with commum primitive types in FPC and Delphi.
>
> Please see the LOG_*.TXT files, it has the comparition between FPC (trunk)
> and Delphi  (XE7), both tests done in 32 and 64 CPUs.
>
> Is this bug or a normal behaviour of FPC RTTI? If you confirm it as but, I
> can try to send a patch to fix that.
>
> Thank you!
>

Nobody? =/

It seems that current FPC SetPropValue looks like Delphi 7, but IMHO this
function could follow the new Delphi implementation, including new unicode
support. BTW, if anyone confirm it as bug, I can try to make a patch and
send it via bugtracker.

I haven't tested function GetPropValue yet. And I haven't tested in Linux,
but I believe that this problem occurs there too.

Just for check the difference between currently TypInfo of FPC and TypInfo
of XE 7, bellow the two logs generated by my previous attached demo:

------- FPC -------
CPUX86

STRINGS:

MyString empty: OK
MyString: OK
MyAnsiString: OK
MyWideString: OK
MyUnicodeString: OK
MyShortString: OK

CHARS:

EVariantError: Invalid variant type cast
MyChar null: Fail
EVariantError: Invalid variant type cast
MyChar: Fail
EVariantError: Invalid variant type cast
MyAnsiChar: Fail
EVariantError: Invalid variant type cast
MyWideChar a: Fail
EVariantError: Invalid variant type cast
MyWideChar a: Fail
EVariantError: Invalid variant type cast
MyUnicodeChar a: Fail
EVariantError: Invalid variant type cast
MyUnicodeChar a: Fail

INTEGERS:

MyInteger zero: OK
MyByte <: OK
MyByte >: OK
MyShortInt <: OK
MyShortInt >: OK
MySmallInt <: OK
MySmallInt >: OK
MyWord <: OK
MyWord >: OK
MyInteger <: OK
MyInteger >: OK

INT64S:

MyInt64 zero: OK
MyCardinal <: OK
MyCardinal >: OK
MyLongInt <: OK
MyLongInt >: OK
MyLongWord <: OK
MyLongWord >: OK
MyInt64 <: OK
MyInt64 >: OK
MyQWord <: OK
MyQWord >: OK

BOOLEANS:

MyBoolean f: OK
MyBoolean t: OK
ERangeError: Range error
MyByteBool f: Fail
ERangeError: Range error
MyByteBool t: Fail
ERangeError: Range error
MyWordBool f: Fail
ERangeError: Range error
MyWordBool t: Fail
ERangeError: Range error
MyLongBool f: Fail
ERangeError: Range error
MyLongBool t: Fail

FLOATS:

MyFloat zero: OK
MySingle <: OK
MySingle >: OK
MyExtended <: OK
MyExtended >: OK
MyCurrency <: OK
MyCurrency >: OK
MyFloat <: OK
MyFloat >: OK
MyComp <: OK
MyComp >: OK

ENUMS:

MyEnum <: OK
MyEnum >: OK

SETS:

MySet <: OK
MySet >: OK
MySet <: OK
MySet >: OK
MySet <: OK
MySet >: OK
MySet <: OK
MySet >: OK
------- FPC -------

------- XE 7 -------
CPUX86

STRINGS:

MyString empty: OK
MyString: OK
MyAnsiString: OK
MyWideString: OK
MyUnicodeString: OK
MyShortString: OK

CHARS:

MyChar null: OK
MyChar: OK
MyAnsiChar: OK
MyWideChar a: OK
MyWideChar a: OK
MyUnicodeChar a: OK
MyUnicodeChar a: OK

INTEGERS:

MyInteger zero: OK
MyByte <: OK
MyByte >: OK
MyShortInt <: OK
MyShortInt >: OK
MySmallInt <: OK
MySmallInt >: OK
MyWord <: OK
MyWord >: OK
MyInteger <: OK
MyInteger >: OK

INT64S:

MyInt64 zero: OK
MyCardinal <: OK
MyCardinal >: OK
MyLongInt <: OK
MyLongInt >: OK
MyLongWord <: OK
MyLongWord >: OK
MyInt64 <: OK
MyInt64 >: OK

BOOLEANS:

MyBoolean f: OK
MyBoolean t: OK
MyByteBool f: OK
MyByteBool t: OK
MyWordBool f: OK
MyWordBool t: OK
MyLongBool f: OK
MyLongBool t: OK

FLOATS:

MyFloat zero: OK
MySingle <: OK
MySingle >: OK
MyExtended <: OK
MyExtended >: OK
MyCurrency <: OK
MyCurrency >: OK
MyFloat <: OK
MyFloat >: OK
MyComp <: OK
MyComp >: OK

ENUMS:

MyEnum <: OK
MyEnum >: OK

SETS:

MySet <: OK
MySet >: OK
MySet <: OK
MySet >: OK
MySet <: OK
MySet >: OK
MySet <: OK
MySet >: OK
------- XE 7 -------

-- 
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150613/d511bbf5/attachment.html>


More information about the fpc-pascal mailing list