# HG changeset patch # User John W. Eaton # Date 1560355386 18000 # Node ID 8498dccc15c7d6639a168e8a9926f4ba74144930 # Parent 0112951951a9ca11fdffd62dea23a7a88c586653 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. diff -r 0112951951a9 -r 8498dccc15c7 liboctave/util/action-container.h --- 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) { } diff -r 0112951951a9 -r 8498dccc15c7 liboctave/util/functor.h --- 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 class fcn_ptr { public: + typedef RT (*TYPE) (PT); }; @@ -36,28 +39,32 @@ class functor { private: + typedef typename fcn_ptr::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 class functor_with_conversion { private: + typedef typename fcn_ptr::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 diff -r 0112951951a9 -r 8498dccc15c7 liboctave/util/oct-binmap.h --- 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 -F bsxfun_wrapper::f; +F bsxfun_wrapper::s_fcn; // scalar-Array template diff -r 0112951951a9 -r 8498dccc15c7 liboctave/util/oct-refcount.h --- 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); + return static_cast (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; }; } diff -r 0112951951a9 -r 8498dccc15c7 liboctave/util/sparse-sort.cc --- 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; diff -r 0112951951a9 -r 8498dccc15c7 liboctave/util/sparse-sort.h --- 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; }; diff -r 0112951951a9 -r 8498dccc15c7 liboctave/util/str-vec.h --- 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::elem (i); } + { + return Array::elem (i); + } std::string operator[] (octave_idx_type i) const - { return Array::elem (i); } + { + return Array::elem (i); + } string_vector& sort (bool make_uniq = false); diff -r 0112951951a9 -r 8498dccc15c7 liboctave/util/unwind-prot.h --- 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 ptr (lifo.top ()); - lifo.pop (); + std::unique_ptr 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 lifo; + std::stack m_lifo; }; // Like unwind_protect, but this one will guard against the possibility