mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 22:09:32 +02:00
+ VarArrayPut and VarArrayGet from Igor, resolves #9161
git-svn-id: trunk@8117 -
This commit is contained in:
parent
fa2a2b0bd0
commit
dc2a8787a1
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8343,6 +8343,7 @@ tests/webtbs/tw9139.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw9139a.pp svneol=native#text/plain
|
tests/webtbs/tw9139a.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw9141.pp svneol=native#text/plain
|
tests/webtbs/tw9141.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw9145.pp svneol=native#text/plain
|
tests/webtbs/tw9145.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw9161.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw9162.pp svneol=native#text/plain
|
tests/webtbs/tw9162.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw9167.pp svneol=native#text/plain
|
tests/webtbs/tw9167.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw9174.pp svneol=native#text/plain
|
tests/webtbs/tw9174.pp svneol=native#text/plain
|
||||||
|
@ -613,6 +613,24 @@ procedure VarArrayRedim(var A: Variant; HighBound: SizeInt);
|
|||||||
variantmanager.vararrayredim(a,highbound);
|
variantmanager.vararrayredim(a,highbound);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure VarArrayPut(var A: Variant; const Value: Variant; const Indices: array of SizeInt);
|
||||||
|
begin
|
||||||
|
if Length(Indices)>0 then
|
||||||
|
variantmanager.vararrayput(A, Value, Length(Indices), @Indices[0])
|
||||||
|
else
|
||||||
|
variantmanager.vararrayput(A, Value, 0, nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function VarArrayGet(const A: Variant; const Indices: array of SizeInt): Variant;
|
||||||
|
begin
|
||||||
|
if Length(Indices)>0 then
|
||||||
|
Result:=variantmanager.vararrayget(A, Length(Indices), @Indices[0])
|
||||||
|
else
|
||||||
|
Result:=variantmanager.vararrayget(A, 0, nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure VarCast(var dest : variant;const source : variant;vartype : longint);
|
procedure VarCast(var dest : variant;const source : variant;vartype : longint);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -341,6 +341,8 @@ operator <=(const op1,op2 : variant) dest : boolean;{$ifdef SYSTEMINLINE}inline;
|
|||||||
|
|
||||||
{ variant helpers }
|
{ variant helpers }
|
||||||
procedure VarArrayRedim(var A: Variant; HighBound: SizeInt);
|
procedure VarArrayRedim(var A: Variant; HighBound: SizeInt);
|
||||||
|
procedure VarArrayPut(var A: Variant; const Value: Variant; const Indices: array of SizeInt);
|
||||||
|
function VarArrayGet(const A: Variant; const Indices: array of SizeInt): Variant;
|
||||||
procedure VarCast(var dest : variant;const source : variant;vartype : longint);
|
procedure VarCast(var dest : variant;const source : variant;vartype : longint);
|
||||||
|
|
||||||
{**********************************************************************
|
{**********************************************************************
|
||||||
|
17
tests/webtbs/tw9161.pp
Normal file
17
tests/webtbs/tw9161.pp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
uses
|
||||||
|
variants,sysutils;
|
||||||
|
var a:variant;
|
||||||
|
begin
|
||||||
|
a:=VarArrayCreate([0,2,0,2],varVariant);
|
||||||
|
if VarArrayDimCount(a)<>2 then
|
||||||
|
halt(1);
|
||||||
|
VarArrayPut(a,'b',[1,1]);
|
||||||
|
if String(VarArrayGet(a,[1,1]))<>'b' then
|
||||||
|
halt(2);
|
||||||
|
a[2,1]:='asdf';
|
||||||
|
if VarArrayGet(a,[2,1])<>'asdf' then
|
||||||
|
halt(2);
|
||||||
|
writeln('ok');
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user