| 1 | package Data::Path::XS; | ||||||||||
| 2 | 21 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 21 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 21 | our $VERSION = '0.04'; | |||||||||
| 6 | |||||||||||
| 7 | 21 | ▶ | use parent 'Exporter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 21 | our @EXPORT_OK = qw(path_get path_set path_delete path_exists | |||||||||
| 9 | patha_get patha_set patha_delete patha_exists | ||||||||||
| 10 | path_compile pathc_get pathc_set pathc_delete pathc_exists); | ||||||||||
| 11 | |||||||||||
| 12 | 21 | require XSLoader; | |||||||||
| 13 | 21 | XSLoader::load('Data::Path::XS', $VERSION); | |||||||||
| 14 | |||||||||||
| 15 | # Custom import to handle both Exporter and keyword hints | ||||||||||
| 16 | 35 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=5 SCAR=16.1
| |||||||||||
| 17 | 35 | my $class = shift; | |||||||||
| 18 | 35 | my @args = @_; | |||||||||
| 19 | |||||||||||
| 20 | # Check for :keywords tag | ||||||||||
| 21 | 35 | my $enable_keywords = 0; | |||||||||
| 22 | 35 | my @export_args; | |||||||||
| 23 | 35 | for my $arg (@args) { | |||||||||
| 24 | 146 | ▶ | if ($arg eq ':keywords') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 19 | $enable_keywords = 1; | |||||||||
| 26 | } else { | ||||||||||
| 27 | 127 | push @export_args, $arg; | |||||||||
| 28 | } | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | # Enable keyword hints if requested | ||||||||||
| 32 | 35 | ▶ | if ($enable_keywords) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 19 | $^H{"Data::Path::XS/pathget"} = 1; | |||||||||
| 34 | 19 | $^H{"Data::Path::XS/pathset"} = 1; | |||||||||
| 35 | 19 | $^H{"Data::Path::XS/pathdelete"} = 1; | |||||||||
| 36 | 19 | $^H{"Data::Path::XS/pathexists"} = 1; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | # Forward to Exporter for function exports | ||||||||||
| 40 | 35 | ▶ | if (@export_args) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 16 | $class->export_to_level(1, $class, @export_args); | |||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 1 | ▶ | sub unimport { | ||||||||
|
Subroutine
unimport: called CC=1 SCAR=0.0
| |||||||||||
| 46 | 1 | my $class = shift; | |||||||||
| 47 | 1 | delete $^H{"Data::Path::XS/pathget"}; | |||||||||
| 48 | 1 | delete $^H{"Data::Path::XS/pathset"}; | |||||||||
| 49 | 1 | delete $^H{"Data::Path::XS/pathdelete"}; | |||||||||
| 50 | 1 | delete $^H{"Data::Path::XS/pathexists"}; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 21 | 1; | |||||||||
| 54 | |||||||||||
| 55 | __END__ | ||||||||||