Modified:
trunk/perl/lib/Protobuf/Decoder.pm
Log:
sfixed64
Modified: trunk/perl/lib/Protobuf/Decoder.pm
==============================================================================
--- trunk/perl/lib/Protobuf/Decoder.pm (original)
+++ trunk/perl/lib/Protobuf/Decoder.pm Wed Jul 30 14:00:35 2008
@@ -24,6 +24,20 @@
return unpack("l", $v);
}
+sub decode_field_sfixed64 {
+ my ($class, $v) = @_;
+ die "assert: length not 8 bytes" unless length($v) == 8;
+ my $is_neg = vec($v, 63, 1);
+ # TODO(bradfitz): sick of the pack manpage... this works for now.
+ my $hex = join('', sprintf("%02x"x8, reverse unpack("C16", $v)));
+ my $int = Math::BigInt->new("0x$hex");
+ if ($is_neg) {
+ $int->bnot;
+ $int->binc;
+ }
+ return $int;
+}
+
sub decode_field_float {
my ($class, $v) = @_;
die 'assert: should be 8 bytes' unless length($v) == 4;