line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Type::PtrObject; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
257118
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
5
|
use FFI::Platypus 1.11; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
24
|
|
6
|
1
|
|
|
1
|
|
530
|
use Ref::Util qw( is_blessed_hashref ); |
|
1
|
|
|
|
|
1755
|
|
|
1
|
|
|
|
|
65
|
|
7
|
1
|
|
|
1
|
|
8
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
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.02'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
push @FFI::Platypus::CARP_NOT, __PACKAGE__; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub ffi_custom_type_api_1 |
17
|
|
|
|
|
|
|
{ |
18
|
3
|
|
|
3
|
0
|
9057
|
my(undef, undef, $wrapper_class, $constructor) = @_; |
19
|
|
|
|
|
|
|
|
20
|
3
|
100
|
|
|
|
194
|
Carp::croak("no class specified") unless defined $wrapper_class; |
21
|
2
|
100
|
|
|
|
142
|
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
|
2
|
100
|
|
2
|
|
12
|
defined $_[0] ? bless { ptr => $_[0] }, $wrapper_class : undef; |
25
|
1
|
|
50
|
|
|
11
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return { |
28
|
|
|
|
|
|
|
native_type => 'opaque', |
29
|
|
|
|
|
|
|
perl_to_native => sub { |
30
|
8
|
100
|
100
|
8
|
|
5617
|
Carp::croak("argument is not a $wrapper_class") unless is_blessed_hashref($_[0]) && $_[0]->isa($wrapper_class); |
31
|
6
|
|
|
|
|
15
|
my $ptr = $_[0]->{ptr}; |
32
|
6
|
100
|
|
|
|
127
|
Carp::croak("pointer for $wrapper_class went away") unless defined $ptr; |
33
|
5
|
|
|
|
|
37
|
$ptr; |
34
|
|
|
|
|
|
|
}, |
35
|
1
|
|
|
|
|
9
|
native_to_perl => $constructor, |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |