line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ZMQ::FFI::ErrorHelper; |
2
|
|
|
|
|
|
|
$ZMQ::FFI::ErrorHelper::VERSION = '0.18'; |
3
|
14
|
|
|
14
|
|
10823
|
use Moo; |
|
14
|
|
|
|
|
245937
|
|
|
14
|
|
|
|
|
123
|
|
4
|
14
|
|
|
14
|
|
34146
|
use namespace::autoclean; |
|
14
|
|
|
|
|
178050
|
|
|
14
|
|
|
|
|
92
|
|
5
|
|
|
|
|
|
|
|
6
|
14
|
|
|
14
|
|
898
|
use Carp; |
|
14
|
|
|
|
|
21
|
|
|
14
|
|
|
|
|
1726
|
|
7
|
14
|
|
|
14
|
|
88
|
use FFI::Raw; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
4793
|
|
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__ |