line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Raw::Ptr; |
2
|
|
|
|
|
|
|
$FFI::Raw::Ptr::VERSION = '0.32'; |
3
|
12
|
|
|
12
|
|
69
|
use strict; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
459
|
|
4
|
12
|
|
|
12
|
|
64
|
use warnings; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
1623
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
FFI::Raw::Ptr - Base FFI::Raw pointer type |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
version 0.32 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Foo; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use FFI::Raw; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use base qw(FFI::Raw::Ptr); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
*_foo_new = FFI::Raw -> new( |
23
|
|
|
|
|
|
|
$shared, 'foo_new', |
24
|
|
|
|
|
|
|
FFI::Raw::ptr |
25
|
|
|
|
|
|
|
) -> coderef; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
|
|
|
|
|
|
bless shift -> SUPER::new(_foo_new()); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
*get_bar = FFI::Raw -> new( |
32
|
|
|
|
|
|
|
$shared, 'foo_get_bar', |
33
|
|
|
|
|
|
|
FFI::Raw::int, |
34
|
|
|
|
|
|
|
FFI::Raw::ptr |
35
|
|
|
|
|
|
|
) -> coderef; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
*set_bar = FFI::Raw -> new( |
38
|
|
|
|
|
|
|
$shared, 'foo_set_bar', |
39
|
|
|
|
|
|
|
FFI::Raw::void, |
40
|
|
|
|
|
|
|
FFI::Raw::ptr, |
41
|
|
|
|
|
|
|
FFI::Raw::int |
42
|
|
|
|
|
|
|
) -> coderef; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
*DESTROY = FFI::Raw -> new( |
45
|
|
|
|
|
|
|
$shared, 'foo_free', |
46
|
|
|
|
|
|
|
FFI::Raw::void, |
47
|
|
|
|
|
|
|
FFI::Raw::ptr |
48
|
|
|
|
|
|
|
) -> coderef; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package main; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $foo = Foo -> new; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$foo -> set_bar(42); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
A B represents a pointer to memory which can be passed to |
61
|
|
|
|
|
|
|
functions taking a C argument. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Note that differently from L, C pointers are |
64
|
|
|
|
|
|
|
not automatically deallocated once not in use anymore. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 METHODS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 new( $ptr ) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Create a new C pointing to C<$ptr>, which can be either a |
71
|
|
|
|
|
|
|
C or a pointer returned by a C function. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub new { |
76
|
1
|
|
|
1
|
1
|
6
|
my($class, $ptr) = @_; |
77
|
1
|
|
|
|
|
10
|
bless \$ptr, $class; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHOR |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Graham Ollis |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Alessandro Ghedini |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Copyright 2014 Alessandro Ghedini. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
91
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
92
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; # End of FFI::Raw::Ptr |