changeset 25849:2ee4d384224f

* oct-inttypes.cc: Make a few more style fixes.
author John W. Eaton <jwe@octave.org>
date Fri, 31 Aug 2018 15:25:58 -0400
parents 4c25d8d3a0ae
children 153495e05477
files liboctave/util/oct-inttypes.cc
diffstat 1 files changed, 56 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/oct-inttypes.cc	Thu Aug 30 16:55:17 2018 -0400
+++ b/liboctave/util/oct-inttypes.cc	Fri Aug 31 15:25:58 2018 -0400
@@ -35,20 +35,21 @@
 template <typename T>
 const octave_int<T> octave_int<T>::one (static_cast<T> (1));
 
-// define type names.
-#define DECLARE_OCTAVE_INT_TYPENAME(TYPE, TYPENAME)             \
+// Define type names.
+
+#define DEFINE_OCTAVE_INT_TYPENAME(TYPE, TYPENAME)              \
   template <>                                                   \
   OCTAVE_API const char *                                       \
   octave_int<TYPE>::type_name (void) { return TYPENAME; }
 
-DECLARE_OCTAVE_INT_TYPENAME (int8_t, "int8")
-DECLARE_OCTAVE_INT_TYPENAME (int16_t, "int16")
-DECLARE_OCTAVE_INT_TYPENAME (int32_t, "int32")
-DECLARE_OCTAVE_INT_TYPENAME (int64_t, "int64")
-DECLARE_OCTAVE_INT_TYPENAME (uint8_t, "uint8")
-DECLARE_OCTAVE_INT_TYPENAME (uint16_t, "uint16")
-DECLARE_OCTAVE_INT_TYPENAME (uint32_t, "uint32")
-DECLARE_OCTAVE_INT_TYPENAME (uint64_t, "uint64")
+DEFINE_OCTAVE_INT_TYPENAME (int8_t, "int8")
+DEFINE_OCTAVE_INT_TYPENAME (int16_t, "int16")
+DEFINE_OCTAVE_INT_TYPENAME (int32_t, "int32")
+DEFINE_OCTAVE_INT_TYPENAME (int64_t, "int64")
+DEFINE_OCTAVE_INT_TYPENAME (uint8_t, "uint8")
+DEFINE_OCTAVE_INT_TYPENAME (uint16_t, "uint16")
+DEFINE_OCTAVE_INT_TYPENAME (uint32_t, "uint32")
+DEFINE_OCTAVE_INT_TYPENAME (uint64_t, "uint64")
 
 template <class T>
 template <class S>
@@ -181,7 +182,7 @@
 // Similarly, the conversion from the 64-bit integer type to long double
 // must also occur in long double rounding mode.
 
-#    define OCTAVE_LONG_DOUBLE_OP(T, OP, NAME)                  \
+#    define DEFINE_OCTAVE_LONG_DOUBLE_OP(T, OP, NAME)           \
   T                                                             \
   external_double_ ## T ## _ ## NAME (double x, T y)            \
   {                                                             \
@@ -206,14 +207,14 @@
     return retval;                                              \
   }
 
-#    define OCTAVE_LONG_DOUBLE_OPS(T)           \
-  OCTAVE_LONG_DOUBLE_OP (T, +, add);            \
-  OCTAVE_LONG_DOUBLE_OP (T, -, sub);            \
-  OCTAVE_LONG_DOUBLE_OP (T, *, mul);            \
-  OCTAVE_LONG_DOUBLE_OP (T, /, div)
+#    define DEFINE_OCTAVE_LONG_DOUBLE_OPS(T)    \
+  DEFINE_OCTAVE_LONG_DOUBLE_OP (T, +, add);     \
+  DEFINE_OCTAVE_LONG_DOUBLE_OP (T, -, sub);     \
+  DEFINE_OCTAVE_LONG_DOUBLE_OP (T, *, mul);     \
+  DEFINE_OCTAVE_LONG_DOUBLE_OP (T, /, div)
 
-OCTAVE_LONG_DOUBLE_OPS(octave_int64);
-OCTAVE_LONG_DOUBLE_OPS(octave_uint64);
+DEFINE_OCTAVE_LONG_DOUBLE_OPS (octave_int64);
+DEFINE_OCTAVE_LONG_DOUBLE_OPS (octave_uint64);
 
 #  endif
 
@@ -350,7 +351,7 @@
 
   return res;
 
-overflow:
+ overflow:
   return max_val ();
 }
 
@@ -426,7 +427,7 @@
         return -static_cast<int64_t> (res);
     }
 
-overflow:
+ overflow:
   return positive ? max_val () : min_val ();
 
 }
@@ -679,22 +680,22 @@
     return x * (1.0/y);
 }
 
-#define INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP,T1,T2)                      \
+#define INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP, T1, T2)                    \
   template OCTAVE_API bool                                              \
   octave_int_cmp_op::emulate_mop<octave_int_cmp_op::OP> (T1 x, T2 y)
 
 #define INSTANTIATE_INT64_DOUBLE_CMP_OP(OP)                     \
-  INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP, double, int64_t);        \
-  INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP, double, uint64_t);       \
-  INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP, int64_t, double);        \
-  INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP, uint64_t, double)
+  INSTANTIATE_INT64_DOUBLE_CMP_OP0 (OP, double, int64_t);       \
+  INSTANTIATE_INT64_DOUBLE_CMP_OP0 (OP, double, uint64_t);      \
+  INSTANTIATE_INT64_DOUBLE_CMP_OP0 (OP, int64_t, double);       \
+  INSTANTIATE_INT64_DOUBLE_CMP_OP0 (OP, uint64_t, double)
 
-INSTANTIATE_INT64_DOUBLE_CMP_OP(lt);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(le);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(gt);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(ge);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(eq);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(ne);
+INSTANTIATE_INT64_DOUBLE_CMP_OP (lt);
+INSTANTIATE_INT64_DOUBLE_CMP_OP (le);
+INSTANTIATE_INT64_DOUBLE_CMP_OP (gt);
+INSTANTIATE_INT64_DOUBLE_CMP_OP (ge);
+INSTANTIATE_INT64_DOUBLE_CMP_OP (eq);
+INSTANTIATE_INT64_DOUBLE_CMP_OP (ne);
 
 #endif
 
@@ -704,8 +705,8 @@
 {
   octave_int<T> retval;
 
-  octave_int<T> zero = static_cast<T> (0);
-  octave_int<T> one = static_cast<T> (1);
+  const octave_int<T> zero = octave_int<T>::zero;
+  const octave_int<T> one = octave_int<T>::one;
 
   if (b == zero || a == one)
     retval = one;
@@ -791,13 +792,28 @@
 
 #define INSTANTIATE_INTTYPE(T)                                          \
   template class OCTAVE_API octave_int<T>;                              \
-  template OCTAVE_API octave_int<T> pow (const octave_int<T>&, const octave_int<T>&); \
-  template OCTAVE_API octave_int<T> pow (const double&, const octave_int<T>&); \
-  template OCTAVE_API octave_int<T> pow (const octave_int<T>&, const double&); \
-  template OCTAVE_API octave_int<T> pow (const float&, const octave_int<T>&); \
-  template OCTAVE_API octave_int<T> pow (const octave_int<T>&, const float&); \
-  template OCTAVE_API octave_int<T> powf (const float&, const octave_int<T>&); \
-  template OCTAVE_API octave_int<T> powf (const octave_int<T>&, const float&); \
+                                                                        \
+  template OCTAVE_API octave_int<T>                                     \
+  pow (const octave_int<T>&, const octave_int<T>&);                     \
+                                                                        \
+  template OCTAVE_API octave_int<T>                                     \
+  pow (const double&, const octave_int<T>&);                            \
+                                                                        \
+  template OCTAVE_API octave_int<T>                                     \
+  pow (const octave_int<T>&, const double&);                            \
+                                                                        \
+  template OCTAVE_API octave_int<T>                                     \
+  pow (const float&, const octave_int<T>&);                             \
+                                                                        \
+  template OCTAVE_API octave_int<T>                                     \
+  pow (const octave_int<T>&, const float&);                             \
+                                                                        \
+  template OCTAVE_API octave_int<T>                                     \
+  powf (const float&, const octave_int<T>&);                            \
+                                                                        \
+  template OCTAVE_API octave_int<T>                                     \
+  powf (const octave_int<T>&, const float&);                            \
+                                                                        \
   template OCTAVE_API octave_int<T>                                     \
   bitshift (const octave_int<T>&, int, const octave_int<T>&);