line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ZMQ::FFI::ErrorHelper; |
2
|
|
|
|
|
|
|
$ZMQ::FFI::ErrorHelper::VERSION = '0.16'; |
3
|
10
|
|
|
10
|
|
20508
|
use Moo; |
|
10
|
|
|
|
|
242297
|
|
|
10
|
|
|
|
|
80
|
|
4
|
10
|
|
|
10
|
|
34971
|
use namespace::autoclean; |
|
10
|
|
|
|
|
186683
|
|
|
10
|
|
|
|
|
74
|
|
5
|
|
|
|
|
|
|
|
6
|
10
|
|
|
10
|
|
690
|
use Carp; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
995
|
|
7
|
10
|
|
|
10
|
|
59
|
use FFI::Raw; |
|
10
|
|
|
|
|
1350
|
|
|
10
|
|
|
|
|
3921
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has soname => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
required => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has _err_ffi => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
builder => '_init_err_ffi', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub BUILD { |
21
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
22
|
0
|
|
|
|
|
|
$self->_err_ffi; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub check_error { |
26
|
0
|
|
|
0
|
0
|
|
my ($self, $func, $rc) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if ( $rc == -1 ) { |
29
|
0
|
|
|
|
|
|
$self->fatal($func); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub check_null { |
34
|
0
|
|
|
0
|
0
|
|
my ($self, $func, $obj) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
unless ($obj) { |
37
|
0
|
|
|
|
|
|
$self->fatal($func); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub fatal { |
42
|
0
|
|
|
0
|
0
|
|
my ($self, $func) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $ffi = $self->_err_ffi; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $errno = $ffi->{zmq_errno}->(); |
47
|
0
|
|
|
|
|
|
my $strerr = $ffi->{zmq_strerror}->($errno); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
confess "$func: $strerr"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _init_err_ffi { |
53
|
0
|
|
|
0
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $ffi = {}; |
56
|
0
|
|
|
|
|
|
my $soname = $self->soname; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$ffi->{zmq_errno} = FFI::Raw->new( |
59
|
|
|
|
|
|
|
$soname => 'zmq_errno', |
60
|
|
|
|
|
|
|
FFI::Raw::int # returns errno |
61
|
|
|
|
|
|
|
# void |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$ffi->{zmq_strerror} = FFI::Raw->new( |
65
|
|
|
|
|
|
|
$soname => 'zmq_strerror', |
66
|
|
|
|
|
|
|
FFI::Raw::str, # returns error str |
67
|
|
|
|
|
|
|
FFI::Raw::int # errno |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return $ffi; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |