Mercurial > octave
annotate liboctave/util/quit.h @ 27933:863ae57eee69
maint: Use Octave coding conventions in liboctave/
* Array-C.cc, Array-d.cc, Array-f.cc, MSparse.cc, Sparse.cc, dim-vector.h,
xerbla.cc, aepbalance.cc, eigs-base.cc, gepbalance.cc, oct-fftw.cc,
randmtzig.cc, mx-inlines.cc, lo-sysdep.cc, base-list.h, cmd-edit.h,
lo-regexp.cc, oct-atomic.h, oct-binmap.h, oct-inttypes.cc, oct-inttypes.h,
quit.h, url-transfer.cc:
Use Octave coding conventions in liboctave.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 11 Jan 2020 12:53:20 -0800 |
parents | bd51beb6205e |
children | e90e3155cd01 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 2002-2020 The Octave Project Developers |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
4153 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20785
diff
changeset
|
26 #if ! defined (octave_quit_h) |
4153 | 27 #define octave_quit_h 1 |
28 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21227
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21227
diff
changeset
|
30 |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21849
diff
changeset
|
31 /* The signal header is just needed for the sig_atomic_t type. */ |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
32 #if defined (__cplusplus) |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21849
diff
changeset
|
33 # include <csignal> |
27471 | 34 # include <iosfwd> |
35 # include <list> | |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
36 # include <string> |
4153 | 37 extern "C" { |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21849
diff
changeset
|
38 #else |
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21849
diff
changeset
|
39 # include <signal.h> |
4153 | 40 #endif |
41 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
42 #if defined (__cplusplus) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
43 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
44 namespace octave |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
45 { |
27471 | 46 class frame_info |
47 { | |
48 public: | |
49 | |
50 frame_info (void) = default; | |
51 | |
52 frame_info (const std::string& file_name, const std::string& fcn_name, | |
53 int line, int column) | |
54 : m_file_name (file_name), m_fcn_name (fcn_name), m_line (line), | |
55 m_column (column) | |
56 { } | |
57 | |
58 frame_info (const frame_info&) = default; | |
59 | |
60 frame_info& operator = (const frame_info&) = default; | |
61 | |
62 ~frame_info (void) = default; | |
63 | |
64 std::string file_name (void) const { return m_file_name; } | |
65 | |
66 std::string fcn_name (void) const { return m_fcn_name; } | |
67 | |
68 int line (void) const { return m_line; } | |
69 | |
70 int column (void) const { return m_column; } | |
71 | |
72 private: | |
73 | |
74 std::string m_file_name; | |
75 | |
76 std::string m_fcn_name; | |
77 | |
78 int m_line; | |
79 | |
80 int m_column; | |
81 }; | |
82 | |
83 inline bool operator == (const frame_info& a, const frame_info& b) | |
84 { | |
85 return (a.file_name () == b.file_name () | |
86 && a.fcn_name () == b.fcn_name () | |
87 && a.line () == b.line () | |
88 && a.column () == b.column ()); | |
89 } | |
90 | |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
91 class |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
92 execution_exception |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
93 { |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
94 public: |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
95 |
27471 | 96 typedef std::list<frame_info> stack_info_type; |
97 | |
98 execution_exception (const std::string& err_type = "error", | |
99 const std::string& id = "", | |
100 const std::string& message = "unspecified error", | |
101 const stack_info_type& stack_info = stack_info_type ()) | |
102 : m_err_type (err_type), m_id (id), m_message (message), | |
103 m_stack_info (stack_info) | |
104 { } | |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
105 |
27381
d4fdaeaab7f3
use default or deleted ctors/dtors/assignment ops in liboctave/util
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
106 execution_exception (const execution_exception&) = default; |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
107 |
27381
d4fdaeaab7f3
use default or deleted ctors/dtors/assignment ops in liboctave/util
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
108 execution_exception& operator = (const execution_exception&) = default; |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
109 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
110 ~execution_exception (void) = default; |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
111 |
27471 | 112 void set_err_type (const std::string& et) |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
113 { |
27471 | 114 m_err_type = et; |
115 } | |
116 | |
117 std::string err_type (void) const { return m_err_type; } | |
118 | |
119 virtual std::string stack_trace (void) const; | |
120 | |
121 void set_identifier (const std::string& id) | |
122 { | |
123 m_id = id; | |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
124 } |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
125 |
27471 | 126 virtual std::string identifier (void) const { return m_id; } |
127 | |
128 void set_message (const std::string& msg) | |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
129 { |
27471 | 130 m_message = msg; |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
131 } |
20785
b6f2909e7f94
always throw exception after debugging with debug_on_error
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
132 |
27471 | 133 virtual std::string message (void) const { return m_message; } |
134 | |
135 virtual stack_info_type stack_info (void) const | |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
136 { |
27471 | 137 return m_stack_info; |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
138 } |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
139 |
27471 | 140 void set_stack_info (const stack_info_type& stack_info) |
141 { | |
142 m_stack_info = stack_info; | |
143 } | |
144 | |
145 virtual void display (std::ostream& os) const; | |
146 | |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
147 private: |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
148 |
27471 | 149 std::string m_err_type; |
150 | |
151 std::string m_id; | |
152 | |
153 std::string m_message; | |
154 | |
155 stack_info_type m_stack_info; | |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
156 }; |
20785
b6f2909e7f94
always throw exception after debugging with debug_on_error
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
157 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
158 class |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
159 exit_exception |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
160 { |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
161 public: |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
162 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
163 exit_exception (int exit_status = 0, bool safe_to_return = false) |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
164 : m_exit_status (exit_status), m_safe_to_return (safe_to_return) |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
165 { } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
166 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
167 exit_exception (const exit_exception& ex) |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
168 : m_exit_status (ex.m_exit_status), m_safe_to_return (ex.m_safe_to_return) |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
169 { } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
170 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
171 exit_exception& operator = (exit_exception& ex) |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
172 { |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
173 if (this != &ex) |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
174 { |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
175 m_exit_status = ex.m_exit_status; |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
176 m_safe_to_return = ex.m_safe_to_return; |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
177 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
178 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
179 return *this; |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
180 } |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
181 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
182 ~exit_exception (void) = default; |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
183 |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
184 int exit_status (void) const { return m_exit_status; } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
185 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
186 bool safe_to_return (void) const { return m_safe_to_return; } |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
187 |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
188 private: |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
189 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
190 int m_exit_status; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
191 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
192 bool m_safe_to_return; |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
193 }; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
194 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
195 class |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
196 interrupt_exception |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
197 { |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
198 }; |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
199 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
200 |
4153 | 201 #endif |
202 | |
27933
863ae57eee69
maint: Use Octave coding conventions in liboctave/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
203 // The following enum values are deprecated and will eventually be |
863ae57eee69
maint: Use Octave coding conventions in liboctave/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
204 // removed from Octave, but there seems to be no universally good way |
863ae57eee69
maint: Use Octave coding conventions in liboctave/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
205 // to tag them with an attribute that will generate a warning. |
27536
d389416f0e50
remove OCTAVE_DEPRECTED tags from enum values (bug #57092)
John W. Eaton <jwe@octave.org>
parents:
27520
diff
changeset
|
206 |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
207 enum |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
208 octave_exception |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
209 { |
27536
d389416f0e50
remove OCTAVE_DEPRECTED tags from enum values (bug #57092)
John W. Eaton <jwe@octave.org>
parents:
27520
diff
changeset
|
210 octave_no_exception = 0, |
d389416f0e50
remove OCTAVE_DEPRECTED tags from enum values (bug #57092)
John W. Eaton <jwe@octave.org>
parents:
27520
diff
changeset
|
211 octave_exec_exception = 1, |
d389416f0e50
remove OCTAVE_DEPRECTED tags from enum values (bug #57092)
John W. Eaton <jwe@octave.org>
parents:
27520
diff
changeset
|
212 octave_alloc_exception = 3, |
d389416f0e50
remove OCTAVE_DEPRECTED tags from enum values (bug #57092)
John W. Eaton <jwe@octave.org>
parents:
27520
diff
changeset
|
213 octave_quit_exception = 4 |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
214 }; |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
215 |
5133 | 216 /* |
217 > 0: interrupt pending | |
218 0: no interrupt pending | |
219 < 0: handling interrupt | |
220 */ | |
21227 | 221 OCTAVE_API extern sig_atomic_t octave_interrupt_state; |
4180 | 222 |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
223 OCTAVE_DEPRECATED (6, "'octave_exception_state' is an obsolete internal variable; any uses should be removed") |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
224 OCTAVE_API extern sig_atomic_t octave_exception_state; |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
225 |
21227 | 226 OCTAVE_API extern volatile sig_atomic_t octave_signal_caught; |
5142 | 227 |
21227 | 228 OCTAVE_API extern void octave_handle_signal (void); |
5142 | 229 |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
230 OCTAVE_DEPRECATED (6, "use 'throw octave::interrupt_exception' instead") |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
231 OCTAVE_NORETURN OCTAVE_API extern void octave_throw_interrupt_exception (void); |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
232 |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
233 OCTAVE_DEPRECATED (6, "use 'throw octave::execution_exception' instead") |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
234 OCTAVE_NORETURN OCTAVE_API extern void octave_throw_execution_exception (void); |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
235 |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
236 OCTAVE_DEPRECATED (6, "use 'throw std::bad_alloc' instead") |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
237 OCTAVE_NORETURN OCTAVE_API extern void octave_throw_bad_alloc (void); |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
238 |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
239 OCTAVE_DEPRECATED (6, "use 'throw' instead") |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
240 OCTAVE_API extern void octave_rethrow_exception (void); |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
241 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
242 #if defined (__cplusplus) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
243 |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
244 inline void octave_quit (void) |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
245 { |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
246 if (octave_signal_caught) |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
247 { |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
248 octave_signal_caught = 0; |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
249 octave_handle_signal (); |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
250 } |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
251 }; |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
252 |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
253 #define OCTAVE_QUIT octave_quit () |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
254 |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
255 #else |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
256 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
257 #define OCTAVE_QUIT \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
258 do \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
259 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
260 if (octave_signal_caught) \ |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
261 { \ |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
262 octave_signal_caught = 0; \ |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
263 octave_handle_signal (); \ |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
264 } \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
265 } \ |
4153 | 266 while (0) |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
267 #endif |
4153 | 268 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
269 /* The following macros are obsolete. Interrupting immediately by |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
270 calling siglongjmp or similar from a signal handler is asking for |
27480
63b417917f5e
remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
271 trouble. Rather than remove them, however, please leave them in |
63b417917f5e
remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
272 place so that old code that uses them will continue to compile. They |
63b417917f5e
remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
273 are defined to create a dummy do-while block to match the previous |
63b417917f5e
remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
274 definitions. */ |
4302 | 275 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
276 #define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE \ |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
277 do \ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
278 { |
4302 | 279 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
280 #define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE \ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
281 } \ |
4153 | 282 while (0) |
283 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
284 #if defined (__cplusplus) |
4196 | 285 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
286 /* Likewise, these are obsolete. They are defined to create a |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
287 dummy scope to match the previous versions that created a try-catch |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
288 block. */ |
4180 | 289 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
290 #define BEGIN_INTERRUPT_WITH_EXCEPTIONS \ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
291 { |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
292 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
293 #define END_INTERRUPT_WITH_EXCEPTIONS \ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
294 } |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
295 |
4196 | 296 #endif |
4153 | 297 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
298 #if defined (__cplusplus) |
4153 | 299 } |
4560 | 300 |
4572 | 301 /* These should only be declared for C++ code, and should also be |
302 outside of any extern "C" block. */ | |
4560 | 303 |
21227 | 304 extern OCTAVE_API void (*octave_signal_hook) (void); |
305 extern OCTAVE_API void (*octave_interrupt_hook) (void); | |
4560 | 306 |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
307 OCTAVE_DEPRECATED (6, "'octave_bad_alloc_hook' is obsolete and no longer used") |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
308 extern OCTAVE_API void (*octave_bad_alloc_hook) (void); |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
309 |
4153 | 310 #endif |
311 | |
312 #endif |