Show quoted text 7 lines
I've try to discover why LRS don't work with TColor, and I think I found:
in ReadPropValue for enumeration identifier can't be a VALUE
this is my proposition to solve:
tkEnumeration:
- TColor is not an enum
- Even FindIdentToInt will fail, for the simple reason that the ColorToInt/IntToColor functions can't be found. These functions are registered by the return value of TypeInfo(TColor), which should return one unique pointer for each type. But fpc 1.0.x and 1.9.x returns different values, depending on where you use the TypeInfo function. In this case: TypeInfo(TColor) called in graphics.pp returns a different value than called in classes.pp.
One solution would be to add a further list of IntToIdent functions identified by names instead of TypeInfo. The disadvantage is, that it can be ambgious. But since the TypeInfo registering does not work, it is not used, so this workaround will not break any code. And what is more important: These things are rarely used, so as soon as the TypeInfo works, we only need to change a few lines of code.
About the addition: I think, it can be useful for alias enums (e.g. myenum =
(a:=b, c:=d, ...) ). What do the fpc devels think about?
Mattias
Show quoted text 20 lines
begin
Value := GetEnumValue(PropType, ReadIdent);
if value = -1 then begin
IdentToIntFn := FindIdentToInt(PPropInfo(PropInfo)^.PropType);
Ident := ReadIdent;
if Assigned(IdentToIntFn) then IdentToIntFn(Ident, Value);
end;
if Value = -1 then
raise EReadError.Create(SInvalidPropertyValue);
SetOrdProp(Instance, PropInfo, Value);
end;
Darek
_______________________________________________
fpc-devel maillist -
http://lists.freepascal.org/mailman/listinfo/fpc-devel