Mercurial > hg > octave-nkf
annotate src/ov-base-scalar.cc @ 10315:57a59eae83cc
untabify src C++ source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:41:46 -0500 |
parents | cd96d29c5efa |
children | ffe28cdc6fe2 |
rev | line source |
---|---|
3277 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 1999, 2000, 2002, 2004, 2005, 2007, 2008, 2009 |
7017 | 4 John W. Eaton |
3277 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
3277 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
3277 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
3503 | 28 #include <iostream> |
3277 | 29 |
4055 | 30 #include "oct-obj.h" |
3277 | 31 #include "ov-base.h" |
3933 | 32 #include "ov-cx-mat.h" |
33 #include "ov-re-mat.h" | |
3277 | 34 #include "ov-base-scalar.h" |
35 #include "pr-output.h" | |
36 | |
37 template <class ST> | |
3933 | 38 octave_value |
4247 | 39 octave_base_scalar<ST>::subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
40 const std::list<octave_value_list>& idx) |
3933 | 41 { |
42 octave_value retval; | |
43 | |
44 switch (type[0]) | |
45 { | |
46 case '(': | |
47 retval = do_index_op (idx.front ()); | |
48 break; | |
49 | |
50 case '{': | |
51 case '.': | |
52 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
53 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
54 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
3933 | 55 } |
56 break; | |
57 | |
58 default: | |
59 panic_impossible (); | |
60 } | |
61 | |
62 return retval.next_subsref (type, idx); | |
63 } | |
64 | |
65 template <class ST> | |
66 octave_value | |
4247 | 67 octave_base_scalar<ST>::subsasgn (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
68 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
69 const octave_value& rhs) |
3933 | 70 { |
71 octave_value retval; | |
72 | |
73 switch (type[0]) | |
74 { | |
75 case '(': | |
76 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
77 if (type.length () == 1) |
8437
f00578b495e9
remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
78 retval = numeric_assign (type, idx, rhs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
79 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
80 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
81 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
82 error ("in indexed assignment of %s, last rhs index must be ()", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
83 nm.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
84 } |
3933 | 85 } |
86 break; | |
87 | |
88 case '{': | |
89 case '.': | |
90 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
91 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
92 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
3933 | 93 } |
94 break; | |
95 | |
96 default: | |
97 panic_impossible (); | |
98 } | |
99 | |
100 return retval; | |
101 } | |
102 | |
103 template <class ST> | |
8626
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
104 bool |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
105 octave_base_scalar<ST>::is_true (void) const |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
106 { |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
107 bool retval = false; |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
108 |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
109 if (xisnan (scalar)) |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
110 error ("invalid conversion from NaN to logical"); |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
111 else |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
112 retval = (scalar != ST ()); |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
113 |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
114 return retval; |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
115 } |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
116 |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8437
diff
changeset
|
117 template <class ST> |
3277 | 118 void |
3523 | 119 octave_base_scalar<ST>::print (std::ostream& os, bool pr_as_read_syntax) const |
3277 | 120 { |
121 print_raw (os, pr_as_read_syntax); | |
122 newline (os); | |
123 } | |
124 | |
125 template <class ST> | |
126 void | |
3933 | 127 octave_base_scalar<ST>::print_raw (std::ostream& os, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
128 bool pr_as_read_syntax) const |
3277 | 129 { |
130 indent (os); | |
131 octave_print_internal (os, scalar, pr_as_read_syntax); | |
132 } | |
133 | |
134 template <class ST> | |
135 bool | |
3933 | 136 octave_base_scalar<ST>::print_name_tag (std::ostream& os, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
137 const std::string& name) const |
3277 | 138 { |
139 indent (os); | |
140 os << name << " = "; | |
141 return false; | |
142 } |