[protobuf-perl commit] r151 - trunk/perl/lib/Protobuf

1 view
Skip to first unread message

codesite...@google.com

unread,
Jul 30, 2008, 5:04:54 PM7/30/08
to protobuf-p...@googlegroups.com
Author: br...@danga.com
Date: Wed Jul 30 14:02:33 2008
New Revision: 151

Modified:
trunk/perl/lib/Protobuf/Decoder.pm

Log:
fixed64

Modified: trunk/perl/lib/Protobuf/Decoder.pm
==============================================================================
--- trunk/perl/lib/Protobuf/Decoder.pm (original)
+++ trunk/perl/lib/Protobuf/Decoder.pm Wed Jul 30 14:02:33 2008
@@ -38,6 +38,16 @@
return $int;
}

+sub decode_field_fixed64 {
+ 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");
+ return $int;
+}
+
sub decode_field_float {
my ($class, $v) = @_;
die 'assert: should be 8 bytes' unless length($v) == 4;

Reply all
Reply to author
Forward
0 new messages