# HG changeset patch # User Rik # Date 1631053607 25200 # Node ID 938794bc82b72e3dbe128ccf17017bbe4a4ff618 # Parent 72afd5cd4a0c953ac5b2b1cbad72b3b9d213a06c maint: use "m_" prefix for member variables in class octave_base_value. * ov-base-diag.cc, ov-base.cc, ov-base.h, ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-java.cc, ov-perm.cc, ov-re-diag.cc, ov-struct.cc, ov.cc, ov.h: Use "m_" prefix for member variables in class octave_base_value. diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-base-diag.cc --- a/libinterp/octave-value/ov-base-diag.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-base-diag.cc Tue Sep 07 15:26:47 2021 -0700 @@ -192,7 +192,7 @@ { matrix.dgelem (i0(0)) = val; retval = this; - this->count++; + this->m_count++; // invalidate cache dense_cache = octave_value (); } @@ -220,7 +220,7 @@ { matrix.dgelem (i0(0)) = val; retval = this; - this->count++; + this->m_count++; // invalidate cache dense_cache = octave_value (); } diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-base.cc --- a/libinterp/octave-value/ov-base.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-base.cc Tue Sep 07 15:26:47 2021 -0700 @@ -1248,7 +1248,7 @@ if (done) { - count++; + m_count++; retval = octave_value (this); } else @@ -1311,7 +1311,7 @@ else tmp_rhs = rhs; - count++; + m_count++; octave_value tmp_lhs = octave_value (this); if (cf_this) diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-base.h --- a/libinterp/octave-value/ov-base.h Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-base.h Tue Sep 07 15:26:47 2021 -0700 @@ -254,9 +254,9 @@ friend class octave_value; - octave_base_value (void) : count (1) { } + octave_base_value (void) : m_count (1) { } - octave_base_value (const octave_base_value&) : count (1) { } + octave_base_value (const octave_base_value&) : m_count (1) { } virtual ~octave_base_value (void) = default; @@ -274,7 +274,8 @@ virtual octave_base_value * unique_clone (void) { return clone (); } - virtual void break_closure_cycles (const std::shared_ptr&) { } + virtual void break_closure_cycles (const std::shared_ptr&) + { } virtual type_conv_info numeric_conversion_function (void) const @@ -301,7 +302,8 @@ virtual octave_value as_uint32 (void) const; virtual octave_value as_uint64 (void) const; - virtual octave_base_value * try_narrowing_conversion (void) { return nullptr; } + virtual octave_base_value * try_narrowing_conversion (void) + { return nullptr; } virtual void maybe_economize (void) { } @@ -890,21 +892,25 @@ OCTINTERP_API void reset (void) const; - // A reference count. - // NOTE: the declaration is octave_idx_type because with 64-bit indexing, - // it is well possible to have more than MAX_INT copies of a single value - // (think of an empty cell array with >2G elements). - octave::refcount count; - OCTINTERP_API static const char * get_umap_name (unary_mapper_t); OCTINTERP_API void warn_load (const char *type) const; OCTINTERP_API void warn_save (const char *type) const; + //-------- + + // A reference count. + // NOTE: the declaration is octave_idx_type because with 64-bit indexing, + // it is well possible to have more than MAX_INT copies of a single value + // (think of an empty cell array with >2G elements). + octave::refcount m_count; + private: OCTINTERP_API void wrong_type_arg_error (void) const; + //-------- + static int curr_print_indent_level; static bool beginning_of_line; diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-cell.cc --- a/libinterp/octave-value/ov-cell.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-cell.cc Tue Sep 07 15:26:47 2021 -0700 @@ -364,7 +364,7 @@ else octave_base_matrix::assign (i, Cell (t_rhs)); - count++; + m_count++; retval = octave_value (this); } break; @@ -396,7 +396,7 @@ else err_nonbraced_cs_list_assignment (); - count++; + m_count++; retval = octave_value (this); } break; diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-class.cc --- a/libinterp/octave-value/ov-class.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-class.cc Tue Sep 07 15:26:47 2021 -0700 @@ -208,16 +208,16 @@ octave_base_value * octave_class::unique_clone (void) { - if (count == m_obsolete_copies) + if (m_count == m_obsolete_copies) { // All remaining copies are obsolete. We don't actually need to clone. - count++; + m_count++; return this; } else { // In theory, this shouldn't be happening, but it's here just in case. - if (count < m_obsolete_copies) + if (m_count < m_obsolete_copies) m_obsolete_copies = 0; return clone (); @@ -320,7 +320,7 @@ if (meth.is_defined ()) { - count++; + m_count++; octave_value_list args (1, octave_value (this)); octave_value_list lv = octave::feval (meth.function_value (), args, 1); @@ -363,7 +363,7 @@ { octave_value_list args (idx.length () + 1, octave_value ()); - count++; + m_count++; args(0) = octave_value (this); for (octave_idx_type i = 0; i < idx.length (); i++) @@ -461,7 +461,7 @@ args(1) = make_idx_args (type, idx, "subsref"); - count++; + m_count++; args(0) = octave_value (this); // FIXME: for Matlab compatibility, let us attempt to set up a proper @@ -525,7 +525,7 @@ const std::list& idx, const octave_value& rhs) { - count++; + m_count++; return subsasgn_common (octave_value (this), type, idx, rhs); } @@ -627,7 +627,7 @@ obvp->subsasgn (type, idx, rhs); - count++; + m_count++; retval = octave_value (this); return retval; @@ -753,7 +753,7 @@ m_map.assign (idx.front (), key, t_rhs); - count++; + m_count++; retval = octave_value (this); } else @@ -764,7 +764,7 @@ m_map.assign (idx.front (), rhs_map); - count++; + m_count++; retval = octave_value (this); } else @@ -774,7 +774,7 @@ m_map.delete_elements (idx.front ()); - count++; + m_count++; retval = octave_value (this); } } @@ -809,7 +809,7 @@ m_map.setfield (key, tmp_cell); } - count++; + m_count++; retval = octave_value (this); } break; diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-classdef.cc --- a/libinterp/octave-value/ov-classdef.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-classdef.cc Tue Sep 07 15:26:47 2021 -0700 @@ -88,7 +88,7 @@ args(1) = make_idx_args (type, idx, "subsref"); - count++; + m_count++; args(0) = octave_value (this); retval = meth.execute (args, nargout, true, "subsref"); @@ -131,7 +131,7 @@ args(1) = make_idx_args (type, idx, "subsref"); - count++; + m_count++; args(0) = octave_value (this); retval = meth.execute (args, 1, true, "subsref"); @@ -167,7 +167,7 @@ args(1) = make_idx_args (type, idx, "subsasgn"); - count++; + m_count++; args(0) = octave_value (this); args(2) = rhs; @@ -216,7 +216,7 @@ if (meth.ok ()) { - count++; + m_count++; octave_value_list args (1, octave_value (this)); octave_value_list lv = meth.execute (args, 1, true, "size"); @@ -246,7 +246,7 @@ { octave_value_list args (idx.length () + 1, octave_value ()); - count++; + m_count++; args(0) = octave_value (this); for (octave_idx_type i = 0; i < idx.length (); i++) diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-java.cc Tue Sep 07 15:26:47 2021 -0700 @@ -2197,7 +2197,7 @@ if (type.length () > 1 && type[1] == '(') { octave_value_list ovl; - count++; + m_count++; ovl(1) = octave_value (this); ovl(0) = (idx.front ())(0); auto it = idx.begin (); @@ -2208,7 +2208,7 @@ else { octave_value_list ovl; - count++; + m_count++; ovl(0) = octave_value (this); ovl(1) = (idx.front ())(0); retval = octave::F__java_get__ (ovl, 1); @@ -2263,13 +2263,13 @@ { // field assignment octave_value_list ovl; - count++; + m_count++; ovl(0) = octave_value (this); ovl(1) = (idx.front ())(0); ovl(2) = rhs; octave::F__java_set__ (ovl); - count++; + m_count++; retval = octave_value (this); } else if (type.length () > 2 && type[1] == '(') @@ -2285,7 +2285,7 @@ next_idx.erase (next_idx.begin ()); u(0).subsasgn (type.substr (2), next_idx, rhs); - count++; + m_count++; retval = octave_value (this); } else if (type[1] == '.') @@ -2296,7 +2296,7 @@ next_idx.erase (next_idx.begin ()); u(0).subsasgn (type.substr (1), next_idx, rhs); - count++; + m_count++; retval = octave_value (this); } else @@ -2309,7 +2309,7 @@ set_array_elements (current_env, TO_JOBJECT (to_java ()), idx.front (), rhs); - count++; + m_count++; retval = octave_value (this); } break; diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-perm.cc --- a/libinterp/octave-value/ov-perm.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-perm.cc Tue Sep 07 15:26:47 2021 -0700 @@ -118,7 +118,7 @@ else { retval = this; - this->count++; + this->m_count++; } } } diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-re-diag.cc --- a/libinterp/octave-value/ov-re-diag.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-re-diag.cc Tue Sep 07 15:26:47 2021 -0700 @@ -118,7 +118,7 @@ else { retval = this; - this->count++; + this->m_count++; } } } diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov-struct.cc --- a/libinterp/octave-value/ov-struct.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov-struct.cc Tue Sep 07 15:26:47 2021 -0700 @@ -465,7 +465,7 @@ m_map.assign (idxf, key, tmp_cell); - count++; + m_count++; retval = octave_value (this); } else @@ -478,7 +478,7 @@ m_map.assign (idxf, key, Cell (t_rhs.storable_value ())); - count++; + m_count++; retval = octave_value (this); } else @@ -493,7 +493,7 @@ m_map.assign (idx.front (), rhs_map); - count++; + m_count++; retval = octave_value (this); } else @@ -503,7 +503,7 @@ m_map.delete_elements (idx.front ()); - count++; + m_count++; retval = octave_value (this); } } @@ -540,7 +540,7 @@ m_map.setfield (key, tmp_cell); } - count++; + m_count++; retval = octave_value (this); } break; @@ -1268,7 +1268,7 @@ m_map.setfield (key, t_rhs.storable_value ()); - count++; + m_count++; retval = this; } else diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov.cc --- a/libinterp/octave-value/ov.cc Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov.cc Tue Sep 07 15:26:47 2021 -0700 @@ -1232,7 +1232,7 @@ : m_rep (new_rep) { if (borrow) - m_rep->count++; + m_rep->m_count++; } octave_base_value * @@ -1275,7 +1275,7 @@ if (tmp && tmp != m_rep) { - if (--m_rep->count == 0) + if (--m_rep->m_count == 0) delete m_rep; m_rep = tmp; @@ -1666,7 +1666,7 @@ octave::type_info::assign_op_fcn f = nullptr; // Only attempt to operate in-place if this variable is unshared. - if (m_rep->count == 1) + if (m_rep->m_count == 1) { int tthis = this->type_id (); int trhs = rhs.type_id (); @@ -2292,14 +2292,14 @@ if (isnull ()) { octave_base_value *rc = m_rep->empty_clone (); - if (--m_rep->count == 0) + if (--m_rep->m_count == 0) delete m_rep; m_rep = rc; } else if (is_magic_int ()) { octave_base_value *rc = new octave_scalar (m_rep->double_value ()); - if (--m_rep->count == 0) + if (--m_rep->m_count == 0) delete m_rep; m_rep = rc; } @@ -2327,7 +2327,7 @@ octave_value::print_info (std::ostream& os, const std::string& prefix) const { os << prefix << "type_name: " << type_name () << "\n" - << prefix << "count: " << get_count () << "\n" + << prefix << "m_count: " << get_count () << "\n" << prefix << "m_rep info: "; m_rep->print_info (os, prefix + ' '); @@ -2470,14 +2470,14 @@ { f (*m_rep); - if (old_rep && --old_rep->count == 0) + if (old_rep && --old_rep->m_count == 0) delete old_rep; } else { if (old_rep) { - if (--m_rep->count == 0) + if (--m_rep->m_count == 0) delete m_rep; m_rep = old_rep; @@ -2496,7 +2496,7 @@ octave::type_info::non_const_unary_op_fcn f = nullptr; // Only attempt to operate in-place if this variable is unshared. - if (m_rep->count == 1) + if (m_rep->m_count == 1) { octave::type_info& ti = octave::__get_type_info__ ("non_const_unary_op"); diff -r 72afd5cd4a0c -r 938794bc82b7 libinterp/octave-value/ov.h --- a/libinterp/octave-value/ov.h Tue Sep 07 14:39:08 2021 -0700 +++ b/libinterp/octave-value/ov.h Tue Sep 07 15:26:47 2021 -0700 @@ -170,7 +170,7 @@ octave_value (void) : m_rep (nil_rep ()) { - m_rep->count++; + m_rep->m_count++; } OCTINTERP_API octave_value (short int i); @@ -359,7 +359,7 @@ octave_value (const octave_value& a) : m_rep (a.m_rep) { - m_rep->count++; + m_rep->m_count++; } octave_value (octave_value&& a) @@ -383,17 +383,17 @@ // operator, rep may be a nullptr here. We should only need to // protect the move assignment operator in a similar way. - if (m_rep && --m_rep->count == 0 && m_rep != nil_rep ()) + if (m_rep && --m_rep->m_count == 0 && m_rep != nil_rep ()) delete m_rep; } void make_unique (void) { - if (m_rep->count > 1) + if (m_rep->m_count > 1) { octave_base_value *r = m_rep->unique_clone (); - if (--m_rep->count == 0 && m_rep != nil_rep ()) + if (--m_rep->m_count == 0 && m_rep != nil_rep ()) delete m_rep; m_rep = r; @@ -405,11 +405,11 @@ // know a certain copy, typically within a cell array, to be obsolete. void make_unique (int obsolete_copies) { - if (m_rep->count > obsolete_copies + 1) + if (m_rep->m_count > obsolete_copies + 1) { octave_base_value *r = m_rep->unique_clone (); - if (--m_rep->count == 0 && m_rep != nil_rep ()) + if (--m_rep->m_count == 0 && m_rep != nil_rep ()) delete m_rep; m_rep = r; @@ -428,11 +428,11 @@ { if (m_rep != a.m_rep) { - if (--m_rep->count == 0 && m_rep != nil_rep ()) + if (--m_rep->m_count == 0 && m_rep != nil_rep ()) delete m_rep; m_rep = a.m_rep; - m_rep->count++; + m_rep->m_count++; } return *this; @@ -446,7 +446,7 @@ if (this != &a) { - if (m_rep && --m_rep->count == 0 && m_rep != nil_rep ()) + if (m_rep && --m_rep->m_count == 0 && m_rep != nil_rep ()) delete m_rep; m_rep = a.m_rep; @@ -456,7 +456,7 @@ return *this; } - octave_idx_type get_count (void) const { return m_rep->count; } + octave_idx_type get_count (void) const { return m_rep->m_count; } octave_base_value::type_conv_info numeric_conversion_function (void) const { return m_rep->numeric_conversion_function (); }