/usr/lib/x86_64-linux-gnu/perl5/5.24/FFI/Platypus/Record/TieArray.pm is in libffi-platypus-perl 0.45-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | package FFI::Platypus::Record::TieArray;
use strict;
use warnings;
use Carp qw( croak );
# ABSTRACT: Tied array interface for record array members
our $VERSION = '0.45'; # VERSION
sub TIEARRAY
{
my $class = shift;
bless [ @_ ], $class;
}
sub FETCH
{
my($self, $key) = @_;
my($obj, $member) = @$self;
$obj->$member($key);
}
sub STORE
{
my($self, $key, $value) = @_;
my($obj, $member) = @$self;
$obj->$member($key, $value);
}
sub FETCHSIZE
{
my($self) = @_;
$self->[2];
}
sub CLEAR
{
my($self) = @_;
my($obj, $member) = @$self;
$obj->$member([]);
}
sub EXTEND
{
my($self, $count) = @_;
croak "tried to extend a fixed length array" if $count > $self->[2];
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
FFI::Platypus::Record::TieArray - Tied array interface for record array members
=head1 VERSION
version 0.45
=head1 SYNOPSIS
package Foo;
use FFI::Platypus::Record;
use FFI::Platypus::Record::TieArray;
record_layout(qw(
int[20] _bar
));
sub bar
{
my($self, $arg) = @_;
$self->_bar($arg) if ref($arg) eq ' ARRAY';
tie my @list, 'FFI::Platypus::Record::TieArray',
$self, '_bar', 20;
}
package main;
my $foo = Foo->new;
my $bar5 = $foo->bar->[5]; # get the 5th element of the bar array
$foo->bar->[5] = 10; # set the 5th element of the bar array
@{ $foo->bar } = (); # set all elements in bar to 0
@{ $foo->bar } = (1..5); # set the first five elements of the bar array
=head1 DESCRIPTION
B<WARNING>: This module is considered EXPERIMENTAL. It may go away or
be changed in incompatible ways, possibly without notice, but not
without a good reason.
This class provides a tie interface for record array members.
In the future a short cut for using this with L<FFI::Platypus::Record>
directly may be provided.
=head1 SEE ALSO
=over 4
=item L<FFI::Platypus>
The main Platypus documentation.
=item L<FFI::Platypus::Record>
Documentation on Platypus records.
=back
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Bakkiaraj Murugesan (bakkiaraj)
Dylan Cali (calid)
pipcet
Zaki Mughal (zmughal)
Fitz Elliott (felliott)
Vickenty Fesunov (vyf)
Gregor Herrmann (gregoa)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|