Skip to content

Commit

Permalink
STYLE: Convert C++ source files from old-style "Whitesmiths" to "Allm…
Browse files Browse the repository at this point in the history
…an" style

This commit reindents the C++ source files to adhere to the "Allman" style, moving
away from the outdated and VTK-specific "Whitesmiths" style. The changes are applied
using an approach similar to the one utilized in Kitware/VTK@f830ff47b3 ("Reindent
using the reindentation script," 2016-09-23).

These modifications are made in anticipation of future changes that will introduce
the use of a standard configuration based on clang-format.

Steps Taken:

1. The script `Utilities/Maintenance/vtk_reindent_code.py` is executed, leveraging
   the approach from Kitware/VTK@b6fec283cc. The command used is as follows:

   ```
   fd -e cxx -e h -e cpp -e cxx.in -e h.in -e txx -x \
     python3.9 /path/to/VTK/Utilities/Maintenance/vtk_reindent_code.py {}
   ```

2. Manual review and adjustments are performed to address the errors identified
   during the reindentation process (see below).

3. Update the indentations associated with macros to ensure proper alignment of
   backslashes. To identify the affected files, the following one-liner was utilized:

   ```
   for file in $(git diff HEAD --name-only); do
     git diff HEAD -- $file | ack "\+.+\s\\\\$" > /dev/null 2>&1 && echo $file;
   done
   ```

Errors identified during the reindentation process:

```
Libs/MRML/Logic/vtkMRMLApplicationLogic.cxx:715: mismatched delimiter in "#ifdef WIN32" block
Libs/MRML/Logic/vtkMRMLApplicationLogic.cxx:728: mismatched delimiter in "#else" block
Libs/MRML/Logic/vtkMRMLApplicationLogic.cxx:715: mismatched delimiter in "#ifdef WIN32" block
Libs/MRML/Logic/vtkMRMLApplicationLogic.cxx:728: mismatched delimiter in "#else" block
Libs/MRML/DisplayableManager/vtkMRMLDisplayableManagerGroup.cxx:173: mismatched delimiter in "#ifdef MRMLDisplayableManager_USE_PYTHON" block
Libs/MRML/DisplayableManager/vtkMRMLDisplayableManagerGroup.cxx:173: mismatched delimiter in "#ifdef MRMLDisplayableManager_USE_PYTHON" block
Libs/MRML/Core/vtkMRMLVolumeSequenceStorageNode.cxx:128: mismatched delimiter in "#ifdef NRRD_CHUNK_IO_AVAILABLE" block
Libs/MRML/Core/vtkMRMLVolumeSequenceStorageNode.cxx:142: mismatched delimiter in "#else" block
Libs/MRML/Core/vtkMRMLVolumeSequenceStorageNode.cxx:128: mismatched delimiter in "#ifdef NRRD_CHUNK_IO_AVAILABLE" block
Libs/MRML/Core/vtkMRMLVolumeSequenceStorageNode.cxx:142: mismatched delimiter in "#else" block
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:34: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:185: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:185: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:380: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:385: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:465: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:34: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:185: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:185: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:380: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:385: mismatched '}'
Libs/MRML/Core/vtkMRMLNodePropertyMacros.h:465: mismatched '}'
Modules/Loadable/Colors/Logic/vtkSlicerColorLogic.cxx:179: mismatched delimiter in "#ifdef WIN32" block
Modules/Loadable/Colors/Logic/vtkSlicerColorLogic.cxx:192: mismatched delimiter in "#else" block
Modules/Loadable/Colors/Logic/vtkSlicerColorLogic.cxx:179: mismatched delimiter in "#ifdef WIN32" block
Modules/Loadable/Colors/Logic/vtkSlicerColorLogic.cxx:192: mismatched delimiter in "#else" block
```
  • Loading branch information
jcfr authored and pieper committed Feb 21, 2024
1 parent abbc6c0 commit 2762f0c
Show file tree
Hide file tree
Showing 1,147 changed files with 57,746 additions and 57,746 deletions.
12 changes: 6 additions & 6 deletions Applications/SlicerApp/Main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ int SlicerAppMain(int argc, char* argv[])

qSlicerApplication app(argc, argv);
if (app.returnCode() != -1)
{
{
return app.returnCode();
}
}

QScopedPointer<SlicerMainWindowType> window;
QScopedPointer<QSplashScreen> splashScreen;

int exitCode = qSlicerApplicationHelper::postInitializeApplication<SlicerMainWindowType>(
app, splashScreen, window);
if (exitCode != 0)
{
{
return exitCode;
}
}

if (!window.isNull())
{
{
QString windowTitle = QString("%1 %2").arg(window->windowTitle()).arg(Slicer_VERSION_FULL);
window->setWindowTitle(windowTitle);
}
}

return app.exec();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ int qSlicerAppMainWindowTest1(int argc, char * argv[] )
#endif

if (argc < 2 || QString(argv[1]) != "-I")
{
{
QTimer::singleShot(100, qApp, SLOT(quit()));
}
}

return app.exec();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ int qSlicerModuleFactoryManagerTest1(int argc, char * argv[])
qSlicerAbstractCoreModule * abstractModule =
moduleFactoryManager.moduleInstance(moduleName);
if( abstractModule == nullptr )
{
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in loadModule()" << std::endl;
return EXIT_FAILURE;
}
}

if( abstractModule->name() != moduleName )
{
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in moduleTitle() or moduleName()" << std::endl
<< "expected moduleName = " << qPrintable( moduleName ) << std::endl
<< "real moduleName = " << qPrintable( abstractModule->name() ) << std::endl;
return EXIT_FAILURE;
}
}

moduleFactoryManager.unloadModules();

Expand All @@ -76,11 +76,11 @@ int qSlicerModuleFactoryManagerTest1(int argc, char * argv[])
abstractModule = moduleFactoryManager.moduleInstance(moduleName);

if( abstractModule == nullptr )
{
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in instantiateModule()" << std::endl;
return EXIT_FAILURE;
}
}

// Check failure cases (if loading of modules does not work then other tests will fail,
// but module loading failures are not tested elsewhere)
Expand All @@ -91,20 +91,20 @@ int qSlicerModuleFactoryManagerTest1(int argc, char * argv[])
std::cout << "The following module loading is expected to fail..." << std::endl;
bool moduleLoadSuccess = moduleFactoryManager.loadModules(QStringList() << "nonexistent2");
if (moduleLoadSuccess == true)
{
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in loadModules() - it expected to fail for non-existent module" << std::endl;
return EXIT_FAILURE;
}
}
std::cout << "Module loading failed as expected." << std::endl;

moduleLoadSuccess = moduleFactoryManager.loadModules(QStringList());
if (moduleLoadSuccess == false)
{
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in loadModules() - it expected to succeed for empty module list" << std::endl;
return EXIT_FAILURE;
}
}

moduleFactoryManager.unloadModules();

Expand Down
10 changes: 5 additions & 5 deletions Applications/SlicerApp/qSlicerAppMainWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,18 @@ void qSlicerAppMainWindow::on_HelpKeyboardShortcutsAction_triggered()
QList<QAction*> moduleActions;
qSlicerModuleManager * moduleManager = qSlicerApplication::application()->moduleManager();
foreach(const QString& moduleName, moduleManager->modulesNames())
{
{
qSlicerAbstractModule* module =
qobject_cast<qSlicerAbstractModule*>(moduleManager->module(moduleName));
if (module)
{
{
moduleActions << module->action();
}
}
}
if (moduleActions.size())
{
{
actionsDialog.addActions(moduleActions, "Modules");
}
}
// TODO add more actions
actionsDialog.exec();
}
Expand Down

0 comments on commit 2762f0c

Please sign in to comment.