OSDN Git Service

Updated Delphi language bindings.
authorLoRd_MuldeR <mulder2@gmx.de>
Sun, 27 Mar 2016 19:34:04 +0000 (21:34 +0200)
committerLoRd_MuldeR <mulder2@gmx.de>
Sun, 27 Mar 2016 19:34:04 +0000 (21:34 +0200)
.gitignore
Make.cmd
bindings/Delphi/example/Example.exe [deleted file]
bindings/Delphi/example/src/Main.pas

index 332e179..87d995a 100644 (file)
@@ -4,16 +4,18 @@
 *.sdf
 *.suo
 *.user
+*.~ddp
 *.~dfm
 *.~dpr
 *.~pas
-*.~ddp
 /bin
 /bindings/Delphi/example/bin/*.dll
 /bindings/Delphi/example/bin/*.exe
 /bindings/Delphi/example/obj/*.dcu
+/bindings/Delphi/example/src/*.dcu
 /bindings/Delphi/native/bin
 /bindings/Delphi/native/obj
+/bindings/Delphi/wrapper/*.dcu
 /bindings/Java/example/bin
 /bindings/Java/example/out
 /bindings/Java/native/bin
index 18bf12b..6da1251 100644 (file)
--- a/Make.cmd
+++ b/Make.cmd
@@ -18,6 +18,9 @@ REM Python Paths
 set "PYTHON_HOME_X86=C:\Program Files (x86)\Python35-32"
 set "PYTHON_HOME_X64=C:\Program Files\Python35"
 
+REM Delphi Paths
+set "DELPHI_PATH=C:\Program Files (x86)\Borland\Delphi7"
+
 
 REM ///////////////////////////////////////////////////////////////////////////
 REM // Check paths
@@ -68,6 +71,10 @@ if not exist "%PYTHON_HOME_X64%\include\Python.h" (
        pause & goto:eof
 )
 
+if not exist "%DELPHI_PATH%\bin\dcc32.exe" (
+       "%~dp0\tools\cecho.exe" RED "\nDelphi not found.\n%DELPHI_PATH:\=\\%\\bin\\dcc32.exe\n"
+       pause & goto:eof
+)
 
 REM ///////////////////////////////////////////////////////////////////////////
 REM // Get current date and time (in ISO format)
@@ -105,6 +112,14 @@ for %%i in (native\obj,native\out) do (
        del /Q /S /F "%~dp0\bindings\Python\%%i\*.*"
 )
 
+for %%i in (exe,dcu) do (
+       del /Q /S /F "%~dp0\bindings\Delphi\*.%%i"
+)
+
+for %%i in (native\obj,native\out) do (
+       del /Q /S /F "%~dp0\bindings\Delphi\%%i\*.*"
+)
+
 
 REM ///////////////////////////////////////////////////////////////////////////
 REM // Build the binaries
@@ -120,6 +135,7 @@ set "MSVC_PROJECTS=MHashLib.sln"
 set "MSVC_PROJECTS=%MSVC_PROJECTS%,bindings\Microsoft.NET\MHashDotNet384.sln"
 set "MSVC_PROJECTS=%MSVC_PROJECTS%,bindings\Java\native\MHashJava384.sln"
 set "MSVC_PROJECTS=%MSVC_PROJECTS%,bindings\Python\native\MHashPy384_Native.sln"
+set "MSVC_PROJECTS=%MSVC_PROJECTS%,bindings\Delphi\native\MHashDelphi384.sln"
 
 for %%q in (%MSVC_PROJECTS%) do (
        for %%p in (x86,x64) do (
@@ -131,6 +147,17 @@ for %%q in (%MSVC_PROJECTS%) do (
        )
 )
 
+for %%q in (example) do (
+       echo pushd "%~dp0\bindings\Delphi\%%~q"
+       pushd "%~dp0\bindings\Delphi\%%~q"
+       for %%p in (*.dpr) do (
+               "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~np ]----\n"
+               "%DELPHI_PATH%\bin\dcc32.exe" -B -CG -$O+ -E"bin" -N"obj" "%%~nxp"
+               if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
+       )
+       popd
+)
+
 for %%q in (wrapper,example) do (
        "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq ]----\n"
        pushd "%~dp0\bindings\Java\%%~q"
@@ -166,6 +193,7 @@ set "OUT_PATH_JNI_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.java-win-x86.zip"
 set "OUT_PATH_JNI_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.java-win-x64.zip"
 set "OUT_PATH_PYC_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.python-win-x86.zip"
 set "OUT_PATH_PYC_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.python-win-x64.zip"
+set "OUT_PATH_PAS_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.delphi-win-x86.zip"
 set "OUT_PATH_SRC_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.sources.tar.gz"
 
 set /a COUNTER=COUNTER+1
@@ -179,6 +207,7 @@ if exist "%OUT_PATH_JNI_X86%" goto GenerateOutfileNameNext
 if exist "%OUT_PATH_JNI_X64%" goto GenerateOutfileNameNext
 if exist "%OUT_PATH_PYC_X86%" goto GenerateOutfileNameNext
 if exist "%OUT_PATH_PYC_X64%" goto GenerateOutfileNameNext
+if exist "%OUT_PATH_PAS_X86%" goto GenerateOutfileNameNext
 if exist "%OUT_PATH_SRC_GEN%" goto GenerateOutfileNameNext
 
 
@@ -200,6 +229,8 @@ REM ///////////////////////////////////////////////////////////////////////////
 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_PYC_X86%" "%~dp0\bindings\Python\native\bin\x86\Release\MHashPy384_Native.x86.pyd" "%~dp0\bindings\Python\wrapper\MHashPy384_Wrapper.py" "%~dp0\bindings\Python\wrapper\mhash.pth" "%~dp0\bindings\Python\example\Example.py" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_PYC_X64%" "%~dp0\bindings\Python\native\bin\x64\Release\MHashPy384_Native.x64.pyd" "%~dp0\bindings\Python\wrapper\MHashPy384_Wrapper.py" "%~dp0\bindings\Python\wrapper\mhash.pth" "%~dp0\bindings\Python\example\Example.py" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
 
+"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_PAS_X86%" "%~dp0\bindings\Delphi\native\bin\x86\Release\MHashDelphi384.x86.dll" "%~dp0\bindings\Delphi\wrapper\MHash384.pas" "%~dp0\bindings\Delphi\example\bin\Example.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
+
 "%GIT2_PATH%\git.exe" archive --format tar.gz -9 --verbose --output "%OUT_PATH_SRC_GEN%" HEAD
 
 
diff --git a/bindings/Delphi/example/Example.exe b/bindings/Delphi/example/Example.exe
deleted file mode 100644 (file)
index 46a4d53..0000000
Binary files a/bindings/Delphi/example/Example.exe and /dev/null differ
index 6473259..1da5c4c 100644 (file)
@@ -160,8 +160,6 @@ begin
 end;
 
 function TComputeThread.GetResult: String;
-var
-  exitCode: Cardinal;
 begin
   Result := hashString;
 end;
@@ -187,31 +185,33 @@ begin
     AssignFile(inputFile, Self.inputFile);
     FileMode := fmOpenRead;
     Reset(inputFile, 1);
-
     try
       digest := TMHash384.Create();
-      while not Eof(inputFile) do
-      begin
-        BlockRead(inputFile, buffer[0], Length(buffer), count);
-        if count > 0 then
+      try
+        while not Eof(inputFile) do
         begin
-          digest.Update(buffer, 0, count);
-          spinner := spinner + 1;
-          processed := processed + count;
-          if spinner >= 100 then
+          BlockRead(inputFile, buffer[0], Length(buffer), count);
+          if count > 0 then
           begin
-            SetProgress(processed, totalSize);
-            spinner := 0;
+            digest.Update(buffer, 0, count);
+            spinner := spinner + 1;
+            processed := processed + count;
+            if spinner >= 100 then
+            begin
+              SetProgress(processed, totalSize);
+              spinner := 0;
+            end;
           end;
         end;
+        digest.Result(result);
+        HashString := ByteToHex(result);
+        ReturnValue := 1;
+      finally
+        digest.Destroy();
+        SetProgress(100, 100);
       end;
-      digest.Result(result);
-      HashString := ByteToHex(result);
-      ReturnValue := 1;
     finally
       CloseFile(inputFile);
-      digest.Destroy();
-      SetProgress(100, 100);
     end;
   except
      on E: Exception do
@@ -251,16 +251,13 @@ var
   nextProgress: Integer;
   totalSizeDbl, processedDbl: Double;
 begin
+  nextProgress := 0;
   if (processed > 0) and (totalSize > 0) then
   begin
     totalSizeDbl := totalSize;
     processedDbl := processed;
     nextProgress := Round((processedDbl / totalSizeDbl) * 100.0);
-  end else
-  begin
-    progressValue := 0;
   end;
-
   if nextProgress <> progressValue then
   begin
     progressValue := nextProgress;