more `<> nil` and `= nil` replaced with isAss/isNotAss

and inline those helpers
This commit is contained in:
Basile Burg 2020-07-12 00:20:16 +02:00
parent a2a53632d8
commit 0b641095be
27 changed files with 78 additions and 80 deletions

View File

@ -706,7 +706,7 @@ begin
// field is specified // field is specified
if fOutputFilename.isNotEmpty then if fOutputFilename.isNotEmpty then
begin begin
if (fSymStringExpander <> nil) then if fSymStringExpander.isAssigned then
fOutputFilename := fSymStringExpander.expand(fOutputFilename); fOutputFilename := fSymStringExpander.expand(fOutputFilename);
fOutputFilename := expandFilenameEx(fBasePath, fOutputFilename); fOutputFilename := expandFilenameEx(fBasePath, fOutputFilename);
{$IFDEF WINDOWS} {$IFDEF WINDOWS}

View File

@ -147,12 +147,12 @@ inherited ProjectConfigurationWidget: TProjectConfigurationWidget
end end
end end
inherited contextMenu: TPopupMenu inherited contextMenu: TPopupMenu
left = 8 Left = 8
top = 8 Top = 8
end end
object imgList: TImageList[2] object imgList: TImageList[2]
left = 40 Left = 40
top = 8 Top = 8
Bitmap = { Bitmap = {
4C690200000010000000100000008D8B89008D8B89008F8D8B008F8D8B008C8A 4C690200000010000000100000008D8B89008D8B89008F8D8B008F8D8B008C8A
880092908E00908E8CFF8F8D8BFF908E8CFF92908E008F8D8B008F8D8B008F8D 880092908E00908E8CFF8F8D8BFF908E8CFF92908E008F8D8B008F8D8B008F8D

View File

@ -225,7 +225,7 @@ begin
fProj.beginUpdate; fProj.beginUpdate;
try try
src_prop := src_list.Find(propstr); src_prop := src_list.Find(propstr);
if src_prop = nil then if src_prop <> nil then
exit; exit;
storage.AObject := getGridTarget; storage.AObject := getGridTarget;
storage.StoreAnyProperty(src_prop); storage.StoreAnyProperty(src_prop);

View File

@ -64,8 +64,8 @@ type
// sugar for classes // sugar for classes
TObjectHelper = class helper for TObject TObjectHelper = class helper for TObject
function isNotAssigned: boolean; function isNotAssigned: boolean; inline;
function isAssigned: boolean; function isAssigned: boolean; inline;
end; end;
IDexedBaseInterface = interface IDexedBaseInterface = interface
@ -73,8 +73,8 @@ type
// sugar for interfaces // sugar for interfaces
TDexedInterfaceHelper = type helper for IDexedBaseInterface TDexedInterfaceHelper = type helper for IDexedBaseInterface
function isNotAssigned: boolean; function isNotAssigned: boolean; inline;
function isAssigned: boolean; function isAssigned: boolean; inline;
end; end;
// maybe one day, sugar for events // maybe one day, sugar for events
@ -85,8 +85,8 @@ type
// sugar for pointers // sugar for pointers
TPointerHelper = type helper for Pointer TPointerHelper = type helper for Pointer
function isNotAssigned: boolean; function isNotAssigned: boolean; inline;
function isAssigned: boolean; function isAssigned: boolean; inline;
end; end;
// sugar for strings // sugar for strings
@ -956,7 +956,7 @@ begin
listFiles(files, pth, true); listFiles(files, pth, true);
for fname in files do for fname in files do
begin begin
if exts = nil then if exts.isNotAssigned then
list.Add(fname) list.Add(fname)
else else
begin begin

View File

@ -1203,7 +1203,7 @@ end;
procedure TSynD2Syn.ResetRange; procedure TSynD2Syn.ResetRange;
begin begin
if fCurrRange = nil then if fCurrRange.isNotAssigned then
fCurrRange := TSynD2SynRange.Create(nil) fCurrRange := TSynD2SynRange.Create(nil)
else else
fCurrRange.Clear; fCurrRange.Clear;

View File

@ -1684,7 +1684,7 @@ var
fe: boolean; fe: boolean;
i: integer; i: integer;
begin begin
if (base = nil) or (base = self) then if base.isNotAssigned or (base = self) then
begin begin
fDocOpts.getOpts(list); fDocOpts.getOpts(list);
fDebugOpts.getOpts(list); fDebugOpts.getOpts(list);

View File

@ -1921,7 +1921,7 @@ const
asmFlavorStr: array[TAsmSyntax] of string = ('intel','att'); asmFlavorStr: array[TAsmSyntax] of string = ('intel','att');
begin begin
clearDisplays; clearDisplays;
if (fDebugTargetKind = dtkProject) and (fProj = nil) then if (fDebugTargetKind = dtkProject) and fProj.isNotAssigned then
begin begin
dlgOkInfo('No project to debug', 'GDB commander'); dlgOkInfo('No project to debug', 'GDB commander');
exit; exit;
@ -2084,7 +2084,7 @@ begin
dbgeeOptsEd.ItemIndex:=-1; dbgeeOptsEd.ItemIndex:=-1;
dbgeeOptsEd.TIObject := nil; dbgeeOptsEd.TIObject := nil;
case fDebugTargetKind of case fDebugTargetKind of
dtkProject : if fProj <> nil then dtkProject : if fProj.isAssigned then
nme := fProj.filename; nme := fProj.filename;
dtkRunnable : if fDoc.isAssigned then dtkRunnable : if fDoc.isAssigned then
nme := fDoc.filename; nme := fDoc.filename;
@ -2727,7 +2727,7 @@ procedure TGdbWidget.gdboutJsonize(sender: TObject);
var var
str: string; str: string;
begin begin
if fMsg = nil then if fMsg.isNotAssigned then
exit; exit;
fLog.Clear; fLog.Clear;

View File

@ -597,7 +597,7 @@ end;
{$REGION ISingleService getters ----------------------------------------------} {$REGION ISingleService getters ----------------------------------------------}
function getMessageDisplay(var obj: IMessagesDisplay): IMessagesDisplay; function getMessageDisplay(var obj: IMessagesDisplay): IMessagesDisplay;
begin begin
if obj = nil then if obj.isNotAssigned then
obj := EntitiesConnector.getSingleService('IMessagesDisplay') as IMessagesDisplay; obj := EntitiesConnector.getSingleService('IMessagesDisplay') as IMessagesDisplay;
exit(obj); exit(obj);
end; end;
@ -609,7 +609,7 @@ end;
function getprocInputHandler(var obj: IProcInputHandler): IProcInputHandler; function getprocInputHandler(var obj: IProcInputHandler): IProcInputHandler;
begin begin
if obj = nil then if obj.isNotAssigned then
obj := EntitiesConnector.getSingleService('IProcInputHandler') as IProcInputHandler; obj := EntitiesConnector.getSingleService('IProcInputHandler') as IProcInputHandler;
exit(obj); exit(obj);
end; end;
@ -621,7 +621,7 @@ end;
function getMultiDocHandler(var obj: IMultiDocHandler): IMultiDocHandler; function getMultiDocHandler(var obj: IMultiDocHandler): IMultiDocHandler;
begin begin
if obj = nil then if obj.isNotAssigned then
obj := EntitiesConnector.getSingleService('IMultiDocHandler') as IMultiDocHandler; obj := EntitiesConnector.getSingleService('IMultiDocHandler') as IMultiDocHandler;
exit(obj); exit(obj);
end; end;

View File

@ -561,7 +561,7 @@ var
lib: TLibraryItem; lib: TLibraryItem;
i: Integer; i: Integer;
begin begin
if fMsgs = nil then if fMsgs.isNotAssigned then
fMsgs := getMessageDisplay; fMsgs := getMessageDisplay;
// no selector = all libs // no selector = all libs
if aliases.isNotAssigned then if aliases.isNotAssigned then
@ -599,7 +599,7 @@ var
dep: TLibraryItem; dep: TLibraryItem;
sel: TLibraryList; sel: TLibraryList;
begin begin
if fMsgs = nil then if fMsgs.isNotAssigned then
fMsgs := getMessageDisplay; fMsgs := getMessageDisplay;
imp := TStringList.Create; imp := TStringList.Create;
sel := TLibraryList.create; sel := TLibraryList.create;

View File

@ -113,7 +113,7 @@ procedure TLibManEditorWidget.updateButtonsState;
var var
i: TIconScaledSize; i: TIconScaledSize;
begin begin
btnReg.Enabled := (fProj <> nil) and fProj.Filename.fileExists; btnReg.Enabled := fProj.isAssigned and fProj.Filename.fileExists;
btnOpenProj.Enabled := List.Selected.isAssigned and btnOpenProj.Enabled := List.Selected.isAssigned and
List.Selected.SubItems[2].fileExists; List.Selected.SubItems[2].fileExists;
i := GetIconScaledSize; i := GetIconScaledSize;
@ -152,7 +152,7 @@ end;
procedure TLibManEditorWidget.projChanged(project: ICommonProject); procedure TLibManEditorWidget.projChanged(project: ICommonProject);
begin begin
if fProj = nil then if fProj.isNotAssigned then
exit; exit;
if fProj <> project then if fProj <> project then
exit; exit;
@ -688,7 +688,7 @@ var
row: TListItem; row: TListItem;
itf: IMessagesDisplay; itf: IMessagesDisplay;
begin begin
if fProj = nil then if fProj.isNotAssigned then
exit; exit;
fname := fProj.outputFilename; fname := fProj.outputFilename;

View File

@ -3921,7 +3921,7 @@ begin
exit; exit;
fProjectGroup.closeGroup; fProjectGroup.closeGroup;
fProjectGroup.openGroup(TMenuItem(Sender).Hint); fProjectGroup.openGroup(TMenuItem(Sender).Hint);
if (fProj = nil) and (fProjectGroup.getProjectIndex < fProjectGroup.projectCount) then if fProj.isNotAssigned and (fProjectGroup.getProjectIndex < fProjectGroup.projectCount) then
fProjectGroup.getProject(fProjectGroup.getProjectIndex).activate(); fProjectGroup.getProject(fProjectGroup.getProjectIndex).activate();
end; end;
@ -4053,7 +4053,7 @@ var
s1: string; s1: string;
s2: string; s2: string;
begin begin
if fProj = nil then if fProj.isNotAssigned then
exit; exit;
pth := exeFullName('dscanner' + exeExt); pth := exeFullName('dscanner' + exeExt);
@ -4249,7 +4249,7 @@ begin
finally finally
free; free;
end; end;
if (fProj = nil) and (fProjectGroup.getProjectIndex < fProjectGroup.projectCount) then if fProj.isNotAssigned and (fProjectGroup.getProjectIndex < fProjectGroup.projectCount) then
fProjectGroup.getProject(fProjectGroup.getProjectIndex).activate(); fProjectGroup.getProject(fProjectGroup.getProjectIndex).activate();
end; end;

View File

@ -48,7 +48,7 @@ inherited MessagesWidget: TMessagesWidget
OnResize = toolbarResize OnResize = toolbarResize
object sep: TDexedToolButton[0] object sep: TDexedToolButton[0]
Left = 832 Left = 832
Height = 28 Height = 5
Hint = 'Clean filtered messages' Hint = 'Clean filtered messages'
Top = 0 Top = 0
AutoSize = True AutoSize = True
@ -65,7 +65,7 @@ inherited MessagesWidget: TMessagesWidget
end end
object button2: TDexedToolButton[2] object button2: TDexedToolButton[2]
Left = 257 Left = 257
Height = 28 Height = 5
Top = 0 Top = 0
AutoSize = True AutoSize = True
Caption = 'button2' Caption = 'button2'
@ -82,7 +82,7 @@ inherited MessagesWidget: TMessagesWidget
end end
object button4: TDexedToolButton[4] object button4: TDexedToolButton[4]
Left = 171 Left = 171
Height = 28 Height = 5
Top = 0 Top = 0
AutoSize = True AutoSize = True
Caption = 'button4' Caption = 'button4'
@ -99,7 +99,7 @@ inherited MessagesWidget: TMessagesWidget
end end
object button6: TDexedToolButton[6] object button6: TDexedToolButton[6]
Left = 113 Left = 113
Height = 28 Height = 5
Top = 0 Top = 0
AutoSize = True AutoSize = True
Caption = 'button6' Caption = 'button6'
@ -116,7 +116,7 @@ inherited MessagesWidget: TMessagesWidget
end end
object button8: TDexedToolButton[8] object button8: TDexedToolButton[8]
Left = 62 Left = 62
Height = 28 Height = 5
Top = 0 Top = 0
AutoSize = True AutoSize = True
Caption = 'button8' Caption = 'button8'
@ -158,7 +158,7 @@ inherited MessagesWidget: TMessagesWidget
end end
object sepCat: TDexedToolButton[12] object sepCat: TDexedToolButton[12]
Left = 29 Left = 29
Height = 28 Height = 5
Top = 0 Top = 0
AutoSize = True AutoSize = True
Caption = 'sepCat' Caption = 'sepCat'
@ -168,7 +168,7 @@ inherited MessagesWidget: TMessagesWidget
end end
end end
inherited contextMenu: TPopupMenu inherited contextMenu: TPopupMenu
left = 32 Left = 32
top = 40 Top = 40
end end
end end

View File

@ -776,7 +776,7 @@ begin
clearbyContext(fCtxt); clearbyContext(fCtxt);
amcEdit: if fDoc.isAssigned then amcEdit: if fDoc.isAssigned then
clearbyData(fDoc); clearbyData(fDoc);
amcProj: if fProj <> nil then amcProj: if fProj.isAssigned then
clearbyData(fProj); clearbyData(fProj);
end; end;
end; end;
@ -1293,7 +1293,7 @@ begin
getMultiDocHandler.openDocument(ident); getMultiDocHandler.openDocument(ident);
exit(true); exit(true);
end; end;
if fProj <> nil then if fProj.isAssigned then
begin begin
// if fname relative to project path // if fname relative to project path
absName := expandFilenameEx(fProj.filename.extractFileDir + DirectorySeparator, ident); absName := expandFilenameEx(fProj.filename.extractFileDir + DirectorySeparator, ident);

View File

@ -238,7 +238,7 @@ procedure TMRUProjectList.projClosing(project: ICommonProject);
var var
fname: string; fname: string;
begin begin
if project = nil then if project.isNotAssigned then
exit; exit;
fname := project.filename; fname := project.filename;

View File

@ -174,7 +174,7 @@ end;
procedure TEntitiesConnector.addSubject(subject: TObject); procedure TEntitiesConnector.addSubject(subject: TObject);
begin begin
if (subject as ISubject) = nil then if (subject as ISubject).isNotAssigned then
exit; exit;
if fSubjects.IndexOf(subject) <> -1 then if fSubjects.IndexOf(subject) <> -1 then
exit; exit;
@ -188,7 +188,7 @@ var
begin begin
fObservers.Remove(observer); fObservers.Remove(observer);
for i := 0 to fSubjects.Count - 1 do for i := 0 to fSubjects.Count - 1 do
if fSubjects[i] <> nil then if fSubjects[i].isAssigned then
(fSubjects[i] as ISubject).removeObserver(observer); (fSubjects[i] as ISubject).removeObserver(observer);
tryUpdate; tryUpdate;
end; end;

View File

@ -208,7 +208,7 @@ begin
end else end else
begin begin
dt := PCategoryData(selCat.Selected.Data); dt := PCategoryData(selCat.Selected.Data);
if dt^.container.isNotAssigned or (dt^.observer = nil) then if dt^.container.isNotAssigned or dt^.observer.isNotAssigned then
exit; exit;
if dt^.observer.optionedOptionsModified() then if dt^.observer.optionedOptionsModified() then
begin begin

View File

@ -102,7 +102,7 @@ implementation
procedure killProcess(var proc: TDexedProcess); procedure killProcess(var proc: TDexedProcess);
begin begin
if proc = nil then if proc.isNotAssigned then
exit; exit;
if proc.Running then if proc.Running then
proc.Terminate(0); proc.Terminate(0);
@ -217,7 +217,7 @@ procedure TDexedProcess.fillOutputStack;
c: integer; c: integer;
begin begin
s := outStr.size; s := outStr.size;
while (inStr <> nil) and (inStr.NumBytesAvailable > 0) do while inStr.isAssigned and (inStr.NumBytesAvailable > 0) do
begin begin
outStr.SetSize(s + 1024); outStr.SetSize(s + 1024);
c := inStr.Read((outStr.Memory + s)^, 1024); c := inStr.Read((outStr.Memory + s)^, 1024);

View File

@ -212,13 +212,13 @@ end;
procedure TProjectGroup.projClosing(project: ICommonProject); procedure TProjectGroup.projClosing(project: ICommonProject);
begin begin
if (project <> nil) and (project = fFreeStanding) then if project.isAssigned and (project = fFreeStanding) then
fFreeStanding := nil; fFreeStanding := nil;
end; end;
procedure TProjectGroup.projFocused(project: ICommonProject); procedure TProjectGroup.projFocused(project: ICommonProject);
begin begin
if (project <> nil) and not project.inGroup then if project.isAssigned and not project.inGroup then
fFreeStanding := project; fFreeStanding := project;
end; end;
@ -490,8 +490,8 @@ end;
procedure TProjectGroupItem.lazyLoad; procedure TProjectGroupItem.lazyLoad;
begin begin
if fProj = nil then if fProj.isAssigned then
begin exit;
//setActiveConfigurationIndex changes the project //setActiveConfigurationIndex changes the project
//modified flag //modified flag
@ -504,11 +504,10 @@ begin
projectGroup.restoreModified; projectGroup.restoreModified;
end; end;
end;
destructor TProjectGroupItem.destroy; destructor TProjectGroupItem.destroy;
begin begin
if fProj <> nil then if fProj.isAssigned then
fProj.getProject.free; fProj.getProject.free;
fProj := nil; fProj := nil;
inherited; inherited;
@ -634,7 +633,7 @@ begin
exit; exit;
for fname in Files do for fname in Files do
begin begin
if projectGroup.findProject(fname.normalizePath) <> nil then if projectGroup.findProject(fname.normalizePath).isAssigned then
continue; continue;
projectGroup.addItem(fname.normalizePath); projectGroup.addItem(fname.normalizePath);
added := true; added := true;
@ -648,15 +647,13 @@ end;
procedure TProjectGroupWidget.btnFreeFocusClick(Sender: TObject); procedure TProjectGroupWidget.btnFreeFocusClick(Sender: TObject);
begin begin
if fFreeProj <> nil then if fFreeProj.isAssigned then
subjProjFocused(fProjSubj, fFreeProj); subjProjFocused(fProjSubj, fFreeProj);
end; end;
procedure TProjectGroupWidget.btnAddUnfocusedClick(Sender: TObject); procedure TProjectGroupWidget.btnAddUnfocusedClick(Sender: TObject);
begin begin
if fFreeProj = nil then if fFreeProj.isNotAssigned or not fFreeProj.filename.fileExists then
exit;
if not fFreeProj.filename.fileExists then
exit; exit;
projectGroup.addProject(fFreeProj); projectGroup.addProject(fFreeProj);
fFreeProj := nil; fFreeProj := nil;
@ -806,7 +803,7 @@ begin
lstProj.ItemIndex:= i; lstProj.ItemIndex:= i;
end; end;
lstProj.EndUpdate; lstProj.EndUpdate;
if fFreeProj <> nil then if fFreeProj.isAssigned then
begin begin
if fFreeProj.filename.fileExists then if fFreeProj.filename.fileExists then
case fFreeProj.getFormat of case fFreeProj.getFormat of

View File

@ -238,7 +238,7 @@ end;
procedure TProjectInspectWidget.actBuildExecute(sender: TObject); procedure TProjectInspectWidget.actBuildExecute(sender: TObject);
begin begin
if fProj <> nil then if fProj.isAssigned then
begin begin
actOpenFileExecute(sender); actOpenFileExecute(sender);
fProj.compile; fProj.compile;

View File

@ -259,12 +259,12 @@ inherited SearchWidget: TSearchWidget
end end
end end
inherited contextMenu: TPopupMenu inherited contextMenu: TPopupMenu
left = 216 Left = 216
top = 16 Top = 16
end end
object imgList: TImageList[2] object imgList: TImageList[2]
left = 248 Left = 248
top = 16 Top = 16
Bitmap = { Bitmap = {
4C690200000010000000100000007B7977007B7977007B7977FF73716FFF6D6B 4C690200000010000000100000007B7977007B7977007B7977FF73716FFF6D6B
69FF696665FF625F5EFF615E5D007E7C7A007B7977FF73716FFF6D6B69FF6966 69FF696665FF625F5EFF615E5D007E7C7A007B7977FF73716FFF6D6B69FF6966

View File

@ -390,7 +390,7 @@ var
h: IMultiDocHandler; h: IMultiDocHandler;
begin begin
if (fDoc.isNotAssigned and (fFindScope <> scProj)) or if (fDoc.isNotAssigned and (fFindScope <> scProj)) or
((fProj = nil) and (fFindScope = scProj)) then (fProj.isNotAssigned and (fFindScope = scProj)) then
exit; exit;
fSearchMru.Insert(0,fToFind); fSearchMru.Insert(0,fToFind);
@ -829,7 +829,7 @@ var
hasTxt: boolean; hasTxt: boolean;
begin begin
canAll := ((fDoc.isAssigned and (fFindScope <> scProj)) or canAll := ((fDoc.isAssigned and (fFindScope <> scProj)) or
((fFindScope = scProj) and (fProj <> nil))); ((fFindScope = scProj) and fProj.isAssigned));
hasTxt := fToFind.isNotEmpty and not fToFind.isBlank; hasTxt := fToFind.isNotEmpty and not fToFind.isBlank;
btnFind.Enabled := fDoc.isAssigned and hasTxt; btnFind.Enabled := fDoc.isAssigned and hasTxt;
btnFindAll.Enabled := canAll and hasTxt; btnFindAll.Enabled := canAll and hasTxt;

View File

@ -190,7 +190,7 @@ begin
fNeedUpdate := false; fNeedUpdate := false;
hasNativeProj := fProj.isAssigned; hasNativeProj := fProj.isAssigned;
hasProjItf := fProjInterface <> nil; hasProjItf := fProjInterface.isAssigned;
hasDoc := fDoc.isAssigned; hasDoc := fDoc.isAssigned;
if fExp.isNotAssigned then if fExp.isNotAssigned then
fExp := getExplorer; fExp := getExplorer;

View File

@ -1065,7 +1065,7 @@ begin
fScrollMemo := TScrollMemo.construct(self); fScrollMemo := TScrollMemo.construct(self);
i := getLifeTimeManager(); i := getLifeTimeManager();
if (i <> nil) then if i.isAssigned then
fLifeTimeManager := i.asObject; fLifeTimeManager := i.asObject;
OnShowHint:= @showHintEvent; OnShowHint:= @showHintEvent;

View File

@ -434,9 +434,9 @@ begin
c := getContext; c := getContext;
case c of case c of
tcNone: exit; tcNone: exit;
tcProject: if (fProj = nil) or fProj.sourcesCount.equals(0) then tcProject: if fProj.isNotAssigned or fProj.sourcesCount.equals(0) then
exit; exit;
tcFile: if fDoc = nil then tcFile: if fDoc.isNotAssigned then
exit; exit;
end; end;

View File

@ -219,11 +219,11 @@ begin
u_processes.killProcess(fProcess); u_processes.killProcess(fProcess);
fTerminatedFlag := false; fTerminatedFlag := false;
if fMsgs = nil then if fMsgs.isNotAssigned then
fMsgs := getMessageDisplay; fMsgs := getMessageDisplay;
if fClearMessages then if fClearMessages then
fMsgs.clearByContext(amcMisc); fMsgs.clearByContext(amcMisc);
if fSymStringExpander = nil then if fSymStringExpander.isNotAssigned then
fSymStringExpander:= getSymStringExpander; fSymStringExpander:= getSymStringExpander;
if askConfirmation and (dlgOkCancel(format(confSpec, [toolAlias])) <> mrOk) then if askConfirmation and (dlgOkCancel(format(confSpec, [toolAlias])) <> mrOk) then

View File

@ -9,6 +9,7 @@ object DexedWidget: TDexedWidget
ClientWidth = 332 ClientWidth = 332
ShowHint = True ShowHint = True
ShowInTaskBar = stNever ShowInTaskBar = stNever
LCLVersion = '2.0.10.0'
object Back: TPanel object Back: TPanel
Left = 0 Left = 0
Height = 121 Height = 121

View File

@ -208,7 +208,7 @@ begin
if isDockable then if isDockable then
begin begin
win := DockMaster.GetAnchorSite(self); win := DockMaster.GetAnchorSite(self);
if win <> nil then if win.isAssigned then
begin begin
win.Show; win.Show;
win.BringToFront; win.BringToFront;