LCL: Remove tests for define WithOldDebugln. It has been there since 2012.

This commit is contained in:
Juha 2021-10-26 13:32:39 +03:00
parent 9a8163981a
commit d5596c80a9
4 changed files with 0 additions and 542 deletions

View File

@ -182,12 +182,8 @@ type
{$endif}
{$ifdef CD_Android}
CombiningAccent: Cardinal;
{$IFnDEF WithOldDebugln}
procedure AndroidDebugLn(ASender: TObject; AStr: string; var AHandled: Boolean;
Target: TLazLoggerWriteTarget; Data: Pointer);
{$ELSE}
procedure AndroidDebugLn(AStr: string);
{$ENDIF}
function AndroidKeyCodeToLCLKeyCode(AAndroidKeyCode: Integer): Word;
function DoOpenURLWidgetsetImplementation(AURL: string): Boolean;
function DoOpenDocumentWidgetsetImplementation(APath: string): Boolean;
@ -239,12 +235,8 @@ type
// Mobile emulator and mobile mode
MobileMainForm: TLCLIntfHandle;
// For unusual implementations of DebugLn/DebugOut
{$IFnDEF WithOldDebugln}
procedure AccumulatingDebugOut(ASender: TObject; AStr: string; var AHandled: Boolean;
Target: TLazLoggerWriteTarget; Data: Pointer);
{$ELSE}
procedure AccumulatingDebugOut(AStr: string);
{$ENDIF}
//
procedure CDSetFocusToControl(ALCLControl, AIntfControl: TWinControl);
//

View File

@ -9,7 +9,6 @@
}
//---------------------------------------------------------------
{$IFnDEF WithOldDebugln}
procedure TCDWidgetSet.AccumulatingDebugOut(ASender: TObject; AStr: string; var AHandled: Boolean;
Target: TLazLoggerWriteTarget; Data: Pointer);
begin
@ -17,12 +16,6 @@ begin
if not AHandled then exit;
AccumulatedStr := AccumulatedStr + AStr;
end;
{$ELSE}
procedure TCDWidgetSet.AccumulatingDebugOut(AStr: string);
begin
AccumulatedStr := AccumulatedStr + AStr;
end;
{$ENDIF}
procedure TCDWidgetSet.CDSetFocusToControl(ALCLControl, AIntfControl: TWinControl);
var

View File

@ -613,7 +613,6 @@ procedure JNI_OnUnload(vm:PJavaVM;reserved:pointer); cdecl;
begin
end;
{$IFnDEF WithOldDebugln}
procedure TCDWidgetSet.AndroidDebugLn(ASender: TObject; AStr: string; var AHandled: Boolean;
Target: TLazLoggerWriteTarget; Data: Pointer);
begin
@ -622,13 +621,6 @@ begin
__android_log_write(ANDROID_LOG_INFO, 'lclapp', PChar(AccumulatedStr+AStr));
AccumulatedStr := '';
end;
{$ELSE}
procedure TCDWidgetSet.AndroidDebugLn(AStr: string);
begin
__android_log_write(ANDROID_LOG_INFO, 'lclapp', PChar(AccumulatedStr+AStr));
AccumulatedStr := '';
end;
{$ENDIF}
function TCDWidgetSet.AndroidKeyCodeToLCLKeyCode(AAndroidKeyCode: Integer): Word;
var
@ -1154,13 +1146,8 @@ end;
procedure TCDWidgetSet.BackendCreate;
begin
// Setup DebugLn
{$IFnDEF WithOldDebugln}
OnWidgetSetDebugLn := @AndroidDebugLn;
OnWidgetSetDbgOut := @AccumulatingDebugOut;
{$ELSE}
DebugLnProc := @AndroidDebugLn;
DebugOutProc := @AccumulatingDebugOut;
{$ENDIF}
{$ifdef CD_UseNativeText}
// Create the dummy screen DC

View File

