line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Buffer; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
186706
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
97
|
|
4
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
87
|
|
5
|
4
|
|
|
4
|
|
58
|
use 5.008004; |
|
4
|
|
|
|
|
12
|
|
6
|
4
|
|
|
4
|
|
595
|
use FFI::Platypus; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
89
|
|
7
|
4
|
|
|
4
|
|
25
|
use Exporter qw( import ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
477
|
|
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.07'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use constant _incantation => |
17
|
4
|
50
|
33
|
|
|
397
|
$^O eq 'MSWin32' && do { require Config; $Config::Config{archname} =~ /MSWin32-x64/ } |
18
|
|
|
|
|
|
|
? 'Q' |
19
|
4
|
|
|
4
|
|
23
|
: 'L!'; |
|
4
|
|
|
|
|
5
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub scalar_to_buffer ($) |
23
|
|
|
|
|
|
|
{ |
24
|
4
|
|
|
4
|
1
|
25
|
(unpack(_incantation, pack 'P', $_[0]), do { use bytes; length $_[0] }); |
|
4
|
|
|
23
|
|
6
|
|
|
4
|
|
|
|
|
25
|
|
|
23
|
|
|
|
|
65472
|
|
|
23
|
|
|
|
|
64
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub scalar_to_pointer ($) |
29
|
|
|
|
|
|
|
{ |
30
|
46
|
|
|
46
|
1
|
2969
|
unpack(_incantation, pack 'P', $_[0]); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub buffer_to_scalar ($$) |
35
|
|
|
|
|
|
|
{ |
36
|
15
|
50
|
|
15
|
1
|
1266
|
unpack 'P'.$_[1], pack _incantation, defined $_[0] ? $_[0] : 0; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |