Mercurial > hg > octave-lyh
changeset 9704:bb413c0d0d6d
whos: kluge fix to get size right for objects
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 07 Oct 2009 14:34:53 -0400 |
parents | 9a5598cf899d |
children | 5acd99c3e794 |
files | src/ChangeLog src/variables.cc |
diffstat | 2 files changed, 28 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2009-10-07 John W. Eaton <jwe@octave.org> + + * variables.cc (get_dims_str): New function. + (symbol_info_list::display_line, + symbol_info_list::parse_whos_line_format): Use it to get dims string. + 2009-10-07 John W. Eaton <jwe@octave.org> * ov.h (octave_value::get_count): Return octave_idx_type, not int.
--- a/src/variables.cc +++ b/src/variables.cc @@ -883,6 +883,26 @@ os << param_buf.str (); } +// FIXME -- This is a bit of a kluge. We'd like to just use val.dims() +// and if val is an object, expect that dims will call size if it is +// overloaded by a user-defined method. But there are currently some +// unresolved const issues that prevent that solution from working. + +std::string +get_dims_str (const octave_value& val) +{ + octave_value tmp = val; + + Matrix sz = tmp.size (); + + dim_vector dv (sz.numel ()); + + for (octave_idx_type i = 0; i < dv.length (); i++) + dv(i) = sz(i); + + return dv.str (); +} + class symbol_info_list { @@ -903,8 +923,7 @@ void display_line (std::ostream& os, const std::list<whos_parameter>& params) const { - dim_vector dims = varval.dims (); - std::string dims_str = dims.str (); + std::string dims_str = get_dims_str (varval); std::list<whos_parameter>::const_iterator i = params.begin (); @@ -1300,8 +1319,7 @@ p != lst.end (); p++) { octave_value val = p->varval; - dim_vector dims = val.dims (); - std::string dims_str = dims.str (); + std::string dims_str = get_dims_str (val); int first1 = dims_str.find ('x'); int total1 = dims_str.length (); int rest1 = total1 - first1;