SWF/Type/CLIPACTIONRECORD.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 73 CC 5 SCAR 17.6
CC
5
Cov
0%
build
12.0
parse
6.0
string
6.0
CRAP 5.8
1 package IO::SWF::Type::CLIPACTIONRECORD;
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::Action;
10  
11 sub parse {
12 my ($reader, $opts_href) = @_;
13 my %clipactionrecord = ();
14 $clipactionrecord{'EventFlags'} = IO::SWF::Type::CLIPEVENTFLAGS::parse($reader, $opts_href);
15 $clipactionrecord{'ActionRecordSize'} = $reader->getUI32LE();
16 if ($clipactionrecord{'EventFlags'}->{'ClipEventKeyPress'} == 1) {
17 $clipactionrecord{'KeyCode'} = $reader->getUI8();
18 }
19 my @actions = ();
20 while ($reader->getUI8() != 0) {
21 $reader->incrementOffset(-1, 0); # 1 byte back
22 my $action = IO::SWF::Type::Action::parse($reader);
23 push @actions, $action;
24 }
25 $clipactionrecord{'Actions'} = \@actions;
26 return \%clipactionrecord;
27 }
28  
29 sub build {
30 my ($writer, $clipactionrecord_href, $opts_href) = @_;
31 my %clipactionrecord = ref($clipactionrecord_href) ? %{$clipactionrecord_href} : ();
32  
33 IO::SWF::Type::CLIPEVENTFLAGS::build($writer, $clipactionrecord{'EventFlags'}, $opts_href);
34 my $actionRecordSize = $clipactionrecord{'ActionRecordSize'}; # XXX
35 $writer->putUI32LE($actionRecordSize);
36 if ($clipactionrecord{'EventFlags'}->{'ClipEventKeyPress'} == 1) {
37 $writer->putUI8($clipactionrecord{'KeyCode'});
38 }
39 my @actions = ();
40 foreach my $action (@{$clipactionrecord{'Actions'}}) {
41 IO::SWF::Type::Action::build($writer, $action);
42 }
43 $writer->putUI8(0); # ActionEndFlag
44 }
45  
46 sub string {
47 my ($clipactionrecord_href, $opts_href) = @_;
48 my %clipactionrecord = ref($clipactionrecord_href) ? %{$clipactionrecord_href} : ();
49  
50 my $text = '';
51 $text .= IO::SWF::Type::CLIPEVENTFLAGS::string($clipactionrecord{'EventFlags'}, $opts_href);
52 $text .= "\n";
53 $text .= "\tActions:\n";
54 foreach my $action (@{$clipactionrecord{'Actions'}}) {
55 $text .= "\t";
56 $text .= IO::SWF::Type::Action::string($action, $opts_href);
57 $text .= "\n";
58 }
59 return $text;
60 }
61  
62 1;