| 1 | package Code::Class::C; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.010000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | my $LastClassID = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | return $self->_init(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub func | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
func: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my ($self, $name, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $sign = $self->_parse_signature($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | die "Error: function name '$sign->{'name'}' is not a valid function name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if $sign->{'name'} !~ /^[a-z][a-zA-Z0-9\_]*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | die "Error: function must not be named 'main'\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if $sign->{'name'} eq 'main'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $name = $self->_signature_to_string($sign); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | die "Error: trying to redefine function '$name'\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if exists $self->{'functions'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $self->{'functions'}->{$name} = $self->_load_code_from_file($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | $self->{'functions-doc'}->{$name} = '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | unless exists $self->{'functions-doc'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | sub attr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attr: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my ($self, $classname, $attrname, $attrtype) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | die "Error: no class '$classname' defined\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | unless exists $self->{'classes'}->{$classname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | die "Error: attribute name '$attrname' is not a valid attribute name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | if $attrname !~ /^[a-z][a-zA-Z0-9\_]*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $class->{'attr'}->{$attrname} = $attrtype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | $class->{'attr-doc'}->{$attrname} = '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | unless exists $class->{'attr-doc'}->{$attrname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | sub meth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meth: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my ($self, $classname, $name, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | die "Error: no class '$classname' defined\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | unless exists $self->{'classes'}->{$classname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $sign = $self->_parse_signature($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | die "Error: failed to parse method with signature '$name'.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if !defined $sign->{'returns'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | die "Error: methodname '$sign->{'name'}' is not a valid method name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if $sign->{'name'} !~ /^[a-z][a-zA-Z0-9\_]*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # add implicit "self" first parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | unshift @{$sign->{'params'}}, ['self',$classname]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $name = $self->_signature_to_string($sign); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | die "Error: trying to redefine method '$name' in class '$classname'\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if exists $class->{'subs'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $class->{'subs'}->{$name} = $self->_load_code_from_file($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | $class->{'subs-doc'}->{$name} = '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | unless exists $class->{'subs-doc'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | sub parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my ($self, $classname, @parentclassnames) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | die "Error: no class '$classname' defined\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | unless exists $self->{'classes'}->{$classname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | foreach my $parentclassname (@parentclassnames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | push @{$class->{'isa'}}, $parentclassname | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | unless scalar grep { $parentclassname eq $_ } @{$class->{'isa'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | sub before | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my ($self, $classname, $methname, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | die "Error: no class '$classname' defined\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | unless exists $self->{'classes'}->{$classname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | die "Error: methodname '$methname' is not a valid method name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | if $methname !~ /^[a-z][a-zA-Z0-9\_]*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $class->{'before'}->{$methname} = $self->_load_code_from_file($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | sub after | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my ($self, $classname, $methname, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | die "Error: no class '$classname' defined\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | unless exists $self->{'classes'}->{$classname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | die "Error: methodname '$methname' is not a valid method name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | if $methname !~ /^[a-z][a-zA-Z0-9\_]*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $class->{'after'}->{$methname} = $self->_load_code_from_file($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | sub class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my ($self, $name, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | die "Error: cannot redefine class '$name': $!\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if exists $self->{'classes'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | die "Error: classname '$name' does not qualify for a valid name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | unless $name =~ /^[A-Z][a-zA-Z0-9\_]*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | die "Error: classname must not be 'Object'\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | if $name eq 'Object'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | die "Error: classname must not be longer than 256 characters\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | if length $name > 256; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $LastClassID++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | $self->{'classes'}->{$name} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 'id' => $LastClassID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 'name' => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 'doc' => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 'isa' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 'attr' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 'attr-doc' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 'subs' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 'subs-doc' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 'top' => ($opts{'top'} || ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | 'bottom' => ($opts{'bottom'} || ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$opts{'top'} || ''
$opts{'bottom'} || ''
MC/DC0%0/1
$opts{'top'} || ''
$opts{'top'}
MC/DC0%0/1
$opts{'bottom'} || ''
$opts{'bottom'}
Truth table0%0/2
A
A= $opts{'top'}
Truth table0%0/2
A
A= $opts{'bottom'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 'after' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # define attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | my $attr = $opts{'attr'} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'attr'} || {}
MC/DC0%0/1
$opts{'attr'} || {}
$opts{'attr'}
Truth table0%0/2
A
A= $opts{'attr'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | map { $self->attr($name, $_, $attr->{$_}) } keys %{$attr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # define methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | my $subs = $opts{'subs'} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'subs'} || {}
MC/DC0%0/1
$opts{'subs'} || {}
$opts{'subs'}
Truth table0%0/2
A
A= $opts{'subs'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | map { $self->meth($name, $_, $subs->{$_}) } keys %{$subs}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # set parent classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | $self->parent($name, @{$opts{'isa'} || []}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'isa'} || []
MC/DC0%0/1
$opts{'isa'} || []
$opts{'isa'}
Truth table0%0/2
A
A= $opts{'isa'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | sub readFile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readFile: not called CC=30 SCAR=68.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my ($self, $filename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | open SRCFILE, $filename or die "Error: cannot open source file '$filename': $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | #print "reading '$filename'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $classname = undef; # if set, name of current class | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $subname = undef; # if set, name of current method | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $funcname = undef; # if set, name of current function | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $top = undef; # if set, means currently parsing a @top block | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $bottom = undef; # if set, means currently parsing a @bottom block | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $types = undef; # if set, means currently parsing a @types block | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $after = undef; # if set, the method name for current @after block | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $before = undef; # if set, the method name for current @before block | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $buffer = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $l = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $docref = undef; # ref to docstring of previous entry | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | while (<SRCFILE>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | next if /^\/[\/\*]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if (/^\@class/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my ($class, $parents) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | $_ =~ /^\@class[\s\t]+([^\s\t\:]+)[\s\t]*\:?[\s\t]*(.*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my @parents = split /[\s\t]*\,[\s\t]*/, $parents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | $self->class($class) unless exists $self->{'classes'}->{$class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->parent($class, @parents); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $classname = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $docref = \$self->{'classes'}->{$class}->{'doc'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | elsif (/^\@attr/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | die "Error: no classname present at line $l.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | unless defined $classname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my ($attr, $type) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | $_ =~ /^\@attr[\s\t]+([^\s\t\:]+)[\s\t]*\:?[\s\t]*(.*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $type =~ s/[\s\t\n\r]*$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | warn "Warning: attribute definition $classname/$attr overwrites present one.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if exists $self->{'classes'}->{$classname}->{'attr'}->{$attr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $self->attr($classname, $attr, $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | $self->{'classes'}->{$classname}->{'attr-doc'}->{$attr} = '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | unless exists $self->{'classes'}->{$classname}->{'attr-doc'}->{$attr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $docref = \$self->{'classes'}->{$classname}->{'attr-doc'}->{$attr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | elsif (/^\@(sub|func|before|after)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | unless (/^\@func/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | die "Error: no classname present at line $l.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | unless defined $classname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # save previous "something" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | _save_current_buffer($self, $classname, $subname, $funcname, $before, $after, $buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # start new "something" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if (/^\@sub/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ($subname) = $_ =~ /^\@sub[\s\t]+(.+)[\s\t\n\r]*$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $funcname = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $before = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $after = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $methname = $self->_get_complete_method_name($classname, $subname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | #print "($methname)\n" if $methname =~ /^getAppWindow/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | $self->{'classes'}->{$classname}->{'subs-doc'}->{$methname} = '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | unless exists $self->{'classes'}->{$classname}->{'subs-doc'}->{$methname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | #print ">>docref meth $methname\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $docref = \$self->{'classes'}->{$classname}->{'subs-doc'}->{$methname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | elsif (/^\@func/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ($funcname) = $_ =~ /^\@func[\s\t]+(.+)[\s\t\n\r]*$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $subname = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $before = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $after = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | $self->{'functions-doc'}->{$funcname} = '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | unless exists $self->{'functions-doc'}->{$funcname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $docref = \$self->{'functions-doc'}->{$funcname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | elsif (/^\@after/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my ($methname) = $_ =~ /^\@after[\s\t]+(.+)[\s\t\n\r]*$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $after = $methname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $funcname = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $before = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $subname = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | elsif (/^\@before/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my ($methname) = $_ =~ /^\@before[\s\t]+(.+)[\s\t\n\r]*$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $before = $methname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $funcname = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $after = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $subname = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $buffer = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $bottom = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $top = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $types = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | elsif (/^\@top/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $top = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $bottom = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $types = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | elsif (/^\@bottom/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $bottom = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $top = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $types = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | elsif (/^\@types/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $types = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $bottom = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $top = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | elsif (/^[\s\t]*\@/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my ($doc) = $_ =~ /^[\s\t]*\@[\s\t]*(.*)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | #print "[$doc]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | ${$docref} .= ' '.$doc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | if defined $docref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # store current line in a buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ▶ | elsif (!defined $subname && defined $top) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not defined $subname and defined $top
MC/DC0%0/2
not defined $subname and defined $top
not defined $subname
defined $top
Truth table0%0/3
not(A) and B
A= not defined $subnameB= defined $top
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->{'area'}->{'top'} .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | ▶ | elsif (!defined $subname && defined $bottom) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not defined $subname and defined $bottom
MC/DC0%0/2
not defined $subname and defined $bottom
not defined $subname
defined $bottom
Truth table0%0/3
not(A) and B
A= not defined $subnameB= defined $bottom
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $self->{'area'}->{'bottom'} .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | ▶ | elsif (!defined $subname && defined $types) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not defined $subname and defined $types
MC/DC0%0/2
not defined $subname and defined $types
not defined $subname
defined $types
Truth table0%0/3
not(A) and B
A= not defined $subnameB= defined $types
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $self->{'area'}->{'types'} .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $buffer .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $l++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # save last "something" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | _save_current_buffer($self, $classname, $subname, $funcname, $before, $after, $buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | close SRCFILE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | sub _save_current_buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_current_buffer: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my ($self, $classname, $subname, $funcname, $before, $after, $buffer) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if (defined $classname && defined $subname && defined $buffer) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/6
defined $classname and defined $subname and defined $buffer
defined $classname and defined $subname
MC/DC0%0/3
defined $classname and defined $subname and defined $buffer
defined $classname
defined $subname
defined $buffer
Truth table0%0/4
A and B and C
A= defined $classnameB= defined $subnameC= defined $buffer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # add method to class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $methname = $self->meth($classname, $subname, $buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ▶ | elsif (defined $funcname && defined $buffer) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $funcname and defined $buffer
MC/DC0%0/2
defined $funcname and defined $buffer
defined $funcname
defined $buffer
Truth table0%0/3
A and B
A= defined $funcnameB= defined $buffer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # add function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $self->func($funcname, $buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | ▶ | elsif (defined $classname && defined $before && defined $buffer) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
defined $classname and defined $before and defined $buffer
defined $classname and defined $before
MC/DC0%0/3
defined $classname and defined $before and defined $buffer
defined $classname
defined $before
defined $buffer
Truth table0%0/4
A and B and C
A= defined $classnameB= defined $beforeC= defined $buffer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # add 'before'-hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->before($classname, $before, $buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | ▶ | elsif (defined $classname && defined $after && defined $buffer) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
defined $classname and defined $after and defined $buffer
defined $classname and defined $after
MC/DC0%0/3
defined $classname and defined $after and defined $buffer
defined $classname
defined $after
defined $buffer
Truth table0%0/4
A and B and C
A= defined $classnameB= defined $afterC= defined $buffer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # add 'after'-hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $self->after($classname, $after, $buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | sub _get_complete_method_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_complete_method_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my ($self, $classname, $methname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $sign = $self->_parse_signature($methname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | unshift @{$sign->{'params'}}, ['self', $classname]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | return $self->_signature_to_string($sign); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | sub _skip_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_skip_class: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my ($classname, $classnames) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | defined $classnames && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | !scalar grep { $_ eq $classname } @{$classnames}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $classnames && !scalar(grep {$_ eq $classname;} @{$classnames;})
MC/DC0%0/2
defined $classnames && !scalar(grep {$_ eq $classname;} @{$classnames;})
defined $classnames
!scalar(grep {$_ eq $classname;} @{$classnames;})
Truth table0%0/3
A && not(B)
A= defined $classnamesB= !scalar(grep {$_ eq $classname;} @{$classnames;})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | sub functionsToLaTeX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
functionsToLaTeX: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my ($self, $autogen) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $autogen = 0 unless defined $autogen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | die "Error: cannot call toLaTeX() method AFTER generate() method has been called\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if $autogen == 0 && $self->{'autogen'} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$autogen == 0 and $self->{"autogen"} == 1
MC/DC0%0/2
$autogen == 0 and $self->{"autogen"} == 1
$autogen == 0
$self->{"autogen"} == 1
Truth table0%0/3
A and B
A= $autogen == 0B= $self->{"autogen"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | #$self->_autogen(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $tex = "\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | if (scalar keys %{$self->{'functions'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $tex .= '\subsection{Statische Funktionen}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $tex .= '\begin{description*}'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | foreach my $funcname (sort keys %{$self->{'functions'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my $sign = $self->_parse_signature($funcname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $code = $self->{'functions'}->{$funcname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $code =~ s/\t/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $code =~ s/(\r?\n)\s\s/$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | $tex .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | '\item \texttt{\color{orange}'.$sign->{'name'}.'(} '. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | join(",\n", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | '\texttt{'.$_->[0].'} '.$self->_mkClassRef($_->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | } @{$sign->{'params'}}).'\texttt{\color{orange})}'. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ': '.$self->_mkClassRef($sign->{'returns'})."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | if (scalar @{$sign->{'params'}} > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $tex .= "\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $tex .= _docToLaTeX($self->{'functions-doc'}->{$funcname})."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | # $tex .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | # '\item \texttt{\color{red}'.$sign->{'name'}.' ('. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # join(', ', map { $_->[0] } @{$sign->{'params'}}).'):} '. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # $self->_mkClassRef($sign->{'returns'})."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | # if (scalar @{$sign->{'params'}} > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # $tex .= '\begin{description*}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # foreach my $param (@{$sign->{'params'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # $tex .= '\item \texttt{'.$param->[0].'} :\hspace{1ex} '.$self->_mkClassRef($param->[1])."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # $tex .= '\end{description*}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # $tex .= _docToLaTeX($self->{'functions-doc'}->{$funcname})."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # $tex .= '\vspace{3mm}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $tex .= '\end{description*}'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | return $tex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | sub toLaTeX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toLaTeX: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my ($self, $autogen, $classnames) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | $autogen = 0 unless defined $autogen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | die "Error: cannot call toLaTeX() method AFTER generate() method has been called\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | if $autogen == 0 && $self->{'autogen'} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$autogen == 0 and $self->{"autogen"} == 1
MC/DC0%0/2
$autogen == 0 and $self->{"autogen"} == 1
$autogen == 0
$self->{"autogen"} == 1
Truth table0%0/3
A and B
A= $autogen == 0B= $self->{"autogen"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | #$self->_autogen(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $tex = "\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | next if _skip_class($classname,$classnames); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $tex .= $self->_classToLaTeX($classname)."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | return $tex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | sub _classToLaTeX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_classToLaTeX: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my ($self, $classname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $tex = '\subsection{'.$classname."}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $tex .= '\label{Class'.$classname."}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $tex .= _docToLaTeX($self->{'classes'}->{$classname}->{'doc'})."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $tex .= 'Die Implementierung dieser Klasse ist in der Datei \texttt{'. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | $classname.'.c} zu finden.'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $tex .= '\begin{figure}[H]'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $tex .= ' \centering'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $tex .= ' \fbox{\makebox[0.5\textwidth]{'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $tex .= ' \includegraphics[width=0.5\textwidth,keepaspectratio]{diagrams/'.$classname.'.png}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $tex .= ' }}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $tex .= ' \caption{UML Klassendiagramm der Klasse '.$classname.'.}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | $tex .= ' \label{Block}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $tex .= '\end{figure}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | if (scalar @{$class->{'isa'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $tex .= '\subsubsection{Elternklassen}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | #$tex .= '\begin{itemize*}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | #foreach my $classname (@{$class->{'isa'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # #$tex .= '\item '.$self->_mkClassRef($classname)."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | #$tex .= '\end{itemize*}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $tex .= join ', ', map { $self->_mkClassRef($_) } @{$class->{'isa'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $tex .= "\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $subclasses = $self->_get_subclasses()->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | #use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | #print Dumper($subclasses); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | if (scalar keys %{$subclasses}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $tex .= '\subsubsection{Kindklassen}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | #$tex .= '\begin{itemize*}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | #foreach my $classname (keys %{$subclasses}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # $tex .= '\item '.$self->_mkClassRef($classname)."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | #$tex .= '\end{itemize*}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $tex .= join ', ', map { $self->_mkClassRef($_) } keys %{$subclasses}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $tex .= "\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | if (scalar keys %{$class->{'attr'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $tex .= '\subsubsection{Attribute}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $tex .= '\begin{description*}'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | foreach my $attrname (sort keys %{$class->{'attr'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $tex .= '\item \texttt{\color{blue}'.$attrname.'} '.$self->_mkClassRef($class->{'attr'}->{$attrname})."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $tex .= _docToLaTeX($class->{'attr-doc'}->{$attrname})."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | #$tex .= '\vspace{3mm}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | $tex .= '\end{description*}'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if (scalar keys %{$class->{'subs'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $tex .= '\subsubsection{Methoden}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | #$tex .= '\setlength{\parskip}{-6pt}'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $tex .= '\begin{description*}'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | foreach my $methname (sort keys %{$class->{'subs'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $sign = $self->_parse_signature($methname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $code = $class->{'subs'}->{$methname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $code =~ s/\t/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $code =~ s/(\r?\n)\s\s/$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | $tex .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | '\item \texttt{\color{orange}'.$sign->{'name'}.'(} '. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | join(",\n", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | '\texttt{'.$_->[0].'} '.$self->_mkClassRef($_->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | } @{$sign->{'params'}}).'\texttt{\color{orange})}'. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | #join(', ', map { $_->[0] } @{$sign->{'params'}}).'):} '. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ': '.$self->_mkClassRef($sign->{'returns'})."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | if (scalar @{$sign->{'params'}} > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | #$tex .= '\renewcommand{\arraystretch}{1.0}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | #$tex .= '\begin{tabular}{lcl}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | #$tex .= join(",\n", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | # '\texttt{'.$_->[0].'} : '.$self->_mkClassRef($_->[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | #} @{$sign->{'params'}}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | #foreach my $param (@{$sign->{'params'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # $tex .= '\texttt{'.$param->[0].'} : '.$self->_mkClassRef($param->[1])."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # # $code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | #$tex .= '\end{tabular}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | #$tex .= '\renewcommand{\arraystretch}{1.2}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $tex .= "\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | # if ($methname =~ /^getAppWindow/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | # use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | # print Dumper($class->{'subs-doc'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | $tex .= _docToLaTeX($class->{'subs-doc'}->{$methname})."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # $tex .= '\begin{Verbatim}[fontsize=\footnotesize]'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # $tex .= $code."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # $tex .= '\end{Verbatim}'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | #$tex .= '\vspace{3mm}'."\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | $tex .= '\end{description*}'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | #$tex .= '\setlength{\parskip}{6pt}'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | return $tex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | sub _docToLaTeX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_docToLaTeX: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | my ($doc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | my %replacements = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | '{ae}' => '\"a', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | '{oe}' => '\"o', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | '{ue}' => '\"u', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | '{Ae}' => '\"A', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | '{Oe}' => '\"O', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | '{Ue}' => '\"U', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | '{AE}' => '\"A', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | '{OE}' => '\"O', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | '{UE}' => '\"U', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | '{ss}' => '\ss{}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my $match = quotemeta $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $replace = $replacements{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $doc =~ s/$match/$replace/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | keys %replacements; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | # special replacements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $doc =~ s/t\{([^\}]*)\}/\\texttt{$1}/g; # t{...} -> fixed width text | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $doc =~ s/i\{([^\}]*)\}/\\textit{$1}/g; # i{...} -> italic text | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | $doc =~ s/b\{([^\}]*)\}/\\textbf{$1}/g; # b{...} -> bold text | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | sub _mkClassRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mkClassRef: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my ($self, $classname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | (exists $self->{'classes'}->{$classname} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | '\textit{'.$classname.'}$_{\ref{Class'.$classname.'}}$' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | '\textit{\color{gray}'.$classname.'}'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | sub toDot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toDot: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my ($self, $autogen, $classnames) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | $autogen = 0 unless defined $autogen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | die "Error: cannot call toDot() method AFTER generate() method has been called\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | if $autogen == 0 && $self->{'autogen'} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$autogen == 0 and $self->{"autogen"} == 1
MC/DC0%0/2
$autogen == 0 and $self->{"autogen"} == 1
$autogen == 0
$self->{"autogen"} == 1
Truth table0%0/3
A and B
A= $autogen == 0B= $self->{"autogen"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | #$self->_autogen(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | my $dot = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 'digraph {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | q{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | fontname="Bitstream Vera Sans" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | fontsize=8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | overlap=scale | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | node [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | fontname="Bitstream Vera Sans" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | fontsize=8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | shape="record" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | edge [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | fontname="Bitstream Vera Sans" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | fontsize=8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | //weight=0.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # add class nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | next if _skip_class($classname,$classnames); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | $dot .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ' '.$classname.' ['."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | ' label="{'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | $classname.'|'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | join('\l', map { '+ '.$_.' : '.$class->{'attr'}->{$_} } keys %{$class->{'attr'}}).'\l|'. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | join('\l', map { $_ } keys %{$class->{'subs'}}).'\l}"'."\n". | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | " ]\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # add class relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | $dot .= 'edge [ arrowhead="empty" color="black" ]'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | next if _skip_class($classname,$classnames); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | foreach my $parentclassname (@{$class->{'isa'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | next if _skip_class($parentclassname,$classnames); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | $dot .= ' '.$classname.' -> '.$parentclassname."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | # add "contains" relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | $dot .= 'edge [ arrowhead="vee" color="gray" ]'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | next if _skip_class($classname,$classnames); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | foreach my $attrname (keys %{$class->{'attr'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my $attrtype = $class->{'attr'}->{$attrname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | $dot .= ' '.$classname.' -> '.$attrtype."\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | if exists $self->{'classes'}->{$attrtype} && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"classes"}{$attrtype} and not _skip_class($attrtype, $classnames)
MC/DC0%0/2
exists $self->{"classes"}{$attrtype} and not _skip_class($attrtype, $classnames)
exists $self->{"classes"}{$attrtype}
not _skip_class($attrtype, $classnames)
Truth table0%0/3
A and not(B)
A= exists $self->{"classes"}{$attrtype}B= not _skip_class($attrtype, $classnames)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | !_skip_class($attrtype,$classnames); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | return $dot.'}'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | sub toHtml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toHtml: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | my $html = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | $self->_autogen(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # oben: dropdown mit klassen-namen -> onclick wird klasse unten angezeigt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # unten: Beschreibung der aktuell ausgewaehlten klasse: isa, attr, subs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | # (auch geerbte!) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my @classnames = sort keys %{$self->{'classes'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | '<html>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | '<head>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | '<title>API</title>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | '<style type="text/css">'.q{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | background: #fff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | margin: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | padding: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | body, div, select, h1, h2, h3, p, i, span { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | font-size: 12pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | font-family: sans-serif; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | font-weight: 200; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | a { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | color: blue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | a:hover { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | color: #99f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | p i { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | font-size: 80%; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | h1 { font-size: 200%; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | h2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | font-size: 140%; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | padding-bottom: 0.2em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | border-bottom: solid 1px #ccc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | h3 { font-size: 120%; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | #top { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | width: 100%; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | position: fixed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | top: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | left: 220px; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | background: #eee; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | padding: 1em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | #left { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | width: 200px; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | float: left; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | background: #eee; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | padding: 1em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | border-left: solid 1px #666; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | overflow: auto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | #content { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | padding: 4em 1em 1em 260px; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | select { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | vertical-align: middle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | padding: 0.3em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | li { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | font-size: 90%; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | margin: 0 0 0 16px; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | list-style: circle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | li a { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | text-decoration: none; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | ul { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | margin: 0.2em 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | padding: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | dl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | dt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | margin-top: 0.4em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | dd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | margin: 0.6em 0 0 2em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | .typename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | color: #66c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | .typename:hover { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | color: #99f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | .methname { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | color: green; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | p.methnames { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | border-bottom: dotted 1px #ccc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | padding-bottom: 10pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | margin-bottom: 10pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | p.methnames a { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | display: inline-block; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | background: #eee; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | -moz-border-radius: 0.4em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | -webkit-border-radius: 0.4em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | border-radius: 0.4em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | padding: 4pt 6pt 3pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | margin-bottom: 2pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | pre { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | background: #eee; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | font-size: 9pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | padding: 0.4em 0.5em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | overflow: auto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | -moz-border-radius: 0.4em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | -webkit-border-radius: 0.4em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | border-radius: 0.4em; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | border: solid 1px #ccc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | font-weight: 200; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | font-family: Monaco, fixed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | pre span { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | font-size: inherit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | font-weight: inherit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | font-family: inherit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | pre .keyword { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | color: #099; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | pre .string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | color: #669; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | pre .comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | color: #999; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | pre .call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | color: #009; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | }.'</style>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | '<script type="text/javascript">'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 'function showClass (id) {'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | ' id = \'class-\'+id;'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | ' document.getElementById(\'content\').innerHTML = document.getElementById(id).innerHTML;'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | ' scroll(0,0);'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | '}'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | '</script>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | '</head>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | '<body onload="showClass(\''.$classnames[0].'\');">'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | '<div id="top">'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 'Class: '. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | '<select onchange="showClass(this.value);">'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | join('', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | '<option value="'.$_.'">'.$_.'</option>' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } @classnames). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | '</select>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | '</div>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | '<div id="left">'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | $self->_mkClassTree(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | '<p><i>generated by Code::Class::C</i></p>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | '</div>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | '<div id="content"></div>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | join('', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | '<div id="class-'.$_.'" style="display:none">'.$self->_classToHtml($_).'</div>' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } @classnames). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | '</body>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | '</html>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | sub _mkClassTree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mkClassTree: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | # find top classes (those without any parent classes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | my @topclasses = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | foreach my $classname (sort keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | push @topclasses, $classname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | unless scalar @{$self->{'classes'}->{$classname}->{'isa'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | my $html = '<ul>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | foreach my $classname (@topclasses) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | $html .= | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | '<li>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | $self->_mkClassLink($classname).' '. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | $self->_mkSubclassList($classname). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | '</li>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | return $html.'</ul>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | sub _mkSubclassList | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mkSubclassList: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | my ($self, $classname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | # find direct children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | my @children = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | foreach my $cname (sort keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | foreach my $parentclassname (sort @{$self->{'classes'}->{$cname}->{'isa'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | push @children, $cname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | if $classname eq $parentclassname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | (scalar @children ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | '<ul>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | join('', map { '<li>'.$self->_mkClassLink($_).' '.$self->_mkSubclassList($_).'</li>' } @children). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | '</ul>' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | sub _classToHtml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_classToHtml: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | my ($self, $classname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | my $html = '<h1 class="typename">'.$classname.'</h1>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | $html .= '<h2>Parent classes</h2><dl><dt>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | $html .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | join(', ', map { $self->_mkClassLink($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | sort @{$class->{'isa'}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | $html .= '</dt></dl>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | $html .= '<p><i>none</i></p>' unless scalar @{$class->{'isa'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | $html .= '<h2>Child classes</h2><dl><dt>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | my $subclasses = $self->_get_subclasses(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | $html .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | join(', ', map { $self->_mkClassLink($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | sort keys %{$subclasses->{$classname}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | $html .= '</dt></dl>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | $html .= '<p><i>none</i></p>' unless scalar keys %{$subclasses->{$classname}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $html .= '<h2>Attributes</h2><dl>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | foreach my $attrname (sort keys %{$class->{'attr'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | $html .= '<dt>'.$self->_mkClassLink($class->{'attr'}->{$attrname}).' '.$attrname.'</dt>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | $html .= '</dl>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | $html .= '<p><i>none</i></p>' unless scalar keys %{$class->{'attr'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | $html .= '<h2>Methods</h2><p class="methnames">'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | my $meths = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | foreach my $methname (sort keys %{$class->{'subs'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | my $sign = $self->_parse_signature($methname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | my $code = $class->{'subs'}->{$methname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $code =~ s/\t/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | $code =~ s/(\r?\n)\s\s/$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | $html .= '<a href="#'.$sign->{'name'}.'">'.$sign->{'name'}.'</a> '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | $meths .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | '<dt>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | '<a name="'.$sign->{'name'}.'"></a>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | $self->_mkClassLink($sign->{'returns'}).' : '. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | '<span class="methname">'.$sign->{'name'}.'</span>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ' ( '.join(', ', map { $self->_mkClassLink($_->[1]).' '.$_->[0] } @{$sign->{'params'}}).' )'. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | '</dt><dd><pre>'.$self->_highlightC($code).'</pre></dd>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | $html .= '</p><dl>'.$meths.'</dl>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | $html .= '<p><i>none</i></p>' unless scalar keys %{$class->{'subs'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | return $html; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | sub _highlightC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_highlightC: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | my ($self, $c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | $c =~ s/(\"[^\"]*\")/<span class="string">$1<\/span>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | $c =~ s/(if|else|for|return|self|while|void|static)/<span class="keyword">$1<\/span>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | $c =~ s/(\/\/[^\n]*)/<span class="comment">$1<\/span>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | $c =~ s/(\/\*[^\*]*\*\/)/<span class="comment">$1<\/span>/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | $c =~ s/([a-zA-Z\_][a-zA-Z0-9\_]*)\(/<span class="call">$1<\/span>\(/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | return $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | sub _mkClassLink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mkClassLink: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | my ($self, $classname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | ▶ | (exists $self->{'classes'}->{$classname} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | '<a href="javascript:showClass(\''.$classname.'\');" class="typename">'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | $classname. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | '</a>' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | : '<span class="typename">'.$classname.'</span>'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | sub generate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate: not called CC=25 SCAR=64.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | my $file = $opts{'file'} || die "Error: generate() needs a filename.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'file'} || die("Error: generate() needs a filename.\n")
MC/DC0%0/1
$opts{'file'} || die("Error: generate() needs a filename.\n")
$opts{'file'}
Truth table0%0/2
A
A= $opts{'file'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | ▶ | my $lheaders = $opts{'localheaders'} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'localheaders'} || []
MC/DC0%0/1
$opts{'localheaders'} || []
$opts{'localheaders'}
Truth table0%0/2
A
A= $opts{'localheaders'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | push @{$lheaders}, @{$opts{'headers'} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'headers'} || []
MC/DC0%0/1
$opts{'headers'} || []
$opts{'headers'}
Truth table0%0/2
A
A= $opts{'headers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | ▶ | my $gheaders = $opts{'globalheaders'} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'globalheaders'} || []
MC/DC0%0/1
$opts{'globalheaders'} || []
$opts{'globalheaders'}
Truth table0%0/2
A
A= $opts{'globalheaders'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | my $maincode = $self->_load_code_from_file($opts{'main'} || ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'main'} || ''
MC/DC0%0/1
$opts{'main'} || ''
$opts{'main'}
Truth table0%0/2
A
A= $opts{'main'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | ▶ | my $debug = $opts{'debug'} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'debug'} || 0
MC/DC0%0/1
$opts{'debug'} || 0
$opts{'debug'}
Truth table0%0/2
A
A= $opts{'debug'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | my $topcode = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | $self->_load_code_from_file($opts{'top'} || '')."\n\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | ▶ | $self->_load_code_from_file($self->{'area'}->{'top'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'top'} || ''
MC/DC0%0/1
$opts{'top'} || ''
$opts{'top'}
Truth table0%0/2
A
A= $opts{'top'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | my $bottomcode = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | $self->_load_code_from_file($opts{'bottom'} || '')."\n\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | ▶ | $self->_load_code_from_file($self->{'area'}->{'bottom'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'bottom'} || ''
MC/DC0%0/1
$opts{'bottom'} || ''
$opts{'bottom'}
Truth table0%0/2
A
A= $opts{'bottom'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | my $typescode = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | $self->_load_code_from_file($opts{'types'} || '')."\n\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | $self->_load_code_from_file($self->{'area'}->{'types'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'types'} || ''
MC/DC0%0/1
$opts{'types'} || ''
$opts{'types'}
Truth table0%0/2
A
A= $opts{'types'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | $self->_autogen(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | # add standard headers needed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | foreach my $h (qw(string stdio stdlib stdarg)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | unshift @{$gheaders}, $h | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | unless scalar grep { $_ eq $h } @{$gheaders}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | my $ccode = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | # write headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | $ccode .= join '', map { '#include <'.$_.'.h>'."\n" } @{$gheaders}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | $ccode .= join '', map { '#include "'.$_.'.h"'."\n" } @{$lheaders}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | ▶ | $ccode .= '#define CREATE_STACK_TRACE ('.($debug ? 1 : 0).')'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | $ccode .= q{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | /*----------------------------------------------------------------------------*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | #if CREATE_STACK_TRACE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | #define STACKTRACE_MAX_LENGTH (10) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | char StackTrace[STACKTRACE_MAX_LENGTH][255]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | int StackTraceLength = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | void printStackTrace (void) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | int i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | printf("Stack trace (last one last):\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | for (i = 0; i < StackTraceLength; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | printf(" %d. %s()\n", i, StackTrace[i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | void logStackTraceEntry (char* msg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | if (StackTraceLength < STACKTRACE_MAX_LENGTH) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | sprintf(StackTrace[StackTraceLength], "%s", msg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | StackTraceLength++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | /* move all entries one down */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | int i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | for (i = 1; i < StackTraceLength; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | sprintf(StackTrace[i-1], "%s", StackTrace[i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | /* set last one */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | sprintf(StackTrace[StackTraceLength-1], "%s", msg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | /*----------------------------------------------------------------------------*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | typedef struct S_Object* Object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | struct S_Object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | int classid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | char classname[256]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | void* data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | typedef Object my; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | /*----------------------------------------------------------------------------*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | /* String functions */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | void setstr (char* dest, const char* src) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | int i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | for (i = 0; i < 256; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | dest[i] = src[i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | int streq (char* s1, char* s2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | return (strcmp(s1, s2) == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | # create hash of subclasses for each class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | my %subclasses = %{$self->_get_subclasses()}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | $ccode .= "/*-----------------------------------------------------------*/\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | $ccode .= "/* ISA Function */\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | $ccode .= 'int isa (int childid, int classid) {'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | $ccode .= ' if (childid == classid) { return 1; }'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | my $first = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | foreach my $classname (keys %subclasses) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | ▶ | next unless scalar keys %{$subclasses{$classname}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | my $classid = $self->{'classes'}->{$classname}->{'id'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | my @clauses = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | foreach my $childclassname (keys %{$subclasses{$classname}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | my $childclassid = $self->{'classes'}->{$childclassname}->{'id'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | push @clauses, 'childid == '.$childclassid.'/*'.$childclassname.'*/'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | $ccode .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | ▶ | ' '.($first ? 'if' : 'else if').' (classid == '.$classid.'/*'.$classname.'*/'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | (scalar @clauses ? ' && ('.join(' || ',@clauses).')' : '').') {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | ' return 1;'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | ' }'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | $ccode .= ' return 0;'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | $ccode .= '}'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | $ccode .= 'int classname2classid (char* classname) {'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | $first = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | my $classid = $self->{'classes'}->{$classname}->{'id'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | ▶ | $ccode .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | ' '.($first ? 'if' : 'else if').' (streq(classname, "'.$classname.'")) {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | ' return '.$classid.';'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | ' }'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | $ccode .= ' return -1;'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | $ccode .= '}'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | $ccode .= "/*-----------------------------------------------------------*/\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | $ccode .= "/* Types */\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | my $typedefs = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | my $structs = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | # typedef for class-specific struct pointer (member 'data' in S_Object struct) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | $typedefs .= 'typedef struct S_'.$self->_get_c_typename($classname).'* '.$self->_get_c_typename($classname).';'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | # struct for the class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | $structs .= 'struct S_'.$self->_get_c_typename($classname).' {'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | ▶ | $structs .= ' int dummy'.";\n" unless scalar keys %{$class->{'attr'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | foreach my $attrname (sort keys %{$class->{'attr'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | my $attrtype = $class->{'attr'}->{$attrname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | $structs .= ' '.$self->_get_c_attrtype($attrtype).' CCC_'.$attrname.";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | $structs .= "};\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | $ccode .= $typedefs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | $ccode .= $typescode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | $ccode .= $structs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | $ccode .= "/*-----------------------------------------------------------*/\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | $ccode .= "/* User top code */\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | $ccode .= $topcode."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | $ccode .= $self->_generate_functions()."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | $ccode .= "/*-----------------------------------------------------------*/\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | $ccode .= "/* User bottom code */\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | $ccode .= $bottomcode."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | ▶ | if (length $maincode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | $ccode .= "/*-----------------------------------------------------------*/\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | $ccode .= "/* Main function */\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | $ccode .= 'int main (int argc, char** argv) {'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | $ccode .= ' '.$maincode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | $ccode .= "\n}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | ▶ | open OUTFILE, '>'.$file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | or die "Error: failed to open output file '$file': $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | print OUTFILE $ccode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | close OUTFILE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | ################################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | ################################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | ################################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | sub _parse_signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_signature: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | my ($self, $signature_string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | # render(self:Square,self:Vertex,self:Point):void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | my $rs = '[\s\t\n\r]*'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | my $rn = '[^\(\)\,\:]+'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | my ($name, $args, $returns) = ($signature_string =~ /^$rs($rn)$rs\($rs(.*)$rs\)$rs\:$rs($rn)$rs$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | my @params = map { [split /$rs\:$rs/] } split /$rs\,$rs/, $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | my $sign = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | returns => $returns, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | params => \@params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | return $sign; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | sub _dbg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbg: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | my (@msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | eval('use Data::Dump;'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | Data::Dump::dump(\@msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | sub _get_subclasses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_subclasses: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | my %subclasses = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | my $classid = $self->{'classes'}->{$classname}->{'id'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | ▶ | $subclasses{$classname} = {} unless exists $subclasses{$classname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | #$subclasses{$classname}->{$classname} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | foreach my $parentclassname ($self->_get_parent_classes($classname)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | my $parentclassid = $self->{'classes'}->{$parentclassname}->{'id'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | $subclasses{$parentclassname}->{$classname} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | return \%subclasses; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | sub _autogen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_autogen: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | ▶ | unless ($self->{'autogen'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | $self->_inherit_members(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | $self->_define_accessors(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | $self->_add_hook_code(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | $self->_define_constructors(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | $self->_define_destructors(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | $self->_define_dumpers(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | $self->{'autogen'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | sub _generate_functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_functions: not called CC=29 SCAR=67.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | # find all functions and store them by their name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | my %functions = (); # "<funcname>" => {"<signature>" => [...], ...} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | foreach my $name (keys %{$class->{'subs'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | my $sign = $self->_parse_signature($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | $functions{$sign->{'name'}} = {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | unless exists $functions{$sign->{'name'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | $functions{$sign->{'name'}}->{$name} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 'classname' => $classname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 'number' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 'name' => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | 'code' => $self->{'classes'}->{$classname}->{'subs'}->{$name}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | # add normal functions, too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | foreach my $fname (keys %{$self->{'functions'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | my $sign = $self->_parse_signature($fname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | $functions{$sign->{'name'}}->{$fname} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 'classname' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 'number' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 'name' => $fname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | 'code' => $self->{'functions'}->{$fname}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | # give every implementation a unique number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | foreach my $fname (keys %functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | foreach my $name (keys %{$functions{$fname}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | $functions{$fname}->{$name}->{'number'} = $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | ###### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | # check all overloaded functions: they are only allowed if they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | # take class-typed parameters ONLY! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | my %infos = (); # <functionname> => {...} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | foreach my $fname (keys %functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | #print "($fname)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | # define scheme of signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | my $first_sign = $self->_parse_signature((keys %{$functions{$fname}})[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | my $returns = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | (exists $self->{'classes'}->{$first_sign->{'returns'}} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | ▶ | 'Object' : $first_sign->{'returns'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | my $all_class_types = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | (scalar(grep { exists $self->{'classes'}->{$_} } @{$first_sign->{'params'}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | ▶ | == scalar(@{$first_sign->{'params'}}) ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | my $params = [ # sequence of "Object" or "<c-type>" strings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | ▶ | map { exists $self->{'classes'}->{$_->[1]} ? 'Object' : $_->[1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | @{$first_sign->{'params'}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | $infos{$fname} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 'all-class-types' => $all_class_types, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 'params-scheme' => $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 'returns' => $returns, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 'at-least-one-impl-has-zero-params' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | 'has-only-one-implementation' => (scalar(keys %{$functions{$fname}}) == 1), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 0 | ▶ | if (scalar keys %{$functions{$fname}} > 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | # check if all signatures match the scheme | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | foreach my $name (keys %{$functions{$fname}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | #print " [$name]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | my $sign = $self->_parse_signature($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | $sign->{'returns'} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | (exists $self->{'classes'}->{$sign->{'returns'}} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | ▶ | 'Object' : $sign->{'returns'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | die "Error: overloaded method '$name' does not return a valid ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | "return type (is '$sign->{'returns'}', must be '$returns')\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | ▶ | if $returns ne $sign->{'returns'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | $infos{$name}->{'at-least-one-impl-has-zero-params'} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | ▶ | if scalar @{$sign->{'params'}} == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | ▶ | if ($all_class_types) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | # all parameters should be class-typed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | die "Error: overloaded method '$name' is not allowed to take ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | "non-class typed parameters\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 0 | ▶ | if !exists $self->{'classes'}->{$_->[1]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | @{$sign->{'params'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | # the parameter list should match the $params list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | ▶ | for (my $p = 0; $p < @{$params}; $p++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 0 | my $paramtype = $params->[$p]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | die "Error: overloaded method '$name' does not ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | "follow the scheme 'method(".join(',',@{$params})."):$returns'\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 0 | ▶ | ($p > scalar @{$sign->{'params'}} - 1) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$paramtype eq "Object" and not exists $self->{"classes"}{$sign->{"params"}[$p][1]}
$paramtype ne "Object" and $paramtype ne $sign->{"params"}[$p][1]
MC/DC0%0/2
$paramtype eq "Object" and not exists $self->{"classes"}{$sign->{"params"}[$p][1]}
$paramtype eq "Object"
not exists $self->{"classes"}{$sign->{"params"}[$p][1]}
MC/DC0%0/2
$paramtype ne "Object" and $paramtype ne $sign->{"params"}[$p][1]
$paramtype ne "Object"
$paramtype ne $sign->{"params"}[$p][1]
Truth table0%0/3
A and not(B)
A= $paramtype eq "Object"B= not exists $self->{"classes"}{$sign->{"params"}[$p][1]}
Truth table0%0/3
A and B
A= $paramtype ne "Object"B= $paramtype ne $sign->{"params"}[$p][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | ($paramtype eq 'Object' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | !exists $self->{'classes'}->{$sign->{'params'}->[$p]->[1]}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | ($paramtype ne 'Object' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | ▶ | $paramtype ne $sign->{'params'}->[$p]->[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$p > scalar @{$sign->{"params"};} - 1 or $paramtype eq "Object" and not exists $self->{"classes"}{$sign->{"params"}[$p][1]} or $paramtype ne "Object" and $paramtype ne $sign->{"params"}[$p][1]
$p > scalar @{$sign->{"params"};} - 1 or $paramtype eq "Object" and not exists $self->{"classes"}{$sign->{"params"}[$p][1]}
MC/DC0%0/3
$p > scalar @{$sign->{"params"};} - 1 or $paramtype eq "Object" and not exists $self->{"classes"}{$sign->{"params"}[$p][1]} or $paramtype ne "Object" and $paramtype ne $sign->{"params"}[$p][1]
$p > scalar @{$sign->{"params"};} - 1
$paramtype eq "Object" and not exists $self->{"classes"}{$sign->{"params"}[$p][1]}
$paramtype ne "Object" and $paramtype ne $sign->{"params"}[$p][1]
Truth table0%0/4
A or B or C
A= $p > scalar @{$sign->{"params"};} - 1B= $paramtype eq "Object" and not exists $self->{"classes"}{$sign->{"params"}[$p][1]}C= $paramtype ne "Object" and $paramtype ne $sign->{"params"}[$p][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | # generate c code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | my $protos = ''; # prototypes for implementation functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | my $impls = ''; # implementation functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | foreach my $fname (sort keys %functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | my $info = $infos{$fname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 0 | my $first_impl_name = (keys %{$functions{$fname}})[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | my $first_sign = $self->_parse_signature($first_impl_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | $protos .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | $info->{'returns'}.' '.$fname.' ('. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | $self->_generate_params_declaration($first_impl_name).');'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | $impls .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | $info->{'returns'}.' '.$fname.' ('. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | $self->_generate_params_declaration($first_impl_name).') {'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | my $first = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | for my $name (keys %{$functions{$fname}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | $impls .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | ' '.($first ? '' : 'else ').'if '. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | '('.$self->_generate_wrapper_select_clause($name).') {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | ' #if CREATE_STACK_TRACE'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | ' logStackTraceEntry("'.$name.'");'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | ' #endif'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | ' {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 0 | ▶ | ' '.$functions{$fname}->{$name}->{'code'}."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | ' }'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | ' }'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | $impls .= ' else {'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | $impls .= ' printf("Error: Failed to find an implementation of function/method \''.$fname.'\'.\n");'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | $impls .= ' #if CREATE_STACK_TRACE'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | $impls .= ' printStackTrace();'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | $impls .= ' #endif'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | $impls .= ' printf("The parameters passed were:\n");'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | my $p = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | for my $param (@{$first_sign->{'params'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | my $paramname = $param->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | my $paramtype = $param->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | ▶ | if (exists $self->{'classes'}->{$paramtype}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | $impls .= ' printf(" ['.$p.'] = %s\n", '.$paramname.'->classname);'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | $impls .= ' printf(" ['.$p.'] = '.$paramtype.'\n");'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | $p++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | $impls .= ' exit(0);'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | $impls .= ' }'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | $impls .= '}'."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | "/*-----------------------------------------------------------*/\n". | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | "/* Prototypes for implementation functions */\n\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | $protos."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | "/*-----------------------------------------------------------*/\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | "/* Implementation functions */\n\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | $impls."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | sub _generate_wrapper_select_clause | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_wrapper_select_clause: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | my ($self, $implname, $use_isa) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | my $sign = $self->_parse_signature($implname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | my @clauses = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | my $p = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 0 | foreach my $param (@{$sign->{'params'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | my $paramname = $param->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | my $paramtype = $param->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 0 | ▶ | if (exists $self->{'classes'}->{$paramtype}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 0 | my $class = $self->{'classes'}->{$param->[1]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | push @clauses, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | ($p > 0 ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | '('.$paramname.' == NULL || isa('.$paramname.'->classid, '.$class->{'id'}.'/* '.$paramtype.' */))' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 0 | ▶ | $paramname.'->classid == '.$class->{'id'}.'/* '.$paramtype.' */'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 0 | $p++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 0 | ▶ | return (scalar @clauses ? join(' && ',@clauses) : '1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | sub _generate_params_declaration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_params_declaration: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | my ($self, $implname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | my $sign = $self->_parse_signature($implname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | my @params = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | foreach my $param (@{$sign->{'params'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | my $paramtype = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | ▶ | (exists $self->{'classes'}->{$param->[1]} ? 'Object' : $param->[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | push @params, $paramtype.' '.$param->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | ▶ | return (scalar @params ? join(', ', @params) : 'void'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | sub _init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | $self->{'classes'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | $self->{'functions'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | # if attributes/methods etc. have been auto-generated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 0 | $self->{'autogen'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | # prefix for type names created by this module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | $self->{'prefix-types'} = 'T_'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | # code areas that can be filled as classes are parsed/read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 0 | $self->{'area'} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 'top' => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 'bottom' => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | # inherits all members from parent classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | sub _inherit_members | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inherit_members: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | # copy all inherited members from the parent classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 0 | foreach my $parentclassname ($self->_get_parent_classes($classname)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | my $parentclass = $self->{'classes'}->{$parentclassname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 0 | foreach my $membertype (qw(attr subs after before)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | foreach my $membername (keys %{$parentclass->{$membertype}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | ▶ | if ($membertype eq 'attr' && exists $class->{$membertype}->{$membername}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$membertype eq "attr" and exists $class->{$membertype}{$membername}
MC/DC0%0/2
$membertype eq "attr" and exists $class->{$membertype}{$membername}
$membertype eq "attr"
exists $class->{$membertype}{$membername}
Truth table0%0/3
A and B
A= $membertype eq "attr"B= exists $class->{$membertype}{$membername}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | die "Error: inherited attribute '$membername' in class $classname must be of the same type as in class '$parentclassname'\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 0 | ▶ | if $class->{$membertype}->{$membername} ne $parentclass->{$membertype}->{$membername}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | 0 | my $orig_membername = $membername; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | ▶ | if ($membertype eq 'subs') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | my $sign = $self->_parse_signature($membername); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 0 | $sign->{'params'}->[0]->[1] = $classname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | $membername = $self->_signature_to_string($sign); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | ▶ | unless (exists $class->{$membertype}->{$membername}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | $class->{$membertype}->{$membername} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | $parentclass->{$membertype}->{$orig_membername}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | sub _add_hook_code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_hook_code: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | 0 | foreach my $hooktype (qw(before after)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | foreach my $methname (keys %{$class->{$hooktype}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 0 | ▶ | next if $methname eq 'new' || $methname eq 'delete'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$methname eq "new" or $methname eq "delete"
MC/DC0%0/2
$methname eq "new" or $methname eq "delete"
$methname eq "new"
$methname eq "delete"
Truth table0%0/3
A or B
A= $methname eq "new"B= $methname eq "delete"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | my $methods = $self->_get_methods_by_name($class, $methname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | die "Error: $hooktype-hook for $classname.$methname cannot be installed, ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | "because no method with that name exists in $classname.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | ▶ | unless scalar keys %{$methods}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | # add hook code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | foreach my $meth (keys %{$methods}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 0 | ▶ | if ($hooktype eq 'before') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | $class->{'subs'}->{$meth} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 0 | "{\n".$class->{$hooktype}->{$methname}."\n}\n".$class->{'subs'}->{$meth}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | elsif ($hooktype eq 'after') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | $class->{'subs'}->{$meth} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 0 | $class->{'subs'}->{$meth}."{\n".$class->{$hooktype}->{$methname}."\n}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | # finds all methods in a class with the same name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | sub _get_methods_by_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_methods_by_name: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 0 | my ($self, $class, $methname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 0 | my %subs = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | foreach my $s (keys %{$class->{'subs'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 0 | my $sign = $self->_parse_signature($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | $subs{$s} = $class->{'subs'}->{$s} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | ▶ | if $sign->{'name'} eq $methname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 0 | return \%subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | sub _define_constructors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_define_constructors: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | $self->func( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 'new_'.ucfirst($classname).'():Object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | 'Object self = NULL;'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | # pre hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | (exists $class->{'before'}->{'new'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | "{\n".$class->{'before'}->{'new'}."\n}\n" : ''). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | "{\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | ' self = (Object)malloc(sizeof(struct S_Object));'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | ' if (self == (Object)NULL) {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | ' printf("Failed to allocate memory for instance of class \''.$classname.'\'\n");'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | ' exit(1);'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | ' }'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | ' self->classid = '.$class->{'id'}.';'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | ' setstr(self->classname, "'.$classname.'");'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | ' self->data = malloc(sizeof(struct S_'.$self->_get_c_typename($classname).'));'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | ' if (self->data == NULL) {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | ' printf("Failed to allocate memory for instance-data of class \''.$classname.'\'\n");'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | ' exit(1);'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | ' }'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | join('', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 0 | my $attrtype = $class->{'attr'}->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | 0 | ▶ | ($attrtype eq 'pthread_mutex_t' ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | '' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | ' (('.$self->_get_c_typename($classname).')(self->data))->CCC_'.$_. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | ' = '.$self->_get_init_c_code($attrtype).';'."\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | ▶ | sort keys %{$class->{'attr'}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | "}\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | # post hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | (exists $class->{'after'}->{'new'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | ▶ | "{\n".$class->{'after'}->{'new'}."\n}\n" : ''). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | ' return self;'."\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | sub _define_dumpers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_define_dumpers: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | 0 | my $funcsign = 'dump(self:'.$classname.',level:int,maxLevel:int):void'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 0 | ▶ | next if exists $self->{'functions'}->{$funcsign}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | $self->func( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | $funcsign, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | # pre hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | (exists $class->{'before'}->{'dump'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | "{\n".$class->{'before'}->{'dump'}."\n}\n" : ''). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | "{\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | ' int i;'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | ' char indent[256];'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | ' indent[0] = \'\\0\';'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | ' for (i = 0; i < level; i += 1) {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | ' strcat(indent, " ");'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | ' }'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 'if (level <= maxLevel && maxLevel <= 64) {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | ' if (self == NULL) {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | ' printf("%s(NULL)\n", indent);'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | ' }'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | ' else {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | ' printf("%s{'.$classname.' #'.$class->{'id'}.'\n", indent);'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | join('', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 0 | my $s = ' printf("%s .'.$_.' <'.$class->{'attr'}->{$_}.'> = ", indent);'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | ▶ | if (exists $self->{'classes'}->{$class->{'attr'}->{$_}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 0 | $s .= | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | ' printf("\n");'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | ' if (get'.ucfirst($_).'(self) == NULL)'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | ' printf("%s (NULL)\n", indent);'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | ' else '."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | ' dump(get'.ucfirst($_).'(self),level+1,maxLevel);'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | elsif ($class->{'attr'}->{$_} eq 'float') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | $s .= ' printf("%f\n", get'.ucfirst($_).'(self));'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | elsif ($class->{'attr'}->{$_} eq 'int') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | $s .= ' printf("%d\n", get'.ucfirst($_).'(self));'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | elsif ($class->{'attr'}->{$_} eq 'long int') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 0 | $s .= ' printf("%ld\n", get'.ucfirst($_).'(self));'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | elsif ($class->{'attr'}->{$_} eq 'char') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | $s .= ' printf("%d / \'%c\'\n", get'.ucfirst($_).'(self), get'.ucfirst($_).'(self));'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | elsif ($class->{'attr'}->{$_} eq 'char*') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | $s .= ' printf("\'%s\'\n", get'.ucfirst($_).'(self));'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | $s .= ' printf("?\n");'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | ▶ | sort keys %{$class->{'attr'}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | ' printf("%s}\n", indent);'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | ' }'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | "}\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 'else {'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | ' printf("%s...\n", indent);'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | "}\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | "}\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | # post hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | (exists $class->{'after'}->{'dump'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | ▶ | "{\n".$class->{'after'}->{'dump'}."\n}\n" : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | sub _get_init_c_code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_init_c_code: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | my ($self, $attrtype) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | ▶ | (exists $self->{'classes'}->{$attrtype} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | '(Object)NULL' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | ($attrtype eq 'pthread_mutex_t' ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | '(pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | '('.$attrtype.')0')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | sub _define_destructors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_define_destructors: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | $self->func( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 'delete(self:'.$classname.'):void', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | # pre hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | (exists $class->{'before'}->{'delete'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | "{\n".$class->{'before'}->{'delete'}."\n}\n" : ''). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | 'free(('.$self->_get_c_typename($classname).')(self->data));'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 'free(self);'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | # post hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | (exists $class->{'after'}->{'delete'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | 0 | ▶ | "{\n".$class->{'after'}->{'delete'}."\n}\n" : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | sub _define_accessors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_define_accessors: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 0 | foreach my $classname (keys %{$self->{'classes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | 0 | foreach my $attrname (keys %{$class->{'attr'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | #my $attrtype = $self->_get_c_attrtype($class->{'attr'}->{$attrname}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | 0 | my $attrtype = $class->{'attr'}->{$attrname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | # getter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | 0 | $self->meth( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | $classname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 'get'.ucfirst($attrname).'():'.$attrtype, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 'return (('.$self->_get_c_typename($classname).')(self->data))->CCC_'.$attrname.';', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | # getter to pointer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | $self->meth( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | $classname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 'get'.ucfirst($attrname).'Ptr():'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | 0 | ▶ | (exists $self->{'classes'}->{$attrtype} ? 'Object' : $attrtype).'*', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 'return &((('.$self->_get_c_typename($classname).')(self->data))->CCC_'.$attrname.');', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | # setter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | 0 | $self->meth( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | $classname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | 'set'.ucfirst($attrname).'(value:'.$attrtype.'):void', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | '(('.$self->_get_c_typename($classname).')(self->data))->CCC_'.$attrname.' = value;', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | # setter for pointer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | $self->meth( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | $classname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | 'set'.ucfirst($attrname).'Ptr(value:'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 0 | ▶ | (exists $self->{'classes'}->{$attrtype} ? 'Object' : $attrtype).'*):void', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | 'if (value == NULL) { printf("In set'.ucfirst($attrname).'Ptr(): cannot handle NULL pointer\n"); exit(1); }'."\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | '(('.$self->_get_c_typename($classname).')(self->data))->CCC_'.$attrname.' = *value;', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | sub _get_c_typename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_c_typename: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | my ($self, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | 0 | ▶ | return (exists $self->{'classes'}->{$type} ? $self->{'prefix-types'}.$type : $type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | sub _get_c_attrtype | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_c_attrtype: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 0 | my ($self, $attrtype) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 0 | ▶ | return (exists $self->{'classes'}->{$attrtype} ? 'Object' : $attrtype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | sub _signature_to_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_signature_to_string: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | 0 | my ($self, $sign) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | $sign->{'name'}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 0 | '('.join(',',map { $_->[0].':'.$_->[1] } @{$sign->{'params'}}).'):'. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 0 | $sign->{'returns'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | sub _load_code_from_file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_code_from_file: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 0 | ▶ | $code = '' unless defined $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | 0 | ▶ | if (($code =~ /^\.?\.?\/[^\*]/) || ($code !~ /\n/ && -f $code && -r $code)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$code =~ m[^\.?\.?/[^\*]] or not $code =~ /\n/ and -f $code and -r $code
not $code =~ /\n/ and -f $code and -r $code
not $code =~ /\n/ and -f $code
MC/DC0%0/4
$code =~ m[^\.?\.?/[^\*]] or not $code =~ /\n/ and -f $code and -r $code
$code =~ m[^\.?\.?/[^\*]]
not $code =~ /\n/
-f $code
-r $code
Truth table0%0/5
A or not(B) and C and D
A= $code =~ m[^\.?\.?/[^\*]]B= not $code =~ /\n/C= -f $codeD= -r $code
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | ▶ | open SRCFILE, $code or die "Error: cannot open source file '$code': $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | $code = join '', <SRCFILE>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | close SRCFILE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 0 | $code =~ s/^[\s\t\n\r]*//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | 0 | $code =~ s/[\s\t\n\r]*$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 0 | $code =~ s/(\r?\n\r?)([^\s])/$1 $2/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | # experimental: replace "//..." comments with "/*...*/" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | 0 | $code =~ s/\/\/+(.*)$/\/*$1*\//mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 0 | return $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | sub _get_parent_classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_parent_classes: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | my ($self, $classname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | my @parents = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | my @parents_parents = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | my $class = $self->{'classes'}->{$classname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | 0 | foreach my $name (@{$class->{'isa'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 0 | push @parents, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | push @parents_parents, $self->_get_parent_classes($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | 0 | push @parents, @parents_parents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | # delete dublicates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | my @clean = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | my $x = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | 0 | ▶ | push(@clean, $x) unless scalar(grep { $x eq $_ } @clean); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | @parents; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | return @clean; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||