Mercurial > hg > octave-nkf
diff 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 |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-classdef.cc +++ b/libinterp/octave-value/ov-classdef.cc @@ -1125,23 +1125,47 @@ if (prop.ok ()) { - if (type.length () == 1) + if (prop.is_constant ()) + error ("subsasgn: cannot assign constant property: %s", + name.c_str ()); + else { refcount++; cdef_object obj (this); - prop.set_value (obj, rhs, true, "subsasgn"); - - if (! error_state) - retval = to_ov (obj); - } - else - { - } - - if (! error_state) - { + if (type.length () == 1) + { + prop.set_value (obj, rhs, true, "subsasgn"); + + if (! error_state) + retval = to_ov (obj); + } + else + { + octave_value val = + prop.get_value (obj, true, "subsasgn"); + + if (! error_state) + { + std::list<octave_value_list> args (idx); + + args.erase (args.begin ()); + + val = val.assign (octave_value::op_asn_eq, + type.substr (1), args, rhs); + + if (! error_state) + { + if (val.class_name () != "object" + || ! to_cdef (val).is_handle_object ()) + prop.set_value (obj, val, true, "subsasgn"); + + if (! error_state) + retval = to_ov (obj); + } + } + } } } else