Ich habe da aktuell so meine Proble mit fpc Code, wo wild durcheinander konvertiert wird, wenn man aber Rangecheck einschaltet genaugenommen nicht funktioniert ausser Rangeerrors.
Code: Alles auswählen
maxLongint = $7fffffff;
.....
const
MaxInt = MaxLongint;
type
Integer = longint;
.....
TFPReportColor = type UInt32;
.....
const
{ The format is always RRGGBB (Red, Green, Blue) - no alpha channel }
clNone = TFPReportColor($80000000); // a special condition: $80 00 00 00
......
AWriter.WriteInteger('FontColor', Font.Color);
.....
Font.Color := AReader.ReadInteger('FontColor', Font.Color);
......
function TFPReportJSONStreamer.ReadInteger(AName: String; ADefault: Integer): Integer;
var
d: TJSONData;
begin
d := FindChild(AName) as TJSONData;
if d = nil then
Result := ADefault
else
begin
if d.JSONType = jtNumber then
Result := d.AsInt64
else
Result := ADefault;
end;
end;
Irgendwie kommt mir das ganze schon wild vor, vor allen der cast von Integer zu UInt32 macht natürlich Probleme. WIe löst man sowas richtig (und sauber) ?
Andreas