| 1 | package Tie::Filter::Array; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.008; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use Tie::Filter; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | our $VERSION = '1.02'; | |
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | Tie::Filter::Array - Tie a facade around an array | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | Don't use this package directly. Instead, see L<Tie::Filter>. | ||
| 18 | |||
| 19 | =cut | ||
| 20 | |||
| 21 | 1 | ▶ | sub TIEARRAY { |
|
Subroutine
TIEARRAY: called CC=1 SCAR=0.0
| |||
| 22 | 1 | my ($class, $array, %args) = @_; | |
| 23 | 1 | $args{WRAP} = $array; | |
| 24 | 1 | return bless \%args, $class; | |
| 25 | } | ||
| 26 | |||
| 27 | 5 | ▶ | sub FETCH { |
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||
| 28 | 5 | my ($self, $index) = @_; | |
| 29 | 5 | Tie::Filter::_filter($$self{FETCH}, $$self{WRAP}[$index]); | |
| 30 | } | ||
| 31 | |||
| 32 | 3 | ▶ | sub STORE { |
|
Subroutine
STORE: called CC=1 SCAR=0.0
| |||
| 33 | 3 | my ($self, $index, $value) = @_; | |
| 34 | 3 | $$self{WRAP}[$index] = Tie::Filter::_filter($$self{STORE}, $value); | |
| 35 | } | ||
| 36 | |||
| 37 | 3 | ▶ | sub FETCHSIZE { |
|
Subroutine
FETCHSIZE: called CC=1 SCAR=0.0
| |||
| 38 | 3 | my $self = shift; | |
| 39 | 3 | scalar(@{$$self{WRAP}}); | |
| 40 | } | ||
| 41 | |||
| 42 | 0 | ▶ | sub STORESIZE { |
|
Subroutine
STORESIZE: not called CC=1 SCAR=6.9
| |||
| 43 | 0 | my ($self, $count) = @_; | |
| 44 | 0 | $#{$$self{WRAP}} = $count - 1; | |
| 45 | } | ||
| 46 | |||
| 47 | # TODO (?) Detect if the wrappee is tied and call it's EXTEND if it is, | ||
| 48 | # otherwise do nothing. | ||
| 49 | 0 | ▶ | sub EXTEND { } |
|
Subroutine
EXTEND: not called CC=1 SCAR=0.0
| |||
| 50 | |||
| 51 | 1 | ▶ | sub EXISTS { |
|
Subroutine
EXISTS: called CC=1 SCAR=0.0
| |||
| 52 | 1 | my ($self, $index) = @_; | |
| 53 | 1 | exists $$self{WRAP}[$index]; | |
| 54 | } | ||
| 55 | |||
| 56 | 1 | ▶ | sub DELETE { |
|
Subroutine
DELETE: called CC=1 SCAR=0.0
| |||
| 57 | 1 | my ($self, $index) = @_; | |
| 58 | 1 | delete $$self{WRAP}[$index]; | |
| 59 | } | ||
| 60 | |||
| 61 | 1 | ▶ | sub CLEAR { |
|
Subroutine
CLEAR: called CC=1 SCAR=0.0
| |||
| 62 | 1 | my $self = shift; | |
| 63 | 1 | @{$$self{WRAP}} = (); | |
| 64 | } | ||
| 65 | |||
| 66 | 0 | ▶ | sub PUSH { |
|
Subroutine
PUSH: not called CC=1 SCAR=6.9
| |||
| 67 | 0 | my $self = shift; | |
| 68 | 0 | push @{$$self{WRAP}}, map Tie::Filter::_filter($$self{STORE}, $_), @_; | |
| 69 | } | ||
| 70 | |||
| 71 | 0 | ▶ | sub POP { |
|
Subroutine
POP: not called CC=1 SCAR=6.9
| |||
| 72 | 0 | my $self = shift; | |
| 73 | 0 | Tie::Filter::_filter($$self{FETCH}, pop @{$$self{WRAP}}); | |
| 74 | } | ||
| 75 | |||
| 76 | 0 | ▶ | sub SHIFT { |
|
Subroutine
SHIFT: not called CC=1 SCAR=6.9
| |||
| 77 | 0 | my $self = shift; | |
| 78 | 0 | Tie::Filter::_filter($$self{FETCH}, shift @{$$self{WRAP}}); | |
| 79 | } | ||
| 80 | |||
| 81 | 0 | ▶ | sub UNSHIFT { |
|
Subroutine
UNSHIFT: not called CC=1 SCAR=6.9
| |||
| 82 | 0 | my $self = shift; | |
| 83 | 0 | unshift @{$$self{WRAP}}, map Tie::Filter::_filter($$self{STORE}, $_), @_; | |
| 84 | } | ||
| 85 | |||
| 86 | 0 | ▶ | sub SPLICE { |
|
Subroutine
SPLICE: not called CC=1 SCAR=6.9
| |||
| 87 | 0 | my $self = shift; | |
| 88 | 0 | my $offset = shift; | |
| 89 | 0 | my $length = shift; | |
| 90 | map(Tie::Filter::_filter($$self{FETCH}, $_), | ||
| 91 | 0 | splice(@{$$self{WRAP}}, $offset, $length, | |
| 92 | 0 | map(Tie::Filter::_filter($$self{STORE}, $_), @_))); | |
| 93 | } | ||
| 94 | |||
| 95 | 0 | ▶ | sub UNTIE { } |
|
Subroutine
UNTIE: not called CC=1 SCAR=0.0
| |||
| 96 | |||
| 97 | 0 | ▶ | sub DESTROY { } |
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||
| 98 | |||
| 99 | =head1 SEE ALSO | ||
| 100 | |||
| 101 | L<perltie>, L<Tie::Filter> | ||
| 102 | |||
| 103 | =head1 AUTHOR | ||
| 104 | |||
| 105 | Andrew Sterling Hanenkamp, <sterling@hanenkamp.com> | ||
| 106 | |||
| 107 | =head1 LICENSE AND COPYRIGHT | ||
| 108 | |||
| 109 | Copyright 2003 Andrew Sterling Hanenkamp. All Rights Reserved. This library is | ||
| 110 | free software; you can redistribute it and/or modify it under the same terms as | ||
| 111 | Perl itself. | ||
| 112 | |||
| 113 | =cut | ||
| 114 | |||
| 115 | 1 | 1 | |
| 116 | |||