| 1 | 1 | ▶ | use 5.008003; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | package JavaScript::Any; | ||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 1 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Exporter::Shiny qw( jseval ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | sub _generate_jseval { | ||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_jseval: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 14 | 1 | my ($name, $args) = @_; | |||||||||||||||||||||||||||||||||||||
| 15 | return sub { | ||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | my $ctx = $me->new_context($args or {}); | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args || {}
MC/DC0%0/1
$args || {}
$args
Truth table50%1/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||
| 18 | 1 | $ctx->eval($code); | |||||||||||||||||||||||||||||||||||||
| 19 | 1 | }; | |||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my $IMPLEMENTATION; | |||||||||||||||||||||||||||||||||||||
| 23 | 1 | my @IMPLEMENTATIONS = qw( | |||||||||||||||||||||||||||||||||||||
| 24 | JavaScript::Any::Context::V8 | ||||||||||||||||||||||||||||||||||||||
| 25 | JavaScript::Any::Context::Duktape | ||||||||||||||||||||||||||||||||||||||
| 26 | JavaScript::Any::Context::JE | ||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | sub new_context { | ||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new_context: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | my $args = ref($_[0]) eq 'HASH' ? $_[0] : +{ @_ }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||
| 33 | my $impl = delete($args->{implementation}) | ||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | || ($IMPLEMENTATION ||= $me->implementation); | ||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
delete $args->{'implementation'} || ($IMPLEMENTATION ||= $me->implementation)
$IMPLEMENTATION ||= $me->implementation
MC/DC0%0/2
delete $args->{'implementation'} || ($IMPLEMENTATION ||= $me->implementation)
delete $args->{'implementation'}
($IMPLEMENTATION ||= $me->implementation)
MC/DC0%0/2
$IMPLEMENTATION ||= $me->implementation
$IMPLEMENTATION
$me->implementation
Truth table33%1/3
A || B
A= delete $args->{'implementation'}B= ($IMPLEMENTATION ||= $me->implementation)
Truth table66%2/3
A ||= B
A= $IMPLEMENTATIONB= $me->implementation
| |||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||
| 36 | # ehhh, should probably load $impl. | ||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | 2 | $impl->new($args); | |||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||
| 41 | sub implementation { | ||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | return $IMPLEMENTATION if defined $IMPLEMENTATION; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
implementation: called CC=4 SCAR=14.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | 1 | for my $try (@IMPLEMENTATIONS) { | |||||||||||||||||||||||||||||||||||||
| 45 | 3 | ▶ | eval "require $try" or next; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 46 | 1 | return $try; | |||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||
| 50 | 0 | Carp::croak("No Javascript implementation available. Please install JavaScript::Duktape or JE"); | |||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | 1 | 1; | |||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||||||||||||