blib/lib/FFI/Raw/Ptr.pm

filter: Statementstmt 100% 10 / 10 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 100% 14 / 14 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
new
1.0
CRAP 1.0
« blib/lib/FFI/Raw/MemPtr.pm ↑ Summary
1 package FFI::Raw::Ptr;
2 14 $FFI::Raw::Ptr::VERSION = '0.32';
3 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
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<FFI::Raw::Ptr> represents a pointer to memory which can be passed to
61 functions taking a C<FFI::Raw::ptr> argument.
62  
63 Note that differently from L<FFI::Raw::MemPtr>, C<FFI::Raw::Ptr> 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<FFI::Raw::Ptr> pointing to C<$ptr>, which can be either a
71 C<FFI::Raw::MemPtr> or a pointer returned by a C function.
72  
73 =cut
74  
75 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
76 1 my($class, $ptr) = @_;
77 1 bless \$ptr, $class;
78 }
79  
80 =head1 AUTHOR
81  
82 Graham Ollis <plicease@cpan.org>
83  
84 Alessandro Ghedini <alexbio@cpan.org>
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 14 1; # End of FFI::Raw::Ptr
« blib/lib/FFI/Raw/MemPtr.pm ↑ Summary