GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
cruft
misc
quit.cc
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 2002-2013 John W. Eaton
4
5
This file is part of Octave.
6
7
Octave is free software; you can redistribute it and/or modify it
8
under the terms of the GNU General Public License as published by the
9
Free Software Foundation; either version 3 of the License, or (at your
10
option) any later version.
11
12
Octave is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with Octave; see the file COPYING. If not, see
19
<http://www.gnu.org/licenses/>.
20
21
*/
22
23
#ifdef HAVE_CONFIG_H
24
#include <config.h>
25
#endif
26
27
#include <cstring>
28
29
#include <iostream>
30
#include <new>
31
32
#include "
quit.h
"
33
34
void
(*
octave_signal_hook
) (
void
) = 0;
35
void
(*
octave_interrupt_hook
) (
void
) = 0;
36
void
(*
octave_bad_alloc_hook
) (
void
) = 0;
37
38
void
39
octave_handle_signal
(
void
)
40
{
41
if
(
octave_signal_hook
)
42
octave_signal_hook
();
43
44
if
(
octave_interrupt_state
> 0)
45
{
46
octave_interrupt_state
= -1;
47
octave_throw_interrupt_exception
();
48
}
49
}
50
51
void
52
octave_throw_interrupt_exception
(
void
)
53
{
54
if
(
octave_interrupt_hook
)
55
octave_interrupt_hook
();
56
57
throw
octave_interrupt_exception ();
58
}
59
60
void
61
octave_throw_execution_exception
(
void
)
62
{
63
// FIXME: would a hook function be useful here?
64
65
octave_exception_state
=
octave_exec_exception
;
66
67
throw
octave_execution_exception ();
68
}
69
70
void
71
octave_throw_bad_alloc
(
void
)
72
{
73
if
(
octave_bad_alloc_hook
)
74
octave_bad_alloc_hook
();
75
76
octave_exception_state
=
octave_alloc_exception
;
77
78
throw
std::bad_alloc ();
79
}
80
81
void
82
octave_rethrow_exception
(
void
)
83
{
84
if
(
octave_interrupt_state
)
85
{
86
octave_interrupt_state
= -1;
87
octave_throw_interrupt_exception
();
88
}
89
else
90
{
91
switch
(
octave_exception_state
)
92
{
93
case
octave_exec_exception
:
94
octave_throw_execution_exception
();
95
break
;
96
97
case
octave_alloc_exception
:
98
octave_throw_bad_alloc
();
99
break
;
100
101
default
:
102
break
;
103
}
104
}
105
}
Generated on Mon Dec 30 2013 03:04:46 for GNU Octave by
1.8.1.2