* pos(...,...) overloads with variants, see tb0520.pp for the reason

git-svn-id: trunk@5770 -
This commit is contained in:
florian 2006-12-31 17:47:05 +00:00
parent 779b33148c
commit 28d59bbf6f
4 changed files with 88 additions and 3 deletions

1
.gitattributes vendored
View File

@ -6244,6 +6244,7 @@ tests/tbs/tb0516.pp svneol=native#text/plain
tests/tbs/tb0517.pp svneol=native#text/plain
tests/tbs/tb0518.pp svneol=native#text/plain
tests/tbs/tb0519.pp svneol=native#text/plain
tests/tbs/tb0520.pp svneol=native#text/plain
tests/tbs/ub0060.pp svneol=native#text/plain
tests/tbs/ub0069.pp svneol=native#text/plain
tests/tbs/ub0119.pp svneol=native#text/plain

View File

@ -117,12 +117,12 @@ function fpc_idispatch_to_variant(const i : idispatch) : variant;compilerproc;
end;
procedure fpc_dispinvoke_variant(dest : pvardata;const source : tvardata;
procedure fpc_dispinvoke_variant(dest : pvardata;const source : tvardata;
calldesc : pcalldesc;params : pointer); compilerproc;
begin
variantmanager.dispinvoke(dest,source,calldesc,params);
end;
{ ---------------------------------------------------------------------
Overloaded operators.
@ -948,7 +948,7 @@ operator :=(const source : terror) dest : olevariant;{$ifdef SYSTEMINLINE}inline
begin
variantmanager.olevarfromint(dest,source,-sizeof(terror));
end;
function Unassigned: Variant; // Unassigned standard constant
begin
@ -980,3 +980,58 @@ end;
procedure initvariantmanager;
begin
end;
Function Pos (c : Char; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Result:=Pos(c,ShortString(v));
end;
Function Pos (s : ShortString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Result:=Pos(s,ShortString(v));
end;
Function Pos (a : AnsiString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Result:=Pos(a,AnsiString(v));
end;
Function Pos (w : WideString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Result:=Pos(w,WideString(v));
end;
Function Pos (v : Variant; Const c : Char) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Result:=Pos(ShortString(v),c);
end;
Function Pos (v : Variant; Const s : ShortString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Result:=Pos(ShortString(v),s);
end;
Function Pos (v : Variant; Const a : AnsiString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Result:=Pos(AnsiString(v),a);
end;
Function Pos (v : Variant; Const w : WideString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Result:=Pos(WideString(v),w);
end;
Function Pos (v1 : Variant; Const v2 : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Result:=Pos(WideString(v1),WideString(v2));
end;

View File

@ -442,6 +442,17 @@ operator :=(const source : currency) dest : olevariant;{$ifdef SYSTEMINLINE}inli
operator :=(const source : tdatetime) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
operator :=(const source : terror) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
{ silly, but how else should the compiler know what to do with pos(<string type>,<variant>)? (FK) }
Function Pos (c : Char; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Pos (s : ShortString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Pos (a : AnsiString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Pos (w : WideString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Pos (v : Variant; Const c : Char) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Pos (v : Variant; Const s : ShortString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Pos (v : Variant; Const a : AnsiString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Pos (v : Variant; Const w : WideString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Pos (v1 : Variant; Const v2 : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
{**********************************************************************
OLEVariant Operators
**********************************************************************}

18
tests/tbs/tb0520.pp Normal file
View File

@ -0,0 +1,18 @@
uses
variants;
var
w : widestring;
v : variant;
a : ansistring;
begin
a:='';
w:='';
v:='asdf';
pos(a,v);
pos(w,v);
pos(v,v);
pos(v,a);
pos(v,w);
pos(v,v);
end.