]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Tidy up the Assert macros.
authorDavid Wells <wellsd2@rpi.edu>
Sun, 8 Apr 2018 21:32:02 +0000 (17:32 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Mon, 9 Apr 2018 12:27:39 +0000 (08:27 -0400)
This commit makes the backslashes align neatly in doxygen output for the various
standard assertions.

doc/doxygen/scripts/filter
include/deal.II/base/exceptions.h

index 6ecf2a2891c0f99b5156d34e457dddaea9fddefa..884f43cdf503c359971738d20686a46dab847bd3 100755 (executable)
@@ -35,12 +35,35 @@ while (<>)
     # We don't let doxygen put everything into a namespace
     # dealii. consequently, doxygen can't link references that contain an
     # explicit dealii:: qualification. remove it and replace it by the
-    # global scope
+    # global scope.
+    #
+    # Try to detect whether or not ::dealii:: is part of a macro (e.g., Assert)
+    # continuation line (line ending in '\'): if it is then replace it with
+    # spaces. This keeps the '\'s aligned, e.g., the following snippet (which is
+    # part of the definition of Assert)
+    #
+    # ::dealii::internals::abort(__LINE__,             \ # part of macro
+    #                            __PRETTY_FUNCTION__)
+    #
+    # will be converted to
+    #
+    #         ::internals::abort(__LINE__,             \ # part of macro
+    #                            __PRETTY_FUNCTION__)
+    #
+    # so the '\' is kept in the same column.
     #
     # Now, as of doxygen 1.5, this still produces the wrong result, but
     # that's not our fault. This is reported here:
     #    http://bugzilla.gnome.org/show_bug.cgi?id=365053
-    s/(::)?dealii::/::/g;
+    if (m/^ *(::)?dealii::.*\\$/)
+    {
+        s/::dealii::(.*)\\$/::\1        \\/g;
+        s/dealii::(.*)\\$/\1        \\/g;
+    }
+    else
+    {
+        s/(::)?dealii::/::/g;
+    }
 
     # Replace all occurrences of something like step-xx by
     #    @ref step_xx "step-xx"
index f87fd5324855d98769921b740bdbee2e2ea316c9..631f5c74b04e022286e8176d2128d38c0246b36d 100644 (file)
@@ -348,26 +348,24 @@ namespace deal_II_exceptions
  */
 #ifdef DEBUG
 #  ifdef DEAL_II_HAVE_BUILTIN_EXPECT
-#    define Assert(cond, exc)                                          \
-  {                                                                    \
-    if (__builtin_expect(!(cond), false))                              \
-      ::dealii::deal_II_exceptions::internals::                        \
-      issue_error_noreturn(                                            \
-          ::dealii::deal_II_exceptions::internals::abort_on_exception, \
-          __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);  \
-  }
+#    define Assert(cond, exc)                                                  \
+{                                                                              \
+  if (__builtin_expect(!(cond), false))                                        \
+    ::dealii::deal_II_exceptions::internals:: issue_error_noreturn(            \
+        ::dealii::deal_II_exceptions::internals::abort_on_exception,           \
+        __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);            \
+}
 #  else
-#    define Assert(cond, exc)                                          \
-  {                                                                    \
-    if (!(cond))                                                       \
-      ::dealii::deal_II_exceptions::internals::                        \
-      issue_error_noreturn(                                            \
-          ::dealii::deal_II_exceptions::internals::abort_on_exception, \
-          __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);  \
-  }
+#    define Assert(cond, exc)                                                  \
+{                                                                              \
+  if (!(cond))                                                                 \
+    ::dealii::deal_II_exceptions::internals:: issue_error_noreturn(            \
+        ::dealii::deal_II_exceptions::internals::abort_on_exception,           \
+        __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);            \
+}
 #  endif
 #else
-#define Assert(cond, exc)                                              \
+#define Assert(cond, exc)                                                      \
   {}
 #endif
 
@@ -390,31 +388,27 @@ namespace deal_II_exceptions
  */
 #ifdef DEBUG
 #  ifdef DEAL_II_HAVE_BUILTIN_EXPECT
-#    define AssertNothrow(cond, exc)                                            \
-  {                                                                             \
-    if (__builtin_expect(!(cond), false))                                       \
-      ::dealii::deal_II_exceptions::internals::                                 \
-      issue_error_nothrow(                                                      \
-          ::dealii::deal_II_exceptions::internals::abort_nothrow_on_exception,  \
-          __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);           \
-  }
+#    define AssertNothrow(cond, exc)                                           \
+{                                                                              \
+  if (__builtin_expect(!(cond), false))                                        \
+    ::dealii::deal_II_exceptions::internals::issue_error_nothrow(              \
+        ::dealii::deal_II_exceptions::internals::abort_nothrow_on_exception,   \
+        __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);            \
+}
 #  else
-#    define AssertNothrow(cond, exc)                                            \
-  {                                                                             \
-    if (!(cond))                                                                \
-      ::dealii::deal_II_exceptions::internals::                                 \
-      issue_error_nothrow(                                                      \
-          ::dealii::deal_II_exceptions::internals::abort_nothrow_on_exception,  \
-          __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);           \
-  }
+#    define AssertNothrow(cond, exc)                                           \
+{                                                                              \
+  if (!(cond))                                                                 \
+    ::dealii::deal_II_exceptions::internals::issue_error_nothrow(              \
+        ::dealii::deal_II_exceptions::internals::abort_nothrow_on_exception,   \
+        __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);            \
+}
 #  endif
 #else
-#define AssertNothrow(cond, exc)                                                \
+#define AssertNothrow(cond, exc)                                               \
   {}
 #endif
 
-
-
 /**
  * A macro that serves as the main routine in the exception mechanism for dynamic
  * error checking. It asserts that a certain condition is fulfilled, otherwise
@@ -431,23 +425,21 @@ namespace deal_II_exceptions
  * @author Wolfgang Bangerth, 1997, 1998, Matthias Maier, 2013
  */
 #ifdef DEAL_II_HAVE_BUILTIN_EXPECT
-#define AssertThrow(cond, exc)                                         \
-  {                                                                    \
-    if (__builtin_expect(!(cond), false))                              \
-      ::dealii::deal_II_exceptions::internals::                        \
-      issue_error_noreturn(                                            \
-          ::dealii::deal_II_exceptions::internals::throw_on_exception, \
-          __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);  \
-  }
+#define AssertThrow(cond, exc)                                                 \
+{                                                                              \
+  if (__builtin_expect(!(cond), false))                                        \
+    ::dealii::deal_II_exceptions::internals:: issue_error_noreturn(            \
+        ::dealii::deal_II_exceptions::internals::throw_on_exception,           \
+        __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);            \
+}
 #else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
-#define AssertThrow(cond, exc)                                         \
-  {                                                                    \
-    if (!(cond))                                                       \
-      ::dealii::deal_II_exceptions::internals::                        \
-      issue_error_noreturn(                                            \
-          ::dealii::deal_II_exceptions::internals::throw_on_exception, \
-          __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);  \
-  }
+#define AssertThrow(cond, exc)                                                 \
+{                                                                              \
+  if (!(cond))                                                                 \
+    ::dealii::deal_II_exceptions::internals::issue_error_noreturn(             \
+        ::dealii::deal_II_exceptions::internals::throw_on_exception,           \
+        __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc);            \
+}
 #endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
 
 
@@ -1214,7 +1206,6 @@ namespace StandardExceptions
 #endif // DEAL_II_WITH_MPI
 } /*namespace StandardExceptions*/
 
-
 /**
  * Special assertion for dimension mismatch.
  *
@@ -1225,8 +1216,8 @@ namespace StandardExceptions
  * @ingroup Exceptions
  * @author Guido Kanschat 2007
  */
-#define AssertDimension(dim1,dim2) Assert((dim1) == (dim2),       \
-                                          dealii::ExcDimensionMismatch((dim1),(dim2)))
+#define AssertDimension(dim1,dim2) \
+Assert((dim1) == (dim2), dealii::ExcDimensionMismatch((dim1),(dim2)))
 
 
 /**
@@ -1236,8 +1227,9 @@ namespace StandardExceptions
  * @ingroup Exceptions
  * @author Guido Kanschat 2010
  */
-#define AssertVectorVectorDimension(vec,dim1,dim2) AssertDimension((vec).size(), (dim1)) \
-  for (unsigned int i=0;i<dim1;++i) { AssertDimension((vec)[i].size(), (dim2)); }
+#define AssertVectorVectorDimension(vec,dim1,dim2)                             \
+AssertDimension((vec).size(), (dim1));                                         \
+for (unsigned int i=0;i<dim1;++i) {AssertDimension((vec)[i].size(), (dim2));}  \
 
 namespace internal
 {
@@ -1260,12 +1252,11 @@ namespace internal
  * @ingroup Exceptions
  * @author Guido Kanschat 2007
  */
-#define AssertIndexRange(index,range) \
-  Assert((index) < (range), \
-         dealii::ExcIndexRangeType< \
-         typename ::dealii::internal::argument_type< \
-         void(typename std::common_type<decltype(index), \
-              decltype(range)>::type)>::type>((index),0,(range)))
+#define AssertIndexRange(index,range)                                          \
+Assert((index) < (range),                                                      \
+dealii::ExcIndexRangeType<typename ::dealii::internal::argument_type<          \
+void(typename std::common_type<decltype(index),                                \
+     decltype(range)>::type)>::type>((index),0,(range)))
 
 /**
  * An assertion that checks whether a number is finite or not. We explicitly
@@ -1276,8 +1267,9 @@ namespace internal
  * @ingroup Exceptions
  * @author Wolfgang Bangerth, 2015
  */
-#define AssertIsFinite(number) Assert(dealii::numbers::is_finite(number), \
-                                      dealii::ExcNumberNotFinite(std::complex<double>(number)))
+#define AssertIsFinite(number)                                                 \
+Assert(dealii::numbers::is_finite(number),                                     \
+dealii::ExcNumberNotFinite(std::complex<double>(number)))
 
 #ifdef DEAL_II_WITH_MPI
 /**
@@ -1290,8 +1282,8 @@ namespace internal
  * @ingroup Exceptions
  * @author David Wells, 2016
  */
-#define AssertThrowMPI(error_code) AssertThrow(error_code == MPI_SUCCESS, \
-                                               dealii::ExcMPI(error_code))
+#define AssertThrowMPI(error_code) \
+AssertThrow(error_code == MPI_SUCCESS, dealii::ExcMPI(error_code))
 #else
 #define AssertThrowMPI(error_code) {}
 #endif // DEAL_II_WITH_MPI

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.