From 3df3a2e7f092ae4b148ca728050ad630876dbab7 Mon Sep 17 00:00:00 2001 From: Alexandre Mestiashvili Date: Mon, 16 Sep 2013 10:00:55 +0200 Subject: [PATCH] Imported Upstream version 0.37 --- Changes | 11 ++++++ MANIFEST | 3 +- META.json | 58 +++++++++++++++++++++++++++++++ META.yml | 60 ++++++++++++++++----------------- author_tools/hobodecoder.pl | 11 ++++-- const-c.inc | 15 +++++++-- lib/Sereal/Encoder.pm | 5 +-- lib/Sereal/Encoder/Constants.pm | 1 + srl_encoder.c | 9 +++-- srl_protocol.h | 1 + t/020_sort_keys.t | 5 ++- 11 files changed, 136 insertions(+), 43 deletions(-) create mode 100644 META.json diff --git a/Changes b/Changes index 27eee8e..2c2a378 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,16 @@ Revision history for Perl extension Sereal-Encoder +0.37 Mon Sep 2 07:40 2013 (AMS time) + - Windows and C89 fixes + - Band-aid: Skip test failing due to hash-randomization [Zefram] + +0.36 Tue May 7 12:00 2013 (AMS time) + [changelog for encoder and decoder both] + - Add "incremental" option to decoder for easier decoding of + multiple sereal documents in one buffer. + - Make snappy and snappy_incr options mutually exclusive. + - Feature: Implement aliasing for deduping (aliased_dedupe_strings) + 0.35 Mon Apr 1 11:50 2013 (AMS time) - Add new no_bless_objects option from Simon Bertrang. diff --git a/MANIFEST b/MANIFEST index bb55adb..190a106 100644 --- a/MANIFEST +++ b/MANIFEST @@ -45,4 +45,5 @@ t/data/corpus t/lib/Sereal/BulkTest.pm t/lib/Sereal/TestSet.pm typemap -META.yml Module meta-data (added by MakeMaker) +META.yml Module YAML meta-data (added by MakeMaker) +META.json Module JSON meta-data (added by MakeMaker) diff --git a/META.json b/META.json new file mode 100644 index 0000000..d671f20 --- /dev/null +++ b/META.json @@ -0,0 +1,58 @@ +{ + "abstract" : "Fast, compact, powerful binary serialization", + "author" : [ + "Steffen Mueller , Yves Orton " + ], + "dynamic_config" : 1, + "generated_by" : "ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Sereal-Encoder", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, + "prereqs" : { + "build" : { + "requires" : { + "Data::Dumper" : "0", + "ExtUtils::ParseXS" : "2.21", + "File::Find" : "0", + "File::Path" : "0", + "File::Spec" : "0", + "Scalar::Util" : "0", + "Test::LongString" : "0", + "Test::More" : "0.88", + "Test::Warn" : "0" + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "runtime" : { + "requires" : { + "XSLoader" : "0", + "perl" : "5.008" + } + } + }, + "release_status" : "stable", + "resources" : { + "bugtracker" : { + "web" : "https://github.com/Sereal/Sereal/issues" + }, + "repository" : { + "url" : "git://github.com/Sereal/Sereal.git" + } + }, + "version" : "0.37" +} diff --git a/META.yml b/META.yml index 208d57e..99a6669 100644 --- a/META.yml +++ b/META.yml @@ -1,34 +1,34 @@ ---- #YAML:1.0 -name: Sereal-Encoder -version: 0.36 -abstract: Fast, compact, powerful binary serialization +--- +abstract: 'Fast, compact, powerful binary serialization' author: - - Steffen Mueller , Yves Orton -license: perl -distribution_type: module -configure_requires: - ExtUtils::MakeMaker: 0 + - 'Steffen Mueller , Yves Orton ' build_requires: - Data::Dumper: 0 - ExtUtils::ParseXS: 2.21 - File::Find: 0 - File::Path: 0 - File::Spec: 0 - Scalar::Util: 0 - Test::LongString: 0 - Test::More: 0.88 - Test::Warn: 0 + Data::Dumper: 0 + ExtUtils::ParseXS: 2.21 + File::Find: 0 + File::Path: 0 + File::Spec: 0 + Scalar::Util: 0 + Test::LongString: 0 + Test::More: 0.88 + Test::Warn: 0 +configure_requires: + ExtUtils::MakeMaker: 0 +dynamic_config: 1 +generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: Sereal-Encoder +no_index: + directory: + - t + - inc requires: - perl: 5.008 - XSLoader: 0 + XSLoader: 0 + perl: 5.008 resources: - bugtracker: https://github.com/Sereal/Sereal/issues - repository: git://github.com/Sereal/Sereal.git -no_index: - directory: - - t - - inc -generated_by: ExtUtils::MakeMaker version 6.56 -meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 + bugtracker: https://github.com/Sereal/Sereal/issues + repository: git://github.com/Sereal/Sereal.git +version: 0.37 diff --git a/author_tools/hobodecoder.pl b/author_tools/hobodecoder.pl index 2c16628..87fb11d 100644 --- a/author_tools/hobodecoder.pl +++ b/author_tools/hobodecoder.pl @@ -50,6 +50,9 @@ sub parse_header { my $flags = $2; my $len = varint(); my $hdr = substr($data, 0, $len, ''); + + my $proto_version = ord($flags) & SRL_PROTOCOL_VERSION_MASK; + print "Sereal protocol version: $proto_version\n"; if (length($hdr)) { print "Header($len): " . join(" ", map ord, split //, $hdr) . "\n"; } @@ -59,11 +62,15 @@ sub parse_header { my $encoding= ord($flags) & SRL_PROTOCOL_ENCODING_MASK; if ($encoding == SRL_PROTOCOL_ENCODING_SNAPPY) { + print "Header says: Document body is Snappy-compressed.\n"; require Compress::Snappy; my $out = Compress::Snappy::decompress($data); $data = $out; - } elsif ($encoding) { - die "Invalid encoding"; + } elsif ($encoding == SRL_PROTOCOL_ENCODING_SNAPPY_INCREMENTAL) { + die "Incremental Snappy encoding not implemented in hobodecoder. (yet. It's easy to do.)"; + } + elsif ($encoding) { + die "Invalid encoding '" . ($encoding >> SRL_PROTOCOL_VERSION_BITS) . "'"; } } diff --git a/const-c.inc b/const-c.inc index 911c30d..705fc3f 100644 --- a/const-c.inc +++ b/const-c.inc @@ -366,7 +366,7 @@ constant_16 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. SRL_HDR_ARRAYREF SRL_HDR_NEG_HIGH SRL_HDR_POS_HIGH SRL_HDR_RESERVED - SRL_HDR_STR_UTF8 SRL_NEG_MIN_SIZE SRL_POS_MAX_SIZE */ + SRL_HDR_STR_UTF8 SRL_MAGIC_STRLEN SRL_NEG_MIN_SIZE SRL_POS_MAX_SIZE */ /* Offset 8 gives the best switch position. */ switch (name[8]) { case 'A': @@ -377,6 +377,17 @@ constant_16 (pTHX_ const char *name, IV *iv_return) { return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; +#endif + } + break; + case 'C': + if (memEQ(name, "SRL_MAGIC_STRLEN", 16)) { + /* ^ */ +#ifdef SRL_MAGIC_STRLEN + *iv_return = SRL_MAGIC_STRLEN; + return PERL_constant_ISIV; +#else + return PERL_constant_NOTDEF; #endif } break; @@ -623,7 +634,7 @@ my @names = (qw(SRL_HDR_ALIAS SRL_HDR_ARRAY SRL_HDR_ARRAYREF SRL_HDR_SHORT_BINARY SRL_HDR_SHORT_BINARY_HIGH SRL_HDR_SHORT_BINARY_LOW SRL_HDR_STR_UTF8 SRL_HDR_TRACK_FLAG SRL_HDR_TRUE SRL_HDR_UNDEF SRL_HDR_VARINT SRL_HDR_WEAKEN - SRL_HDR_ZIGZAG SRL_MAGIC_STRING_LILIPUTIAN + SRL_HDR_ZIGZAG SRL_MAGIC_STRING_LILIPUTIAN SRL_MAGIC_STRLEN SRL_MASK_ARRAYREF_COUNT SRL_MASK_HASHREF_COUNT SRL_MASK_SHORT_BINARY_LEN SRL_NEG_MIN_SIZE SRL_POS_MAX_SIZE SRL_PROTOCOL_ENCODING_MASK SRL_PROTOCOL_ENCODING_RAW diff --git a/lib/Sereal/Encoder.pm b/lib/Sereal/Encoder.pm index fa75a93..58ee05c 100644 --- a/lib/Sereal/Encoder.pm +++ b/lib/Sereal/Encoder.pm @@ -5,7 +5,7 @@ use warnings; use Carp qw/croak/; use XSLoader; -our $VERSION = '0.36'; # Don't forget to update the TestCompat set for testing against installed decoders! +our $VERSION = '0.37'; # Don't forget to update the TestCompat set for testing against installed decoders! # not for public consumption, just for testing. my $TestCompat = [ map sprintf("%.2f", $_/100), reverse( 23 .. int($VERSION * 100) ) ]; # compat with 0.23 to ... @@ -42,9 +42,6 @@ Sereal::Encoder - Fast, compact, powerful binary serialization =head1 DESCRIPTION -B - This library implements an efficient, compact-output, and feature-rich serializer using a binary protocol called I. Its sister module L implements a decoder for this format. diff --git a/lib/Sereal/Encoder/Constants.pm b/lib/Sereal/Encoder/Constants.pm index 5edf80c..d0d03df 100644 --- a/lib/Sereal/Encoder/Constants.pm +++ b/lib/Sereal/Encoder/Constants.pm @@ -9,6 +9,7 @@ our @ISA = qw(Exporter); require Exporter; our @EXPORT_OK; BEGIN { @EXPORT_OK = qw( + SRL_MAGIC_STRLEN SRL_MAGIC_STRING_LILIPUTIAN SRL_PROTOCOL_VERSION SRL_PROTOCOL_VERSION_BITS diff --git a/srl_encoder.c b/srl_encoder.c index 914c332..24554ef 100644 --- a/srl_encoder.c +++ b/srl_encoder.c @@ -40,7 +40,9 @@ extern "C" { #define MY_CAN_FIND_PLACEHOLDERS #define HAS_SV2OBJ #endif -#if (PERL_VERSION >= 10) + +/* hv_backreferences_p is not marked as exported in embed.fnc in any perl */ +#if (PERL_VERSION >= 10 && !defined(WIN32) && !defined(_WIN32)) #define HAS_HV_BACKREFS #endif @@ -715,7 +717,7 @@ srl_fixup_weakrefs(pTHX_ srl_encoder_t *enc) # define RX_PRECOMP(re) ((re)->precomp) # define RX_PRELEN(re) ((re)->prelen) -// Maybe this is only on OS X, where SvUTF8(sv) exists but looks at flags that don't exist +/* Maybe this is only on OS X, where SvUTF8(sv) exists but looks at flags that don't exist */ # define RX_UTF8(re) (RX_EXTFLAGS(re) & RXf_UTF8) #elif defined(SvRX) @@ -1084,9 +1086,10 @@ srl_dump_sv(pTHX_ srl_encoder_t *enc, SV *src) AV *backrefs; SV* refsv= NULL; UV weakref_ofs= 0; /* preserved between loops */ + int nobless; SSize_t ref_rewrite_pos= 0; /* preserved between loops - note SSize_t is a perl define */ assert(src); - int nobless = SRL_ENC_HAVE_OPTION(enc, SRL_F_NO_BLESS_OBJECTS); + nobless = SRL_ENC_HAVE_OPTION(enc, SRL_F_NO_BLESS_OBJECTS); if (++enc->recursion_depth == enc->max_recursion_depth) { croak("Hit maximum recursion depth (%lu), aborting serialization", diff --git a/srl_protocol.h b/srl_protocol.h index 95d9d9d..16af658 100644 --- a/srl_protocol.h +++ b/srl_protocol.h @@ -141,6 +141,7 @@ /* magic string, protocol version and encoding information */ #define SRL_MAGIC_STRING "=srl" /* Magic string for header. Every packet starts with this */ +#define SRL_MAGIC_STRLEN 4 /* Length of SRL_MAGIC_STRING */ #define SRL_MAGIC_STRING_LILIPUTIAN 0x6c72733d /* SRL_MAGIC_STRING as a little endian integer */ #define SRL_PROTOCOL_VERSION ( 1 ) /* this is the first. for some reason we did not use 0 */ diff --git a/t/020_sort_keys.t b/t/020_sort_keys.t index 4ba6d6a..a69043a 100644 --- a/t/020_sort_keys.t +++ b/t/020_sort_keys.t @@ -59,7 +59,10 @@ if ( @keys > 1 ) { foreach my $x ( 0 .. $#keys ) { foreach my $y ($x + 1 .. $#keys) { is($encoded{$keys[$x]}, $encoded{$keys[$y]},"$keys[$x] vs $keys[$y] (same: sort_keys)"); - isnt($encoded_unsorted{$keys[$x]}, $encoded_unsorted{$keys[$y]},"$keys[$x] vs $keys[$y] (different: no sort_keys)"); + SKIP: { + skip "test causes random false failures", 1; + isnt($encoded_unsorted{$keys[$x]}, $encoded_unsorted{$keys[$y]},"$keys[$x] vs $keys[$y] (different: no sort_keys)"); + } } } -- 2.30.2