Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-06

SetPropValue: value as string does not work for Chars and Booleans

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

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!

Silvio Clécio My public projects - github.com/silvioprog
silvioprog
to silvioprog
silvioprog wrote 19 lines
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
Michael Van Canneyt
to silvioprog
silvioprog wrote 19 lines
On Thu, Jun 11, 2015 at 2:26 AM, silvioprog 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.

Please do. Include your test program.

Michael.

silvioprog
to Michael Van Canneyt

On Sat, Jun 13, 2015 at 7:04 AM, Michael Van Canneyt <

Show quoted text 36 lines
wrote: On Sat, 13 Jun 2015, silvioprog wrote: > On Thu, Jun 11, 2015 at 2:26 AM, silvioprog 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. > > Please do. Include your test program. Michael.

Nice.

Done in:

http://bugs.freepascal.org/view.php?id=28290

It could be related to:

http://bugs.freepascal.org/view.php?id=28278 (patch for fix attached there)

Thank buddy! (y)

Silvio Clécio My public projects - github.com/silvioprog