App-cpanurl
view release on metacpan or search on metacpan
script/cpanurl view on Meta::CPAN
}
if ($] >= 5.008 and $] < 5.008003) { # join() in 5.8.0 - 5.8.2 is broken.
package App::cpanurl::JSON::PP;
require subs;
subs->import('join');
eval q|
sub join {
return '' if (@_ < 2);
my $j = shift;
my $str = shift;
for (@_) { $str .= $j . $_; }
return $str;
}
|;
}
sub App::cpanurl::JSON::PP::incr_parse {
local $Carp::CarpLevel = 1;
( $_[0]->{_incr_parser} ||= App::cpanurl::JSON::PP::IncrParser->new )->incr_parse( @_ );
}
sub App::cpanurl::JSON::PP::incr_skip {
( $_[0]->{_incr_parser} ||= App::cpanurl::JSON::PP::IncrParser->new )->incr_skip;
}
sub App::cpanurl::JSON::PP::incr_reset {
( $_[0]->{_incr_parser} ||= App::cpanurl::JSON::PP::IncrParser->new )->incr_reset;
}
eval q{
sub App::cpanurl::JSON::PP::incr_text : lvalue {
$_[0]->{_incr_parser} ||= App::cpanurl::JSON::PP::IncrParser->new;
if ( $_[0]->{_incr_parser}->{incr_parsing} ) {
Carp::croak("incr_text can not be called when the incremental parser already started parsing");
}
$_[0]->{_incr_parser}->{incr_text};
}
} if ( $] >= 5.006 );
} # Setup for various Perl versions (the code from App::cpanurl::JSON::PP58)
###############################
# Utilities
#
BEGIN {
eval 'require Scalar::Util';
unless($@){
*App::cpanurl::JSON::PP::blessed = \&Scalar::Util::blessed;
*App::cpanurl::JSON::PP::reftype = \&Scalar::Util::reftype;
*App::cpanurl::JSON::PP::refaddr = \&Scalar::Util::refaddr;
}
else{ # This code is from Sclar::Util.
# warn $@;
eval 'sub UNIVERSAL::a_sub_not_likely_to_be_here { ref($_[0]) }';
*App::cpanurl::JSON::PP::blessed = sub {
local($@, $SIG{__DIE__}, $SIG{__WARN__});
ref($_[0]) ? eval { $_[0]->a_sub_not_likely_to_be_here } : undef;
};
my %tmap = qw(
B::NULL SCALAR
B::HV HASH
B::AV ARRAY
B::CV CODE
B::IO IO
B::GV GLOB
B::REGEXP REGEXP
);
*App::cpanurl::JSON::PP::reftype = sub {
my $r = shift;
return undef unless length(ref($r));
my $t = ref(B::svref_2object($r));
return
exists $tmap{$t} ? $tmap{$t}
: length(ref($$r)) ? 'REF'
: 'SCALAR';
};
*App::cpanurl::JSON::PP::refaddr = sub {
return undef unless length(ref($_[0]));
my $addr;
if(defined(my $pkg = blessed($_[0]))) {
$addr .= bless $_[0], 'Scalar::Util::Fake';
bless $_[0], $pkg;
}
else {
$addr .= $_[0]
}
$addr =~ /0x(\w+)/;
local $^W;
#no warnings 'portable';
hex($1);
}
}
}
# shamely copied and modified from JSON::XS code.
$App::cpanurl::JSON::PP::true = do { bless \(my $dummy = 1), "App::cpanurl::JSON::PP::Boolean" };
$App::cpanurl::JSON::PP::false = do { bless \(my $dummy = 0), "App::cpanurl::JSON::PP::Boolean" };
sub is_bool { defined $_[0] and UNIVERSAL::isa($_[0], "App::cpanurl::JSON::PP::Boolean"); }
sub true { $App::cpanurl::JSON::PP::true }
sub false { $App::cpanurl::JSON::PP::false }
sub null { undef; }
###############################
package App::cpanurl::JSON::PP::Boolean;
use overload (
"0+" => sub { ${$_[0]} },
( run in 0.826 second using v1.01-cache-2.11-cpan-39bf76dae61 )