[fpc-devel] RTTI's GetPropValue returns corrupt Boolean value

Joao Morais post at joaomorais.com.br
Tue Nov 20 16:27:39 CET 2007


Graeme Geldenhuys wrote:
> On 20/11/2007, Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:
>> I've extended the PropertyMatch() function to test for tkBool types
>> (no variants) and do a writeln when it finds it. That parts seems to
>> work fine.
> 
> Here is the debug code I added to PropertyMatch() which successfully
> compare the results, but I have to explicitly cast GetOrdProp to a
> Boolean.  Is that normal???
> 
>     PropInfo := GetPropInfo(AObject.ClassType, PropName);
>     if tiGetTypeInfo(PropInfo)^.Kind = tkBool then
>     begin
>       writeln('Found rtti bool type');
>       lbool := Boolean(GetOrdProp(AObject, PropName));
>       if lSearch = lbool then
>         writeln('Comparison was a success');
>     end;

Sounds familiar. Here I have:

   if UsePublishedGetter then
     Result := Boolean(GetOrdProp(Owner, Metadata.Name))
   else
     Result := Value;

--
Joao Morais



More information about the fpc-devel mailing list