comparison src/ov-struct.cc @ 4994:48d0defe9445

[project @ 2004-09-15 20:31:31 by jwe]
author jwe
date Wed, 15 Sep 2004 20:31:31 +0000
parents 44046bbaa52c
children 4e4062bb9807
comparison
equal deleted inserted replaced
4993:761b8d760785 4994:48d0defe9445
95 gripe_failed_assignment (void) 95 gripe_failed_assignment (void)
96 { 96 {
97 error ("assignment to structure element failed"); 97 error ("assignment to structure element failed");
98 } 98 }
99 99
100 octave_value 100 octave_value_list
101 octave_struct::subsref (const std::string& type, 101 octave_struct::subsref (const std::string& type,
102 const std::list<octave_value_list>& idx) 102 const std::list<octave_value_list>& idx,
103 { 103 int nargout)
104 octave_value retval; 104 {
105 octave_value_list retval;
105 106
106 int skip = 1; 107 int skip = 1;
107 108
108 switch (type[0]) 109 switch (type[0])
109 { 110 {
118 119
119 if (! error_state) 120 if (! error_state)
120 { 121 {
121 Cell t = tmp.index (idx.front ()); 122 Cell t = tmp.index (idx.front ());
122 123
123 retval = (t.length () == 1) ? t(0) : octave_value (t, true); 124 retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
124 125
125 // We handled two index elements, so tell 126 // We handled two index elements, so tell
126 // next_subsref to skip both of them. 127 // next_subsref to skip both of them.
127 128
128 skip++; 129 skip++;
129 } 130 }
130 } 131 }
131 else 132 else
132 retval = map.index (idx.front ()); 133 retval(0) = map.index (idx.front ());
133 } 134 }
134 break; 135 break;
135 136
136 case '.': 137 case '.':
137 { 138 {
138 Cell t = dotref (idx.front ()); 139 Cell t = dotref (idx.front ());
139 140
140 retval = (t.length () == 1) ? t(0) : octave_value (t, true); 141 retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
141 } 142 }
142 break; 143 break;
143 144
144 case '{': 145 case '{':
145 gripe_invalid_index_type (type_name (), type[0]); 146 gripe_invalid_index_type (type_name (), type[0]);
147 148
148 default: 149 default:
149 panic_impossible (); 150 panic_impossible ();
150 } 151 }
151 152
152 if (! error_state) 153 // XXX FIXME XXX -- perhaps there should be an
153 retval = retval.next_subsref (type, idx, skip); 154 // octave_value_list::next_subsref member function? See also
155 // octave_user_function::subsref.
156
157 if (idx.size () > 1)
158 retval = retval(0).next_subsref (nargout, type, idx);
154 159
155 return retval; 160 return retval;
156 } 161 }
157 162
158 octave_value 163 octave_value