First pass at adding key files

This commit is contained in:
dsainty
2024-06-17 21:49:12 +10:00
commit aa25e9347f
1274 changed files with 392549 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
=head1 NAME
GT::JSON::PP::Boolean - dummy module providing JSON::PP::Boolean
=head1 SYNOPSIS
# do not "use" yourself
=head1 DESCRIPTION
This module exists only to provide overload resolution for Storable and similar modules. See
L<GT::JSON::PP> for more info about this class.
=cut
use GT::JSON::PP ();
use strict;
1;
=head1 AUTHOR
This idea is from L<JSON::XS::Boolean> written by Marc Lehmann <schmorp[at]schmorp.de>
=cut

View File

@ -0,0 +1,148 @@
package GT::JSON::PP5005;
use 5.005;
use strict;
my @properties;
$GT::JSON::PP5005::VERSION = '1.08';
BEGIN {
sub utf8::is_utf8 {
0; # It is considered that UTF8 flag off for Perl 5.005.
}
sub utf8::upgrade {
}
sub utf8::downgrade {
1; # must always return true.
}
sub utf8::encode {
}
sub utf8::decode {
}
*GT::JSON::PP::JSON_PP_encode_ascii = \&_encode_ascii;
*GT::JSON::PP::JSON_PP_encode_latin1 = \&_encode_latin1;
*GT::JSON::PP::JSON_PP_decode_surrogates = \&_decode_surrogates;
*GT::JSON::PP::JSON_PP_decode_unicode = \&_decode_unicode;
# missing in B module.
sub B::SVf_IOK () { 0x00010000; }
sub B::SVf_NOK () { 0x00020000; }
sub B::SVf_POK () { 0x00040000; }
sub B::SVp_IOK () { 0x01000000; }
sub B::SVp_NOK () { 0x02000000; }
$INC{'bytes.pm'} = 1; # dummy
}
sub _encode_ascii {
join('', map { $_ <= 127 ? chr($_) : sprintf('\u%04x', $_) } unpack('C*', $_[0]) );
}
sub _encode_latin1 {
join('', map { chr($_) } unpack('C*', $_[0]) );
}
sub _decode_surrogates { # from http://homepage1.nifty.com/nomenclator/unicode/ucs_utf.htm
my $uni = 0x10000 + (hex($_[0]) - 0xD800) * 0x400 + (hex($_[1]) - 0xDC00); # from perlunicode
my $bit = unpack('B32', pack('N', $uni));
if ( $bit =~ /^00000000000(...)(......)(......)(......)$/ ) {
my ($w, $x, $y, $z) = ($1, $2, $3, $4);
return pack('B*', sprintf('11110%s10%s10%s10%s', $w, $x, $y, $z));
}
else {
Carp::croak("Invalid surrogate pair");
}
}
sub _decode_unicode {
my ($u) = @_;
my ($utf8bit);
if ( $u =~ /^00([89a-f][0-9a-f])$/i ) { # 0x80-0xff
return pack( 'H2', $1 );
}
my $bit = unpack("B*", pack("H*", $u));
if ( $bit =~ /^00000(.....)(......)$/ ) {
$utf8bit = sprintf('110%s10%s', $1, $2);
}
elsif ( $bit =~ /^(....)(......)(......)$/ ) {
$utf8bit = sprintf('1110%s10%s10%s', $1, $2, $3);
}
else {
Carp::croak("Invalid escaped unicode");
}
return pack('B*', $utf8bit);
}
sub GT::JSON::PP::incr_parse {
local $Carp::CarpLevel = 1;
( $_[0]->{_incr_parser} ||= GT::JSON::PP::IncrParser->new )->incr_parse( @_ );
}
sub GT::JSON::PP::incr_text {
$_[0]->{_incr_parser} ||= GT::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} = $_[1] if ( @_ > 1 );
$_[0]->{_incr_parser}->{incr_text};
}
sub GT::JSON::PP::incr_skip {
( $_[0]->{_incr_parser} ||= GT::JSON::PP::IncrParser->new )->incr_skip;
}
sub GT::JSON::PP::incr_reset {
( $_[0]->{_incr_parser} ||= GT::JSON::PP::IncrParser->new )->incr_reset;
}
1;
__END__
=pod
=head1 NAME
GT::JSON::PP5005 - Helper module in using GT::JSON::PP in Perl 5.005
=head1 DESCRIPTION
GT::JSON::PP calls internally.
=head1 AUTHOR
Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright 2007-2008 by Makamaka Hannyaharamitu
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

View File

