line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
353
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use utf8; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
184
|
use JavaScript::SpiderMonkey (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package JSON::T::SpiderMonkey; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
11
|
|
|
|
|
|
|
our $VERSION = '0.104'; |
12
|
|
|
|
|
|
|
our @ISA = qw( JSON::T ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub init |
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
my $self = shift; |
17
|
|
|
|
|
|
|
my (@args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $JS = $self->{engine} = JavaScript::SpiderMonkey::->new(); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$JS->init; |
22
|
|
|
|
|
|
|
$JS->function_set("return_to_perl", sub { |
23
|
|
|
|
|
|
|
$self->_accept_return_value(@_); |
24
|
|
|
|
|
|
|
}); |
25
|
|
|
|
|
|
|
$JS->function_set("print_to_perl", sub { |
26
|
|
|
|
|
|
|
print @_; |
27
|
|
|
|
|
|
|
}); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$self->SUPER::init(@args); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub engine_eval |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
my ($code) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return $self->{engine}->eval($code); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub parameters |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
my $self = shift; |
43
|
|
|
|
|
|
|
my (%args) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
for my $k (sort keys %args) |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
my $v = $args{$k}; |
48
|
|
|
|
|
|
|
$v = $v->[1] if ref $v eq 'ARRAY'; |
49
|
|
|
|
|
|
|
$self->{engine}->property_by_path($k, "$v"); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |