Skip to content

Commit

Permalink
Callback.pm: add FFI::Raw::Callback docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ghedo committed Feb 11, 2013
1 parent 4917087 commit b54fc13
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/FFI/Raw.pm
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,15 @@ This works becasue FFI::Raw overloads the C<&{}> operator.
=head2 memptr( $number )
Allocate C<$number> bytes and return a L<FFI::Raw::MemPtr> pointing to the
allocated memory. This is a shortcut for C<FFI::Raw::MemPtr -> new(...)>.
Create a L<FFI::Raw::MemPtr>. This is a shortcut for C<FFI::Raw::MemPtr-E<gt>new(...)>.
=cut

sub memptr { FFI::Raw::MemPtr -> new(@_) }

=head2 callback( $coderef, $ret_type [, $arg_type ...] )
Create a callback using code reference C<$coderef> as body and return a
C<FFI::Raw::Callback> poiting to it. The signature (return and arguments types)
must also be passed. This can be passed to functions which take a
C<FFI::Raw::ptr> argument.
Create a L<FFI::Raw::Callback>. This is a shortcut for C<FFI::Raw::Callback-E<gt>new(...)>.
=cut

Expand Down
38 changes: 38 additions & 0 deletions lib/FFI/Raw/Callback.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package FFI::Raw::Callback;

use strict;
use warnings;

=head1 NAME
FFI::Raw::Callback - FFI::Raw function pointer type
=head1 DESCRIPTION
A B<FFI::Raw::Callback> represents a function pointer to a Perl routine. It can
be passed to functions taking a C<FFI::Raw::ptr> type.
=head1 METHODS
=head2 new( $coderef, $ret_type [, $arg_type ...] )
Create a C<FFI::Raw::Callback> using the code reference C<$coderef> as body. The
signature (return and arguments types) must also be passed.
=head1 AUTHOR
Alessandro Ghedini <alexbio@cpan.org>
=head1 LICENSE AND COPYRIGHT
Copyright 2013 Alessandro Ghedini.
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
=cut

1; # End of FFI::Raw::Callback

0 comments on commit b54fc13

Please sign in to comment.