Mercurial > hg > octave-terminal
changeset 10768:8a868004a437
use octave_map for octave_class
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 07 Jul 2010 10:57:52 +0200 |
parents | 2b041d3995a3 |
children | 569823598028 |
files | src/ChangeLog src/ov-base.cc src/ov-base.h src/ov-class.cc src/ov-class.h src/ov.cc src/ov.h |
diffstat | 7 files changed, 52 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-07-07 Jaroslav Hajek <highegg@gmail.com> + + * ov-class.h (octave_class::map): Turn to octave_map. + * ov-class.cc (octave_class): Update methods. + * ov-base.h, ov-base.cc (octave_base_value::old_map_value) : Remove. + * ov.h, ov.cc (octave_value::old_map_value) : Remove. + 2010-07-02 Jaroslav Hajek <highegg@gmail.com> * toplev.cc (octave_call_stack::do_backtrace): Use static
--- a/src/ov-base.cc +++ b/src/ov-base.cc @@ -909,12 +909,6 @@ } } -Octave_map -octave_base_value::old_map_value (void) const -{ - return map_value (); -} - string_vector octave_base_value::map_keys (void) const {
--- a/src/ov-base.h +++ b/src/ov-base.h @@ -548,8 +548,6 @@ virtual octave_scalar_map scalar_map_value (void) const; - virtual Octave_map old_map_value (void) const; - virtual string_vector map_keys (void) const; virtual size_t nparents (void) const;
--- a/src/ov-class.cc +++ b/src/ov-class.cc @@ -66,7 +66,7 @@ (octave_class::t_name, "<unknown>", octave_value (new octave_class ())); } -octave_class::octave_class (const Octave_map& m, const std::string& id, +octave_class::octave_class (const octave_map& m, const std::string& id, const octave_value_list& parents) : octave_base_value (), map (m), c_name (id), obsolete_copies (0) { @@ -231,7 +231,7 @@ } } - Octave_map m; + octave_map m; m.assign ("type", type_field); m.assign ("subs", subs_field); @@ -259,15 +259,15 @@ octave_base_value *obvp = method_class.empty () ? 0 : find_parent_class (method_class); - Octave_map my_map; + octave_map my_map; - my_map = obvp ? obvp->old_map_value () : map; + my_map = obvp ? obvp->map_value () : map; std::string nm = idx(0).string_value (); if (! error_state) { - Octave_map::const_iterator p = my_map.seek (nm); + octave_map::const_iterator p = my_map.seek (nm); if (p != my_map.end ()) retval = my_map.contents (p); @@ -486,7 +486,7 @@ retval = val(0); if (type.length () > 0 && type[0] == '.' && ! retval.is_map ()) - retval = Octave_map (); + retval = octave_map (); } else gripe_invalid_index_for_assignment (); @@ -646,11 +646,11 @@ std::string next_type = type.substr (1); Cell tmpc (1, 1); - Octave_map::iterator pkey = map.seek (key); + octave_map::iterator pkey = map.seek (key); if (pkey != map.end ()) { - pkey->second.make_unique (); - tmpc = pkey->second; + map.contents (pkey).make_unique (); + tmpc = map.contents (pkey); } // FIXME: better code reuse? @@ -721,7 +721,7 @@ { if (t_rhs.is_object () || t_rhs.is_map ()) { - Octave_map rhs_map = t_rhs.old_map_value (); + octave_map rhs_map = t_rhs.map_value (); if (! error_state) { @@ -742,7 +742,7 @@ { if (t_rhs.is_empty ()) { - map.maybe_delete_elements (idx.front()); + map.delete_elements (idx.front()); if (! error_state) { @@ -851,7 +851,7 @@ size_t retval = 0; - for (Octave_map::const_iterator p = map.begin (); p != map.end (); p++) + for (octave_map::const_iterator p = map.begin (); p != map.end (); p++) { std::string key = map.key (p); @@ -884,9 +884,9 @@ pit != parent_list.end (); pit++) { - Octave_map::const_iterator smap = map.seek (*pit); + octave_map::const_iterator smap = map.seek (*pit); - const Cell& tmp = smap->second; + const Cell& tmp = map.contents (smap); octave_value vtmp = tmp(0); @@ -915,9 +915,9 @@ pit != parent_list.end (); pit++) { - Octave_map::iterator smap = map.seek (*pit); + octave_map::iterator smap = map.seek (*pit); - Cell& tmp = smap->second; + Cell& tmp = map.contents (smap); octave_value& vtmp = tmp(0); @@ -1053,7 +1053,7 @@ std::string dbgstr = "dork"; // First, check to see if there might be an issue with inheritance. - for (Octave_map::const_iterator p = map.begin (); p != map.end (); p++) + for (octave_map::const_iterator p = map.begin (); p != map.end (); p++) { std::string key = map.key (p); Cell val = map.contents (p); @@ -1102,22 +1102,22 @@ octave_class::save_ascii (std::ostream& os) { os << "# classname: " << class_name () << "\n"; - Octave_map m; + octave_map m; if (load_path::find_method (class_name (), "saveobj") != std::string ()) { octave_value in = new octave_class (*this); octave_value_list tmp = feval ("saveobj", in, 1); if (! error_state) - m = tmp(0).old_map_value (); + m = tmp(0).map_value (); else return false; } else - m = old_map_value (); + m = map_value (); os << "# length: " << m.nfields () << "\n"; - Octave_map::iterator i = m.begin (); + octave_map::iterator i = m.begin (); while (i != m.end ()) { octave_value val = map.contents (i); @@ -1146,7 +1146,7 @@ { if (len > 0) { - Octave_map m (map); + octave_map m (map); for (octave_idx_type j = 0; j < len; j++) { @@ -1189,7 +1189,7 @@ octave_value_list tmp = feval ("loadobj", in, 1); if (! error_state) - map = tmp(0).old_map_value (); + map = tmp(0).map_value (); else success = false; } @@ -1203,7 +1203,7 @@ } else if (len == 0 ) { - map = Octave_map (dim_vector (1, 1)); + map = octave_map (dim_vector (1, 1)); c_name = classname; } else @@ -1232,23 +1232,23 @@ os.write (reinterpret_cast<char *> (&classname_len), 4); os << class_name (); - Octave_map m; + octave_map m; if (load_path::find_method (class_name (), "saveobj") != std::string ()) { octave_value in = new octave_class (*this); octave_value_list tmp = feval ("saveobj", in, 1); if (! error_state) - m = tmp(0).old_map_value (); + m = tmp(0).map_value (); else return false; } else - m = old_map_value (); + m = map_value (); int32_t len = m.nfields(); os.write (reinterpret_cast<char *> (&len), 4); - Octave_map::iterator i = m.begin (); + octave_map::iterator i = m.begin (); while (i != m.end ()) { octave_value val = map.contents (i); @@ -1295,7 +1295,7 @@ if (len > 0) { - Octave_map m (map); + octave_map m (map); for (octave_idx_type j = 0; j < len; j++) { @@ -1335,7 +1335,7 @@ octave_value_list tmp = feval ("loadobj", in, 1); if (! error_state) - map = tmp(0).old_map_value (); + map = tmp(0).map_value (); else success = false; } @@ -1348,7 +1348,7 @@ } } else if (len == 0 ) - map = Octave_map (dim_vector (1, 1)); + map = octave_map (dim_vector (1, 1)); else panic_impossible (); @@ -1366,8 +1366,8 @@ hid_t space_hid = -1; hid_t class_hid = -1; hid_t data_hid = -1; - Octave_map m; - Octave_map::iterator i; + octave_map m; + octave_map::iterator i; #if HAVE_HDF5_18 group_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -1410,12 +1410,12 @@ octave_value in = new octave_class (*this); octave_value_list tmp = feval ("saveobj", in, 1); if (! error_state) - m = tmp(0).old_map_value (); + m = tmp(0).map_value (); else goto error_cleanup; } else - m = old_map_value (); + m = map_value (); // recursively add each element of the class to this group i = m.begin (); @@ -1468,7 +1468,7 @@ hdf5_callback_data dsub; herr_t retval2 = 0; - Octave_map m (dim_vector (1, 1)); + octave_map m (dim_vector (1, 1)); int current_item = 0; hsize_t num_obj = 0; int slen = 0; @@ -1576,7 +1576,7 @@ if (! error_state) { - map = tmp(0).old_map_value (); + map = tmp(0).map_value (); retval = true; } else @@ -1624,7 +1624,7 @@ { if (obj.is_object ()) { - Octave_map m = obj.old_map_value (); + octave_map m = obj.map_value (); field_names = m.keys (); parent_class_names = obj.parent_class_name_list (); @@ -1646,7 +1646,7 @@ { if (nfields () == obj.nfields ()) { - Octave_map obj_map = obj.old_map_value (); + octave_map obj_map = obj.map_value (); string_vector obj_fnames = obj_map.keys (); string_vector fnames = fields (); @@ -1725,7 +1725,7 @@ if (fcn && fcn->is_class_constructor ()) { - Octave_map m = args(0).old_map_value (); + octave_map m = args(0).map_value (); if (! error_state) {
--- a/src/ov-class.h +++ b/src/ov-class.h @@ -52,14 +52,14 @@ octave_class (void) : octave_base_value (), obsolete_copies (0) { } - octave_class (const Octave_map& m, const std::string& id) + octave_class (const octave_map& m, const std::string& id) : octave_base_value (), map (m), c_name (id), obsolete_copies (0) { } octave_class (const octave_class& s) : octave_base_value (s), map (s.map), c_name (s.c_name), parent_list (s.parent_list), obsolete_copies (0) { } - octave_class (const Octave_map& m, const std::string& id, + octave_class (const octave_map& m, const std::string& id, const octave_value_list& parents); ~octave_class (void) { } @@ -70,7 +70,7 @@ octave_base_value *empty_clone (void) const { - return new octave_class (Octave_map (map.keys ()), class_name ()); + return new octave_class (octave_map (map.keys ()), class_name ()); } Cell dotref (const octave_value_list& idx); @@ -122,7 +122,7 @@ { return map.reshape (new_dims); } octave_value resize (const dim_vector& dv, bool = false) const - { Octave_map tmap = map; tmap.resize (dv); return tmap; } + { octave_map tmap = map; tmap.resize (dv); return tmap; } bool is_defined (void) const { return true; } @@ -132,8 +132,6 @@ octave_map map_value (void) const { return map; } - Octave_map old_map_value (void) const { return map; } - string_vector map_keys (void) const; std::list<std::string> parent_class_name_list (void) const @@ -180,7 +178,7 @@ private: - Octave_map map; + octave_map map; DECLARE_OCTAVE_ALLOCATOR