annotate src/oct-obj.cc @ 11586:12df7854fa7c

strip trailing whitespace from source files
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:24:59 -0500
parents a83bad07f7e3
children 826f008c829b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
1 /*
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
2
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10552
diff changeset
3 Copyright (C) 1994-2011 John W. Eaton
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
4 Copyright (C) 2009 VZLU Prague
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
5
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
7
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5846
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5846
diff changeset
11 option) any later version.
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
12
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
16 for more details.
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
17
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5846
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5846
diff changeset
20 <http://www.gnu.org/licenses/>.
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
21
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
22 */
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
23
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1009
diff changeset
25 #include <config.h>
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
26 #endif
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
27
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
28 #include "error.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1352
diff changeset
29 #include "oct-obj.h"
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
30 #include "Cell.h"
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
31
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
32 octave_value_list::octave_value_list (const std::list<octave_value_list>& lst)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
33 {
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
34 octave_idx_type n = 0, nel = 0;
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
35
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
36 // Determine number.
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
37 for (std::list<octave_value_list>::const_iterator p = lst.begin ();
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
38 p != lst.end (); p++)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
39 {
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
40 n++;
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
41 nel += p->length ();
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
42 }
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
43
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
44 // Optimize single-element case
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
45 if (n == 1)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
46 data = lst.front ().data;
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
47 else if (nel > 0)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
48 {
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11568
diff changeset
49 data.resize (dim_vector (1, nel));
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
50 octave_idx_type k = 0;
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
51 for (std::list<octave_value_list>::const_iterator p = lst.begin ();
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
52 p != lst.end (); p++)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
53 {
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
54 data.assign (idx_vector (k, k + p->length ()), p->data);
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
55 k += p->length ();
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
56 }
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
57 assert (k == nel);
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
58 }
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
59
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
60 }
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
61
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2872
diff changeset
62 octave_allocator
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2872
diff changeset
63 octave_value_list::allocator (sizeof (octave_value_list));
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2872
diff changeset
64
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
65 octave_value_list&
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
66 octave_value_list::prepend (const octave_value& val)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
67 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
68 octave_idx_type n = length ();
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
69
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
70 resize (n + 1);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
71
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
72 while (n > 0)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
73 {
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
74 elem (n) = elem (n - 1);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
75 n--;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
76 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
77
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
78 elem (0) = val;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
79
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
80 return *this;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
81 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
82
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
83 octave_value_list&
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
84 octave_value_list::append (const octave_value& val)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
85 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
86 octave_idx_type n = length ();
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
87
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
88 resize (n + 1);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
89
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
90 elem (n) = val;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
91
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
92 return *this;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
93 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
94
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
95 octave_value_list&
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
96 octave_value_list::append (const octave_value_list& lst)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
97 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
98 octave_idx_type len = length ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
99 octave_idx_type lst_len = lst.length ();
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
100
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
101 resize (len + lst_len);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
102
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
103 for (octave_idx_type i = 0; i < lst_len; i++)
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
104 elem (len + i) = lst (i);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
105
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
106 return *this;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
107 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
108
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
109 octave_value_list&
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
110 octave_value_list::reverse (void)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
111 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
112 octave_idx_type n = length ();
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
113
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
114 for (octave_idx_type i = 0; i < n / 2; i++)
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
115 {
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
116 octave_value tmp = elem (i);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
117 elem (i) = elem (n - i - 1);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
118 elem (n - i - 1) = tmp;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
119 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
120
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
121 return *this;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
122 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
123
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
124 octave_value_list
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
125 octave_value_list::splice (octave_idx_type offset, octave_idx_type rep_length,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
126 const octave_value_list& lst) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
127 {
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
128 octave_value_list retval;
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
129
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
130 octave_idx_type len = length ();
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
131
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
132 if (offset < 0 || offset >= len)
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
133 {
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3195
diff changeset
134 if (! (rep_length == 0 && offset == len))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
135 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
136 error ("octave_value_list::splice: invalid OFFSET");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
137 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
138 }
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
139 }
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
140
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
141 if (rep_length < 0 || rep_length + offset > len)
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
142 {
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
143 error ("octave_value_list::splice: invalid LENGTH");
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
144 return retval;
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
145 }
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
146
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
147 octave_idx_type lst_len = lst.length ();
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
148
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
149 octave_idx_type new_len = len - rep_length + lst_len;
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
150
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
151 retval.resize (new_len);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
152
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
153 octave_idx_type k = 0;
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
154
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
155 for (octave_idx_type i = 0; i < offset; i++)
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
156 retval(k++) = elem (i);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
157
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
158 for (octave_idx_type i = 0; i < lst_len; i++)
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
159 retval(k++) = lst(i);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
160
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
161 for (octave_idx_type i = offset + rep_length; i < len; i++)
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
162 retval(k++) = elem (i);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
163
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
164 return retval;
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
165 }
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
166
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
167 bool
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
168 octave_value_list::all_strings_p (void) const
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
169 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
170 octave_idx_type n = length ();
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
171
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
172 for (octave_idx_type i = 0; i < n; i++)
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
173 if (! elem(i).is_string ())
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
174 return false;
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
175
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
176 return true;
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
177 }
1746
08e778219ef0 [project @ 1996-01-13 08:35:32 by jwe]
jwe
parents: 1742
diff changeset
178
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
179 bool
8455
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
180 octave_value_list::all_scalars (void) const
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
181 {
11568
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
182 octave_idx_type n = length ();
8455
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
183
11568
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
184 for (octave_idx_type i = 0; i < n; i++)
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
185 {
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
186 dim_vector dv = elem(i).dims ();
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
187 if (! dv.all_ones ())
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
188 return false;
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
189 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
190
11568
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
191 return true;
8455
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
192 }
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
193
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
194 bool
10086
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
195 octave_value_list::any_cell (void) const
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
196 {
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
197 octave_idx_type n = length ();
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
198
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
199 for (octave_idx_type i = 0; i < n; i++)
10099
29959c705df2 avoid assignment in condition of if statement
John W. Eaton <jwe@octave.org>
parents: 10086
diff changeset
200 if (elem (i).is_cell ())
29959c705df2 avoid assignment in condition of if statement
John W. Eaton <jwe@octave.org>
parents: 10086
diff changeset
201 return true;
29959c705df2 avoid assignment in condition of if statement
John W. Eaton <jwe@octave.org>
parents: 10086
diff changeset
202
29959c705df2 avoid assignment in condition of if statement
John W. Eaton <jwe@octave.org>
parents: 10086
diff changeset
203 return false;
10086
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
204 }
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
205
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
206 bool
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
207 octave_value_list::has_magic_colon (void) const
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
208 {
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
209 octave_idx_type n = length ();
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
210
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
211 for (octave_idx_type i = 0; i < n; i++)
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
212 if (elem(i).is_magic_colon ())
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
213 return true;
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
214
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
215 return false;
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
216 }
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
217
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
218 string_vector
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3264
diff changeset
219 octave_value_list::make_argv (const std::string& fcn_name) const
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
220 {
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
221 string_vector argv;
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
222
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
223 if (all_strings_p ())
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
224 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
225 octave_idx_type len = length ();
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
226
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
227 octave_idx_type total_nr = 0;
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
228
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
229 for (octave_idx_type i = 0; i < len; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
230 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
231 // An empty std::string ("") has zero columns and zero rows (a
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
232 // change that was made for Matlab contemptibility.
3264
973c81fbe144 [project @ 1999-09-02 17:47:15 by jwe]
jwe
parents: 3219
diff changeset
233
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
234 octave_idx_type n = elem(i).rows ();
3264
973c81fbe144 [project @ 1999-09-02 17:47:15 by jwe]
jwe
parents: 3219
diff changeset
235
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
236 total_nr += n ? n : 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
237 }
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
238
8034
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
239 octave_idx_type k = 0;
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
240 if (! fcn_name.empty ())
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
241 {
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
242 argv.resize (total_nr+1);
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
243 argv[0] = fcn_name;
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
244 k = 1;
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
245 }
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
246 else
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
247 argv.resize (total_nr);
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
248
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
249 for (octave_idx_type i = 0; i < len; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
250 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
251 octave_idx_type nr = elem(i).rows ();
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
252
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
253 if (nr < 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
254 argv[k++] = elem(i).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
255 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
256 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
257 string_vector tmp = elem(i).all_strings ();
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
258
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
259 for (octave_idx_type j = 0; j < nr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
260 argv[k++] = tmp[j];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
261 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
262 }
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
263 }
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
264 else
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
265 error ("%s: expecting all arguments to be strings", fcn_name.c_str ());
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
266
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
267 return argv;
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
268 }
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
269
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
270 void
8523
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8455
diff changeset
271 octave_value_list::make_storable_values (void)
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
272 {
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
273 octave_idx_type len = length ();
8579
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
274 const Array<octave_value>& cdata = data;
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
275
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
276 for (octave_idx_type i = 0; i < len; i++)
8579
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
277 {
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
278 // This is optimized so that we don't force a copy unless necessary.
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
279 octave_value tmp = cdata(i).storable_value ();
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
280 if (! tmp.is_copy_of (cdata (i)))
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
281 data(i) = tmp;
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
282 }
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
283 }