@ -139,7 +139,6 @@ function CompareCaret(const FirstCaret, SecondCaret: TPoint): integer;
// Call debugging procedure in LazLoggerBase.
procedure RaiseGDBException(const Msg: string); inline;
{$IFnDEF WithOldDebugln}
procedure DbgOut(const s: string = ''); inline; overload;
procedure DbgOut(Args: array of const); {inline;} overload;
procedure DbgOut(const S: String; Args: array of const); {inline;} overload;// similar to Format(s,Args)
@ -181,62 +180,6 @@ procedure DebugLnExit (const s1, s2: string; const s3: string = '';
const s16: string = ''; const s17: string = ''; const s18: string = ''); inline; overload;
procedure CloseDebugOutput; inline;
{$ELSE}
procedure DebugLn(Args: array of const); overload;
procedure DebugLn(const S: String; Args: array of const); overload;// similar to Format(s,Args)
procedure DebugLn; overload;
procedure DebugLn(const s: string); overload;
procedure DebugLn(const s1,s2: string); overload;
procedure DebugLn(const s1,s2,s3: string); overload;
procedure DebugLn(const s1,s2,s3,s4: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7,s8: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7,s8,s9: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15: string); overload;
procedure DebugLn(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16: string); overload;
procedure DebugLnEnter(const s: string = ''); overload;
procedure DebugLnEnter(Args: array of const); overload;
procedure DebugLnEnter(s: string; Args: array of const); overload;
procedure DebugLnEnter(const s1, s2: string; const s3: string = '';
const s4: string = ''; const s5: string = ''; const s6: string = '';
const s7: string = ''; const s8: string = ''; const s9: string = '';
const s10: string = ''; const s11: string = ''; const s12: string = '';
const s13: string = ''; const s14: string = ''; const s15: string = '';
const s16: string = ''; const s17: string = ''; const s18: string = ''); overload;
procedure DebugLnExit(const s: string = ''); overload;
procedure DebugLnExit(Args: array of const); overload;
procedure DebugLnExit(s: string; Args: array of const); overload;
procedure DebugLnExit (const s1, s2: string; const s3: string = '';
const s4: string = ''; const s5: string = ''; const s6: string = '';
const s7: string = ''; const s8: string = ''; const s9: string = '';
const s10: string = ''; const s11: string = ''; const s12: string = '';
const s13: string = ''; const s14: string = ''; const s15: string = '';
const s16: string = ''; const s17: string = ''; const s18: string = ''); overload;
procedure DbgOut(const S: String; Args: array of const); overload;
procedure DbgOut(const s: string); overload;
procedure DbgOut(const s1,s2: string); overload;
procedure DbgOut(const s1,s2,s3: string); overload;
procedure DbgOut(const s1,s2,s3,s4: string); overload;
procedure DbgOut(const s1,s2,s3,s4,s5: string); overload;
procedure DbgOut(const s1,s2,s3,s4,s5,s6: string); overload;
procedure DbgOut(const s1,s2,s3,s4,s5,s6,s7: string); overload;
procedure DbgOut(const s1,s2,s3,s4,s5,s6,s7,s8: string); overload;
procedure DbgOut(const s1,s2,s3,s4,s5,s6,s7,s8,s9: string); overload;
procedure DbgOut(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10: string); overload;
procedure DbgOut(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11: string); overload;
procedure DbgOut(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12: string); overload;
procedure CloseDebugOutput;
{$ENDIF}
function DbgS(const c: cardinal): string; overload; inline;
function DbgS(const i: longint): string; overload; inline;
@ -301,37 +244,15 @@ function CreateNextIdentifier(const Identifier: string): string;
// Font
function IsFontNameDefault(const AName: string): boolean; inline;
{$IFDEF WithOldDebugln}
type
TDebugLnProc = procedure (s: string) of object;
var
DebugLnMaxNestPrefixLen: Integer = 15;
DebugLnNestLvlIndent: Integer = 2;
DebugText: ^Text;
DebugLnProc: TDebugLnProc = nil;
DebugOutProc: TDebugLnProc = nil;
{$ENDIF}
implementation
const
{$IFDEF WithOldDebugln}
Str_LCL_Debug_File = 'lcldebug.log';
{$ENDIF}
UNKNOWN_VK_PREFIX = 'Word(''';
UNKNOWN_VK_POSTFIX = ''')';
var
InterfaceInitializationHandlers: TFPList = nil;
InterfaceFinalizationHandlers: TFPList = nil;
{$IFDEF WithOldDebugln}
DebugTextAllocated: boolean;
DebugNestLvl: Integer = 0;
DebugNestPrefix: PChar = nil;
DebugNestAtBOL: Boolean;
{$ENDIF}
function DeleteAmpersands(var Str : String) : Integer;
// Replace all &x with x and return the position of the first accelerator letter in
@ -1261,7 +1182,6 @@ begin
LazTracer.RaiseGDBException(Msg);
end;
{$IFnDEF WithOldDebugln}
procedure CloseDebugOutput;
begin
DebugLogger.Finish;
@ -1361,434 +1281,6 @@ begin
DebugLogger.DebugLnExit(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18);
end;
{$ELSE}
procedure InitializeDebugOutput;
var
DebugFileName: string;
function GetDebugFileName: string;
const
DebugLogStart = '--debug-log=';
DebugLogStartLength = length(DebugLogStart);
var
i: integer;
EnvVarName: string;
begin
Result := '';
// first try to find the log file name in the command line parameters
for i:= 1 to Paramcount do begin
if copy(ParamStrUTF8(i),1, DebugLogStartLength)=DebugLogStart then begin
Result := copy(ParamStrUTF8(i), DebugLogStartLength+1,
Length(ParamStrUTF8(i))-DebugLogStartLength);
end;
end;
// if not found yet, then try to find in the environment variables
if (length(result)=0) then begin
EnvVarName:= ChangeFileExt(ExtractFileName(ParamStrUTF8(0)),'') + '_debuglog';
Result := GetEnvironmentVariableUTF8(EnvVarName);
end;
if (length(result)>0) then
Result := ExpandFileNameUTF8(Result);
end;
var
fm: Byte;
begin
DebugText := nil;
DebugFileName := GetDebugFileName;
if (length(DebugFileName)>0) and
(DirPathExists(ExtractFileDir(DebugFileName))) then
begin
fm:=Filemode;
new(DebugText);
try
Filemode:=fmShareDenyNone;
Assign(DebugText^, DebugFileName);
if FileExistsUTF8(DebugFileName) then
Append(DebugText^)
else
Rewrite(DebugText^);
except
Freemem(DebugText);
DebugText := nil;
// Add extra line ending: a dialog will be shown in windows gui application
writeln(StdOut, 'Cannot open file: ', DebugFileName+LineEnding);
end;
Filemode:=fm;
end;
if DebugText=nil then
begin
if TextRec(Output).Mode=fmClosed then
DebugText := nil
else
DebugText := @Output;
DebugTextAllocated := false;
end else
DebugTextAllocated := true;
end;
procedure CloseDebugOutput;
begin
if DebugTextAllocated then begin
Close(DebugText^);
Dispose(DebugText);
DebugTextAllocated := false;
end;
DebugText := nil;
end;
procedure FinalizeDebugOutput;
begin
CloseDebugOutput;
end;
procedure DebugLnNestCreatePrefix;
const
CurrentLen: Integer = 0;
var
s: String;
NewLen: Integer;
begin
NewLen := DebugNestLvl * DebugLnNestLvlIndent;
if NewLen < 0 then NewLen := 0;
if (NewLen >= DebugLnMaxNestPrefixLen) then begin
NewLen := DebugLnMaxNestPrefixLen;
s := IntToStr(DebugNestLvl);
if length(s)+1 > NewLen then
NewLen := length(s)+1;
end else
s := '';
if NewLen > CurrentLen then
ReAllocMem(DebugNestPrefix, NewLen+21);
CurrentLen := NewLen+20;
FillChar(DebugNestPrefix^, NewLen, ' ');
if s <> '' then
System.Move(s[1], DebugNestPrefix[0], length(s));
if (NewLen >= DebugLnMaxNestPrefixLen) then
DebugNestPrefix[DebugLnMaxNestPrefixLen] := #0
else
DebugNestPrefix[NewLen] := #0;
end;
procedure DebugLnNestFreePrefix;
begin
if DebugNestPrefix <> nil then
ReAllocMem(DebugNestPrefix, 0);
end;
procedure DumpStack;
begin
if Assigned(DebugText) then
Dump_Stack(DebugText^, get_frame);
end;
procedure DebugLn(Args: array of const);
var
i: Integer;
begin
for i:=Low(Args) to High(Args) do begin
case Args[i].VType of
vtInteger: DbgOut(dbgs(Args[i].vinteger));
vtInt64: DbgOut(dbgs(Args[i].VInt64^));
vtQWord: DbgOut(dbgs(Args[i].VQWord^));
vtBoolean: DbgOut(dbgs(Args[i].vboolean));
vtExtended: DbgOut(dbgs(Args[i].VExtended^));
{$ifdef FPC_CURRENCY_IS_INT64}
// MWE:
// fpc 2.x has troubles in choosing the right dbgs()
// so we convert here
vtCurrency: DbgOut(dbgs(int64(Args[i].vCurrency^)/10000, 4));
{$else}
vtCurrency: DbgOut(dbgs(Args[i].vCurrency^));
{$endif}
vtString: DbgOut(Args[i].VString^);
vtAnsiString: DbgOut(AnsiString(Args[i].VAnsiString));
vtChar: DbgOut(Args[i].VChar);
vtPChar: DbgOut(Args[i].VPChar);
vtPWideChar: DbgOut(Args[i].VPWideChar);
vtWideChar: DbgOut(AnsiString(Args[i].VWideChar));
vtWidestring: DbgOut(AnsiString(WideString(Args[i].VWideString)));
vtUnicodeString: DbgOut(AnsiString(UnicodeString(Args[i].VUnicodeString)));
vtObject: DbgOut(DbgSName(Args[i].VObject));
vtClass: DbgOut(DbgSName(Args[i].VClass));
vtPointer: DbgOut(Dbgs(Args[i].VPointer));
else
DbgOut('?unknown variant?');
end;
end;
DebugLn;
end;
procedure DebugLn(const S: String; Args: array of const);
begin
DebugLn(Format(S, Args));
end;
procedure DebugLn;
begin
DebugLn('');
end;
procedure DebugLn(const s: string);
begin
{$ifdef WinCE}
if DebugNestAtBOL and (s <> '') then
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + Str_LCL_Debug_File, DebugNestPrefix+s)
else
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + Str_LCL_Debug_File, s);
{$else}
// First of all verify if a widgetset has override DebugLn
if DebugLnProc <> nil then
begin
DebugLnProc(s);
Exit;
end;
// Now the default code
if not Assigned(DebugText) then exit;
if DebugNestAtBOL and (s <> '') then
write(DebugText^, DebugNestPrefix);
writeln(DebugText^, ConvertLineEndings(s));
{$endif}
DebugNestAtBOL := True;
end;
procedure DebugLn(const s1, s2: string);
begin
DebugLn(s1+s2);
end;
procedure DebugLn(const s1, s2, s3: string);
begin
DebugLn(s1+s2+s3);
end;
procedure DebugLn(const s1, s2, s3, s4: string);
begin
DebugLn(s1+s2+s3+s4);
end;
procedure DebugLn(const s1, s2, s3, s4, s5: string);
begin
DebugLn(s1+s2+s3+s4+s5);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7, s8: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7+s8);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7, s8, s9: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7+s8+s9);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11,
s12: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12,
s13: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13,
s14: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13+s14);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13,
s14, s15: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13+s14+s15);
end;
procedure DebugLn(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13,
s14, s15, s16: string);
begin
DebugLn(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13+s14+s15+s16);
end;
procedure DebugLnEnter(const s: string);
begin
if not DebugNestAtBOL then
DebugLn;
if s <> '' then
DebugLn(s);
inc(DebugNestLvl);
DebugLnNestCreatePrefix;
end;
procedure DebugLnEnter(Args: array of const);
begin
if not DebugNestAtBOL then
DebugLn;
DebugLn(Args);
inc(DebugNestLvl);
DebugLnNestCreatePrefix;
end;
procedure DebugLnEnter(s: string; Args: array of const);
begin
DebugLnEnter(Format(s, Args));
end;
procedure DebugLnEnter(const s1: string; const s2: string; const s3: string;
const s4: string; const s5: string; const s6: string; const s7: string;
const s8: string; const s9: string; const s10: string; const s11: string;
const s12: string; const s13: string; const s14: string; const s15: string;
const s16: string; const s17: string; const s18: string);
begin
DebugLnEnter(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13+s14+s15+s16+s17+s18);
end;
procedure DebugLnExit(const s: string);
begin
dec(DebugNestLvl);
if DebugNestLvl < 0 then DebugNestLvl := 0;
DebugLnNestCreatePrefix;
if not DebugNestAtBOL then
DebugLn;
if s <> '' then
DebugLn(s);
end;
procedure DebugLnExit(Args: array of const);
begin
dec(DebugNestLvl);
if DebugNestLvl < 0 then DebugNestLvl := 0;
DebugLnNestCreatePrefix;
if not DebugNestAtBOL then
DebugLn;
DebugLn(Args);
end;
procedure DebugLnExit(s: string; Args: array of const);
begin
DebugLnExit(Format(s, Args));
end;
procedure DebugLnExit(const s1: string; const s2: string; const s3: string;
const s4: string; const s5: string; const s6: string; const s7: string;
const s8: string; const s9: string; const s10: string; const s11: string;
const s12: string; const s13: string; const s14: string; const s15: string;
const s16: string; const s17: string; const s18: string);
begin
DebugLnExit(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13+s14+s15+s16+s17+s18);
end;
procedure DbgOut(const S: String; Args: array of const);
begin
DbgOut(Format(S, Args));
end;
procedure DBGOut(const s: string);
begin
{$ifdef WinCE}
if DebugNestAtBOL and (s <> '') then
DbgAppendToFileWithoutLn(ExtractFilePath(ParamStr(0)) + Str_LCL_Debug_File, DebugNestPrefix);
DbgAppendToFileWithoutLn(ExtractFilePath(ParamStr(0)) + Str_LCL_Debug_File, s);
{$else}
if DebugOutProc <> nil then
begin
DebugOutProc(s);
Exit;
end;
if Assigned(DebugText) then begin
if DebugNestAtBOL and (s <> '') then
write(DebugText^, DebugNestPrefix);
write(DebugText^, s);
end;
{$endif}
DebugNestAtBOL := (s = '') or (s[length(s)] in [#10,#13]);
end;
procedure DBGOut(const s1, s2: string);
begin
DbgOut(s1+s2);
end;
procedure DbgOut(const s1, s2, s3: string);
begin
DbgOut(s1+s2+s3);
end;
procedure DbgOut(const s1, s2, s3, s4: string);
begin
DbgOut(s1+s2+s3+s4);
end;
procedure DbgOut(const s1, s2, s3, s4, s5: string);
begin
DbgOut(s1+s2+s3+s4+s5);
end;
procedure DbgOut(const s1, s2, s3, s4, s5, s6: string);
begin
DbgOut(s1+s2+s3+s4+s5+s6);
end;
procedure DbgOut(const s1, s2, s3, s4, s5, s6, s7: string);
begin
DbgOut(s1+s2+s3+s4+s5+s6+s7);
end;
procedure DbgOut(const s1, s2, s3, s4, s5, s6, s7, s8: string);
begin
DbgOut(s1+s2+s3+s4+s5+s6+s7+s8);
end;
procedure DbgOut(const s1, s2, s3, s4, s5, s6, s7, s8, s9: string);
begin
DbgOut(s1+s2+s3+s4+s5+s6+s7+s8+s9);
end;
procedure DbgOut(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10: string);
begin
DbgOut(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10);
end;
procedure DbgOut(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11: string);
begin
DbgOut(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11);
end;
procedure DbgOut(const s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12: string);
begin
DbgOut(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12);
end;
{$ENDIF}
function DbgS(const c: cardinal): string;
begin
Result:=LazLoggerBase.DbgS(c);
@ -2542,7 +2034,6 @@ begin
end;
initialization
{$IFDEF WithOldDebugln} InitializeDebugOutput; {$ENDIF}
{$ifdef WinCE}
// The stabs based back trace function crashes on wince,
// see http://bugs.freepascal.org/view.php?id=14330
@ -2569,9 +2060,4 @@ finalization
DebugLCLComponents.Free;
DebugLCLComponents:=nil;
{$ENDIF}
{$IFDEF WithOldDebugln}
FinalizeDebugOutput;
DebugLnNestFreePrefix;
{$ENDIF}
end.