root/trunk/extlib/JSON/PP58.pm @ 3531

Revision 3531, 1.9 kB (checked in by fumiakiy, 9 months ago)

Merged sockfish to trunk. "svn merge -r3114:3527 http://code.sixapart.com/svn/movabletype/branches/sockfish/ ."

  • Property svn:keywords set to Id Revision
Line 
1package JSON::PP58;
2
3use 5.008;
4use strict;
5
6my @properties;
7
8$JSON::PP58::VERSION = '1.02';
9
10
11BEGIN {
12
13    unless ( defined &utf8::is_utf8 ) {
14       require Encode;
15       *utf8::is_utf8 = *Encode::is_utf8;
16    }
17
18    *JSON::PP::JSON_PP_encode_ascii      = \&JSON::PP::_encode_ascii;
19    *JSON::PP::JSON_PP_encode_latin1     = \&JSON::PP::_encode_latin1;
20    *JSON::PP::JSON_PP_decode_surrogates = \&JSON::PP::_decode_surrogates;
21    *JSON::PP::JSON_PP_decode_unicode    = \&JSON::PP::_decode_unicode;
22
23    if ($] >= 5.008 and $] < 5.008003) { # join() in 5.8.0 - 5.8.2 is broken.
24        package JSON::PP;
25        require subs;
26        subs->import('join');
27        eval q|
28            sub join {
29                return '' if (@_ < 2);
30                my $j   = shift;
31                my $str = shift;
32                for (@_) { $str .= $j . $_; }
33                return $str;
34            }
35        |;
36    }
37
38}
39
40
41sub JSON::PP::incr_parse {
42    local $Carp::CarpLevel = 1;
43    ( $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new )->incr_parse( @_ );
44}
45
46
47sub JSON::PP::incr_text : lvalue {
48    $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new;
49
50    if ( $_[0]->{_incr_parser}->{incr_parsing} ) {
51        Carp::croak("incr_text can not be called when the incremental parser already started parsing");
52    }
53    $_[0]->{_incr_parser}->{incr_text};
54}
55
56
57sub JSON::PP::incr_skip {
58    ( $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new )->incr_skip;
59}
60
61
62sub JSON::PP::incr_reset {
63    ( $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new )->incr_reset;
64}
65
66
671;
68__END__
69
70=pod
71
72=head1 NAME
73
74JSON::PP58 - Helper module in using JSON::PP in Perl 5.8 and lator
75
76=head1 DESCRIPTION
77
78JSON::PP calls internally.
79
80=head1 AUTHOR
81
82Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>
83
84
85=head1 COPYRIGHT AND LICENSE
86
87Copyright 2008 by Makamaka Hannyaharamitu
88
89This library is free software; you can redistribute it and/or modify
90it under the same terms as Perl itself.
91
92=cut
93
Note: See TracBrowser for help on using the browser.