| 1 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | Mac::PropertyList::SAX - work with Mac plists at a low level, fast | ||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | =cut | ||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | package Mac::PropertyList::SAX; | ||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | See L<Mac::PropertyList|Mac::PropertyList> | ||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | L<Mac::PropertyList|Mac::PropertyList> is useful, but very slow on large files | ||||||||||||||||||||||||||||||||||
| 16 | because it does XML parsing itself, intead of handing it off to a dedicated | ||||||||||||||||||||||||||||||||||
| 17 | parser. This module uses L<XML::SAX::ParserFactory|XML::SAX::ParserFactory> to | ||||||||||||||||||||||||||||||||||
| 18 | select a parser capable of doing the heavy lifting, reducing parsing time on | ||||||||||||||||||||||||||||||||||
| 19 | large files by a factor of 30 or more. | ||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | This module does not replace L<Mac::PropertyList|Mac::PropertyList>: it depends | ||||||||||||||||||||||||||||||||||
| 22 | on it for some package definitions and plist printing routines. You should, | ||||||||||||||||||||||||||||||||||
| 23 | however, be able to replace all C<use Mac::PropertyList> | ||||||||||||||||||||||||||||||||||
| 24 | lines with C<use Mac::PropertyList::SAX>, without changing anything else, and | ||||||||||||||||||||||||||||||||||
| 25 | notice an immediate improvement in performance on large input files. | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | Performance will depend largely on the parser that | ||||||||||||||||||||||||||||||||||
| 28 | L<XML::SAX::ParserFactory|XML::SAX::ParserFactory> selects for you. By default, | ||||||||||||||||||||||||||||||||||
| 29 | L<XML::SAX::Expat|XML::SAX::Expat> is used; to change the parser used, set the | ||||||||||||||||||||||||||||||||||
| 30 | environment variable C<MAC_PROPERTYLIST_SAX_PARSER> to a value accepted by | ||||||||||||||||||||||||||||||||||
| 31 | $XML::SAX::ParserPackage from | ||||||||||||||||||||||||||||||||||
| 32 | L<XML::SAX::ParserFactory|XML::SAX::ParserFactory> (or set | ||||||||||||||||||||||||||||||||||
| 33 | C<$XML::SAX::ParserPackage> directly). | ||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | =cut | ||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 38 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 20 | ▶ | use Carp qw(carp); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 41 | 20 | ▶ | use HTML::Entities qw(encode_entities_numeric); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 42 | 20 | ▶ | use HTML::Entities::Numbered qw(hex2name name2hex_xml); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 43 | # Passthrough function | ||||||||||||||||||||||||||||||||||
| 44 | 20 | ▶ | use Mac::PropertyList qw(plist_as_string); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 45 | 20 | ▶ | use XML::SAX::ParserFactory; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | 20 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | 20 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||
| 50 | parse_plist | ||||||||||||||||||||||||||||||||||
| 51 | parse_plist_fh | ||||||||||||||||||||||||||||||||||
| 52 | parse_plist_file | ||||||||||||||||||||||||||||||||||
| 53 | parse_plist_string | ||||||||||||||||||||||||||||||||||
| 54 | plist_as_string | ||||||||||||||||||||||||||||||||||
| 55 | create_from_ref | ||||||||||||||||||||||||||||||||||
| 56 | create_from_hash | ||||||||||||||||||||||||||||||||||
| 57 | create_from_array | ||||||||||||||||||||||||||||||||||
| 58 | create_from_string | ||||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | 20 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||
| 62 | all => \@EXPORT_OK, | ||||||||||||||||||||||||||||||||||
| 63 | create => [ qw(create_from_ref create_from_hash create_from_array create_from_string plist_as_string) ], | ||||||||||||||||||||||||||||||||||
| 64 | parse => [ qw(parse_plist parse_plist_fh parse_plist_file parse_plist_string) ], | ||||||||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | 20 | our $VERSION = '0.91'; | |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | =head1 CLASS VARIABLES | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | Class scoped variables that control the packages settings. | ||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | =over 4 | ||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | =item ENCODE_ENTITIES | ||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||
| 79 | Allows the XHTML encoding of the data to be turned off. Default = C<1> | ||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | =item ENCODE_UNSAFE_CHARS | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | A Perl character class definition containing the only characters to be | ||||||||||||||||||||||||||||||||||
| 84 | XHTML encoded. See HTML::Entities::encode_entities for description of | ||||||||||||||||||||||||||||||||||
| 85 | the $unsafe_chars parameter. Default = C<undef> | ||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | 20 | our $ENCODE_ENTITIES = 1; | |||||||||||||||||||||||||||||||||
| 90 | 20 | our $ENCODE_UNSAFE_CHARS = undef; | |||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | =item OLD_BEHAVIOR | ||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | Restores the old behavior of double encoding output data. Default = C<0> | ||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | 20 | our $OLD_BEHAVIOR = 0; | |||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | =item XML::SAX::ParserPackage | ||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | Parser to use. Can also be set with environment variable | ||||||||||||||||||||||||||||||||||
| 103 | C<MAC_PROPERTYLIST_SAX_PARSER>. Default = C<"XML::SAX::Expat"> | ||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | =cut | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | 20 | ▶ | $XML::SAX::ParserPackage = $ENV{MAC_PROPERTYLIST_SAX_PARSER} || "XML::SAX::Expat"; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'MAC_PROPERTYLIST_SAX_PARSER'} || 'XML::SAX::Expat'
MC/DC0%0/1
$ENV{'MAC_PROPERTYLIST_SAX_PARSER'} || 'XML::SAX::Expat'
$ENV{'MAC_PROPERTYLIST_SAX_PARSER'}
Truth table50%1/2
A
A= $ENV{'MAC_PROPERTYLIST_SAX_PARSER'}
| |||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | =back | ||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | =head1 EXPORTS | ||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||
| 113 | By default, no functions are exported. Specify individual functions to export | ||||||||||||||||||||||||||||||||||
| 114 | as usual, or use the tags ':all', ':create', and ':parse' for the appropriate | ||||||||||||||||||||||||||||||||||
| 115 | sets of functions (':create' includes the create* functions as well as | ||||||||||||||||||||||||||||||||||
| 116 | plist_as_string; ':parse' includes the parse* functions). | ||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||
| 118 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||
| 120 | =over 4 | ||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||
| 122 | =item parse_plist_file | ||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||
| 124 | See L<Mac::PropertyList/parse_plist_file> | ||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||
| 126 | =cut | ||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||
| 128 | sub parse_plist_file { | ||||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | my $file = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_plist_file: called CC=3 SCAR=15.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | 1 | ▶ | if (ref $file) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 132 | 1 | parse_plist_fh($file); | |||||||||||||||||||||||||||||||||
| 133 | } else { | ||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | carp("parse_plist_file: file [$file] does not exist!"), return unless -e $file; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 135 | 0 | _parse("parse_uri", $file); | |||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||
| 139 | =item parse_plist_fh | ||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||
| 141 | See L<Mac::PropertyList/parse_plist_fh> | ||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | =cut | ||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | 2 | ▶ | sub parse_plist_fh { _parse("parse_file", @_) } | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_plist_fh: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||
| 147 | =item parse_plist | ||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||
| 149 | See L<Mac::PropertyList/parse_plist> | ||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | =cut | ||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||
| 153 | 23 | ▶ | sub parse_plist { _parse("parse_string", @_) } | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_plist: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | =item parse_plist_string | ||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | An alias to parse_plist, provided for better regularity compared to Perl SAX. | ||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||
| 159 | =cut | ||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | 20 | *parse_plist_string = \&parse_plist; | |||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||
| 163 | sub _parse { | ||||||||||||||||||||||||||||||||||
| 164 | # shift off first param in case we use `goto` later (leaving @_ with $data) | ||||||||||||||||||||||||||||||||||
| 165 | 25 | ▶ | my $sub = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_parse: called CC=6 SCAR=19.6
| |||||||||||||||||||||||||||||||||||
| 166 | 25 | my ($data) = @_; | |||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||
| 168 | 25 | my $first; | |||||||||||||||||||||||||||||||||
| 169 | my $fh; | ||||||||||||||||||||||||||||||||||
| 170 | 25 | my $delegate; | |||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||
| 172 | # read initial bytes of file | ||||||||||||||||||||||||||||||||||
| 173 | # if we have a binary plist, delegate to Mac::PropertyList | ||||||||||||||||||||||||||||||||||
| 174 | 25 | ▶ | if ($sub eq "parse_uri") { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 175 | 0 | open $fh, "<", $_[0]; | |||||||||||||||||||||||||||||||||
| 176 | 0 | $sub = "parse_file"; | |||||||||||||||||||||||||||||||||
| 177 | 0 | $_[0] = $fh; | |||||||||||||||||||||||||||||||||
| 178 | # delegate will be set below | ||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||
| 181 | 25 | ▶ | if ($sub eq "parse_file") { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 182 | 2 | read $_[0], $first, length "bplist"; | |||||||||||||||||||||||||||||||||
| 183 | 2 | ▶ | seek $_[0], 0, 0 or die "Can't seek given filehandle"; # seek back to beginning | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 184 | 2 | $delegate = \&Mac::PropertyList::parse_plist_fh; | |||||||||||||||||||||||||||||||||
| 185 | } elsif ($sub eq "parse_string") { | ||||||||||||||||||||||||||||||||||
| 186 | 23 | $first = $_[0]; | |||||||||||||||||||||||||||||||||
| 187 | 23 | $delegate = \&Mac::PropertyList::parse_plist; | |||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||
| 190 | 25 | ▶ | if ($first =~ /^bplist/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 191 | # binary plist -- delegate to non-SAX module | ||||||||||||||||||||||||||||||||||
| 192 | 0 | goto $delegate; | |||||||||||||||||||||||||||||||||
| 193 | } else { | ||||||||||||||||||||||||||||||||||
| 194 | 25 | my $handler = Mac::PropertyList::SAX::Handler->new; | |||||||||||||||||||||||||||||||||
| 195 | 25 | XML::SAX::ParserFactory->parser(Handler => $handler)->$sub($data); | |||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||
| 197 | 0 | return $handler->{struct}; | |||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||
| 201 | =item create_from_ref( HASH_REF | ARRAY_REF ) | ||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||
| 203 | Create a plist from an array or hash reference. | ||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||
| 205 | The values of the hash can be simple scalars or references. Hash and array | ||||||||||||||||||||||||||||||||||
| 206 | references are handled recursively, and L<Mac::PropertyList|Mac::PropertyList> objects are output | ||||||||||||||||||||||||||||||||||
| 207 | correctly. All other scalars are treated as strings (use L<Mac::PropertyList|Mac::PropertyList> | ||||||||||||||||||||||||||||||||||
| 208 | objects to represent other types of scalars). | ||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||
| 210 | Returns a string representing the reference in serialized plist format. | ||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||
| 212 | =cut | ||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||
| 214 | sub create_from_ref { | ||||||||||||||||||||||||||||||||||
| 215 | sub _handle_value { | ||||||||||||||||||||||||||||||||||
| 216 | 14 | ▶ | my ($val) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_handle_value: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | sub _handle_hash { | ||||||||||||||||||||||||||||||||||
| 219 | 3 | ▶ | my ($hash) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_handle_hash: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||
| 220 | Mac::PropertyList::SAX::dict->write_open, | ||||||||||||||||||||||||||||||||||
| 221 | 38 | (map { "\t$_" } map { | |||||||||||||||||||||||||||||||||
| 222 | 3 | Mac::PropertyList::SAX::dict->write_key($OLD_BEHAVIOR ? _escape($_) : $_), | |||||||||||||||||||||||||||||||||
| 223 | 7 | ▶ | _handle_value($hash->{$_}) } keys %$hash), | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 224 | Mac::PropertyList::SAX::dict->write_close | ||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||
| 227 | sub _handle_array { | ||||||||||||||||||||||||||||||||||
| 228 | 2 | ▶ | my ($array) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_handle_array: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 229 | Mac::PropertyList::SAX::array->write_open, | ||||||||||||||||||||||||||||||||||
| 230 | 2 | (map { "\t$_" } map { _handle_value($_) } @$array), | |||||||||||||||||||||||||||||||||
| 231 | Mac::PropertyList::SAX::array->write_close | ||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||
| 234 | # We could hand off serialization of all Mac::PropertyList::Item objects | ||||||||||||||||||||||||||||||||||
| 235 | # but there is no 'write' method defined for it (though all its | ||||||||||||||||||||||||||||||||||
| 236 | # subclasses have one). Let's just handle Scalars, which are safe. | ||||||||||||||||||||||||||||||||||
| 237 | 14 | ▶ | if (UNIVERSAL::can($val, 'write')) { $val->write } | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 238 | 3 | elsif (UNIVERSAL::isa($val, 'HASH')) { _handle_hash ($val) } | |||||||||||||||||||||||||||||||||
| 239 | 2 | elsif (UNIVERSAL::isa($val, 'ARRAY')) { _handle_array($val) } | |||||||||||||||||||||||||||||||||
| 240 | 8 | ▶ | else { Mac::PropertyList::SAX::string->new($OLD_BEHAVIOR ? _escape($val) : $val)->write } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | Mac::PropertyList::XML_head() . | ||||||||||||||||||||||||||||||||
|
Subroutine
create_from_ref: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 244 | (join "\n", _handle_value(shift)) . "\n" . | ||||||||||||||||||||||||||||||||||
| 245 | Mac::PropertyList::XML_foot(); | ||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||
| 248 | =item create_from_hash( HASH_REF ) | ||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||
| 250 | Provided for backward compatibility with L<Mac::PropertyList|Mac::PropertyList>: aliases | ||||||||||||||||||||||||||||||||||
| 251 | create_from_ref. | ||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||
| 253 | =cut | ||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||
| 255 | 20 | *create_from_hash = \&create_from_ref; | |||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||
| 257 | =item create_from_array( ARRAY_REF ) | ||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||
| 259 | Provided for backward compatibility with L<Mac::PropertyList|Mac::PropertyList>: aliases | ||||||||||||||||||||||||||||||||||
| 260 | create_from_ref. | ||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||
| 262 | =cut | ||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||
| 264 | 20 | *create_from_array = \&create_from_ref; | |||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||
| 266 | =item create_from_string( STRING ) | ||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||
| 268 | Provided for backward compatibility with L<Mac::PropertyList|Mac::PropertyList>: aliases C<Mac::PropertyList::create_from_string()>. | ||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||
| 270 | =cut | ||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||
| 272 | 20 | *create_from_string = \&Mac::PropertyList::create_from_string; | |||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||
| 274 | =item _escape( STRING ) | ||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||
| 276 | B<Internal use only.> Escapes illegal characters into XML entities. | ||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||
| 278 | =cut | ||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||
| 280 | sub _escape { | ||||||||||||||||||||||||||||||||||
| 281 | 15 | ▶ | my $string = join("\n",grep(defined,@_)); | ||||||||||||||||||||||||||||||||
|
Subroutine
_escape: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||
| 282 | 15 | ▶ | $ENCODE_ENTITIES && | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 283 | return name2hex_xml(hex2name(encode_entities_numeric($string, | ||||||||||||||||||||||||||||||||||
| 284 | $ENCODE_UNSAFE_CHARS))); | ||||||||||||||||||||||||||||||||||
| 285 | 0 | return $string; | |||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||
| 288 | package Mac::PropertyList::SAX::Handler; | ||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||
| 290 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 291 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 292 | # State definitions | ||||||||||||||||||||||||||||||||||
| 293 | 20 | ▶ | use enum qw(S_EMPTY S_TOP S_FREE S_DICT S_ARRAY S_KEY S_TEXT); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||
| 295 | 20 | ▶ | use Carp qw(carp croak); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 296 | 20 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||
| 298 | # Element-name definitions | ||||||||||||||||||||||||||||||||||
| 299 | 20 | use constant +{ qw( ROOT plist | |||||||||||||||||||||||||||||||||
| 300 | KEY key | ||||||||||||||||||||||||||||||||||
| 301 | DATA data | ||||||||||||||||||||||||||||||||||
| 302 | DICT dict | ||||||||||||||||||||||||||||||||||
| 303 | 20 | ▶ | ARRAY array ) }; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||
| 305 | 20 | ▶ | use base qw(XML::SAX::Base); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||
| 307 | # From the plist DTD | ||||||||||||||||||||||||||||||||||
| 308 | 20 | our (%types, %simple_types, %complex_types, %numerical_types); | |||||||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||||||||
| 310 | 20 | my @complex_types = (DICT, ARRAY); | |||||||||||||||||||||||||||||||||
| 311 | 20 | my @numerical_types = qw(real integer true false); | |||||||||||||||||||||||||||||||||
| 312 | 20 | my @simple_types = qw(data date real integer string true false); | |||||||||||||||||||||||||||||||||
| 313 | 20 | my @types = (@complex_types, @numerical_types, @simple_types); | |||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||
| 315 | 80 | ▶ | my $atoh = sub { map { $_ => 1 } @_ }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||
| 317 | 20 | %types = $atoh->(@ types); | |||||||||||||||||||||||||||||||||
| 318 | 20 | %simple_types = $atoh->(@ simple_types); | |||||||||||||||||||||||||||||||||
| 319 | 20 | %complex_types = $atoh->(@ complex_types); | |||||||||||||||||||||||||||||||||
| 320 | 20 | %numerical_types = $atoh->(@numerical_types); | |||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||
| 323 | sub new { | ||||||||||||||||||||||||||||||||||
| 324 | 25 | ▶ | my %args = ( | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 325 | accum => "", | ||||||||||||||||||||||||||||||||||
| 326 | context => S_EMPTY, | ||||||||||||||||||||||||||||||||||
| 327 | key => undef, | ||||||||||||||||||||||||||||||||||
| 328 | stack => [ ], | ||||||||||||||||||||||||||||||||||
| 329 | struct => undef, | ||||||||||||||||||||||||||||||||||
| 330 | ); | ||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||
| 332 | 25 | shift->SUPER::new(%args, @_) | |||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||
| 335 | sub start_element { | ||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
start_element: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||
| 337 | 0 | my ($data) = @_; | |||||||||||||||||||||||||||||||||
| 338 | 0 | my $name = $data->{Name}; | |||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||
| 340 | # State transition definitions | ||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if ($self->{context} == S_EMPTY and $name eq ROOT) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$self->{"context"} == 0 and $name eq "plist"
MC/DC0%0/2
$self->{"context"} == 0 and $name eq "plist"
$self->{"context"} == 0
$name eq "plist"
Truth table0%0/3
A and B
A= $self->{"context"} == 0B= $name eq "plist"
| |||||||||||||||||||||||||||||||||||
| 342 | 0 | $self->{context} = S_TOP; | |||||||||||||||||||||||||||||||||
| 343 | ▶ | } elsif ($self->{context} == S_TOP or $types{$name} or $name eq KEY) { | |||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->{"context"} == 1 or $Mac::PropertyList::SAX::Handler::types{$name} or $name eq "key"
$self->{"context"} == 1 or $Mac::PropertyList::SAX::Handler::types{$name}
MC/DC0%0/3
$self->{"context"} == 1 or $Mac::PropertyList::SAX::Handler::types{$name} or $name eq "key"
$self->{"context"} == 1
$Mac::PropertyList::SAX::Handler::types{$name}
$name eq "key"
Truth table0%0/4
A or B or C
A= $self->{"context"} == 1B= $Mac::PropertyList::SAX::Handler::types{$name}C= $name eq "key"
| |||||||||||||||||||||||||||||||||||
| 344 | 0 | push @{ $self->{stack} }, { | |||||||||||||||||||||||||||||||||
| 345 | key => $self->{key}, | ||||||||||||||||||||||||||||||||||
| 346 | context => $self->{context}, | ||||||||||||||||||||||||||||||||||
| 347 | struct => $self->{struct}, | ||||||||||||||||||||||||||||||||||
| 348 | 0 | }; | |||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if ($complex_types{$name}) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->{struct} = "Mac::PropertyList::SAX::$name"->new; | |||||||||||||||||||||||||||||||||
| 352 | 0 | $self->{context} = eval "S_" . uc $name; | |||||||||||||||||||||||||||||||||
| 353 | 0 | delete $self->{key}; | |||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||
| 355 | 0 | elsif ($simple_types{$name}) { $self->{context} = S_TEXT } | |||||||||||||||||||||||||||||||||
| 356 | elsif ($name eq KEY) { | ||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | croak "<key/> in improper context $self->{context}" unless $self->{context} == S_DICT; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 358 | 0 | $self->{context} = S_KEY; | |||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||
| 360 | 0 | else { croak "Top-level element '$name' in plist is not recognized" } | |||||||||||||||||||||||||||||||||
| 361 | } else { | ||||||||||||||||||||||||||||||||||
| 362 | 0 | croak "Received invalid start element '$name'"; | |||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||
| 366 | sub end_element { | ||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
end_element: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||
| 368 | 0 | my ($data) = @_; | |||||||||||||||||||||||||||||||||
| 369 | 0 | my $name = $data->{Name}; | |||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if ($name ne ROOT) { # Discard plist element | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 372 | 0 | my $elt = pop @{ $self->{stack} }; | |||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||
| 374 | 0 | my $value = $self->{struct}; | |||||||||||||||||||||||||||||||||
| 375 | 0 | ($self->{struct}, $self->{key}, $self->{context}) = @{$elt}{qw(struct key context)}; | |||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | if ($simple_types{$name}) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 378 | # Wrap accumulated character data in an object | ||||||||||||||||||||||||||||||||||
| 379 | $value = "Mac::PropertyList::SAX::$name"->new( | ||||||||||||||||||||||||||||||||||
| 380 | exists $self->{accum} | ||||||||||||||||||||||||||||||||||
| 381 | ? $name eq DATA | ||||||||||||||||||||||||||||||||||
| 382 | ? MIME::Base64::decode_base64($self->{accum}) | ||||||||||||||||||||||||||||||||||
| 383 | : $self->{accum} | ||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | : "" | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 385 | ); | ||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||
| 387 | 0 | delete $self->{accum}; | |||||||||||||||||||||||||||||||||
| 388 | } elsif ($name eq KEY) { | ||||||||||||||||||||||||||||||||||
| 389 | 0 | $self->{key} = $self->{accum}; | |||||||||||||||||||||||||||||||||
| 390 | 0 | delete $self->{accum}; | |||||||||||||||||||||||||||||||||
| 391 | 0 | return; | |||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ($self->{context} == S_DICT ) { $self->{struct}{$self->{key}} = $value } | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 395 | 0 | elsif ($self->{context} == S_ARRAY) { push @{ $self->{struct} }, $value } | |||||||||||||||||||||||||||||||||
| 396 | 0 | elsif ($self->{context} == S_TOP ) { $self->{struct} = $value } | |||||||||||||||||||||||||||||||||
| 397 | 0 | else { croak "Bad context $self->{context}" } | |||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||
| 401 | sub characters { | ||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
characters: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 403 | 0 | my ($data) = @_; | |||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | $self->{accum} .= $data->{Data} if $self->{context} == S_TEXT or $self->{context} == S_KEY; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"context"} == 6 or $self->{"context"} == 5
MC/DC0%0/2
$self->{"context"} == 6 or $self->{"context"} == 5
$self->{"context"} == 6
$self->{"context"} == 5
Truth table0%0/3
A or B
A= $self->{"context"} == 6B= $self->{"context"} == 5
| |||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||
| 407 | # Convenient subclasses | ||||||||||||||||||||||||||||||||||
| 408 | package Mac::PropertyList::SAX::array; | ||||||||||||||||||||||||||||||||||
| 409 | 20 | ▶ | use base qw(Mac::PropertyList::array); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 410 | package Mac::PropertyList::SAX::dict; | ||||||||||||||||||||||||||||||||||
| 411 | 20 | ▶ | use base qw(Mac::PropertyList::dict); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 412 | 7 | ▶ | sub write_key { "<key>" . (Mac::PropertyList::SAX::_escape($_[1]) || '') . "</key>" } | ||||||||||||||||||||||||||||||||
|
Subroutine
write_key: called CC=2 SCAR=7.6
Condition50%1/2
Mac::PropertyList::SAX::_escape($_[1]) || ''
MC/DC0%0/1
Mac::PropertyList::SAX::_escape($_[1]) || ''
Mac::PropertyList::SAX::_escape($_[1])
Truth table50%1/2
A
A= Mac::PropertyList::SAX::_escape($_[1])
| |||||||||||||||||||||||||||||||||||
| 413 | package Mac::PropertyList::SAX::Scalar; | ||||||||||||||||||||||||||||||||||
| 414 | 20 | ▶ | use base qw(Mac::PropertyList::Scalar); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 415 | sub write { | ||||||||||||||||||||||||||||||||||
| 416 | 8 | ▶ | $_[0]->write_open . | ||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=2 SCAR=7.6
Condition50%1/2
Mac::PropertyList::SAX::_escape($_[0]->value) || ''
MC/DC0%0/1
Mac::PropertyList::SAX::_escape($_[0]->value) || ''
Mac::PropertyList::SAX::_escape($_[0]->value)
Truth table50%1/2
A
A= Mac::PropertyList::SAX::_escape($_[0]->value)
| |||||||||||||||||||||||||||||||||||
| 417 | (Mac::PropertyList::SAX::_escape($_[0]->value) || '') . | ||||||||||||||||||||||||||||||||||
| 418 | $_[0]->write_close | ||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||
| 420 | 20 | ▶ | use overload '""' => sub { $_[0]->as_basic_data }; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||
| 421 | package Mac::PropertyList::SAX::date; | ||||||||||||||||||||||||||||||||||
| 422 | 20 | ▶ | use base qw(Mac::PropertyList::date Mac::PropertyList::SAX::Scalar); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 423 | package Mac::PropertyList::SAX::real; | ||||||||||||||||||||||||||||||||||
| 424 | 20 | ▶ | use base qw(Mac::PropertyList::real Mac::PropertyList::SAX::Scalar); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 425 | package Mac::PropertyList::SAX::integer; | ||||||||||||||||||||||||||||||||||
| 426 | 20 | ▶ | use base qw(Mac::PropertyList::integer Mac::PropertyList::SAX::Scalar); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 427 | package Mac::PropertyList::SAX::string; | ||||||||||||||||||||||||||||||||||
| 428 | 20 | ▶ | use base qw(Mac::PropertyList::string Mac::PropertyList::SAX::Scalar); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 429 | 8 | ▶ | sub write { $_[0]->Mac::PropertyList::SAX::Scalar::write } | ||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 430 | 20 | ▶ | use overload '""' => sub { $_[0]->as_basic_data }; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||
| 431 | package Mac::PropertyList::SAX::data; | ||||||||||||||||||||||||||||||||||
| 432 | 20 | ▶ | use base qw(Mac::PropertyList::data Mac::PropertyList::SAX::Scalar); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 433 | package Mac::PropertyList::SAX::Boolean; | ||||||||||||||||||||||||||||||||||
| 434 | 20 | ▶ | use Object::MultiType; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 435 | 20 | ▶ | use base qw(Mac::PropertyList::Boolean Object::MultiType); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 436 | 20 | ▶ | use overload '""' => sub { shift->value }; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||
| 437 | sub new { | ||||||||||||||||||||||||||||||||||
| 438 | 2 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 439 | 2 | my ($type) = $class =~ /::([^:]+)$/; | |||||||||||||||||||||||||||||||||
| 440 | 2 | my $b = lc $type eq "true"; | |||||||||||||||||||||||||||||||||
| 441 | 2 | bless Object::MultiType->new(scalar => $type, bool => $b) => $class | |||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | sub value { ${${$_[0]}->scalar} } | ||||||||||||||||||||||||||||||||
|
Subroutine
value: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 444 | package Mac::PropertyList::SAX::true; | ||||||||||||||||||||||||||||||||||
| 445 | 20 | ▶ | use base qw(Mac::PropertyList::SAX::Boolean Mac::PropertyList::true); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 446 | package Mac::PropertyList::SAX::false; | ||||||||||||||||||||||||||||||||||
| 447 | 20 | ▶ | use base qw(Mac::PropertyList::SAX::Boolean Mac::PropertyList::true); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||
| 449 | 20 | 1; | |||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||
| 451 | __END__ | ||||||||||||||||||||||||||||||||||