SWF/Type/CLIPEVENTFLAGS.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 64 CC 7 SCAR 24.1
CC
7
Cov
0%
string
20.0
build
12.0
parse
6.0
CRAP 11.2
1 package IO::SWF::Type::CLIPEVENTFLAGS;
2  
3 use strict;
4 use warnings;
5  
6 use base 'IO::SWF::Type';
7  
8 our @clipevent_list = (
9 'KeyUp', 'KeyDown', 'MouseUp', 'MouseDown', 'MouseMove',
10 'Unload', 'EnterFrame', 'Load', 'DragOver',
11 'RollOut', 'RollOver',
12 'ReleaseOutside', 'Release', 'Press', 'Initialize', 'Data');
13  
14 sub parse {
15 my ($reader, $opts_href) = @_;
16 my %clipeventflags = ();
17 foreach my $key (@clipevent_list) {
18 $clipeventflags{'ClipEvent'.$key} = $reader->getUIBit();
19 }
20 if ($opts_href->{'Version'} >= 6) {
21 $clipeventflags{'Reserved'} = $reader->getUIBits(5);
22 $clipeventflags{'ClipEventKeyConstruct'} = $reader->getUIBit();
23 $clipeventflags{'ClipEventKeyPress'} = $reader->getUIBit();
24 $clipeventflags{'ClipEventDragOut'} = $reader->getUIBit();
25 $clipeventflags{'Reserved2'} = $reader->getUIBits(8);
26 }
27 return \%clipeventflags;
28 }
29  
30 sub build {
31 my ($writer, $clipeventflags_href, $opts_href) = @_;
32 my %clipeventflags = ref($clipeventflags_href) ? %{$clipeventflags_href} : ();
33  
34 foreach my $key (@clipevent_list) {
35 $writer->putUIBit($clipeventflags{'ClipEvent'.$key});
36 }
37 if ($opts_href->{'Version'} >= 6) {
38 $writer->putUIBits($clipeventflags{'Reserved'}, 6);
39 $writer->putUIBit($clipeventflags{'ClipEventConstruct'});
40 $writer->putUIBit($clipeventflags{'ClipEventKeyPress'});
41 $writer->putUIBit($clipeventflags{'ClipEventDragOut'});
42 $writer->putUIBits($clipeventflags{'Reserved2'}, 8);
43 }
44 }
45  
46 sub string {
47 my ($clipeventflags_href, $opts_href) = @_;
48 my %clipeventflags = ref($clipeventflags_href) ? %{$clipeventflags_href} : ();
49 my $text = "ClipEvent: ";
50 my @clipevent_list_local = @clipevent_list;
51 if ($opts_href->{'Version'} <= 5) {
52 #
53 } else {
54 push @clipevent_list_local, ('Construct', 'KeyPress', 'DragOut');
55 }
56 foreach my $key (@clipevent_list_local) {
57 if ($clipeventflags{'ClipEvent'.$key} == 1) {
58 $text .= $key.' ';
59 }
60 }
61 return $text;
62 }
63  
64 1;