[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: displaying structures array as table
From: |
John W. Eaton |
Subject: |
Re: displaying structures array as table |
Date: |
Thu, 1 Sep 2011 16:50:22 -0400 |
On 30-Aug-2011, Ben Abbott wrote:
| It appears that ML and Octave are using methods of different names to display
| the contents of built-in objects.
I think we need something like the following patch. I'm not sure this
is the best fix so I'm not checking it in yet.
jwe
# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1314910098 14400
# Node ID c4d6d4ed0be1f1d30e0526c8d06f00c06fc0603e
# Parent 7d4429c8221255c4269c51154bbc7d63710a0cc6
dispatch internal display
* ov-base.cc (octave_base_value::print_with_name): Dispatch to
user-defined display method here.
diff --git a/src/ov-base.cc b/src/ov-base.cc
--- a/src/ov-base.cc
+++ b/src/ov-base.cc
@@ -431,12 +431,28 @@
const std::string& name,
bool print_padding)
{
- bool pad_after = print_name_tag (output_buf, name);
+ std::string c_name = class_name ();
- print (output_buf);
+ octave_value meth = symbol_table::find_method ("display", class_name ());
- if (print_padding && pad_after)
- newline (output_buf);
+ if (meth.is_defined ())
+ {
+ count++;
+ octave_value_list args (1, octave_value (this));
+
+ args.stash_name_tags (string_vector (name));
+
+ feval (meth.function_value (), args, 1);
+ }
+ else
+ {
+ bool pad_after = print_name_tag (output_buf, name);
+
+ print (output_buf);
+
+ if (print_padding && pad_after)
+ newline (output_buf);
+ }
}
void