Modified:
trunk/perl/lib/Protobuf/Decoder.pm
trunk/perl/lib/Protobuf/Encoder.pm
trunk/perl/t/wire-numbers.t
Log:
Support for bool type
Modified: trunk/perl/lib/Protobuf/Decoder.pm
==============================================================================
--- trunk/perl/lib/Protobuf/Decoder.pm (original)
+++ trunk/perl/lib/Protobuf/Decoder.pm Sat Apr 18 17:14:07 2009
@@ -110,6 +110,7 @@
# unsigned integers, so we don't need to do anything:
*decode_field_uint32 = \&_decode_field_no_xform_needed;
*decode_field_uint64 = \&_decode_field_no_xform_needed;
+*decode_field_bool = \&_decode_field_no_xform_needed;
# TODO(bradfitz): This is a lie: Enums can be negative, according to
# the Python impl at least. So we need to fix this in the future.
Modified: trunk/perl/lib/Protobuf/Encoder.pm
==============================================================================
--- trunk/perl/lib/Protobuf/Encoder.pm (original)
+++ trunk/perl/lib/Protobuf/Encoder.pm Sat Apr 18 17:14:07 2009
@@ -142,6 +142,11 @@
$self->encode_wire_varint($field, $int);
}
+sub encode_field_bool {
+ my ( $self, $field, $bool ) = @_;
+ $self->encode_wire_varint($field, $bool);
+}
+
sub encode_field_uint32 {
my ( $self, $field, $int ) = @_;
$self->encode_wire_varint($field, $int);
Modified: trunk/perl/t/wire-numbers.t
==============================================================================
--- trunk/perl/t/wire-numbers.t (original)
+++ trunk/perl/t/wire-numbers.t Sat Apr 18 17:14:07 2009
@@ -97,6 +97,9 @@
['float', 1.0/3.0, "]"."\xab\xaa\xaa>"],
['double', 1.0/3.0, "a"."UUUUUU\xd5?"],
+ ['bool', 0, "h\x00"],
+ ['bool', 1, "h\x01"],
+
['nested_enum', 2, "\xa8\x01\x02"],
# negative enums are allowed, I guess. Python allows them. Not
zigzag, though.