comparison src/ov-struct.cc @ 3932:2e2e32198722

[project @ 2002-05-07 18:10:44 by jwe]
author jwe
date Tue, 07 May 2002 18:10:44 +0000
parents ab7fa5a8f23f
children f9ea3dcf58ee
comparison
equal deleted inserted replaced
3931:311981a9726d 3932:2e2e32198722
30 30
31 #include <iostream> 31 #include <iostream>
32 32
33 #include "error.h" 33 #include "error.h"
34 #include "oct-lvalue.h" 34 #include "oct-lvalue.h"
35 #include "ov-list.h"
35 #include "ov-struct.h" 36 #include "ov-struct.h"
36 #include "unwind-prot.h" 37 #include "unwind-prot.h"
37 #include "variables.h" 38 #include "variables.h"
38 39
39 DEFINE_OCTAVE_ALLOCATOR(octave_struct); 40 DEFINE_OCTAVE_ALLOCATOR(octave_struct);
65 } 66 }
66 67
67 octave_lvalue 68 octave_lvalue
68 octave_struct::struct_elt_ref (octave_value *, const std::string& nm) 69 octave_struct::struct_elt_ref (octave_value *, const std::string& nm)
69 { 70 {
70 return octave_lvalue (&map [nm]); 71 // XXX FIXME XXX -- struct array
72 return octave_lvalue (&map[nm](0));
71 } 73 }
72 74
73 void 75 void
74 octave_struct::print (std::ostream& os, bool) const 76 octave_struct::print (std::ostream& os, bool) const
75 { 77 {
93 os << "{"; 95 os << "{";
94 newline (os); 96 newline (os);
95 97
96 increment_indent_level (); 98 increment_indent_level ();
97 99
100 int n = map.array_length ();
101
98 for (Pix p = map.first (); p; map.next (p)) 102 for (Pix p = map.first (); p; map.next (p))
99 { 103 {
100 std::string key = map.key (p); 104 std::string key = map.key (p);
101 octave_value val = map.contents (p); 105 octave_value_list val = map.contents (p);
102 106
103 val.print_with_name (os, key); 107 if (n == 1)
108 val(0).print_with_name (os, key);
109 else
110 {
111 octave_list tmp (val);
112 tmp.print_with_name (os, key);
113 }
104 } 114 }
105 115
106 decrement_indent_level (); 116 decrement_indent_level ();
107 117
108 indent (os); 118 indent (os);