changeset 6833:e8a18d380097

[project @ 2007-08-27 17:22:50 by jwe]
author jwe
date Mon, 27 Aug 2007 17:22:51 +0000
parents 3c500bc71e14
children 443ee3239abd
files src/Cell.h src/ChangeLog src/ov-cell.cc src/ov-struct.cc src/pt-idx.cc
diffstat 5 files changed, 62 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/Cell.h	Sat Aug 25 00:35:43 2007 +0000
+++ b/src/Cell.h	Mon Aug 27 17:22:51 2007 +0000
@@ -45,7 +45,7 @@
     : ArrayN<octave_value> (dim_vector (1, 1), val) { }
 
   Cell (const octave_value_list& ovl)
-    : ArrayN<octave_value> (dim_vector (ovl.length (), 1))
+    : ArrayN<octave_value> (dim_vector (1, ovl.length ()))
     {
       for (octave_idx_type i = 0; i < ovl.length (); i++)
 	elem (i) = ovl (i);
--- a/src/ChangeLog	Sat Aug 25 00:35:43 2007 +0000
+++ b/src/ChangeLog	Mon Aug 27 17:22:51 2007 +0000
@@ -1,3 +1,17 @@
+2007-08-27  John W. Eaton  <jwe@octave.org>
+
+	* Cell.h (Cell::Cell (const octave_value_list&)): Create row
+	vector instead of column vector.
+
+	* pt-idx.cc (tree_index_expression::lvalue): Handle [x.a] =
+	... style assignments.
+	* ov-struct.cc (octave_struct::subsasgn): Handle case of RHS as
+	comma-separated list.
+
+	* ov-cell.cc (gripe_failed_assignment): New function.
+	(octave_cell::subsasgn): Call gripe_failed_assignment if assign
+	methods fail.
+
 2007-08-24  David Bateman  <dbateman@free.fr>
 
 	* symtab.cc (void symbol_table::clear (void)): If the record in
--- a/src/ov-cell.cc	Sat Aug 25 00:35:43 2007 +0000
+++ b/src/ov-cell.cc	Mon Aug 27 17:22:51 2007 +0000
@@ -59,6 +59,12 @@
 
 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell", "cell");
 
+static void
+gripe_failed_assignment (void)
+{
+  error ("assignment to cell array failed");
+}
+
 octave_value_list
 octave_cell::subsref (const std::string& type,
 		      const std::list<octave_value_list>& idx, int nargout)
@@ -228,8 +234,13 @@
 	      else
 		octave_base_matrix<Cell>::assign (i, Cell (t_rhs));
 
-	    count++;
-	    retval = octave_value (this);
+	    if (! error_state)
+	      {
+		count++;
+		retval = octave_value (this);
+	      }
+	    else
+	      gripe_failed_assignment ();
 	  }
 	  break;
 
@@ -250,8 +261,13 @@
 	    else
 	      octave_base_matrix<Cell>::assign (i, Cell (t_rhs));
 
-	    count++;
-	    retval = octave_value (this);
+	    if (! error_state)
+	      {
+		count++;
+		retval = octave_value (this);
+	      }
+	    else
+	      gripe_failed_assignment ();
 	  }
 	  break;
 
--- a/src/ov-struct.cc	Sat Aug 25 00:35:43 2007 +0000
+++ b/src/ov-struct.cc	Mon Aug 27 17:22:51 2007 +0000
@@ -363,7 +363,18 @@
 
 	    std::string key = key_idx(0).string_value ();
 
-	    map.assign (key, t_rhs);
+	    if (t_rhs.is_cs_list ())
+	      {
+		Cell tmp_cell = Cell (t_rhs.list_value ());
+
+		// FIXME -- shouldn't care if the dimensions of the
+		// RHS don't match the dimensions of the subscriped
+		// LHS.
+
+		map.assign (key, tmp_cell);
+	      }
+	    else
+	      map.assign (key, t_rhs);
 
 	    if (! error_state)
 	      {
--- a/src/pt-idx.cc	Sat Aug 25 00:35:43 2007 +0000
+++ b/src/pt-idx.cc	Mon Aug 27 17:22:51 2007 +0000
@@ -476,9 +476,22 @@
 
 	    case '.':
 	      {
-		idx.push_back (octave_value (get_struct_index (p_arg_nm, p_dyn_field)));
+		octave_value tidx = get_struct_index (p_arg_nm, p_dyn_field);
+
+		if (! error_state)
+		  {
+		    idx.push_back (tidx);
 
-		if (error_state)
+		    if (i == n-1)
+		      {
+			// Last indexing element.  Will this result in a
+			// comma-separated list?
+
+			if (first_retval_object.is_map ())
+			  retval.numel (first_retval_object.numel ());
+		      }
+		  }
+		else
 		  eval_error ();
 	      }
 	      break;