comparison src/ov-cell.cc @ 7622:c195bd0a5c64

treat structs and cells as "constants"
author John W. Eaton <jwe@octave.org>
date Fri, 21 Mar 2008 16:28:47 -0400
parents 8c32f95c2639
children 443a8f5a50fd
comparison
equal deleted inserted replaced
7621:4682dda22527 7622:c195bd0a5c64
63 gripe_failed_assignment (void) 63 gripe_failed_assignment (void)
64 { 64 {
65 error ("assignment to cell array failed"); 65 error ("assignment to cell array failed");
66 } 66 }
67 67
68 octave_value_list 68 octave_value
69 octave_cell::subsref (const std::string& type, 69 octave_cell::subsref (const std::string& type,
70 const std::list<octave_value_list>& idx, int nargout) 70 const std::list<octave_value_list>& idx)
71 { 71 {
72 octave_value_list retval; 72 octave_value retval;
73 73
74 switch (type[0]) 74 switch (type[0])
75 { 75 {
76 case '(': 76 case '(':
77 retval(0) = do_index_op (idx.front ()); 77 retval = do_index_op (idx.front ());
78 break; 78 break;
79 79
80 case '{': 80 case '{':
81 { 81 {
82 octave_value tmp = do_index_op (idx.front ()); 82 octave_value tmp = do_index_op (idx.front ());
84 if (! error_state) 84 if (! error_state)
85 { 85 {
86 Cell tcell = tmp.cell_value (); 86 Cell tcell = tmp.cell_value ();
87 87
88 if (tcell.length () == 1) 88 if (tcell.length () == 1)
89 retval(0) = tcell(0,0); 89 retval = tcell(0,0);
90 else 90 else
91 { 91 {
92 octave_idx_type n = tcell.numel (); 92 octave_idx_type n = tcell.numel ();
93 93
94 octave_value_list lst (n, octave_value ()); 94 octave_value_list lst (n, octave_value ());
97 { 97 {
98 OCTAVE_QUIT; 98 OCTAVE_QUIT;
99 lst(i) = tcell(i); 99 lst(i) = tcell(i);
100 } 100 }
101 101
102 retval(0) = octave_value (lst, true); 102 retval = octave_value (lst, true);
103 } 103 }
104 } 104 }
105 } 105 }
106 break; 106 break;
107 107
119 // FIXME -- perhaps there should be an 119 // FIXME -- perhaps there should be an
120 // octave_value_list::next_subsref member function? See also 120 // octave_value_list::next_subsref member function? See also
121 // octave_user_function::subsref. 121 // octave_user_function::subsref.
122 122
123 if (idx.size () > 1) 123 if (idx.size () > 1)
124 retval = retval(0).next_subsref (nargout, type, idx); 124 retval = retval.next_subsref (type, idx);
125 125
126 return retval; 126 return retval;
127 } 127 }
128 128
129 octave_value 129 octave_value