Rename CompareMethods to more logical SameMethod. Remove old deprecated functions.

This commit is contained in:
Juha 2021-10-09 14:04:37 +03:00
parent 114d4a1714
commit 814e4ba4e2
10 changed files with 22 additions and 58 deletions

View File

@ -870,7 +870,7 @@ begin
and (ShowConsole=Source.ShowConsole) and (ShowConsole=Source.ShowConsole)
and (HideWindow=Source.HideWindow) and (HideWindow=Source.HideWindow)
and (ResolveMacros=Source.ResolveMacros) and (ResolveMacros=Source.ResolveMacros)
and CompareMethods(TMethod(CustomMacroFunction),TMethod(Source.CustomMacroFunction)) and SameMethod(TMethod(CustomMacroFunction),TMethod(Source.CustomMacroFunction))
and (Quiet=Source.Quiet); and (Quiet=Source.Quiet);
end else end else
Result:=inherited Equals(Obj); Result:=inherited Equals(Obj);

View File

@ -1324,7 +1324,7 @@ procedure TIDECommand.SetOnExecute(const aOnExecute: TNotifyEvent);
var var
xUser: TIDESpecialCommand; xUser: TIDESpecialCommand;
begin begin
if CompareMethods(TMethod(FOnExecute), TMethod(aOnExecute)) then Exit; if SameMethod(TMethod(FOnExecute), TMethod(aOnExecute)) then Exit;
FOnExecute := aOnExecute; FOnExecute := aOnExecute;
for xUser in FUsers do for xUser in FUsers do
if xUser.SyncProperties then if xUser.SyncProperties then
@ -1822,7 +1822,7 @@ end;
procedure TIDESpecialCommand.SetOnClickMethod(const aOnClick: TNotifyEvent); procedure TIDESpecialCommand.SetOnClickMethod(const aOnClick: TNotifyEvent);
begin begin
if CompareMethods(TMethod(FOnClickMethod), TMethod(aOnClick)) then Exit; if SameMethod(TMethod(FOnClickMethod), TMethod(aOnClick)) then Exit;
FOnClickMethod := aOnClick; FOnClickMethod := aOnClick;
if (FCommand<>nil) and SyncAvailable then if (FCommand<>nil) and SyncAvailable then
FCommand.OnExecute:=aOnClick; FCommand.OnExecute:=aOnClick;

View File

@ -3428,7 +3428,7 @@ begin
begin begin
OldMethod:=GetMethodProp(InstProp.Instance,InstProp.PropInfo); OldMethod:=GetMethodProp(InstProp.Instance,InstProp.PropInfo);
NewMethod:=GetMethodProp(AncestorInstProp.Instance,AncestorInstProp.PropInfo); NewMethod:=GetMethodProp(AncestorInstProp.Instance,AncestorInstProp.PropInfo);
if CompareMethods(OldMethod,NewMethod) then continue; if SameMethod(OldMethod,NewMethod) then continue;
Changed:=true; Changed:=true;
SetMethodProp(InstProp.Instance,InstProp.PropInfo,NewMethod); SetMethodProp(InstProp.Instance,InstProp.PropInfo,NewMethod);
end; end;

View File

@ -471,7 +471,7 @@ begin
if not CheckFromAction then begin if not CheckFromAction then begin
if Assigned(OnClick) then if Assigned(OnClick) then
if not (Assigned(Action) and if not (Assigned(Action) and
CompareMethods(TMethod(Action.OnExecute), TMethod(OnClick))) SameMethod(TMethod(Action.OnExecute), TMethod(OnClick)))
then OnClick(self); then OnClick(self);
if (Action is TCustomAction) and if (Action is TCustomAction) and
(TCustomAction(Action).Checked <> (AValue = cbChecked)) (TCustomAction(Action).Checked <> (AValue = cbChecked))

View File

@ -64,12 +64,14 @@ type
property AllowDuplicates: boolean read FAllowDuplicates write SetAllowDuplicates; // default false, changed in Lazarus 1.3 property AllowDuplicates: boolean read FAllowDuplicates write SetAllowDuplicates; // default false, changed in Lazarus 1.3
end; end;
function SameMethod(const m1, m2: TMethod): boolean; inline;
function CompareMethods(const m1, m2: TMethod): boolean; inline; function CompareMethods(const m1, m2: TMethod): boolean; inline;
deprecated 'Use SameMethod instead.'; // In 2.3 October 2021. Remove in 2.5.
implementation implementation
function CompareMethods(const m1, m2: TMethod): boolean; function SameMethod(const m1, m2: TMethod): boolean;
begin begin
{$PUSH} {$BOOLEVAL ON} {$PUSH} {$BOOLEVAL ON}
// With a full evaluation of the boolean expression the generated code will not // With a full evaluation of the boolean expression the generated code will not
@ -78,6 +80,11 @@ begin
{$POP} {$POP}
end; end;
function CompareMethods(const m1, m2: TMethod): boolean;
begin
Result := SameMethod(m1, m2);
end;
{ TMethodList.TItemsEnumerator } { TMethodList.TItemsEnumerator }
function TMethodList.TItemsEnumerator.GetCurrent: TMethod; function TMethodList.TItemsEnumerator.GetCurrent: TMethod;
@ -140,7 +147,7 @@ begin
j:=i+1; j:=i+1;
while j<FCount do while j<FCount do
begin begin
if CompareMethods(FItems[i], FItems[j]) then if SameMethod(FItems[i], FItems[j]) then
Delete(j) Delete(j)
else else
inc(j); inc(j);
@ -212,7 +219,7 @@ begin
if Self<>nil then begin if Self<>nil then begin
Result:=FCount-1; Result:=FCount-1;
while Result>=0 do begin while Result>=0 do begin
if CompareMethods(FItems[Result], AMethod) then if SameMethod(FItems[Result], AMethod) then
Exit; Exit;
dec(Result); dec(Result);
end; end;

