comparison libinterp/octave-value/ov-classdef.cc @ 16691:50c8831878d2 classdef

Implement multilevel subsasgn for scalar objects. * libinterp/octave-value/ov-classdef.cc (cdef_object_scalar::subsasgn): Implement assignment for multilevel indexing. * test/classdef/classdef.tst: Remove expected failure for multilevel property indexing/assignment.
author Michael Goffioul <michael.goffioul@gmail.com>
date Mon, 20 May 2013 20:17:19 -0400
parents 1c45e22fc444
children b9833510355d
comparison
equal deleted inserted replaced
16690:1c45e22fc444 16691:50c8831878d2
1123 { 1123 {
1124 cdef_property prop = cls.find_property (name); 1124 cdef_property prop = cls.find_property (name);
1125 1125
1126 if (prop.ok ()) 1126 if (prop.ok ())
1127 { 1127 {
1128 if (type.length () == 1) 1128 if (prop.is_constant ())
1129 error ("subsasgn: cannot assign constant property: %s",
1130 name.c_str ());
1131 else
1129 { 1132 {
1130 refcount++; 1133 refcount++;
1131 1134
1132 cdef_object obj (this); 1135 cdef_object obj (this);
1133 1136
1134 prop.set_value (obj, rhs, true, "subsasgn"); 1137 if (type.length () == 1)
1135 1138 {
1136 if (! error_state) 1139 prop.set_value (obj, rhs, true, "subsasgn");
1137 retval = to_ov (obj); 1140
1138 } 1141 if (! error_state)
1139 else 1142 retval = to_ov (obj);
1140 { 1143 }
1141 } 1144 else
1142 1145 {
1143 if (! error_state) 1146 octave_value val =
1144 { 1147 prop.get_value (obj, true, "subsasgn");
1148
1149 if (! error_state)
1150 {
1151 std::list<octave_value_list> args (idx);
1152
1153 args.erase (args.begin ());
1154
1155 val = val.assign (octave_value::op_asn_eq,
1156 type.substr (1), args, rhs);
1157
1158 if (! error_state)
1159 {
1160 if (val.class_name () != "object"
1161 || ! to_cdef (val).is_handle_object ())
1162 prop.set_value (obj, val, true, "subsasgn");
1163
1164 if (! error_state)
1165 retval = to_ov (obj);
1166 }
1167 }
1168 }
1145 } 1169 }
1146 } 1170 }
1147 else 1171 else
1148 error ("subsasgn: unknown property: %s", name.c_str ()); 1172 error ("subsasgn: unknown property: %s", name.c_str ());
1149 } 1173 }