| 1 | package PPI::XS; # git description: release-0.904-4-g378ef4e | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # See POD at end for documentation | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 2 | ▶ | use 5.005; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 2 | ▶ | use XSLoader; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | # In the unlikely case they someone tries to manually load | ||||||||||||||||||||
| 10 | # PPI::XS without PPI itself loaded, they probably MEAN for us | ||||||||||||||||||||
| 11 | # to load in PPI as well. Pretty useless otherwise, because we | ||||||||||||||||||||
| 12 | # need to _overwrite_ the PPI methods, we can't have it loading | ||||||||||||||||||||
| 13 | # after we do. | ||||||||||||||||||||
| 14 | 2 | ▶ | use PPI 1.000 (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # Define compatibility information | ||||||||||||||||||||
| 17 | 2 | our $VERSION = '0.910'; | |||||||||||||||||||
| 18 | 2 | our $PM_COMPATIBLE = '0.844'; | |||||||||||||||||||
| 19 | 2 | our %EXCLUDE = (); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | # Does the main package define the minimum set of variables? | ||||||||||||||||||||
| 22 | 2 | ▶ | return 1 unless defined $PPI::VERSION; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 23 | 2 | ▶ | return 1 unless defined $PPI::XS_COMPATIBLE; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 2 | ▶ | return 1 if $PPI::VERSION =~ /_/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | # Are we compatible with the main package | ||||||||||||||||||||
| 27 | 2 | ▶ | return 1 unless $VERSION > $PPI::XS_COMPATIBLE; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | 2 | ▶ | return 1 unless $PPI::VERSION > $PM_COMPATIBLE; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | # Provide an option to manually disable this package | ||||||||||||||||||||
| 31 | 2 | ▶ | return 1 if $PPI::XS_DISABLE; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | # If we aren't EXACTLY the same version, determine | ||||||||||||||||||||
| 34 | # which functions we might need to exclude. | ||||||||||||||||||||
| 35 | 2 | ▶ | if ( $VERSION > $PPI::VERSION ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 36 | # We are newer, we have the option of excluding functions | ||||||||||||||||||||
| 37 | ### NOTE: Nothing to exclude in this version | ||||||||||||||||||||
| 38 | # %EXCLUDE = map { $_ => 1 } qw{}; | ||||||||||||||||||||
| 39 | # (example) PPI::Element::exclude_this | ||||||||||||||||||||
| 40 | } elsif ( $VERSION < $PPI::VERSION ) { | ||||||||||||||||||||
| 41 | # It is newer, it has the option of excluding functions | ||||||||||||||||||||
| 42 | 2 | ▶ | if ( @PPI::XS_EXCLUDE ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | # It as defined things for us to exclude | ||||||||||||||||||||
| 44 | 0 | %EXCLUDE = map { $_ => 1 } @PPI::XS_EXCLUDE; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | # Load the XS functions | ||||||||||||||||||||
| 49 | 2 | XSLoader::load( 'PPI::XS' => $VERSION ); | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | # Find all the functions in PPI::XS | ||||||||||||||||||||
| 52 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 53 | 2 | ▶ | foreach ( sort grep { /^_PPI_/ and defined &{"PPI::XS::$_"} } keys %{"PPI::XS::"} ) { | ||||||||||||||||||
|
Condition66%2/3
/^_PPI_/ && defined &{"PPI::XS::$_";}
MC/DC50%1/2
/^_PPI_/ && defined &{"PPI::XS::$_";}
/^_PPI_/
defined &{"PPI::XS::$_";}
Truth table66%2/3
A && B
A= /^_PPI_/B= defined &{"PPI::XS::$_";}
| |||||||||||||||||||||
| 54 | # Prepare | ||||||||||||||||||||
| 55 | 8 | ▶ | /^_(\w+?)__(\w+)$/ or next; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 56 | 8 | my ($class, $function) = ($1, $2); | |||||||||||||||||||
| 57 | 8 | $class =~ s/_/::/g; | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 8 | ▶ | if ( $EXCLUDE{$_} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 60 | # Remove the un-needed function. | ||||||||||||||||||||
| 61 | # The primary purpose of this is to recover the memory | ||||||||||||||||||||
| 62 | # occupied by the useless functions, but has the | ||||||||||||||||||||
| 63 | # additional benefit of allowing us to detect which | ||||||||||||||||||||
| 64 | # functions were actually mapped in by examining the | ||||||||||||||||||||
| 65 | # names of the functions remaining in the PPI::XS symbol | ||||||||||||||||||||
| 66 | # table. | ||||||||||||||||||||
| 67 | 0 | delete ${"PPI::XS::"}{$_}; | |||||||||||||||||||
| 68 | } else { | ||||||||||||||||||||
| 69 | # Map in the function | ||||||||||||||||||||
| 70 | 8 | *{"${class}::${function}"} = *{"PPI::XS::$_"}; | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 2 | 1; | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||