From ca1d14c651b0bd5457800e6daf0f57a01d042f88 Mon Sep 17 00:00:00 2001 From: Bergmann89 Date: Wed, 2 Sep 2015 19:29:53 +0200 Subject: [PATCH] * fixed some compiler warnings and errors in Delphi XE 8 and Delphi 7 --- examples/Delphi/Delphi.cfg | 8 ++++---- examples/Delphi/Delphi.dof | 7 +++---- examples/utils/dglOpenGL.pas | 2 -- examples/utils/uglcContext.pas | 16 ++++++++-------- examples/utils/uglcContextWGL.pas | 2 +- utsFontCreatorGDI.pas | 20 ++++++++++---------- utsGDI.pas | 2 +- utsOpenGLUtils.pas | 1 + utsTextSuite.pas | 19 +++++++++++-------- utsTtfUtils.pas | 16 ++++++++-------- utsUtils.pas | 1 - 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/examples/Delphi/Delphi.cfg b/examples/Delphi/Delphi.cfg index 273c18c..9574168 100644 --- a/examples/Delphi/Delphi.cfg +++ b/examples/Delphi/Delphi.cfg @@ -33,10 +33,10 @@ -K$00400000 -LE"c:\zusatzprogramme\delphi 7\Projects\Bpl" -LN"c:\zusatzprogramme\delphi 7\Projects\Bpl" --U"..\..;..\utils" --O"..\..;..\utils" --I"..\..;..\utils" --R"..\..;..\utils" +-U"..\utils;..\.." +-O"..\utils;..\.." +-I"..\utils;..\.." +-R"..\utils;..\.." -w-UNSAFE_TYPE -w-UNSAFE_CODE -w-UNSAFE_CAST diff --git a/examples/Delphi/Delphi.dof b/examples/Delphi/Delphi.dof index 79fc2c0..8e33096 100644 --- a/examples/Delphi/Delphi.dof +++ b/examples/Delphi/Delphi.dof @@ -94,7 +94,7 @@ OutputDir= UnitOutputDir= PackageDLLOutputDir= PackageDCPOutputDir= -SearchPath=..\..;..\utils +SearchPath=..\utils;..\.. Packages=rtl;vcl;vclie;xmlrtl;inet;inetdbbde;inetdbxpress;vclx;dbrtl;soaprtl;dsnap;VclSmp;dbexpress;vcldb;dbxcds;adortl;ibxpress;vclactnband;bdertl;vclshlctrls;dclOfficeXP Conditionals= DebugSourceDirs= @@ -134,6 +134,5 @@ Comments= Count=1 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [HistoryLists\hlSearchPath] -Count=2 -Item0=..\..;..\utils -Item1=..\..;..\lib +Count=1 +Item0=..\utils;..\.. diff --git a/examples/utils/dglOpenGL.pas b/examples/utils/dglOpenGL.pas index 7772eee..17e6cdf 100644 --- a/examples/utils/dglOpenGL.pas +++ b/examples/utils/dglOpenGL.pas @@ -14877,8 +14877,6 @@ begin if LibHandle = nil then LibHandle := GL_LibHandle; - Result := nil; - {$IFDEF DGL_WIN} Result := GetProcAddress({%H-}HMODULE(LibHandle), ProcName); diff --git a/examples/utils/uglcContext.pas b/examples/utils/uglcContext.pas index 73f419a..4d4468f 100644 --- a/examples/utils/uglcContext.pas +++ b/examples/utils/uglcContext.pas @@ -181,6 +181,7 @@ begin GL_DEBUG_TYPE_OTHER_ARB : typ:= 'OTHER'; end; + sv := svLow; case severity of GL_DEBUG_SEVERITY_LOW_ARB: sv := svLow; GL_DEBUG_SEVERITY_MEDIUM_ARB: sv := svMedium; @@ -207,6 +208,7 @@ begin end; src:= 'GL_' + src; + sv := svLow; case severity of GL_DEBUG_SEVERITY_LOW_AMD: sv := svLow; GL_DEBUG_SEVERITY_MEDIUM_AMD: sv := svMedium; @@ -288,17 +290,15 @@ end; class function TglcContext.GetPlatformClass: TglcContextClass; begin - Result := nil; - {$IFDEF WINDOWS} + {$IF DEFINED(WINDOWS)} Result:= TglcContextWGL; - {$ELSE}{$IFDEF WIN32} + {$ELSEIF DEFINED(WIN32)} Result:= TglcContextWGL; - {$ENDIF}{$ENDIF} - {$IFDEF LINUX} + {$ELSEIF DEFINED(LINUX)} Result:= TglcContextGtk2GLX; - {$ENDIF} - if not Assigned(result) then - raise EGLError.Create('unable to find suitabe context class'); + {$ELSE} + raise EGLError.Create('unable to find suitabe context class'); + {$IFEND} end; class function TglcContext.IsAnyContextActive: boolean; diff --git a/examples/utils/uglcContextWGL.pas b/examples/utils/uglcContextWGL.pas index 16fc885..9da5054 100644 --- a/examples/utils/uglcContextWGL.pas +++ b/examples/utils/uglcContextWGL.pas @@ -157,7 +157,7 @@ var else if multiEXTSup then wglChoosePixelFormatEXT(tmpContext.FDC, @IAttrib[0], @FAttrib, MaxCount, pPFList, @Count); - if Count > length(PFList) then + if Integer(Count) > length(PFList) then Count := length(PFList); QueryAtrib := WGL_SAMPLES_ARB; diff --git a/utsFontCreatorGDI.pas b/utsFontCreatorGDI.pas index 12df120..a3b6001 100644 --- a/utsFontCreatorGDI.pas +++ b/utsFontCreatorGDI.pas @@ -123,9 +123,9 @@ end; procedure TtsFontRegistrationFile.UnregisterFont; begin if Assigned(RemoveFontResourceExA) then - RemoveFontResourceExA(PAnsiChar(fFilename), 0, nil) + RemoveFontResourceExA(PAnsiChar(AnsiString(fFilename)), 0, nil) else if Assigned(RemoveFontResourceA) then - RemoveFontResourceA(PAnsiChar(fFilename)); + RemoveFontResourceA(PAnsiChar(AnsiString(fFilename))); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -143,9 +143,9 @@ begin // register font if Assigned(AddFontResourceExA) then - fIsRegistered := (AddFontResourceExA(PAnsiChar(fFilename), 0, nil) > 0) + fIsRegistered := (AddFontResourceExA(PAnsiChar(AnsiString(fFilename)), 0, nil) > 0) else if Assigned(AddFontResourceA) then - fIsRegistered := (AddFontResourceA(PAnsiChar(fFilename)) > 0) + fIsRegistered := (AddFontResourceA(PAnsiChar(AnsiString(fFilename))) > 0) else fIsRegistered := false; end; @@ -295,7 +295,7 @@ begin exit; w := Metric.gmBlackBoxX; h := Metric.gmBlackBoxY; - srcW := (Size div h) * 8; + srcW := (Integer(Size) div h) * 8; if (w <= 0) or (h <= 0) then exit; aImage.CreateEmpty(aFont.Renderer.Format, w, h); @@ -316,7 +316,8 @@ end; procedure TtsFontGeneratorGDI.GetCharImageAANormal(const aDC: HDC; const aFont: TtsFontGDI; const aCharCode: WideChar; const aImage: TtsImage); var Metric: TGlyphMetrics; - GlyphIndex, OutlineRes, tmp, Spacer, x, y, w, h: Integer; + OutlineRes: DWORD; + GlyphIndex, tmp, Spacer, x, y, w, h: Integer; Size: Cardinal; Buffer, pSrc, pDst: PByte; @@ -390,7 +391,7 @@ var DC: HDC; TableName, BufSize: Cardinal; Buffer: PByte; - Lang: AnsiString; + Lang, tmpName: AnsiString; TextMetric: TTextMetricW; OutlineMetric: TOutlineTextmetricW; @@ -403,8 +404,6 @@ var end; begin - result := 0; - FillChar(aProperties, SizeOf(aProperties), #0); aProperties.Size := aSize; aProperties.Style := aStyle; @@ -413,8 +412,9 @@ begin // prepare font attribs FillChar(LogFont, SizeOf(LogFont), #0); + tmpName := AnsiString(aFontname); for i := 1 to min(Length(aFontname), Length(LogFont.lfFaceName)) do - LogFont.lfFaceName[i-1] := aFontname[i]; + LogFont.lfFaceName[i-1] := tmpName[i]; LogFont.lfCharSet := DEFAULT_CHARSET; LogFont.lfHeight := -aSize; LogFont.lfWeight := _(tsStyleBold in aStyle, FW_BOLD, FW_NORMAL); diff --git a/utsGDI.pas b/utsGDI.pas index e526464..ec06408 100644 --- a/utsGDI.pas +++ b/utsGDI.pas @@ -242,7 +242,7 @@ procedure InitGDI; function GetProcAddr(const aLibHandle: TLibHandle; const aName: String): Pointer; begin - result := GetProcAddress(aLibHandle, PAnsiChar(aName)); + result := GetProcAddress(aLibHandle, PAnsiChar(AnsiString(aName))); if not Assigned(result) then raise EtsException.Create('unable to load procedure from library: ' + aName); end; diff --git a/utsOpenGLUtils.pas b/utsOpenGLUtils.pas index 9f68e29..fa50bf2 100644 --- a/utsOpenGLUtils.pas +++ b/utsOpenGLUtils.pas @@ -279,6 +279,7 @@ var var w, h: Integer; begin + result := false; w := X2 - X1; h := Y2 - Y1; if not Assigned(aItem) or diff --git a/utsTextSuite.pas b/utsTextSuite.pas index 8501c67..1a58fa5 100644 --- a/utsTextSuite.pas +++ b/utsTextSuite.pas @@ -140,9 +140,9 @@ type fChars: array[Byte] of PtsFontCharArray; fCreateChars: Boolean; - function HasChar(const aCharCode: WideChar): Boolean; + //function HasChar(const aCharCode: WideChar): Boolean; function GetChar(const aCharCode: WideChar): TtsChar; - function GetCharCreate(const aCharCode: WideChar): TtsChar; + //function GetCharCreate(const aCharCode: WideChar): TtsChar; procedure AddChar(const aCharCode: WideChar; const aChar: TtsChar); overload; protected constructor Create(const aRenderer: TtsRenderer; const aGenerator: TtsFontGenerator; const aProperties: TtsFontProperties); @@ -911,9 +911,9 @@ var // read color and clear channels v := 0; tsFormatUnmap(aSrc.Format, src, c); - for j := 0 to 3 do - if (TtsColorChannel(j) in aChannelMask) then - c.arr[j] := 0; + for i := 0 to 3 do + if (TtsColorChannel(i) in aChannelMask) then + c.arr[i] := 0; // do blur for i := 0 to aKernel.ItemCount-1 do with aKernel.Items[i] do begin @@ -927,9 +927,9 @@ var end; // calc final color and write - for j := 0 to 3 do + for i := 0 to 3 do if (TtsColorChannel(i) in aChannelMask) then - c.arr[j] := c.arr[j] / v; + c.arr[i] := c.arr[i] / v; tsFormatMap(aDst.Format, dst, c); end; end; @@ -978,10 +978,12 @@ end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TtsFont/////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +{ function TtsFont.HasChar(const aCharCode: WideChar): Boolean; begin result := Assigned(GetChar(aCharCode)); end; +} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function TtsFont.GetChar(const aCharCode: WideChar): TtsChar; @@ -996,12 +998,14 @@ begin end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +{ function TtsFont.GetCharCreate(const aCharCode: WideChar): TtsChar; begin result := GetChar(aCharCode); if not Assigned(result) then result := AddChar(aCharCode); end; +} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TtsFont.AddChar(const aCharCode: WideChar; const aChar: TtsChar); @@ -1664,7 +1668,6 @@ var else Dispose(p); - p := nil; end; end; diff --git a/utsTtfUtils.pas b/utsTtfUtils.pas index 31bf9bf..7ccc00a 100644 --- a/utsTtfUtils.pas +++ b/utsTtfUtils.pas @@ -16,10 +16,10 @@ const NAME_ID_FULL_NAME = 4; function MakeTTTableName(const ch1, ch2, ch3, ch4: Char): Cardinal; -function GetTTString(pBuffer: Pointer; BufferSize: Integer; NameID, LanguageID: Cardinal; var Text: AnsiString): Boolean; +function GetTTString(pBuffer: Pointer; BufferSize: Integer; NameID, LanguageID: Cardinal; var Text: String): Boolean; -function GetTTFontFullNameFromStream(Stream: TStream; LanguageID: Cardinal): AnsiString; -function GetTTFontFullNameFromFile(Filename: AnsiString; LanguageID: Cardinal): AnsiString; +function GetTTFontFullNameFromStream(Stream: TStream; LanguageID: Cardinal): String; +function GetTTFontFullNameFromFile(const aFilename: String; const aLanguageID: Cardinal): String; implementation @@ -141,7 +141,7 @@ begin Result := ord(ch4) shl 24 or ord(ch3) shl 16 or ord(ch2) shl 8 or ord(ch1); end; -function GetTTString(pBuffer: Pointer; BufferSize: Integer; NameID, LanguageID: Cardinal; var Text: AnsiString): Boolean; +function GetTTString(pBuffer: Pointer; BufferSize: Integer; NameID, LanguageID: Cardinal; var Text: String): Boolean; var pActBuffer: pByte; ttNTHeader: TT_NAME_TABLE_HEADER; @@ -287,7 +287,7 @@ begin end; end; -function GetTTFontFullNameFromStream(Stream: TStream; LanguageID: Cardinal): AnsiString; +function GetTTFontFullNameFromStream(Stream: TStream; LanguageID: Cardinal): String; var TableName: Cardinal; Buffer: Pointer; @@ -309,13 +309,13 @@ begin end; end; -function GetTTFontFullNameFromFile(Filename: AnsiString; LanguageID: Cardinal): AnsiString; +function GetTTFontFullNameFromFile(const aFilename: String; const aLanguageID: Cardinal): String; var fs: TFileStream; begin - fs := TFileStream.Create(String(Filename), fmOpenRead or fmShareDenyWrite); + fs := TFileStream.Create(aFilename, fmOpenRead or fmShareDenyWrite); try - result := GetTTFontFullNameFromStream(fs, LanguageID); + result := GetTTFontFullNameFromStream(fs, aLanguageID); finally fs.Free; end; diff --git a/utsUtils.pas b/utsUtils.pas index 237ca02..807a1ac 100644 --- a/utsUtils.pas +++ b/utsUtils.pas @@ -74,7 +74,6 @@ end; function tsAnsiToWide(aDst: PWideChar; const aSize: Integer; aSrc: PAnsiChar; const aCodePage: TtsCodePage; const aDefaultChar: WideChar): Integer; begin - result := 0; case aCodePage of tsUTF8: result := tsUTF8ToWide(aDst, aSize, aSrc, aDefaultChar);