line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
#include <xs/Sub.h> |
3
|
|
|
|
|
|
|
#include <functional> |
4
|
|
|
|
|
|
|
#include <panda/exception.h> |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
namespace xs { |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
using CatchHandlerSimple = std::function<Sv()>; |
9
|
|
|
|
|
|
|
using CatchHandler = std::function<Sv(const Sub&)>; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
using ExceptionProcessor = std::function<Sv(Sv& ex, const Sub&)>; |
12
|
|
|
|
|
|
|
using ExceptionProcessorSimple = std::function<Sv(Sv& ex)>; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
void add_catch_handler (CatchHandlerSimple f); |
15
|
|
|
|
|
|
|
void add_catch_handler (CatchHandler f); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
void add_exception_processor(ExceptionProcessor f); |
18
|
|
|
|
|
|
|
void add_exception_processor(ExceptionProcessorSimple f); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Sv _exc2sv (const Sub&); |
21
|
|
|
|
|
|
|
|
22
|
34
|
|
|
|
|
|
template <typename F> static inline auto throw_guard (CV* context, F&& f) -> decltype(f()) { |
23
|
|
|
|
|
|
|
SV* exc; |
24
|
34
|
50
|
|
|
|
|
try { return f(); } |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
25
|
|
|
|
|
|
|
catch (...) { |
26
|
|
|
|
|
|
|
auto tmp = xs::_exc2sv(context); |
27
|
|
|
|
|
|
|
if (tmp) exc = tmp.detach(); |
28
|
|
|
|
|
|
|
else exc = newSVpvs("<empty exception>"); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
croak_sv(sv_2mortal(exc)); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |