Explorar o código

* patch by Sergey Larin to handle Native(U)Int conversions from/to variants, resolves #37339

git-svn-id: trunk@45797 -
(cherry picked from commit a57f3ba396334fa89013345c530ae3beadd05aee)
Sven/Sarah Barth %!s(int64=3) %!d(string=hai) anos
pai
achega
48c54afabb
Modificáronse 3 ficheiros con 41 adicións e 0 borrados
  1. 25 0
      rtl/inc/variant.inc
  2. 4 0
      rtl/inc/varianth.inc
  3. 12 0
      tests/webtbs/tw37339.pp

+ 25 - 0
rtl/inc/variant.inc

@@ -203,6 +203,19 @@ begin
   Variantmanager.varfromInt64(Dest,Source);
 end;
 
+
+operator :=(const source : NativeInt) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  dest:=PtrInt(source);
+end;
+
+
+operator :=(const source : NativeUInt) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  dest:=PtrUInt(source);
+end;
+
+
 { Boolean }
 
 operator :=(const source : boolean) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -395,6 +408,18 @@ begin
 end;
 
 
+operator :=(const source : variant) dest : NativeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  PtrInt(dest):=source;
+end;
+
+
+operator :=(const source : variant) dest : NativeUInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  PtrUInt(dest):=source;
+end;
+
+
 { Boolean }
 
 operator :=(const source : variant) dest : boolean;{$ifdef SYSTEMINLINE}inline;{$endif}

+ 4 - 0
rtl/inc/varianth.inc

@@ -243,6 +243,8 @@ operator :=(const source : dword) dest : variant;{$ifdef SYSTEMINLINE}inline;{$e
 operator :=(const source : longint) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
 operator :=(const source : qword) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
 operator :=(const source : int64) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : NativeInt) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : NativeUInt) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Boolean }
 operator :=(const source : boolean) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -300,6 +302,8 @@ operator :=(const source : variant) dest : dword;{$ifdef SYSTEMINLINE}inline;{$e
 operator :=(const source : variant) dest : longint;{$ifdef SYSTEMINLINE}inline;{$endif}
 operator :=(const source : variant) dest : qword;{$ifdef SYSTEMINLINE}inline;{$endif}
 operator :=(const source : variant) dest : int64;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : variant) dest : NativeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : variant) dest : NativeUInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Boolean }
 operator :=(const source : variant) dest : boolean;{$ifdef SYSTEMINLINE}inline;{$endif}

+ 12 - 0
tests/webtbs/tw37339.pp

@@ -0,0 +1,12 @@
+{$mode objfpc}
+uses
+  variants;
+   
+function VarToObj(const Value: Variant): TObject;
+begin
+  Result := TObject(Pointer(NativeInt(Value)));
+end; 
+
+begin
+end.
+