changeset 27072:1ccb40372115

fix printing of object arrays broken by changeset 2c4ad1958cab * ov-classdef.cc (octave_classdef::print_raw): If object is an array, print property names without values or value info. Improve display indenting and compact format appearance.
author John W. Eaton <jwe@octave.org>
date Tue, 30 Apr 2019 15:29:59 +0000
parents 4643682db06e
children f02695656257
files libinterp/octave-value/ov-classdef.cc
diffstat 1 files changed, 33 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-classdef.cc	Mon Apr 29 12:56:41 2019 -0500
+++ b/libinterp/octave-value/ov-classdef.cc	Tue Apr 30 15:29:59 2019 +0000
@@ -42,6 +42,7 @@
 #include "ov-typeinfo.h"
 #include "ov-usr-fcn.h"
 #include "parse.h"
+#include "pr-output.h"
 #include "pt-eval.h"
 #include "pt-misc.h"
 
@@ -250,13 +251,20 @@
 
   if (cls.ok ())
     {
+      bool is_array = object.is_array ();
+
+      increment_indent_level ();
+
       indent (os);
       os << class_name () << " object";
-      if (object.is_array ())
+      if (is_array)
         os << " array";
       os << " with properties:";
       newline (os);
-      newline (os);
+      if (! Vcompact_format)
+        newline (os);
+
+      increment_indent_level ();
 
       std::map<std::string, octave::cdef_property> props;
 
@@ -275,20 +283,33 @@
 
       for (auto& nm_prop : props)
         {
+          indent (os);
+
           const std::string& nm = nm_prop.first;
-          octave::cdef_property& prop = nm_prop.second;
-          octave_value val = prop.get_value (object, false);
-          dim_vector dims = val.dims ();
+
+          if (is_array)
+            os << "  " << nm;
+          else
+            {
+              octave::cdef_property& prop = nm_prop.second;
 
-          os << std::setw (max_len+2) << nm << ": ";
-          if (val.is_string ())
-            os << val.string_value ();
-          else if (val.islogical ())
-            os << val.bool_value ();
-          else
-            os << "[" << dims.str () << " " << val.class_name () << "]";
+              octave_value val = prop.get_value (object, false);
+              dim_vector dims = val.dims ();
+
+              os << std::setw (max_len+2) << nm << ": ";
+              if (val.is_string ())
+                os << val.string_value ();
+              else if (val.islogical ())
+                os << val.bool_value ();
+              else
+                os << "[" << dims.str () << " " << val.class_name () << "]";
+            }
+
           newline (os);
         }
+
+      decrement_indent_level ();
+      decrement_indent_level ();
     }
 }