comparison src/ov-struct.cc @ 7651:443a8f5a50fd

require both subsref variants to be defined in octave_value subclasses
author John W. Eaton <jwe@octave.org>
date Wed, 26 Mar 2008 22:09:42 -0400
parents c195bd0a5c64
children d9987dbdf91b
comparison
equal deleted inserted replaced
7650:eb7bdde776f2 7651:443a8f5a50fd
94 gripe_failed_assignment (void) 94 gripe_failed_assignment (void)
95 { 95 {
96 error ("assignment to structure element failed"); 96 error ("assignment to structure element failed");
97 } 97 }
98 98
99 octave_value 99 octave_value_list
100 octave_struct::subsref (const std::string& type, 100 octave_struct::subsref (const std::string& type,
101 const std::list<octave_value_list>& idx) 101 const std::list<octave_value_list>& idx,
102 { 102 int nargout)
103 octave_value retval; 103 {
104 octave_value_list retval;
104 105
105 int skip = 1; 106 int skip = 1;
106 107
107 switch (type[0]) 108 switch (type[0])
108 { 109 {
117 118
118 if (! error_state) 119 if (! error_state)
119 { 120 {
120 Cell t = tmp.index (idx.front (), true); 121 Cell t = tmp.index (idx.front (), true);
121 122
122 retval = (t.length () == 1) ? t(0) : octave_value (t, true); 123 retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
123 124
124 // We handled two index elements, so tell 125 // We handled two index elements, so tell
125 // next_subsref to skip both of them. 126 // next_subsref to skip both of them.
126 127
127 skip++; 128 skip++;
128 } 129 }
129 } 130 }
130 else 131 else
131 retval = map.index (idx.front (), true); 132 retval(0) = map.index (idx.front (), true);
132 } 133 }
133 break; 134 break;
134 135
135 case '.': 136 case '.':
136 { 137 {
137 if (map.numel() > 0) 138 if (map.numel() > 0)
138 { 139 {
139 Cell t = dotref (idx.front ()); 140 Cell t = dotref (idx.front ());
140 141
141 retval = (t.length () == 1) ? t(0) : octave_value (t, true); 142 retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
142 } 143 }
143 } 144 }
144 break; 145 break;
145 146
146 case '{': 147 case '{':
154 // FIXME -- perhaps there should be an 155 // FIXME -- perhaps there should be an
155 // octave_value_list::next_subsref member function? See also 156 // octave_value_list::next_subsref member function? See also
156 // octave_user_function::subsref. 157 // octave_user_function::subsref.
157 158
158 if (idx.size () > 1) 159 if (idx.size () > 1)
159 retval = retval.next_subsref (type, idx, skip); 160 retval = retval(0).next_subsref (nargout, type, idx, skip);
160 161
161 return retval; 162 return retval;
162 } 163 }
163 164
164 octave_value 165 octave_value