comparison libinterp/octave-value/ov-classdef.cc @ 16692:b9833510355d classdef

Add object array property indexing. * libinterp/octave-value/ov-classdef.cc (cdef_object_array::subsref): Support '.' indexing with single property name. Technically this also applies to methods without any arguments.
author Michael Goffioul <michael.goffioul@gmail.com>
date Mon, 20 May 2013 22:59:10 -0400
parents 50c8831878d2
children 50b37deadb66
comparison
equal deleted inserted replaced
16691:50c8831878d2 16692:b9833510355d
1241 } 1241 }
1242 } 1242 }
1243 } 1243 }
1244 } 1244 }
1245 break; 1245 break;
1246
1247 case '.':
1248 if (type.size () == 1 && idx.size () == 1)
1249 {
1250 Cell c (dims ());
1251
1252 octave_idx_type n = array.numel ();
1253
1254 // dummy variables
1255 size_t dummy_skip;
1256 cdef_class dummy_cls;
1257
1258 for (octave_idx_type i = 0; i < n; i++)
1259 {
1260 octave_value_list r = array(i).subsref (type, idx, 1, dummy_skip,
1261 dummy_cls);
1262
1263 if (! error_state)
1264 {
1265 if (r.length () > 0)
1266 c(i) = r(0);
1267 }
1268 else
1269 break;
1270 }
1271
1272 if (! error_state)
1273 retval(0) = octave_value (c, true);
1274
1275 break;
1276 }
1277 // fall through "default"
1246 1278
1247 default: 1279 default:
1248 ::error ("can't perform indexing operation on array of %s objects", 1280 ::error ("can't perform indexing operation on array of %s objects",
1249 class_name ().c_str ()); 1281 class_name ().c_str ());
1250 break; 1282 break;