@ -0,0 +1,198 @@
package GT::JSON::PP56;
use 5.006;
use strict;
my @properties;
$GT::JSON::PP56::VERSION = '1.07';
BEGIN {
sub utf8::is_utf8 {
my $len = length $_[0]; # char length
{
use bytes; # byte length;
return $len != length $_[0]; # if !=, UTF8-flagged on.
}
}
sub utf8::upgrade {
; # noop;
}
sub utf8::downgrade ($;$) {
return 1 unless ( utf8::is_utf8( $_[0] ) );
if ( _is_valid_utf8( $_[0] ) ) {
my $downgrade;
for my $c ( unpack( "U*", $_[0] ) ) {
if ( $c < 256 ) {
$downgrade .= pack("C", $c);
}
else {
$downgrade .= pack("U", $c);
}
}
$_[0] = $downgrade;
return 1;
}
else {
Carp::croak("Wide character in subroutine entry") unless ( $_[1] );
0;
}
}
sub utf8::encode ($) { # UTF8 flag off
if ( utf8::is_utf8( $_[0] ) ) {
$_[0] = pack( "C*", unpack( "C*", $_[0] ) );
}
else {
$_[0] = pack( "U*", unpack( "C*", $_[0] ) );
$_[0] = pack( "C*", unpack( "C*", $_[0] ) );
}
}
sub utf8::decode ($) { # UTF8 flag on
if ( _is_valid_utf8( $_[0] ) ) {
utf8::downgrade( $_[0] );
$_[0] = pack( "U*", unpack( "U*", $_[0] ) );
}
}
*GT::JSON::PP::JSON_PP_encode_ascii = \&_encode_ascii;
*GT::JSON::PP::JSON_PP_encode_latin1 = \&_encode_latin1;
*GT::JSON::PP::JSON_PP_decode_surrogates = \&GT::JSON::PP::_decode_surrogates;
*GT::JSON::PP::JSON_PP_decode_unicode = \&GT::JSON::PP::_decode_unicode;
unless ( defined &B::SVp_NOK ) { # missing in B module.
eval q{ sub B::SVp_NOK () { 0x02000000; } };
}
}
sub _encode_ascii {
join('',
map {
$_ <= 127 ?
chr($_) :
$_ <= 65535 ?
sprintf('\u%04x', $_) : sprintf('\u%x\u%x', GT::JSON::PP::_encode_surrogates($_));
} _unpack_emu($_[0])
);
}
sub _encode_latin1 {
join('',
map {
$_ <= 255 ?
chr($_) :
$_ <= 65535 ?
sprintf('\u%04x', $_) : sprintf('\u%x\u%x', GT::JSON::PP::_encode_surrogates($_));
} _unpack_emu($_[0])
);
}
sub _unpack_emu { # for Perl 5.6 unpack warnings
return !utf8::is_utf8($_[0]) ? unpack('C*', $_[0])
: _is_valid_utf8($_[0]) ? unpack('U*', $_[0])
: unpack('C*', $_[0]);
}
sub _is_valid_utf8 {
my $str = $_[0];
my $is_utf8;
while ($str =~ /(?:
(
[\x00-\x7F]
|[\xC2-\xDF][\x80-\xBF]
|[\xE0][\xA0-\xBF][\x80-\xBF]
|[\xE1-\xEC][\x80-\xBF][\x80-\xBF]
|[\xED][\x80-\x9F][\x80-\xBF]
|[\xEE-\xEF][\x80-\xBF][\x80-\xBF]
|[\xF0][\x90-\xBF][\x80-\xBF][\x80-\xBF]
|[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]
|[\xF4][\x80-\x8F][\x80-\xBF][\x80-\xBF]
)
| (.)
)/xg)
{
if (defined $1) {
$is_utf8 = 1 if (!defined $is_utf8);
}
else {
$is_utf8 = 0 if (!defined $is_utf8);
if ($is_utf8) { # eventually, not utf8
return;
}
}
}
return $is_utf8;
}
sub GT::JSON::PP::incr_parse {
local $Carp::CarpLevel = 1;
( $_[0]->{_incr_parser} ||= GT::JSON::PP::IncrParser->new )->incr_parse( @_ );
}
sub GT::JSON::PP::incr_text : lvalue {
$_[0]->{_incr_parser} ||= GT::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};
}
sub GT::JSON::PP::incr_skip {
( $_[0]->{_incr_parser} ||= GT::JSON::PP::IncrParser->new )->incr_skip;
}
sub GT::JSON::PP::incr_reset {
( $_[0]->{_incr_parser} ||= GT::JSON::PP::IncrParser->new )->incr_reset;
}
1;
__END__
=pod
=head1 NAME
GT::JSON::PP56 - Helper module in using GT::JSON::PP in Perl 5.6
=head1 DESCRIPTION
GT::JSON::PP calls internally.
=head1 AUTHOR
Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright 2007-2008 by Makamaka Hannyaharamitu
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

View File

@ -0,0 +1,93 @@
package GT::JSON::PP58;
use 5.008;
use strict;
my @properties;
$GT::JSON::PP58::VERSION = '1.02';
BEGIN {
unless ( defined &utf8::is_utf8 ) {
require Encode;
*utf8::is_utf8 = *Encode::is_utf8;
}
*GT::JSON::PP::JSON_PP_encode_ascii = \&GT::JSON::PP::_encode_ascii;
*GT::JSON::PP::JSON_PP_encode_latin1 = \&GT::JSON::PP::_encode_latin1;
*GT::JSON::PP::JSON_PP_decode_surrogates = \&GT::JSON::PP::_decode_surrogates;
*GT::JSON::PP::JSON_PP_decode_unicode = \&GT::JSON::PP::_decode_unicode;
if ($] >= 5.008 and $] < 5.008003) { # join() in 5.8.0 - 5.8.2 is broken.
package GT::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 GT::JSON::PP::incr_parse {
local $Carp::CarpLevel = 1;
( $_[0]->{_incr_parser} ||= GT::JSON::PP::IncrParser->new )->incr_parse( @_ );
}
sub GT::JSON::PP::incr_text : lvalue {
$_[0]->{_incr_parser} ||= GT::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};
}
sub GT::JSON::PP::incr_skip {
( $_[0]->{_incr_parser} ||= GT::JSON::PP::IncrParser->new )->incr_skip;
}
sub GT::JSON::PP::incr_reset {
( $_[0]->{_incr_parser} ||= GT::JSON::PP::IncrParser->new )->incr_reset;
}
1;
__END__
=pod
=head1 NAME
GT::JSON::PP58 - Helper module in using GT::JSON::PP in Perl 5.8 and lator
=head1 DESCRIPTION
GT::JSON::PP calls internally.
=head1 AUTHOR
Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright 2008 by Makamaka Hannyaharamitu
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut