changeset 27177:8498dccc15c7

minor style fixes * action-container.h, functor.h, oct-binmap.h, oct-refcount.h, sparse-sort.cc, sparse-sort.h, str-vec.h, unwind-prot.h: Use m_ prefix for class data members and s_ prefix for static data members. Minor style fixes.
author John W. Eaton <jwe@octave.org>
date Wed, 12 Jun 2019 11:03:06 -0500
parents 0112951951a9
children d68968a1277c
files liboctave/util/action-container.h liboctave/util/functor.h liboctave/util/oct-binmap.h liboctave/util/oct-refcount.h liboctave/util/sparse-sort.cc liboctave/util/sparse-sort.h liboctave/util/str-vec.h liboctave/util/unwind-prot.h
diffstat 8 files changed, 54 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/action-container.h	Wed Jun 12 10:51:58 2019 -0500
+++ b/liboctave/util/action-container.h	Wed Jun 12 11:03:06 2019 -0500
@@ -88,7 +88,7 @@
     public:
 
       restore_var_elem (T& ref, const T& val)
-        : e_ptr (&ref), e_val (val) { }
+        : m_ptr (&ref), m_val (val) { }
 
       // No copying!
 
@@ -96,11 +96,11 @@
 
       restore_var_elem& operator = (const restore_var_elem&) = delete;
 
-      void run (void) { *e_ptr = e_val; }
+      void run (void) { *m_ptr = m_val; }
 
     private:
 
-      T *e_ptr, e_val;
+      T *m_ptr, m_val;
     };
 
     // Deletes a class allocated using new.
@@ -111,7 +111,7 @@
     public:
 
       delete_ptr_elem (T *ptr)
-        : e_ptr (ptr) { }
+        : m_ptr (ptr) { }
 
       // No copying!
 
@@ -119,11 +119,11 @@
 
       delete_ptr_elem operator = (const delete_ptr_elem&) = delete;
 
-      void run (void) { delete e_ptr; }
+      void run (void) { delete m_ptr; }
 
     private:
 
-      T *e_ptr;
+      T *m_ptr;
     };
 
     action_container (void) { }
--- a/liboctave/util/functor.h	Wed Jun 12 10:51:58 2019 -0500
+++ b/liboctave/util/functor.h	Wed Jun 12 11:03:06 2019 -0500
@@ -25,10 +25,13 @@
 
 #include "octave-config.h"
 
+// FIXME: could we use std::function objects instead?
+
 template <typename RT, typename PT>
 class fcn_ptr
 {
 public:
+
   typedef RT (*TYPE) (PT);
 };
 
@@ -36,28 +39,32 @@
 class functor
 {
 private:
+
   typedef typename fcn_ptr<RT, PT>::TYPE fcn_ptr_type;
-  fcn_ptr_type fptr;
+
+  fcn_ptr_type m_fptr;
 
 public:
 
-  functor (fcn_ptr_type p) : fptr (p) { }
+  functor (fcn_ptr_type p) : m_fptr (p) { }
 
-  RT operator () (PT arg) { return fptr (arg); }
+  RT operator () (PT arg) { return m_fptr (arg); }
 };
 
 template <typename CT, typename RT, typename PT>
 class functor_with_conversion
 {
 private:
+
   typedef typename fcn_ptr<RT, PT>::TYPE fcn_ptr_type;
-  fcn_ptr_type fptr;
+
+  fcn_ptr_type m_fptr;
 
 public:
 
-  functor_with_conversion (fcn_ptr_type p) : fptr (p) { }
+  functor_with_conversion (fcn_ptr_type p) : m_fptr (p) { }
 
-  CT operator () (PT arg) { return CT (fptr (arg)); }
+  CT operator () (PT arg) { return CT (m_fptr (arg)); }
 };
 
 template <typename RT, typename PT>
--- a/liboctave/util/oct-binmap.h	Wed Jun 12 10:51:58 2019 -0500
+++ b/liboctave/util/oct-binmap.h	Wed Jun 12 11:03:06 2019 -0500
@@ -66,40 +66,42 @@
 class bsxfun_wrapper
 {
 private:
-  static F f;
+
+  static F s_fcn;
 
 public:
+
   static void
   set_f (const F& f_in)
   {
-    f = f_in;
+    s_fcn = f_in;
   }
 
   static void
   op_mm (size_t n, R *r, const X *x , const Y *y)
   {
     for (size_t i = 0; i < n; i++)
-      r[i] = f (x[i], y[i]);
+      r[i] = s_fcn (x[i], y[i]);
   }
 
   static void
   op_sm (size_t n, R *r, X x, const Y *y)
   {
     for (size_t i = 0; i < n; i++)
-      r[i] = f (x, y[i]);
+      r[i] = s_fcn (x, y[i]);
   }
 
   static void
   op_ms (size_t n , R *r, const X *x, Y y)
   {
     for (size_t i = 0; i < n; i++)
-      r[i] = f (x[i], y);
+      r[i] = s_fcn (x[i], y);
   }
 };
 
 // Static init
 template <typename R, typename X, typename Y, typename F>
-F bsxfun_wrapper<R, X, Y, F>::f;
+F bsxfun_wrapper<R, X, Y, F>::s_fcn;
 
 // scalar-Array
 template <typename U, typename T, typename R, typename F>
--- a/liboctave/util/oct-refcount.h	Wed Jun 12 10:51:58 2019 -0500
+++ b/liboctave/util/oct-refcount.h	Wed Jun 12 11:03:06 2019 -0500
@@ -77,33 +77,33 @@
     typedef T count_type;
 
     refcount (count_type initial_count)
-      : count (initial_count)
+      : m_count (initial_count)
     { }
 
     // Increment/Decrement.  int is postfix.
     count_type operator++ (void)
     {
-      return OCTAVE_ATOMIC_INCREMENT (&count);
+      return OCTAVE_ATOMIC_INCREMENT (&m_count);
     }
 
     count_type operator++ (int)
     {
-      return OCTAVE_ATOMIC_POST_INCREMENT (&count);
+      return OCTAVE_ATOMIC_POST_INCREMENT (&m_count);
     }
 
     count_type operator-- (void)
     {
-      return OCTAVE_ATOMIC_DECREMENT (&count);
+      return OCTAVE_ATOMIC_DECREMENT (&m_count);
     }
 
     count_type operator-- (int)
     {
-      return OCTAVE_ATOMIC_POST_DECREMENT (&count);
+      return OCTAVE_ATOMIC_POST_DECREMENT (&m_count);
     }
 
     count_type value (void) const
     {
-      return static_cast<count_type const volatile&> (count);
+      return static_cast<count_type const volatile&> (m_count);
     }
 
     operator count_type (void) const
@@ -113,12 +113,12 @@
 
     count_type * get (void)
     {
-      return &count;
+      return &m_count;
     }
 
   private:
 
-    count_type count;
+    count_type m_count;
   };
 }
 
--- a/liboctave/util/sparse-sort.cc	Wed Jun 12 10:51:58 2019 -0500
+++ b/liboctave/util/sparse-sort.cc	Wed Jun 12 11:03:06 2019 -0500
@@ -42,11 +42,13 @@
                           octave_sparse_sort_idxl *j)
 {
   octave_idx_type tmp = i->c - j->c;
+
   if (tmp < 0)
     return true;
   else if (tmp > 0)
     return false;
-  return  (i->r < j->r);
+
+  return (i->r < j->r);
 }
 
 template class octave_sort<octave_sparse_sort_idxl *>;
--- a/liboctave/util/sparse-sort.h	Wed Jun 12 10:51:58 2019 -0500
+++ b/liboctave/util/sparse-sort.h	Wed Jun 12 11:03:06 2019 -0500
@@ -32,6 +32,7 @@
 octave_sparse_sort_idxl
 {
 public:
+
   octave_idx_type r;
   octave_idx_type c;
   octave_idx_type idx;
@@ -44,6 +45,7 @@
 octave_idx_vector_sort
 {
 public:
+
   octave_idx_type i;
   octave_idx_type idx;
 };
--- a/liboctave/util/str-vec.h	Wed Jun 12 10:51:58 2019 -0500
+++ b/liboctave/util/str-vec.h	Wed Jun 12 11:03:06 2019 -0500
@@ -100,10 +100,14 @@
   }
 
   std::string& operator[] (octave_idx_type i)
-  { return Array<std::string>::elem (i); }
+  {
+    return Array<std::string>::elem (i);
+  }
 
   std::string operator[] (octave_idx_type i) const
-  { return Array<std::string>::elem (i); }
+  {
+    return Array<std::string>::elem (i);
+  }
 
   string_vector& sort (bool make_uniq = false);
 
--- a/liboctave/util/unwind-prot.h	Wed Jun 12 10:51:58 2019 -0500
+++ b/liboctave/util/unwind-prot.h	Wed Jun 12 11:03:06 2019 -0500
@@ -41,7 +41,7 @@
   {
   public:
 
-    unwind_protect (void) : lifo () { }
+    unwind_protect (void) : m_lifo () { }
 
     // No copying!
 
@@ -62,8 +62,8 @@
       if (! empty ())
         {
           // No leak on exception!
-          std::unique_ptr<elem> ptr (lifo.top ());
-          lifo.pop ();
+          std::unique_ptr<elem> ptr (m_lifo.top ());
+          m_lifo.pop ();
           ptr->run ();
         }
     }
@@ -72,22 +72,22 @@
     {
       if (! empty ())
         {
-          elem *ptr = lifo.top ();
-          lifo.pop ();
+          elem *ptr = m_lifo.top ();
+          m_lifo.pop ();
           delete ptr;
         }
     }
 
-    size_t size (void) const { return lifo.size (); }
+    size_t size (void) const { return m_lifo.size (); }
 
   protected:
 
     virtual void add_action (elem *new_elem)
     {
-      lifo.push (new_elem);
+      m_lifo.push (new_elem);
     }
 
-    std::stack<elem *> lifo;
+    std::stack<elem *> m_lifo;
   };
 
   // Like unwind_protect, but this one will guard against the possibility