+ VarArrayPut and VarArrayGet from Igor, resolves #9161

git-svn-id: trunk@8117 -
This commit is contained in:
florian 2007-07-21 18:49:10 +00:00
parent fa2a2b0bd0
commit dc2a8787a1
4 changed files with 38 additions and 0 deletions

1
.gitattributes vendored
View File

@ -8343,6 +8343,7 @@ tests/webtbs/tw9139.pp svneol=native#text/plain
tests/webtbs/tw9139a.pp svneol=native#text/plain
tests/webtbs/tw9141.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/tw9167.pp svneol=native#text/plain
tests/webtbs/tw9174.pp svneol=native#text/plain

View File

@ -613,6 +613,24 @@ procedure VarArrayRedim(var A: Variant; HighBound: SizeInt);
variantmanager.vararrayredim(a,highbound);
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);
begin

View File

@ -341,6 +341,8 @@ operator <=(const op1,op2 : variant) dest : boolean;{$ifdef SYSTEMINLINE}inline;
{ variant helpers }
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);
{**********************************************************************

17
tests/webtbs/tw9161.pp Normal file
View 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.