line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Buffer; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
231382
|
use strict; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
115
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
104
|
|
5
|
4
|
|
|
4
|
|
78
|
use 5.008004; |
|
4
|
|
|
|
|
12
|
|
6
|
4
|
|
|
4
|
|
818
|
use FFI::Platypus; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
130
|
|
7
|
4
|
|
|
4
|
|
23
|
use Exporter qw( import ); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
610
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw( scalar_to_buffer buffer_to_scalar ); |
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw ( scalar_to_pointer grow set_used_length window ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Convert scalars to C buffers |
13
|
|
|
|
|
|
|
our $VERSION = '2.08'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use constant _incantation => |
17
|
4
|
50
|
33
|
|
|
442
|
$^O eq 'MSWin32' && do { require Config; $Config::Config{archname} =~ /MSWin32-x64/ } |
18
|
|
|
|
|
|
|
? 'Q' |
19
|
4
|
|
|
4
|
|
28
|
: 'L!'; |
|
4
|
|
|
|
|
8
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub scalar_to_buffer ($) |
23
|
|
|
|
|
|
|
{ |
24
|
4
|
|
|
4
|
1
|
28
|
(unpack(_incantation, pack 'P', $_[0]), do { use bytes; length $_[0] }); |
|
4
|
|
|
23
|
|
13
|
|
|
4
|
|
|
|
|
33
|
|
|
23
|
|
|
|
|
74181
|
|
|
23
|
|
|
|
|
83
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub scalar_to_pointer ($) |
29
|
|
|
|
|
|
|
{ |
30
|
46
|
|
|
46
|
1
|
3506
|
unpack(_incantation, pack 'P', $_[0]); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub buffer_to_scalar ($$) |
35
|
|
|
|
|
|
|
{ |
36
|
15
|
50
|
|
15
|
1
|
1551
|
unpack 'P'.$_[1], pack _incantation, defined $_[0] ? $_[0] : 0; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |