| 1 | package JSON::T::JE; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use JE; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use base qw[JSON::T]; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | BEGIN | ||||||||||
| 13 | { | ||||||||||
| 14 | 1 | ▶ | $JSON::T::JE::AUTHORITY = 'cpan:TOBYINK'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | $JSON::T::JE::VERSION = '0.103'; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | sub init | ||||||||||
| 19 | { | ||||||||||
| 20 | 1 | ▶ | my ($self, @args) = @_; | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | |||||||||||
| 22 | 1 | my $JS = $self->{engine} = JE->new; | |||||||||
| 23 | |||||||||||
| 24 | $JS->new_function("return_to_perl", sub | ||||||||||
| 25 | { | ||||||||||
| 26 | 1 | ▶ | $self->_accept_return_value(@_); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 1 | }); | |||||||||
| 28 | $JS->new_function("print_to_perl", sub | ||||||||||
| 29 | { | ||||||||||
| 30 | 0 | ▶ | print @_; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 31 | 1 | }); | |||||||||
| 32 | |||||||||||
| 33 | 1 | $self->SUPER::init(@args); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | sub engine_eval | ||||||||||
| 37 | { | ||||||||||
| 38 | 3 | ▶ | my ($self, $code) = @_; | ||||||||
|
Subroutine
engine_eval: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | 3 | $self->{engine}->eval($code); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub parameters | ||||||||||
| 43 | { | ||||||||||
| 44 | 0 | ▶ | my ($self, %args) = @_; | ||||||||
|
Subroutine
parameters: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 45 | 0 | ▶ | while (my ($k,$v) = each %args) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | { | ||||||||||
| 47 | 0 | ▶ | if (ref $v eq 'ARRAY') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | { | ||||||||||
| 49 | 0 | $v = $v->[1]; | |||||||||
| 50 | } | ||||||||||
| 51 | 0 | $self->{'engine'}->eval("var $k;"); | |||||||||
| 52 | $self->{'engine'}->eval($k)->set( | ||||||||||
| 53 | 0 | JE::Object::String->new($self->{'engine'}, $v) | |||||||||
| 54 | ); | ||||||||||
| 55 | } | ||||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 1 | 1; | |||||||||
| 59 | |||||||||||
| 60 | =head1 NAME | ||||||||||
| 61 | |||||||||||
| 62 | JSON::T::JE - transform JSON using JsonT and JE | ||||||||||
| 63 | |||||||||||
| 64 | =head1 DESCRIPTION | ||||||||||
| 65 | |||||||||||
| 66 | This module uses L<JE> to provide JavaScript support. | ||||||||||
| 67 | |||||||||||
| 68 | Implements: | ||||||||||
| 69 | |||||||||||
| 70 | =over | ||||||||||
| 71 | |||||||||||
| 72 | =item C<init> | ||||||||||
| 73 | |||||||||||
| 74 | =item C<engine_eval> | ||||||||||
| 75 | |||||||||||
| 76 | =item C<parameters> | ||||||||||
| 77 | |||||||||||
| 78 | =back | ||||||||||
| 79 | |||||||||||
| 80 | =head1 BUGS | ||||||||||
| 81 | |||||||||||
| 82 | Please report any bugs to L<http://rt.cpan.org/>. | ||||||||||
| 83 | |||||||||||
| 84 | =head1 SEE ALSO | ||||||||||
| 85 | |||||||||||
| 86 | L<JSON::T>. | ||||||||||
| 87 | |||||||||||
| 88 | =head1 AUTHOR | ||||||||||
| 89 | |||||||||||
| 90 | Toby Inkster E<lt>tobyink@cpan.orgE<gt>. | ||||||||||
| 91 | |||||||||||
| 92 | =head1 COPYRIGHT AND LICENCE | ||||||||||
| 93 | |||||||||||
| 94 | Copyright 2008-2011, 2013 Toby Inkster. | ||||||||||
| 95 | |||||||||||
| 96 | Licensed under the Lesser GPL: | ||||||||||
| 97 | L<http://creativecommons.org/licenses/LGPL/2.1/>. | ||||||||||
| 98 | |||||||||||
| 99 | =head1 DISCLAIMER OF WARRANTIES | ||||||||||
| 100 | |||||||||||
| 101 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||||||||||
| 102 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||||||||||
| 103 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||
| 104 | |||||||||||
| 105 | =cut | ||||||||||