Mercurial > octave
diff libinterp/octave-value/ov-struct.cc @ 30077:b16e0d357437
maint: use "m_" prefix for member variables in some octave-value classes.
* ov-cs-list.h, ov-cs-list.cc, ov-dld-fcn.h, ov-dld-fcn.cc,
ov-lazy-idx.h, ov-lazy-idx.cc, ov-oncleanup.h, ov-oncleanup.cc,
ov-perm.h, ov-perm.cc, ov-struct.h, ov-struct.cc, ov-typeinfo.h,
ov-typeinfo.cc: Use "m_" prefix for class member variables.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 30 Aug 2021 14:02:47 -0400 |
parents | 428cccc75cc9 |
children | 938794bc82b7 |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-struct.cc Mon Aug 30 10:52:39 2021 -0700 +++ b/libinterp/octave-value/ov-struct.cc Mon Aug 30 14:02:47 2021 -0400 @@ -66,9 +66,9 @@ void octave_struct::break_closure_cycles (const std::shared_ptr<octave::stack_frame>& frame) { - for (octave_idx_type j = 0; j < map.nfields (); j++) + for (octave_idx_type j = 0; j < m_map.nfields (); j++) { - Cell& c = map.contents (j); + Cell& c = m_map.contents (j); for (octave_idx_type i = 0; i < c.numel (); i++) c(i).break_closure_cycles (frame); @@ -81,7 +81,7 @@ octave_base_value *retval = nullptr; if (numel () == 1) - retval = new octave_scalar_struct (map.checkelem (0)); + retval = new octave_scalar_struct (m_map.checkelem (0)); return retval; } @@ -95,10 +95,10 @@ std::string nm = idx(0).string_value (); - octave_map::const_iterator p = map.seek (nm); - - if (p != map.end ()) - retval = map.contents (p); + octave_map::const_iterator p = m_map.seek (nm); + + if (p != m_map.end ()) + retval = m_map.contents (p); else if (auto_add) retval = (isempty ()) ? Cell (dim_vector (1, 1)) : Cell (dims ()); else @@ -241,7 +241,7 @@ case '.': { - if (map.numel () > 0) + if (m_map.numel () > 0) { const Cell t = dotref (idx.front (), auto_add); @@ -338,11 +338,11 @@ std::string next_type = type.substr (2); Cell tmpc (1, 1); - auto pkey = map.seek (key); - if (pkey != map.end ()) + auto pkey = m_map.seek (key); + if (pkey != m_map.end ()) { - map.contents (pkey).make_unique (); - tmpc = map.contents (pkey).index (idx.front (), true); + m_map.contents (pkey).make_unique (); + tmpc = m_map.contents (pkey).index (idx.front (), true); } // FIXME: better code reuse? @@ -390,11 +390,11 @@ std::string next_type = type.substr (1); Cell tmpc (1, 1); - auto pkey = map.seek (key); - if (pkey != map.end ()) + auto pkey = m_map.seek (key); + if (pkey != m_map.end ()) { - map.contents (pkey).make_unique (); - tmpc = map.contents (pkey); + m_map.contents (pkey).make_unique (); + tmpc = m_map.contents (pkey); } // FIXME: better code reuse? @@ -463,19 +463,19 @@ if (didx.numel () == tmp_cell.numel ()) tmp_cell = tmp_cell.reshape (didx); - map.assign (idxf, key, tmp_cell); + m_map.assign (idxf, key, tmp_cell); count++; retval = octave_value (this); } else { - const octave_map& cmap = const_cast<const octave_map &> (map); + const octave_map& cmap = const_cast<const octave_map &> (m_map); // cast to const reference, avoid forced key insertion. if (idxf.all_scalars () || cmap.contents (key).index (idxf, true).numel () == 1) { - map.assign (idxf, + m_map.assign (idxf, key, Cell (t_rhs.storable_value ())); count++; @@ -491,7 +491,7 @@ { octave_map rhs_map = t_rhs.xmap_value ("invalid structure assignment"); - map.assign (idx.front (), rhs_map); + m_map.assign (idx.front (), rhs_map); count++; retval = octave_value (this); @@ -501,7 +501,7 @@ if (! t_rhs.isnull ()) error ("invalid structure assignment"); - map.delete_elements (idx.front ()); + m_map.delete_elements (idx.front ()); count++; retval = octave_value (this); @@ -531,13 +531,13 @@ if (numel () == tmp_cell.numel ()) tmp_cell = tmp_cell.reshape (dims ()); - map.setfield (key, tmp_cell); + m_map.setfield (key, tmp_cell); } else { Cell tmp_cell(1, 1); tmp_cell(0) = t_rhs.storable_value (); - map.setfield (key, tmp_cell); + m_map.setfield (key, tmp_cell); } count++; @@ -564,10 +564,10 @@ if (idx.length () == 0) { warn_empty_index (type_name ()); - return map; + return m_map; } else // octave_map handles indexing itself. - return map.index (idx, resize_ok); + return m_map.index (idx, resize_ok); } std::size_t @@ -577,11 +577,11 @@ std::size_t retval = 0; - for (auto p = map.cbegin (); p != map.cend (); p++) + for (auto p = m_map.cbegin (); p != m_map.cend (); p++) { - std::string key = map.key (p); - - octave_value val = octave_value (map.contents (p)); + std::string key = m_map.key (p); + + octave_value val = octave_value (m_map.contents (p)); retval += val.byte_size (); } @@ -616,13 +616,13 @@ increment_indent_level (); - string_vector key_list = map.fieldnames (); + string_vector key_list = m_map.fieldnames (); for (octave_idx_type i = 0; i < key_list.numel (); i++) { std::string key = key_list[i]; - Cell val = map.contents (key); + Cell val = m_map.contents (key); if (i > 0 || ! Vcompact_format) newline (os); @@ -686,11 +686,11 @@ octave_idx_type r, octave_idx_type c) const { octave_value val; - if (map.rows () == 1 || map.columns () == 1) + if (m_map.rows () == 1 || m_map.columns () == 1) { // Vector struct. Columns are fields, rows are values. - Cell cval = map.contents (c); + Cell cval = m_map.contents (c); val = cval(r); } @@ -699,7 +699,7 @@ // 2-d struct array. Rows and columns index individual // scalar structs. - val = map(r,c); + val = m_map(r,c); } std::string tname = val.type_name (); @@ -734,7 +734,7 @@ { std::string key = keys(i); - octave_value val = map.contents (key); + octave_value val = m_map.contents (key); bool b = save_text_data (os, val, key, false, 0); @@ -803,10 +803,10 @@ if (! is) error ("load: failed to load structure"); - map = m; + m_map = m; } else if (len == 0) - map = octave_map (dv); + m_map = octave_map (dv); else panic_impossible (); @@ -844,7 +844,7 @@ { std::string key = keys(i); - octave_value val = map.contents (key); + octave_value val = m_map.contents (key); bool b = save_binary_data (os, val, key, "", 0, save_as_floats); @@ -916,10 +916,10 @@ if (! is) error ("load: failed to load structure"); - map = m; + m_map = m; } else if (len == 0) - map = octave_map (dv); + m_map = octave_map (dv); else success = false; @@ -955,7 +955,7 @@ { std::string key = keys(i); - octave_value val = map.contents (key); + octave_value val = m_map.contents (key); bool retval2 = add_hdf5_data (data_hid, val, key, "", false, save_as_floats); @@ -1017,7 +1017,7 @@ if (retval2 >= 0) { - map = m; + m_map = m; retval = true; } @@ -1052,7 +1052,7 @@ for (int i = 0; i < nf; i++) { - Cell c = map.contents (kv[i]); + Cell c = m_map.contents (kv[i]); const octave_value *p = c.data (); @@ -1067,8 +1067,8 @@ octave_value octave_struct::fast_elem_extract (octave_idx_type n) const { - if (n < map.numel ()) - return map.checkelem (n); + if (n < m_map.numel ()) + return m_map.checkelem (n); else return octave_value (); } @@ -1079,14 +1079,14 @@ { bool retval = false; - if (n < map.numel ()) + if (n < m_map.numel ()) { // To avoid copying the scalar struct, it just stores a pointer to // itself. const octave_scalar_map *sm_ptr; void *here = reinterpret_cast<void *>(&sm_ptr); return (x.get_rep ().fast_elem_insert_self (here, btyp_struct) - && map.fast_elem_insert (n, *sm_ptr)); + && m_map.fast_elem_insert (n, *sm_ptr)); } return retval; @@ -1098,8 +1098,8 @@ void octave_scalar_struct::break_closure_cycles (const std::shared_ptr<octave::stack_frame>& frame) { - for (octave_idx_type i = 0; i < map.nfields (); i++) - map.contents(i).break_closure_cycles (frame); + for (octave_idx_type i = 0; i < m_map.nfields (); i++) + m_map.contents(i).break_closure_cycles (frame); } octave_value @@ -1113,7 +1113,7 @@ maybe_warn_invalid_field_name (nm, "subsref"); - retval = map.getfield (nm); + retval = m_map.getfield (nm); if (! auto_add && retval.is_undefined ()) error_with_id ("Octave:invalid-indexing", @@ -1243,11 +1243,11 @@ std::string next_type = type.substr (1); octave_value tmp; - auto pkey = map.seek (key); - if (pkey != map.end ()) + auto pkey = m_map.seek (key); + if (pkey != m_map.end ()) { - map.contents (pkey).make_unique (); - tmp = map.contents (pkey); + m_map.contents (pkey).make_unique (); + tmp = m_map.contents (pkey); } bool orig_undefined = tmp.is_undefined (); @@ -1258,7 +1258,7 @@ tmp.make_unique (); // probably a no-op. } else - // optimization: ignore the copy still stored inside our map. + // optimization: ignore the copy still stored inside our m_map. tmp.make_unique (1); t_rhs = (orig_undefined @@ -1266,7 +1266,7 @@ : tmp.subsasgn (next_type, next_idx, rhs)); } - map.setfield (key, t_rhs.storable_value ()); + m_map.setfield (key, t_rhs.storable_value ()); count++; retval = this; @@ -1274,7 +1274,7 @@ else { // Forward this case to octave_struct. - octave_value tmp (new octave_struct (octave_map (map))); + octave_value tmp (new octave_struct (octave_map (m_map))); retval = tmp.subsasgn (type, idx, rhs); } @@ -1285,7 +1285,7 @@ octave_scalar_struct::do_index_op (const octave_value_list& idx, bool resize_ok) { // octave_map handles indexing itself. - return octave_map (map).index (idx, resize_ok); + return octave_map (m_map).index (idx, resize_ok); } std::size_t @@ -1295,11 +1295,11 @@ std::size_t retval = 0; - for (auto p = map.cbegin (); p != map.cend (); p++) + for (auto p = m_map.cbegin (); p != m_map.cend (); p++) { - std::string key = map.key (p); - - octave_value val = octave_value (map.contents (p)); + std::string key = m_map.key (p); + + octave_value val = octave_value (m_map.contents (p)); retval += val.byte_size (); } @@ -1327,13 +1327,13 @@ increment_indent_level (); increment_indent_level (); - string_vector key_list = map.fieldnames (); + string_vector key_list = m_map.fieldnames (); for (octave_idx_type i = 0; i < key_list.numel (); i++) { std::string key = key_list[i]; - octave_value val = map.contents (key); + octave_value val = m_map.contents (key); if (print_fieldnames_only) { @@ -1397,7 +1397,7 @@ { // Scalar struct. Rows are fields, single column for values. - octave_value val = map.contents (r); + octave_value val = m_map.contents (r); std::string tname = val.type_name (); dim_vector dv = val.dims (); @@ -1430,7 +1430,7 @@ { std::string key = keys(i); - octave_value val = map.contents (key); + octave_value val = m_map.contents (key); bool b = save_text_data (os, val, key, false, 0); @@ -1471,10 +1471,10 @@ if (! is) error ("load: failed to load structure"); - map = m; + m_map = m; } else if (len == 0) - map = octave_scalar_map (); + m_map = octave_scalar_map (); else panic_impossible (); @@ -1499,7 +1499,7 @@ { std::string key = keys(i); - octave_value val = map.contents (key); + octave_value val = m_map.contents (key); bool b = save_binary_data (os, val, key, "", 0, save_as_floats); @@ -1544,10 +1544,10 @@ if (! is) error ("load: failed to load structure"); - map = m; + m_map = m; } else if (len == 0) - map = octave_scalar_map (); + m_map = octave_scalar_map (); else success = false; @@ -1583,7 +1583,7 @@ { std::string key = keys(i); - octave_value val = map.contents (key); + octave_value val = m_map.contents (key); bool retval2 = add_hdf5_data (data_hid, val, key, "", false, save_as_floats); @@ -1643,7 +1643,7 @@ if (retval2 >= 0) { - map = m; + m_map = m; retval = true; } @@ -1678,7 +1678,7 @@ for (int i = 0; i < nf; i++) { - Cell c = map.contents (kv[i]); + Cell c = m_map.contents (kv[i]); const octave_value *p = c.data (); @@ -1693,7 +1693,7 @@ octave_value octave_scalar_struct::to_array (void) { - return new octave_struct (octave_map (map)); + return new octave_struct (octave_map (m_map)); } bool @@ -1703,7 +1703,7 @@ if (btyp == btyp_struct) { - *(reinterpret_cast<const octave_scalar_map **>(where)) = ↦ + *(reinterpret_cast<const octave_scalar_map **>(where)) = &m_map; return true; } else @@ -1837,7 +1837,7 @@ // Create the return value. - octave_map map (dims); + octave_map m_map (dims); for (int i = 0; i < nargin; i+= 2) { @@ -1858,15 +1858,15 @@ const Cell c (args(i+1).cell_value ()); if (scalar (c.dims ())) - map.setfield (key, Cell (dims, c(0))); + m_map.setfield (key, Cell (dims, c(0))); else - map.setfield (key, c); + m_map.setfield (key, c); } else - map.setfield (key, Cell (dims, args(i+1))); + m_map.setfield (key, Cell (dims, args(i+1))); } - return ovl (map); + return ovl (m_map); } /* @@ -2125,16 +2125,16 @@ rdv.resize (nd-1); } - octave_map map (rdv); + octave_map m_map (rdv); Array<idx_vector> ia (dim_vector (nd, 1), idx_vector::colon); for (octave_idx_type i = 0; i < ext; i++) { ia(dim) = i; - map.setfield (fields(i), vals.index (ia).reshape (rdv)); + m_map.setfield (fields(i), vals.index (ia).reshape (rdv)); } - return ovl (map); + return ovl (m_map); } /*