line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Constant; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
223083
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
25
|
use 5.008004; |
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
5
|
use constant 1.32 (); |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
17
|
|
7
|
1
|
|
|
1
|
|
680
|
use FFI::Platypus; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
344
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Define constants in C space for Perl |
10
|
|
|
|
|
|
|
our $VERSION = '2.06_01'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
my $ffi = FFI::Platypus->new( api => 2 ); |
15
|
|
|
|
|
|
|
$ffi->bundle; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$ffi->type( 'opaque' => 'ffi_platypus_constant_t' ); |
18
|
|
|
|
|
|
|
$ffi->type( '(string,string)->void' => 'set_str_t' ); |
19
|
|
|
|
|
|
|
$ffi->type( '(string,sint64)->void' => 'set_sint_t' ); |
20
|
|
|
|
|
|
|
$ffi->type( '(string,uint64)->void' => 'set_uint_t' ); |
21
|
|
|
|
|
|
|
$ffi->type( '(string,double)->void' => 'set_double_t' ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$ffi->mangler(sub { |
24
|
|
|
|
|
|
|
my($name) = @_; |
25
|
|
|
|
|
|
|
$name =~ s/^/ffi_platypus_constant__/; |
26
|
|
|
|
|
|
|
$name; |
27
|
|
|
|
|
|
|
}); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$ffi->attach( new => [ 'set_str_t', 'set_sint_t', 'set_uint_t', 'set_double_t' ] => 'ffi_platypus_constant_t' => sub { |
30
|
|
|
|
|
|
|
my($xsub, $class, $default_package) = @_; |
31
|
|
|
|
|
|
|
my $f = $ffi->closure(sub { |
32
|
|
|
|
|
|
|
my($name, $value) = @_; |
33
|
|
|
|
|
|
|
if($name !~ /::/) |
34
|
|
|
|
|
|
|
{ |
35
|
|
|
|
|
|
|
$name = join('::', $default_package, $name); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
constant->import($name, $value); |
38
|
|
|
|
|
|
|
}); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
bless { |
41
|
|
|
|
|
|
|
ptr => $xsub->($f, $f, $f, $f), |
42
|
|
|
|
|
|
|
f => $f, |
43
|
|
|
|
|
|
|
}, $class; |
44
|
|
|
|
|
|
|
}); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$ffi->attach( DESTROY => ['ffi_platypus_constant_t'] => 'void' => sub { |
47
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
48
|
|
|
|
|
|
|
$xsub->($self->ptr); |
49
|
|
|
|
|
|
|
}); |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
3
|
0
|
112
|
sub ptr { shift->{ptr} } |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |