Skip to content

Commit

Permalink
clang-format: manually format and guard some macros
Browse files Browse the repository at this point in the history
clang-format ends up mangling these macros, so take a hint as to what
they're supposed to look like and then hide them from clang-format.
  • Loading branch information
kwrobot authored and mathstuf committed Nov 18, 2019
1 parent 275a882 commit cc952a6
Show file tree
Hide file tree
Showing 19 changed files with 209 additions and 160 deletions.
19 changes: 15 additions & 4 deletions Common/Core/vtkCommand.cxx
Expand Up @@ -46,12 +46,15 @@ const char *vtkCommand::GetStringFromEventId(unsigned long event)
{
switch (event)
{
#define _vtk_add_event(Enum)\
case Enum: return #Enum;
// clang-format off
#define _vtk_add_event(Enum) \
case Enum: \
return #Enum;

vtkAllEventsMacro()

#undef _vtk_add_event
// clang-format on

case UserEvent:
return "UserEvent";
Expand All @@ -70,15 +73,23 @@ unsigned long vtkCommand::GetEventIdFromString(const char *event)
{
if (event)
{
#define _vtk_add_event(Enum)\
if (strcmp(event, #Enum) == 0) {return Enum;}

// clang-format off
#define _vtk_add_event(Enum) \
if (strcmp(event, #Enum) == 0) \
{ \
return Enum; \
}

vtkAllEventsMacro()

#undef _vtk_add_event

if (strcmp("UserEvent",event) == 0)
{
return vtkCommand::UserEvent;
}
// clang-format on
}

return vtkCommand::NoEvent;
Expand Down
258 changes: 130 additions & 128 deletions Common/Core/vtkCommand.h

Large diffs are not rendered by default.

50 changes: 26 additions & 24 deletions Common/Core/vtkSetGet.h
Expand Up @@ -50,31 +50,33 @@
#define vtkInternalQuoteMacro(x) #x
#define vtkQuoteMacro(x) vtkInternalQuoteMacro(x)

// clang-format off
// A macro to get the name of a type
#define vtkImageScalarTypeNameMacro(type) \
(((type) == VTK_VOID) ? "void" : \
(((type) == VTK_BIT) ? "bit" : \
(((type) == VTK_CHAR) ? "char" : \
(((type) == VTK_SIGNED_CHAR) ? "signed char" : \
(((type) == VTK_UNSIGNED_CHAR) ? "unsigned char" : \
(((type) == VTK_SHORT) ? "short" : \
(((type) == VTK_UNSIGNED_SHORT) ? "unsigned short" : \
(((type) == VTK_INT) ? "int" : \
(((type) == VTK_UNSIGNED_INT) ? "unsigned int" : \
(((type) == VTK_LONG) ? "long" : \
(((type) == VTK_UNSIGNED_LONG) ? "unsigned long" : \
(((type) == VTK_LONG_LONG) ? "long long" : \
(((type) == VTK_UNSIGNED_LONG_LONG) ? "unsigned long long" : \
(((type) == 18 /*VTK___INT64*/) ? "__int64" : \
(((type) == 19 /*VTK_UNSIGNED___INT64*/) ? "unsigned __int64" : \
(((type) == VTK_FLOAT) ? "float" : \
(((type) == VTK_DOUBLE) ? "double" : \
(((type) == VTK_ID_TYPE) ? "idtype" : \
(((type) == VTK_STRING) ? "string" : \
(((type) == VTK_UNICODE_STRING) ? "unicode string" : \
(((type) == VTK_VARIANT) ? "variant" : \
(((type) == VTK_OBJECT) ? "object" : \
"Undefined"))))))))))))))))))))))
#define vtkImageScalarTypeNameMacro(type) \
(((type) == VTK_VOID) ? "void" : \
(((type) == VTK_BIT) ? "bit" : \
(((type) == VTK_CHAR) ? "char" : \
(((type) == VTK_SIGNED_CHAR) ? "signed char" : \
(((type) == VTK_UNSIGNED_CHAR) ? "unsigned char" : \
(((type) == VTK_SHORT) ? "short" : \
(((type) == VTK_UNSIGNED_SHORT) ? "unsigned short" : \
(((type) == VTK_INT) ? "int" : \
(((type) == VTK_UNSIGNED_INT) ? "unsigned int" : \
(((type) == VTK_LONG) ? "long" : \
(((type) == VTK_UNSIGNED_LONG) ? "unsigned long" : \
(((type) == VTK_LONG_LONG) ? "long long" : \
(((type) == VTK_UNSIGNED_LONG_LONG) ? "unsigned long long" : \
(((type) == 18 /*VTK___INT64*/) ? "__int64" : \
(((type) == 19 /*VTK_UNSIGNED___INT64*/) ? "unsigned __int64" : \
(((type) == VTK_FLOAT) ? "float" : \
(((type) == VTK_DOUBLE) ? "double" : \
(((type) == VTK_ID_TYPE) ? "idtype" : \
(((type) == VTK_STRING) ? "string" : \
(((type) == VTK_UNICODE_STRING) ? "unicode string" : \
(((type) == VTK_VARIANT) ? "variant" : \
(((type) == VTK_OBJECT) ? "object" : \
"Undefined"))))))))))))))))))))))
// clang-format on


/* Various compiler-specific performance hints. */
Expand Down
4 changes: 3 additions & 1 deletion Filters/ParallelDIY2/Testing/Cxx/TestPResampleToImage.cxx
Expand Up @@ -32,8 +32,10 @@
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"

#include "vtk_diy2.h" // must include this before any diy header
// clang-format off
#include "vtk_diy2.h" // must include this before any diy header
#include VTK_DIY2(diy/mpi.hpp)
// clang-format on


int TestPResampleToImage(int argc, char *argv[])
Expand Down
Expand Up @@ -34,8 +34,10 @@
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"

#include "vtk_diy2.h" // must include this before any diy header
// clang-format off
#include "vtk_diy2.h" // must include this before any diy header
#include VTK_DIY2(diy/mpi.hpp)
// clang-format on


int TestPResampleToImageCompositeDataSet(int argc, char *argv[])
Expand Down
Expand Up @@ -38,8 +38,10 @@
#include "vtkDummyController.h"
#endif

// clang-format off
#include "vtk_diy2.h"
#include VTK_DIY2(diy/mpi.hpp)
// clang-format on

namespace {
bool ValidateDataset(vtkUnstructuredGrid* input, vtkPartitionedDataSet* output, vtkMultiProcessController* controller)
Expand Down
2 changes: 2 additions & 0 deletions Filters/ParallelDIY2/vtkDIYAggregateDataSetFilter.cxx
Expand Up @@ -45,6 +45,7 @@
#include <map>
#include <set>

// clang-format off
#include "vtk_diy2.h" // must include this before any diy header
#include VTK_DIY2(diy/assigner.hpp)
#include VTK_DIY2(diy/link.hpp)
Expand All @@ -53,6 +54,7 @@
#include VTK_DIY2(diy/reduce.hpp)
#include VTK_DIY2(diy/partners/swap.hpp)
#include VTK_DIY2(diy/decomposition.hpp)
// clang-format on

vtkStandardNewMacro(vtkDIYAggregateDataSetFilter);

Expand Down
1 change: 1 addition & 0 deletions Filters/ParallelDIY2/vtkDIYKdTreeUtilities.cxx
Expand Up @@ -44,6 +44,7 @@
#include VTK_DIY2(diy/assigner.hpp)
#include VTK_DIY2(diy/algorithms.hpp)
// clang-format on

namespace
{
struct PointTT
Expand Down
4 changes: 3 additions & 1 deletion Filters/ParallelDIY2/vtkPResampleToImage.cxx
Expand Up @@ -33,14 +33,16 @@
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkUnsignedCharArray.h"

#include "vtk_diy2.h" // must include this before any diy header
// clang-format off
#include "vtk_diy2.h" // must include this before any diy header
#include VTK_DIY2(diy/assigner.hpp)
#include VTK_DIY2(diy/link.hpp)
#include VTK_DIY2(diy/master.hpp)
#include VTK_DIY2(diy/mpi.hpp)
#include VTK_DIY2(diy/reduce.hpp)
#include VTK_DIY2(diy/partners/swap.hpp)
#include VTK_DIY2(diy/decomposition.hpp)
// clang-format on

#include <algorithm>

Expand Down
4 changes: 3 additions & 1 deletion Filters/ParallelDIY2/vtkPResampleWithDataSet.cxx
Expand Up @@ -35,11 +35,13 @@
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkUnstructuredGrid.h"

#include "vtk_diy2.h" // must include this before any diy header
// clang-format off
#include "vtk_diy2.h" // must include this before any diy header
#include VTK_DIY2(diy/assigner.hpp)
#include VTK_DIY2(diy/link.hpp)
#include VTK_DIY2(diy/master.hpp)
#include VTK_DIY2(diy/mpi.hpp)
// clang-format on

#include <algorithm>
#include <cmath>
Expand Down
2 changes: 2 additions & 0 deletions IO/Core/vtkNumberToString.cxx
Expand Up @@ -14,8 +14,10 @@
=========================================================================*/
#include "vtkNumberToString.h"

// clang-format off
#include "vtk_doubleconversion.h"
#include VTK_DOUBLECONVERSION_HEADER(double-conversion.h)
// clang-format on

#include <sstream>

Expand Down
2 changes: 2 additions & 0 deletions IO/Xdmf3/vtkXdmf3ArrayKeeper.cxx
Expand Up @@ -16,8 +16,10 @@

#include "vtkXdmf3ArrayKeeper.h"

// clang-format off
#include "vtk_xdmf3.h"
#include VTKXDMF3_HEADER(core/XdmfArray.hpp)
// clang-format on

//------------------------------------------------------------------------------
vtkXdmf3ArrayKeeper::vtkXdmf3ArrayKeeper()
Expand Down
2 changes: 2 additions & 0 deletions IO/Xdmf3/vtkXdmf3DataSet.cxx
Expand Up @@ -40,6 +40,7 @@
#include "vtkXdmf3ArrayKeeper.h"
#include "vtkXdmf3ArraySelection.h"

// clang-format off
#include "vtk_xdmf3.h"
#include VTKXDMF3_HEADER(core/XdmfArrayType.hpp)
#include VTKXDMF3_HEADER(XdmfAttribute.hpp)
Expand All @@ -58,6 +59,7 @@
#include VTKXDMF3_HEADER(XdmfTime.hpp)
#include VTKXDMF3_HEADER(XdmfTopology.hpp)
#include VTKXDMF3_HEADER(XdmfTopologyType.hpp)
// clang-format on

//==============================================================================
bool vtkXdmf3DataSet_ReadIfNeeded(XdmfArray *array, bool dbg=false)
Expand Down
4 changes: 4 additions & 0 deletions IO/Xdmf3/vtkXdmf3DataSet.h
Expand Up @@ -28,8 +28,12 @@
#define vtkXdmf3DataSet_h

#include "vtkIOXdmf3Module.h" // For export macro

// clang-format off
#include "vtk_xdmf3.h"
#include VTKXDMF3_HEADER(core/XdmfSharedPtr.hpp)
// clang-format on

#include <string> //Needed only for XdmfArray::getName :(

class vtkXdmf3ArraySelection;
Expand Down
2 changes: 2 additions & 0 deletions IO/Xdmf3/vtkXdmf3HeavyDataHandler.cxx
Expand Up @@ -30,6 +30,7 @@
#include "vtkXdmf3ArraySelection.h"
#include "vtkXdmf3DataSet.h"

// clang-format off
#include "vtk_xdmf3.h"
#include VTKXDMF3_HEADER(XdmfCurvilinearGrid.hpp)
#include VTKXDMF3_HEADER(XdmfDomain.hpp)
Expand All @@ -42,6 +43,7 @@
#include VTKXDMF3_HEADER(XdmfRegularGrid.hpp)
#include VTKXDMF3_HEADER(XdmfSet.hpp)
#include VTKXDMF3_HEADER(XdmfUnstructuredGrid.hpp)
// clang-format on

#include <cassert>

Expand Down
2 changes: 2 additions & 0 deletions IO/Xdmf3/vtkXdmf3HeavyDataHandler.h
Expand Up @@ -31,10 +31,12 @@

#include "vtk_xdmf3.h"

// clang-format off
#include VTKXDMF3_HEADER(core/XdmfInformation.hpp)

#include VTKXDMF3_HEADER(core/XdmfItem.hpp)
#include VTKXDMF3_HEADER(core/XdmfSharedPtr.hpp)
// clang-format on

#include "vtkXdmf3ArrayKeeper.h"
#include "vtkXdmf3ArraySelection.h"
Expand Down
2 changes: 2 additions & 0 deletions IO/Xdmf3/vtkXdmf3LightDataHandler.cxx
Expand Up @@ -20,6 +20,7 @@
#include "vtkXdmf3SILBuilder.h"
#include "vtksys/SystemTools.hxx"

// clang-format off
#include "vtk_xdmf3.h"
#include VTKXDMF3_HEADER(XdmfAttribute.hpp)
#include VTKXDMF3_HEADER(XdmfAttributeCenter.hpp)
Expand All @@ -36,6 +37,7 @@
#include VTKXDMF3_HEADER(XdmfTime.hpp)
#include VTKXDMF3_HEADER(XdmfUnstructuredGrid.hpp)
#include VTKXDMF3_HEADER(core/XdmfVisitor.hpp)
// clang-format on

#include <cassert>
#include <iostream>
Expand Down
2 changes: 2 additions & 0 deletions IO/Xdmf3/vtkXdmf3LightDataHandler.h
Expand Up @@ -31,8 +31,10 @@
#include "vtkIOXdmf3Module.h" // For export macro
#include "vtkType.h"

// clang-format off
#include "vtk_xdmf3.h"
#include VTKXDMF3_HEADER(core/XdmfItem.hpp)
// clang-format on

#include <set>

Expand Down
3 changes: 3 additions & 0 deletions IO/Xdmf3/vtkXdmf3Writer.cxx
Expand Up @@ -29,12 +29,15 @@
#include "vtkStructuredGrid.h"
#include "vtkXdmf3DataSet.h"

// clang-format off
#include "vtk_xdmf3.h"
#include VTKXDMF3_HEADER(XdmfDomain.hpp)
#include VTKXDMF3_HEADER(XdmfGridCollection.hpp)
#include VTKXDMF3_HEADER(XdmfGridCollectionType.hpp)
#include VTKXDMF3_HEADER(core/XdmfHeavyDataWriter.hpp)
#include VTKXDMF3_HEADER(core/XdmfWriter.hpp)
// clang-format on

#include <stack>
#include <string>

Expand Down

0 comments on commit cc952a6

Please sign in to comment.