| 1 | package Store::Indexed::XS; | ||
| 2 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use XSLoader; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | our $VERSION = '0.1'; | ||
| 7 | XSLoader::load(__PACKAGE__, $VERSION); | ||
| 8 | |||
| 9 | 1 | ▶ | sub new { |
|
Subroutine
new: called CC=3 SCAR=17.0
| |||
| 10 | 1 | my ($class, @keys) = @_; | |
| 11 | 1 | my %offset; | |
| 12 | 1 | my $i = 0; | |
| 13 | 1 | $offset{$_} = $i++ for @keys; | |
| 14 | |||
| 15 | # _new returns the blessed scalar reference | ||
| 16 | 1 | my $self = Store::Indexed::XS::_new($class, scalar @keys); | |
| 17 | |||
| 18 | # Method injection | ||
| 19 | 2 | ▶ | no strict 'refs'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 0 | for my $key (@keys) { | |
| 21 | 0 | my $col = $offset{$key}; | |
| 22 | 0 | ▶ | *{"${class}::get_$key"} = sub {$_[0]->_get($_[1], $col)}; |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 23 | 0 | ▶ | *{"${class}::set_$key"} = sub {$_[0]->_set($_[1], $col, $_[2])}; |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 24 | 0 | ▶ | *{"${class}::exists_$key"} = sub {$_[0]->_exists($_[1], $col)}; |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 25 | 0 | ▶ | *{"${class}::delete_$key"} = sub {$_[0]->_delete($_[1], $col)}; |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 26 | } | ||
| 27 | 0 | return $self; | |
| 28 | } | ||
| 29 | 1; | ||