Subject: | Mac::PropertyList::ReadBinary returns unblessed data types |
Date: | Mon, 6 Dec 2010 15:02:56 -0800 |
To: | bug-Mac-PropertyList [...] rt.cpan.org |
From: | Hal Pomeranz <hal [...] deer-run.com> |
Mac::PropertyList::ReadBinary returns unblessed data types for a
few types:
[...]
my $type_readers = {
0 => sub { # the odd balls
my( $self, $length ) = @_;
my %hash = (
0 => [ qw(null 0) ],
8 => [ qw(false 0) ],
9 => [ qw(true 1) ],
15 => [ qw(fill 15) ],
);
return $hash{ $length } || [];
},
[...]
This leads to problems when doing things like this:
use Mac::PropertyList;
use strict;
my $data = Mac::PropertyList::parse_plist_file('myfile.plist');
$ref = $data->as_perl;
If the parsed plist file contains any of the data types listed in the
hash above, then this above program will bomb out with an error like:
Can't call method "value" on unblessed reference at
/some/path/to/PropertyList.pm line 675.
A partial fix would be to modify the above code for the true/false types:
0 => sub { # the odd balls
my( $self, $length ) = @_;
return Mac::PropertyList::false->new if ($length == 8);
return Mac::PropertyList::true->new if ($length == 9);
my %hash = (
0 => [ qw(null 0) ],
15 => [ qw(fill 15) ],
);
return $hash{ $length } || [];
},
A complete fix would involve defining object types in Mac::PropertyList
for null and fill data and then modifying the above program to return them.
Hal Pomeranz
hal@deer-run.com