SWF/Type/CLIPACTIONS.pm untested

filter: Statementstmt 0.0% 0 / 53 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 76 CC 7 SCAR 22.9
CC
7
Cov
0%
parse
20.0
build
12.0
string
6.0
CRAP 9.9
1 package IO::SWF::Type::CLIPACTIONS;
2  
3 use strict;
4 use warnings;
5  
6 use base 'IO::SWF::Type';
7  
8 use IO::SWF::Type::CLIPEVENTFLAGS;
9 use IO::SWF::Type::CLIPACTIONRECORD;
10  
11 sub parse {
12 my ($reader, $opts_href) = @_;
13 my %clipactions = ();
14 $clipactions{'Reserved'} = $reader->getUI16LE(); # must be 0
15 $clipactions{'AllEventFlags'} = IO::SWF::Type::CLIPEVENTFLAGS::parse($reader, $opts_href);
16 my @clipActionRecords = ();
17 while (1) {
18 if ($opts_href->{'Version'} <= 5) {
19 if ($reader->getUI16LE() == 0) {
20 last;
21 }
22 $reader->incrementOffset(-2, 0); # 2 bytes back
23 } else {
24 if ($reader->getUI32LE() == 0) {
25 last;
26 }
27 $reader->incrementOffset(-4, 0); # 4 bytes back
28 }
29 push @clipActionRecords, IO::SWF::Type::CLIPACTIONRECORD::parse($reader, $opts_href);
30 }
31 $clipactions{'ClipActionRecords'} = \@clipActionRecords;
32 return \%clipactions;
33 }
34  
35 sub build {
36 my ($writer, $clipactions_href, $opts_href) = @_;
37 my %clipactions = ref($clipactions_href) ? %{$clipactions_href} : ();
38  
39 $writer->putUI16LE($clipactions{'Reserved'}); # must be 0
40 IO::SWF::Type::CLIPEVENTFLAGS::build($writer, $clipactions{'AllEventFlags'}, $opts_href);
41 foreach my $clipActionRecord (@{$clipactions{'ClipActionRecords'}}) {
42 IO::SWF::Type::CLIPACTIONRECORD::build($writer, $clipActionRecord, $opts_href);
43 }
44 if ($opts_href->{'Version'} <= 5) {
45 $writer->putUI16LE(0); # ClipActionEndFlag
46 } else {
47 $writer->putUI32LE(0); # ClipActionEndFlag
48 }
49 }
50  
51 sub string {
52 my ($clipactions_href, $opts_href) = @_;
53 my %clipactions = ref($clipactions_href) ? %{$clipactions_href} : ();
54  
55 my $text = 'ALLEventFlags: ';
56 $text .= IO::SWF::Type::CLIPEVENTFLAGS::string($clipactions{'AllEventFlags'}, $opts_href);
57 $text .= "\n";
58 $text .= "\tClipActionRecords:\n";
59 foreach my $clipActionRecord (@{$clipactions{'ClipActionRecords'}}) {
60 $text .= "\t".IO::SWF::Type::CLIPACTIONRECORD::string($clipActionRecord, $opts_href)."\n";
61 }
62 return $text;
63 }
64  
65 1;