GCC Code Coverage Report


Directory: avs_core/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 2 / 0 / 2
Functions: 100.0% 2 / 0 / 2
Branches: -% 0 / 0 / 0

core/exception.h
Line Branch Exec Source
1 // This program is free software; you can redistribute it and/or modify
2 // it under the terms of the GNU General Public License as published by
3 // the Free Software Foundation; either version 2 of the License, or
4 // (at your option) any later version.
5 //
6 // This program is distributed in the hope that it will be useful,
7 // but WITHOUT ANY WARRANTY; without even the implied warranty of
8 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 // GNU General Public License for more details.
10 //
11 // You should have received a copy of the GNU General Public License
12 // along with this program; if not, write to the Free Software
13 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
14 // http://www.gnu.org/copyleft/gpl.html .
15 //
16 // Linking Avisynth statically or dynamically with other modules is making a
17 // combined work based on Avisynth. Thus, the terms and conditions of the GNU
18 // General Public License cover the whole combination.
19 //
20 // As a special exception, the copyright holders of Avisynth give you
21 // permission to link Avisynth with independent modules that communicate with
22 // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license
23 // terms of these independent modules, and to copy and distribute the
24 // resulting combined work under terms of your choice, provided that
25 // every copy of the combined work is accompanied by a complete copy of
26 // the source code of Avisynth (the version of Avisynth used to produce the
27 // combined work), being distributed under the terms of the GNU General
28 // Public License plus this exception. An independent module is a module
29 // which is not derived from or based on Avisynth, such as 3rd-party filters,
30 // import and export plugins, or graphical user interfaces.
31
32 #ifndef AVSCORE_EXCEPTION_H
33 #define AVSCORE_EXCEPTION_H
34
35 #include <avs/config.h>
36
37 #if defined(MSVC)
38
39 // IMPORTANT: Project must be compiled with /EHa
40 #include <eh.h>
41
42 extern void SehTranslatorFunction(unsigned int, struct _EXCEPTION_POINTERS*);
43
44 class SehGuard
45 {
46 public:
47 SehGuard()
48 {
49 m_prev = _set_se_translator(SehTranslatorFunction);
50 }
51
52 ~SehGuard()
53 {
54 _set_se_translator(m_prev);
55 }
56
57 private:
58 _se_translator_function m_prev;
59 };
60 #else
61
62 // TODO: port to unix signals
63 class SehGuard
64 {
65 public:
66 6 SehGuard() { }
67
68 6 ~SehGuard() { }
69 };
70
71 #endif
72
73 class SehException
74 {
75 public:
76 SehException(unsigned int code, const void* addr, const char* msg) : m_msg(msg), m_addr(addr), m_code(code) { }
77 const char* m_msg;
78 const void* m_addr;
79 unsigned int m_code;
80 };
81
82 #endif // AVSCORE_EXCEPTION_H
83