Skip to content

Commit 83a9a82

Browse files
authored
Merge pull request #10 from Embarcadero/cpp
Code optimization
2 parents 753ebf9 + 5b057a7 commit 83a9a82

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

Source/PythonTools.IOTAUtils.pas

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ TIOTAUtils = class
2323
class function ModuleIsPas(const AModule: IOTAModule): boolean;
2424
class function ModuleIsCpp(const AModule: IOTAModule): boolean;
2525
class function ModuleIsForm(const AModule: IOTAModule): boolean;
26+
class function ModuleIsExportable(const AModule: IOTAModule): boolean;
2627

2728
class procedure EnumComps(const AFormEditor: IOTAFormEditor; const ACallback: TProc<TComponent>);
2829
class function GetFormCaption(const AComponent: TComponent): string;
@@ -103,7 +104,7 @@ class procedure TIOTAUtils.EnumForms(const AProc: TProc<TIOTAFormInfo>);
103104
LModule := LModuleServices.Modules[I];
104105
LEditor := GetFormEditorFromModule(LModule);
105106

106-
if not ((ModuleIsPas(LModule) or ModuleIsCpp(LModule)) and ModuleIsForm(LModule)) then
107+
if not ModuleIsExportable(LModule) then
107108
Continue;
108109

109110
LDesigner := (LEditor as INTAFormEditor).FormDesigner;
@@ -306,20 +307,12 @@ class function TIOTAUtils.HasForms: boolean;
306307
LModuleServices := (BorlandIDEServices as IOTAModuleServices);
307308
for I := 0 to LModuleServices.ModuleCount - 1 do begin
308309
LModule := LModuleServices.Modules[I];
309-
if (ModuleIsPas(LModule) or ModuleIsCpp(LModule)) and ModuleIsForm(LModule) then
310+
if ModuleIsExportable(LModule) then
310311
Exit(true);
311312
end;
312313
Result := false;
313314
end;
314315

315-
class function TIOTAUtils.ModuleIsCpp(const AModule: IOTAModule): boolean;
316-
begin
317-
if SameText(ExtractFileExt(AModule.FileName), '.cpp') then
318-
Result := true
319-
else
320-
Result := false;
321-
end;
322-
323316
class function TIOTAUtils.ModuleIsForm(const AModule: IOTAModule): boolean;
324317
var
325318
LEditor: IOTAFormEditor;
@@ -347,10 +340,19 @@ class function TIOTAUtils.ModuleIsForm(const AModule: IOTAModule): boolean;
347340

348341
class function TIOTAUtils.ModuleIsPas(const AModule: IOTAModule): boolean;
349342
begin
350-
if SameText(ExtractFileExt(AModule.FileName), '.pas') then
351-
Result := true
352-
else
353-
Result := false;
343+
Result := SameText(ExtractFileExt(AModule.FileName), '.pas');
344+
end;
345+
346+
class function TIOTAUtils.ModuleIsCpp(const AModule: IOTAModule): boolean;
347+
begin
348+
Result := SameText(ExtractFileExt(AModule.FileName), '.cpp');
349+
end;
350+
351+
class function TIOTAUtils.ModuleIsExportable(
352+
const AModule: IOTAModule): boolean;
353+
begin
354+
Result := (ModuleIsPas(AModule) or ModuleIsCpp(AModule))
355+
and ModuleIsForm(AModule);
354356
end;
355357

356358
class procedure TIOTAUtils.EnumComps(const AFormEditor: IOTAFormEditor;

0 commit comments

Comments
 (0)