line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Type::PtrObject; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
251711
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
5
|
use FFI::Platypus 1.11; |
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
25
|
|
6
|
1
|
|
|
1
|
|
492
|
use Ref::Util qw( is_blessed_hashref ); |
|
1
|
|
|
|
|
1614
|
|
|
1
|
|
|
|
|
62
|
|
7
|
1
|
|
|
1
|
|
6
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
17
|
use 5.008001; |
|
1
|
|
|
|
|
3
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Platypus custom type for an object wrapped around an opaque pointer |
11
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
push @FFI::Platypus::CARP_NOT, __PACKAGE__; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub ffi_custom_type_api_1 |
17
|
|
|
|
|
|
|
{ |
18
|
3
|
|
|
3
|
0
|
8773
|
my(undef, undef, $wrapper_class, $constructor) = @_; |
19
|
|
|
|
|
|
|
|
20
|
3
|
100
|
|
|
|
195
|
Carp::croak("no class specified") unless defined $wrapper_class; |
21
|
2
|
100
|
|
|
|
127
|
Carp::croak("illegal class name: $wrapper_class") unless $wrapper_class =~ /^[A-Z_][0-9A-Z_]*(::[A-Z_][0-9A-Z_]*)*$/i; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$constructor ||= sub { |
24
|
1
|
|
|
1
|
|
6
|
bless { ptr => $_[0] }, $wrapper_class; |
25
|
1
|
|
50
|
|
|
11
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return { |
28
|
|
|
|
|
|
|
native_type => 'opaque', |
29
|
|
|
|
|
|
|
perl_to_native => sub { |
30
|
7
|
100
|
100
|
7
|
|
5097
|
Carp::croak("argument is not a $wrapper_class") unless is_blessed_hashref($_[0]) && $_[0]->isa($wrapper_class); |
31
|
5
|
|
|
|
|
13
|
my $ptr = $_[0]->{ptr}; |
32
|
5
|
100
|
|
|
|
94
|
Carp::croak("pointer for $wrapper_class went away") unless defined $ptr; |
33
|
4
|
|
|
|
|
28
|
$ptr; |
34
|
|
|
|
|
|
|
}, |
35
|
1
|
|
|
|
|
9
|
native_to_perl => $constructor, |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |