
| Subject: | RTTI Problems in Delphi 2010 |
| Posted by: | Michael Jung |
| Date: | Mon, 29 Mar 2010 |
Extending a framework for the MGM Pattern makes hevy usage of RTTI and I ran into multiple problems in Delphi 2010:
1) convert an integer into a TValue, then both checks Val.IsType<TDateTime> and Val.IsType<integer> are true.
1a) Is there any other way how to check for data/time type ? TypeKind only leads to tkEnumeration, so workaround atm is checking via TypeInfo.Name
2) convert an integer into a TValue then Val.AsType<string> leads to invalid cast error
3) convert a TTime into a TValue then conversion to string or TCaption leads to an invalid cast error
4) conversion of Boolean types lead also to an invald type cast even if source / target values are both of type Boolean
4a) Workaround: just check if Value.IsType<Boolean> and skipping conversion
5) setting the color property of a control via TRTTIProperty.SetValue leads to an AV in RawInvoke, using TypeInfo.SetPropValue(AInstance, PropInfo, AValue) instead works
Anything I do wrong ?
In RTTI.pas most of Conversions: array[TTypeKind,TTypeKind] of TConvertFunc = ( // [source, target] lead to ConvFail, so you have to check and do it yourself.
So where is it usefull if even basic conversions like StrToInt fail ?
Debugging / breakpoints make the IDE freeze in many cases and then only canceling the process via taskmanager helps.
My enviroment
Windows 7 Ultimate x64 running in a VMWare VM on a MacPro
Embarcadero RadStudio Architect
Regards
Michael Jung
mijn-design