View File

@ -372,7 +372,8 @@ begin
FreeAndNil(InputHistories); FreeAndNil(InputHistories);
FreeAndNil(DefaultCfgVars); FreeAndNil(DefaultCfgVars);
if CompareMethods(TMethod(CodeToolBoss.OnRescanFPCDirectoryCache), TMethod(@DoOnRescanFPCDirectoryCache)) then if SameMethod(TMethod(CodeToolBoss.OnRescanFPCDirectoryCache),
TMethod(@DoOnRescanFPCDirectoryCache)) then
CodeToolBoss.OnRescanFPCDirectoryCache:=nil; CodeToolBoss.OnRescanFPCDirectoryCache:=nil;
inherited Destroy; inherited Destroy;

View File

@ -4432,8 +4432,8 @@ begin
Project1.DefineTemplates.AllChanged(false); Project1.DefineTemplates.AllChanged(false);
IncreaseBuildMacroChangeStamp; IncreaseBuildMacroChangeStamp;
MainBuildBoss.SetBuildTargetProject1(false); MainBuildBoss.SetBuildTargetProject1(false);
MainIDE.UpdateCaption; UpdateCaption;
MainIDE.UpdateDefineTemplates; UpdateDefineTemplates;
end; end;
end; end;
@ -4640,7 +4640,7 @@ end;
procedure TMainIDE.mnuStopProjectClicked(Sender: TObject); procedure TMainIDE.mnuStopProjectClicked(Sender: TObject);
begin begin
if (MainIDE.ToolStatus = itBuilder) then if (ToolStatus = itBuilder) then
mnuAbortBuildProjectClicked(Sender) mnuAbortBuildProjectClicked(Sender)
else else
DebugBoss.DoStopProject; DebugBoss.DoStopProject;

View File

@ -2942,7 +2942,7 @@ procedure TControl.Click;
if Action=nil then exit; if Action=nil then exit;
if not Assigned(Action.OnExecute) then exit; if not Assigned(Action.OnExecute) then exit;
if not Assigned(FOnClick) then exit; if not Assigned(FOnClick) then exit;
Result:=CompareMethods(TMethod(FOnClick),TMethod(Action.OnExecute)); Result:=SameMethod(TMethod(FOnClick),TMethod(Action.OnExecute));
end; end;
var var

View File

@ -57,7 +57,7 @@ procedure TMenuItem.Click;
if Action=nil then exit; if Action=nil then exit;
if not Assigned(Action.OnExecute) then exit; if not Assigned(Action.OnExecute) then exit;
if not Assigned(FOnClick) then exit; if not Assigned(FOnClick) then exit;
Result:=CompareMethods(TMethod(FOnClick),TMethod(Action.OnExecute)); Result:=SameMethod(TMethod(FOnClick),TMethod(Action.OnExecute));
end; end;
var var

View File

@ -136,15 +136,6 @@ function CompareRect(R1, R2: PRect): Boolean;
function ComparePoints(const p1, p2: TPoint): integer; function ComparePoints(const p1, p2: TPoint): integer;
function CompareCaret(const FirstCaret, SecondCaret: TPoint): integer; function CompareCaret(const FirstCaret, SecondCaret: TPoint): integer;
// Deprecated in 2.1 / 12.12.2020 / Remove in 2.3
function CompareMethods(m1, m2: TMethod): boolean; deprecated 'Use LazMethodList.CompareMethods';
function ComparePointers(p1, p2: Pointer): integer; deprecated 'Use LazUtilities.ComparePointers';
function RoundToInt(e: Extended): integer; deprecated 'Use LazUtilities.RoundToInt';
function RoundToCardinal(e: Extended): cardinal; deprecated 'Use LazUtilities.RoundToCardinal';
function TruncToInt(e: Extended): integer; deprecated 'Use LazUtilities.TruncToInt';
function TruncToCardinal(e: Extended): cardinal; deprecated 'Use LazUtilities.TruncToCardinal';
function StrToDouble(const s: string): double; deprecated 'Use LazUtilities.StrToDouble';
// Call debugging procedure in LazLoggerBase. // Call debugging procedure in LazLoggerBase.
procedure RaiseGDBException(const Msg: string); inline; procedure RaiseGDBException(const Msg: string); inline;
@ -1085,41 +1076,6 @@ begin
Result:=0; Result:=0;
end; end;
function CompareMethods(m1, m2: TMethod): boolean;
begin
Result:=LazMethodList.CompareMethods(m1, m2);
end;
function ComparePointers(p1, p2: Pointer): integer;
begin
Result:=LazUtilities.ComparePointers(p1, p2);
end;
function RoundToInt(e: Extended): integer;
begin
Result:=LazUtilities.RoundToInt(e);
end;
function RoundToCardinal(e: Extended): cardinal;
begin
Result:=LazUtilities.RoundToCardinal(e);
end;
function TruncToInt(e: Extended): integer;
begin
Result:=LazUtilities.TruncToInt(e);
end;
function TruncToCardinal(e: Extended): cardinal;
begin
Result:=LazUtilities.TruncToCardinal(e);
end;
function StrToDouble(const s: string): double;
begin
Result:=LazUtilities.StrToDouble(s);
end;
procedure MergeSort(List: TFPList; const OnCompare: TListSortCompare); procedure MergeSort(List: TFPList; const OnCompare: TListSortCompare);
begin begin
if List=nil then exit; if List=nil then exit;