529
|
1 // tree-const.cc -*- C++ -*- |
1
|
2 /* |
|
3 |
296
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
1
|
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 |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
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 |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
1
|
26 #endif |
|
27 |
455
|
28 #if defined (__GNUG__) |
|
29 #pragma implementation |
|
30 #endif |
|
31 |
493
|
32 #include "tree-const.h" |
1
|
33 #include "error.h" |
|
34 #include "gripes.h" |
529
|
35 #include "user-prefs.h" |
1
|
36 |
|
37 tree_constant::~tree_constant (void) |
|
38 { |
|
39 #if defined (MDEBUG) |
|
40 cerr << "~tree_constant: rep: " << rep |
|
41 << " rep->count: " << rep->count << "\n"; |
|
42 #endif |
|
43 |
|
44 if (--rep->count <= 0) |
|
45 { |
|
46 delete rep; |
531
|
47 rep = 0; |
1
|
48 } |
|
49 } |
|
50 |
|
51 #if defined (MDEBUG) |
|
52 void * |
|
53 tree_constant::operator new (size_t size) |
|
54 { |
|
55 tree_constant *p = ::new tree_constant; |
|
56 cerr << "tree_constant::new(): " << p << "\n"; |
|
57 return p; |
|
58 } |
|
59 |
|
60 void |
|
61 tree_constant::operator delete (void *p, size_t size) |
|
62 { |
|
63 cerr << "tree_constant::delete(): " << p << "\n"; |
|
64 ::delete p; |
|
65 } |
|
66 #endif |
|
67 |
|
68 /* |
96
|
69 * Construct return vector of empty matrices. Return empty matrices |
|
70 * and/or gripe when appropriate. |
|
71 */ |
500
|
72 Octave_object |
164
|
73 vector_of_empties (int nargout, const char *fcn_name) |
96
|
74 { |
500
|
75 Octave_object retval; |
96
|
76 |
|
77 // Got an empty argument, check if should gripe/return empty values. |
|
78 |
|
79 int flag = user_pref.propagate_empty_matrices; |
|
80 if (flag != 0) |
|
81 { |
|
82 if (flag < 0) |
|
83 gripe_empty_arg (fcn_name, 0); |
|
84 |
|
85 Matrix m; |
500
|
86 retval.resize (nargout ? nargout : 1); |
96
|
87 for (int i = 0; i < nargout; i++) |
529
|
88 retval(i) = m; |
96
|
89 } |
|
90 else |
|
91 gripe_empty_arg (fcn_name, 1); |
|
92 |
|
93 return retval; |
|
94 } |
|
95 |
|
96 /* |
1
|
97 ;;; Local Variables: *** |
|
98 ;;; mode: C++ *** |
|
99 ;;; page-delimiter: "^/\\*" *** |
|
100 ;;; End: *** |
|
101 */ |