瀏覽代碼

Support implicit conversion between Integer64 and Int64.

This allows the two types to be used interchangeably in assignment
statements and function parameters.

I don't intend to implement more operators (e.g., addition or comparison)
because the ultimate goal is to replace Integer64 usage with Int64 (or
UInt64 in certain cases). This just allows the migration to be done more
incrementally.
Jordan Russell 2 月之前
父節點
當前提交
0793e717af
共有 3 個文件被更改,包括 17 次插入4 次删除
  1. 1 1
      Projects/Src/Setup.InstFunc.pas
  2. 1 1
      Projects/Src/Setup.Install.pas
  3. 15 2
      Projects/Src/Shared.Int64Em.pas

+ 1 - 1
Projects/Src/Setup.InstFunc.pas

@@ -982,7 +982,7 @@ begin
   try
   try
     if Assigned(@GetDiskFreeSpaceExFunc) then begin
     if Assigned(@GetDiskFreeSpaceExFunc) then begin
       Result := GetDiskFreeSpaceExFunc(PChar(AddBackslash(PathExpand(DriveRoot))),
       Result := GetDiskFreeSpaceExFunc(PChar(AddBackslash(PathExpand(DriveRoot))),
-        @TLargeInteger(FreeBytes), @TLargeInteger(TotalBytes), nil);
+        @TLargeInteger(Int64Rec(FreeBytes)), @TLargeInteger(Int64Rec(TotalBytes)), nil);
     end
     end
     else begin
     else begin
       Result := GetDiskFreeSpace(PChar(AddBackslash(PathExtractDrive(PathExpand(DriveRoot)))),
       Result := GetDiskFreeSpace(PChar(AddBackslash(PathExtractDrive(PathExpand(DriveRoot)))),

+ 1 - 1
Projects/Src/Setup.Install.pas

@@ -2749,7 +2749,7 @@ var
                           if not StrToInteger64(ExpandConst(ValueData), QV) then
                           if not StrToInteger64(ExpandConst(ValueData), QV) then
                             InternalError('Failed to parse "qword" value');
                             InternalError('Failed to parse "qword" value');
                           ErrorCode := RegSetValueEx(K, PChar(N), 0, REG_QWORD,
                           ErrorCode := RegSetValueEx(K, PChar(N), 0, REG_QWORD,
-                            @TLargeInteger(QV), SizeOf(TLargeInteger(QV)));
+                            @QV, SizeOf(QV));
                           if (ErrorCode <> ERROR_SUCCESS) and
                           if (ErrorCode <> ERROR_SUCCESS) and
                              not(roNoError in Options) then
                              not(roNoError in Options) then
                             RegError(reRegSetValueEx, RK, S, ErrorCode);
                             RegError(reRegSetValueEx, RK, S, ErrorCode);

+ 15 - 2
Projects/Src/Shared.Int64Em.pas

@@ -17,6 +17,8 @@ interface
 type
 type
   Integer64 = record
   Integer64 = record
     Lo, Hi: LongWord;
     Lo, Hi: LongWord;
+    class operator Implicit(const A: Integer64): Int64;
+    class operator Implicit(const A: Int64): Integer64;
   end;
   end;
 
 
 function Compare64(const N1, N2: Integer64): Integer;
 function Compare64(const N1, N2: Integer64): Integer;
@@ -289,8 +291,19 @@ end;
 
 
 function To64(const Lo: Longword): Integer64;
 function To64(const Lo: Longword): Integer64;
 begin
 begin
-  Result.Lo  := Lo;
-  Result.Hi := 0;
+  Result := Lo;
+end;
+
+{ Integer64 }
+
+class operator Integer64.Implicit(const A: Int64): Integer64;
+begin
+  Int64Rec(Result) := Int64Rec(A);
+end;
+
+class operator Integer64.Implicit(const A: Integer64): Int64;
+begin
+  Int64Rec(Result) := Int64Rec(A);
 end;
 end;
 
 
 end.
 end.