Mercurial > octave
annotate liboctave/util/quit.h @ 29135:1dbeca38c776 stable
Allow Octave class execution_exception to catch std::exception objects (bug #59592).
* quit.h (class octave::execution_exception): Use keyword "public" when
inheriting from std::runtime_error.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 02 Dec 2020 14:06:13 -0800 |
parents | 9a965fec21c1 |
children | 6b3faa844395 0a5b15007766 |
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> | |
27997
e90e3155cd01
derive execution_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27933
diff
changeset
|
36 # include <stdexcept> |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
37 # include <string> |
4153 | 38 extern "C" { |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21849
diff
changeset
|
39 #else |
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21849
diff
changeset
|
40 # include <signal.h> |
4153 | 41 #endif |
42 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
43 #if defined (__cplusplus) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
44 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
45 namespace octave |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
46 { |
27471 | 47 class frame_info |
48 { | |
49 public: | |
50 | |
51 frame_info (void) = default; | |
52 | |
53 frame_info (const std::string& file_name, const std::string& fcn_name, | |
54 int line, int column) | |
55 : m_file_name (file_name), m_fcn_name (fcn_name), m_line (line), | |
56 m_column (column) | |
57 { } | |
58 | |
59 frame_info (const frame_info&) = default; | |
60 | |
61 frame_info& operator = (const frame_info&) = default; | |
62 | |
63 ~frame_info (void) = default; | |
64 | |
65 std::string file_name (void) const { return m_file_name; } | |
66 | |
67 std::string fcn_name (void) const { return m_fcn_name; } | |
68 | |
69 int line (void) const { return m_line; } | |
70 | |
71 int column (void) const { return m_column; } | |
72 | |
73 private: | |
74 | |
75 std::string m_file_name; | |
76 | |
77 std::string m_fcn_name; | |
78 | |
79 int m_line; | |
80 | |
81 int m_column; | |
82 }; | |
83 | |
84 inline bool operator == (const frame_info& a, const frame_info& b) | |
85 { | |
86 return (a.file_name () == b.file_name () | |
87 && a.fcn_name () == b.fcn_name () | |
88 && a.line () == b.line () | |
89 && a.column () == b.column ()); | |
90 } | |
91 | |
29135
1dbeca38c776
Allow Octave class execution_exception to catch std::exception objects (bug #59592).
Rik <rik@octave.org>
parents:
28012
diff
changeset
|
92 class execution_exception : public std::runtime_error |
22327
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 ()) | |
27997
e90e3155cd01
derive execution_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27933
diff
changeset
|
102 : runtime_error (message), m_err_type (err_type), m_id (id), |
e90e3155cd01
derive execution_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27933
diff
changeset
|
103 m_message (message), m_stack_info (stack_info) |
27471 | 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 |
28012
9a965fec21c1
refactor index_exception classes to accommodate std::exception::what method
John W. Eaton <jwe@octave.org>
parents:
28000
diff
changeset
|
133 std::string message (void) const { return m_message; } |
27471 | 134 |
27997
e90e3155cd01
derive execution_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27933
diff
changeset
|
135 // Provided for std::exception interface. |
e90e3155cd01
derive execution_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27933
diff
changeset
|
136 const char * what (void) const noexcept { return m_message.c_str (); } |
e90e3155cd01
derive execution_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27933
diff
changeset
|
137 |
27471 | 138 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
|
139 { |
27471 | 140 return m_stack_info; |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
141 } |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
142 |
27471 | 143 void set_stack_info (const stack_info_type& stack_info) |
144 { | |
145 m_stack_info = stack_info; | |
146 } | |
147 | |
148 virtual void display (std::ostream& os) const; | |
149 | |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
150 private: |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
151 |
27471 | 152 std::string m_err_type; |
153 | |
154 std::string m_id; | |
155 | |
156 std::string m_message; | |
157 | |
158 stack_info_type m_stack_info; | |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
159 }; |
20785
b6f2909e7f94
always throw exception after debugging with debug_on_error
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
160 |
28000
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
161 class exit_exception : public std::exception |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
162 { |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
163 public: |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
164 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
165 exit_exception (int exit_status = 0, bool safe_to_return = false) |
28000
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
166 : std::exception (), m_exit_status (exit_status), |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
167 m_safe_to_return (safe_to_return) |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
168 { } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
169 |
28000
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
170 exit_exception (const exit_exception&) = default; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
171 |
28000
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
172 exit_exception& operator = (exit_exception&) = default; |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
173 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
174 ~exit_exception (void) = default; |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
175 |
28000
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
176 const char * what (void) const noexcept { return "exit exception"; } |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
177 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
178 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
|
179 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
180 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
|
181 |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
182 private: |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
183 |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
184 int 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 m_safe_to_return; |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
187 }; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
188 |
28000
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
189 class interrupt_exception : public std::exception |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
190 { |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
191 public: |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
192 |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
193 interrupt_exception (void) = default; |
27997
e90e3155cd01
derive execution_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27933
diff
changeset
|
194 |
28000
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
195 interrupt_exception (const interrupt_exception&) = default; |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
196 |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
197 interrupt_exception& operator = (const interrupt_exception&) = default; |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
198 |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
199 ~interrupt_exception (void) = default; |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
200 |
768b54395b31
also derive exit_exception and interrupt_exception from std::exception
John W. Eaton <jwe@octave.org>
parents:
27997
diff
changeset
|
201 const char * what (void) const noexcept { return "interrupt exception"; } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
202 }; |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
203 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
204 |
4153 | 205 #endif |
206 | |
27933
863ae57eee69
maint: Use Octave coding conventions in liboctave/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
207 // 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
|
208 // 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
|
209 // 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
|
210 |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
211 enum |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
212 octave_exception |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
213 { |
27536
d389416f0e50
remove OCTAVE_DEPRECTED tags from enum values (bug #57092)
John W. Eaton <jwe@octave.org>
parents:
27520
diff
changeset
|
214 octave_no_exception = 0, |
d389416f0e50
remove OCTAVE_DEPRECTED tags from enum values (bug #57092)
John W. Eaton <jwe@octave.org>
parents:
27520
diff
changeset
|
215 octave_exec_exception = 1, |
d389416f0e50
remove OCTAVE_DEPRECTED tags from enum values (bug #57092)
John W. Eaton <jwe@octave.org>
parents:
27520
diff
changeset
|
216 octave_alloc_exception = 3, |
d389416f0e50
remove OCTAVE_DEPRECTED tags from enum values (bug #57092)
John W. Eaton <jwe@octave.org>
parents:
27520
diff
changeset
|
217 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
|
218 }; |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
219 |
5133 | 220 /* |
221 > 0: interrupt pending | |
222 0: no interrupt pending | |
223 < 0: handling interrupt | |
224 */ | |
21227 | 225 OCTAVE_API extern sig_atomic_t octave_interrupt_state; |
4180 | 226 |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
227 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
|
228 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
|
229 |
21227 | 230 OCTAVE_API extern volatile sig_atomic_t octave_signal_caught; |
5142 | 231 |
21227 | 232 OCTAVE_API extern void octave_handle_signal (void); |
5142 | 233 |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
234 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
|
235 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
|
236 |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
237 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
|
238 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
|
239 |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
240 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
|
241 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
|
242 |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
243 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
|
244 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
|
245 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
246 #if defined (__cplusplus) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
247 |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
248 inline void octave_quit (void) |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
249 { |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
250 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
|
251 { |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
252 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
|
253 octave_handle_signal (); |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
254 } |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
255 }; |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
256 |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
257 #define OCTAVE_QUIT octave_quit () |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
258 |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
259 #else |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
260 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
261 #define OCTAVE_QUIT \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
262 do \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
263 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
264 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
|
265 { \ |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
266 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
|
267 octave_handle_signal (); \ |
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
268 } \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
269 } \ |
4153 | 270 while (0) |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
271 #endif |
4153 | 272 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
273 /* The following macros are obsolete. Interrupting immediately by |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
274 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
|
275 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
|
276 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
|
277 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
|
278 definitions. */ |
4302 | 279 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
280 #define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE \ |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
281 do \ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
282 { |
4302 | 283 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
284 #define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE \ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
285 } \ |
4153 | 286 while (0) |
287 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
288 #if defined (__cplusplus) |
4196 | 289 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
290 /* 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
|
291 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
|
292 block. */ |
4180 | 293 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
294 #define BEGIN_INTERRUPT_WITH_EXCEPTIONS \ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
295 { |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
296 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
297 #define END_INTERRUPT_WITH_EXCEPTIONS \ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
298 } |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
299 |
4196 | 300 #endif |
4153 | 301 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
302 #if defined (__cplusplus) |
4153 | 303 } |
4560 | 304 |
4572 | 305 /* These should only be declared for C++ code, and should also be |
306 outside of any extern "C" block. */ | |
4560 | 307 |
21227 | 308 extern OCTAVE_API void (*octave_signal_hook) (void); |
309 extern OCTAVE_API void (*octave_interrupt_hook) (void); | |
4560 | 310 |
27520
7a871724d4b0
restore some exception handling functions and variables and deprecate them
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
311 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
|
312 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
|
313 |
4153 | 314 #endif |
315 | |
316 #endif |