mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 10:49:17 +02:00
* fixed varbyref in variant conversion helpers (patch+test by Paul Ishenin,
mantis #14536) git-svn-id: trunk@13687 -
This commit is contained in:
parent
0e2f080f07
commit
1aa1686778
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -9302,6 +9302,7 @@ tests/webtbs/tw1445.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1450.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1451.pp svneol=native#text/plain
|
||||
tests/webtbs/tw14514.pp svneol=native#text/plain
|
||||
tests/webtbs/tw14536.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1470.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1472.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1477.pp svneol=native#text/plain
|
||||
|
@ -15,15 +15,8 @@
|
||||
|
||||
Resourcestring
|
||||
|
||||
SNoWidestrings = 'No widestrings supported';
|
||||
SNoInterfaces = 'No interfaces supported';
|
||||
|
||||
Procedure NoWidestrings;
|
||||
|
||||
begin
|
||||
Raise Exception.Create(SNoWideStrings);
|
||||
end;
|
||||
|
||||
Procedure NoInterfaces;
|
||||
|
||||
begin
|
||||
@ -106,7 +99,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varSmallInt);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := PSmallInt(vPointer)^;
|
||||
varShortInt : Result := PShortInt(vPointer)^;
|
||||
varInteger : Result := smallint(PInteger(vPointer)^);
|
||||
@ -189,7 +182,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varShortInt);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := shortint(PSmallInt(vPointer)^);
|
||||
varShortInt : Result := PShortInt(vPointer)^;
|
||||
varInteger : Result := shortint(PInteger(vPointer)^);
|
||||
@ -272,7 +265,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varInteger);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := PSmallInt(vPointer)^;
|
||||
varShortInt : Result := PShortInt(vPointer)^;
|
||||
varInteger : Result := PInteger(vPointer)^;
|
||||
@ -355,7 +348,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varLongWord);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := cardinal(PSmallInt(vPointer)^);
|
||||
varShortInt : Result := cardinal(PShortInt(vPointer)^);
|
||||
varInteger : Result := cardinal(PInteger(vPointer)^);
|
||||
@ -468,7 +461,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varSingle);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := PSmallInt(vPointer)^;
|
||||
varShortInt : Result := PShortInt(vPointer)^;
|
||||
varInteger : Result := PInteger(vPointer)^;
|
||||
@ -561,7 +554,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varDouble);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := PSmallInt(vPointer)^;
|
||||
varShortInt : Result := PShortInt(vPointer)^;
|
||||
varInteger : Result := PInteger(vPointer)^;
|
||||
@ -688,7 +681,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varCurrency);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := PSmallInt(vPointer)^;
|
||||
varShortInt : Result := PShortInt(vPointer)^;
|
||||
varInteger : Result := PInteger(vPointer)^;
|
||||
@ -785,7 +778,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varDate);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := PSmallInt(vPointer)^;
|
||||
varShortInt : Result := PShortInt(vPointer)^;
|
||||
varInteger : Result := PInteger(vPointer)^;
|
||||
@ -864,7 +857,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varBoolean);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := PSmallInt(vPointer)^ <> 0;
|
||||
varShortInt : Result := PShortInt(vPointer)^ <> 0;
|
||||
varInteger : Result := PInteger(vPointer)^ <> 0;
|
||||
@ -947,7 +940,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varByte);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := byte(PSmallInt(vPointer)^);
|
||||
varShortInt : Result := byte(PShortInt(vPointer)^);
|
||||
varInteger : Result := byte(PInteger(vPointer)^);
|
||||
@ -1030,7 +1023,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varInt64);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := PSmallInt(vPointer)^;
|
||||
varShortInt : Result := PShortInt(vPointer)^;
|
||||
varInteger : Result := PInteger(vPointer)^;
|
||||
@ -1113,7 +1106,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varQWord);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := qword(PSmallInt(vPointer)^);
|
||||
varShortInt : Result := qword(PShortInt(vPointer)^);
|
||||
varInteger : Result := qword(PInteger(vPointer)^);
|
||||
@ -1178,7 +1171,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varOleStr);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := IntToStr(PSmallInt(vPointer)^);
|
||||
varShortInt : Result := IntToStr(PShortInt(vPointer)^);
|
||||
varInteger : Result := IntToStr(PInteger(vPointer)^);
|
||||
@ -1243,7 +1236,7 @@ begin
|
||||
else
|
||||
VariantTypeMismatch(vType, varString);
|
||||
end;
|
||||
varByRef: if Assigned(vPointer) then case vType of
|
||||
varByRef: if Assigned(vPointer) then case vType and varTypeMask of
|
||||
varSmallInt : Result := IntToStr(PSmallInt(vPointer)^);
|
||||
varShortInt : Result := IntToStr(PShortInt(vPointer)^);
|
||||
varInteger : Result := IntToStr(PInteger(vPointer)^);
|
||||
|
36
tests/webtbs/tw14536.pp
Normal file
36
tests/webtbs/tw14536.pp
Normal file
@ -0,0 +1,36 @@
|
||||
program test_varbyref;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$apptype console}
|
||||
|
||||
uses
|
||||
Variants, VarUtils;
|
||||
|
||||
var
|
||||
V: Variant;
|
||||
P: Integer;
|
||||
begin
|
||||
P := 1;
|
||||
TVarData(V).vtype := varbyref or varinteger;
|
||||
TVarData(V).vpointer := @P;
|
||||
WriteLn(VariantToAnsiString(TVarData(V)));
|
||||
WriteLn(VariantToSmallInt(TVarData(V)));
|
||||
WriteLn(VariantToLongint(TVarData(V)));
|
||||
WriteLn(VariantToShortint(TVarData(V)));
|
||||
WriteLn(VariantToCardinal(TVarData(V)));
|
||||
WriteLn(VariantToSingle(TVarData(V)));
|
||||
WriteLn(VariantToDouble(TVarData(V)));
|
||||
WriteLn(VariantToDate(TVarData(V)));
|
||||
WriteLn(VariantToCurrency(TVarData(V)));
|
||||
WriteLn(VariantToBoolean(TVarData(V)));
|
||||
WriteLn(VariantToByte(TVarData(V)));
|
||||
WriteLn(VariantToInt64(TVarData(V)));
|
||||
WriteLn(VariantToQWord(TVarData(V)));
|
||||
WriteLn(VariantToWideString(TVarData(V)));
|
||||
WriteLn(VariantToAnsiString(TVarData(V)));
|
||||
WriteLn(VariantToShortString(TVarData(V)));
|
||||
WriteLn(V);
|
||||
TVarData(V).vtype := varEmpty;
|
||||
TVarData(V).vpointer := nil;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user