| 1 | package FFI::Platypus::TypeParser::Version1; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 38 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 38 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 38 | ▶ | use 5.008004; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 38 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 38 | ▶ | use parent qw( FFI::Platypus::TypeParser ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 38 | ▶ | use constant _version => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | # ABSTRACT: FFI Type Parser Version One | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 38 | our $VERSION = '2.12'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 38 | our @CARP_NOT = qw( FFI::Platypus FFI::Platypus::TypeParser ); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 38 | my %reserved = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||
| 17 | string | ||||||||||||||||||||||||||||||||||||||||||
| 18 | object | ||||||||||||||||||||||||||||||||||||||||||
| 19 | type | ||||||||||||||||||||||||||||||||||||||||||
| 20 | role | ||||||||||||||||||||||||||||||||||||||||||
| 21 | union | ||||||||||||||||||||||||||||||||||||||||||
| 22 | class | ||||||||||||||||||||||||||||||||||||||||||
| 23 | struct | ||||||||||||||||||||||||||||||||||||||||||
| 24 | record | ||||||||||||||||||||||||||||||||||||||||||
| 25 | array | ||||||||||||||||||||||||||||||||||||||||||
| 26 | senum | ||||||||||||||||||||||||||||||||||||||||||
| 27 | enum | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # The type parser is responsible for deciding if something is a legal | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # alias name. Since this needs to be checked before the type is parsed | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # it is separate from set_alias below. | ||||||||||||||||||||||||||||||||||||||||||
| 33 | sub check_alias | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 237 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_alias: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 237 | my($self, $alias) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 237 | ▶ | croak "spaces not allowed in alias" if $alias =~ /\s/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 235 | ▶ | croak "allowed characters for alias: [A-Za-z0-9_]" if $alias !~ /^[A-Za-z0-9_]+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | croak "reserved world \"$alias\" cannot be used as an alias" | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 233 | ▶ | if $reserved{$alias}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | croak "alias \"$alias\" conflicts with existing type" | ||||||||||||||||||||||||||||||||||||||||||
| 41 | if defined $self->type_map->{$alias} | ||||||||||||||||||||||||||||||||||||||||||
| 42 | || $self->types->{$alias} | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 229 | ▶ | || $self->global_types->{basic}->{$alias}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $self->type_map->{$alias} or $self->types->{$alias} or $self->global_types->{"basic"}{$alias}
defined $self->type_map->{$alias} or $self->types->{$alias}
MC/DC100%3/3
defined $self->type_map->{$alias} or $self->types->{$alias} or $self->global_types->{"basic"}{$alias}
defined $self->type_map->{$alias}
$self->types->{$alias}
$self->global_types->{"basic"}{$alias}
Truth table100%4/4
A or B or C
A= defined $self->type_map->{$alias}B= $self->types->{$alias}C= $self->global_types->{"basic"}{$alias}
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 223 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | sub set_alias | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 225 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_alias: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 225 | my($self, $alias, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 225 | $self->types->{$alias} = $type; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 38 | ▶ | use constant type_regex => | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | qr/^ # | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # | ||||||||||||||||||||||||||||||||||||||||||
| 57 | \s* # prefix white space | ||||||||||||||||||||||||||||||||||||||||||
| 58 | # | ||||||||||||||||||||||||||||||||||||||||||
| 59 | (?: # | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # | ||||||||||||||||||||||||||||||||||||||||||
| 61 | \( ([^)]*) \) -> (.*) # closure, argument types $1, return type $2 | ||||||||||||||||||||||||||||||||||||||||||
| 62 | | # | ||||||||||||||||||||||||||||||||||||||||||
| 63 | ( string | record ) \s* \( \s* ([0-9]+) \s* \) (?: \s* (\*) | ) # fixed record $3, fixed string $4, ponter $5 | ||||||||||||||||||||||||||||||||||||||||||
| 64 | | # | ||||||||||||||||||||||||||||||||||||||||||
| 65 | record \s* \( ( \s* (?: [A-Za-z_] [A-Za-z_0-9]* :: )* [A-Za-z_] [A-Za-z_0-9]* ) \s* \) (?: \s* (\*) | ) # record class $6, pointer $7 | ||||||||||||||||||||||||||||||||||||||||||
| 66 | | # | ||||||||||||||||||||||||||||||||||||||||||
| 67 | ( (?: [A-Za-z_] [A-Za-z_0-9]* \s+ )* [A-Za-z_] [A-Za-z_0-9]* ) \s* # unit type name $8 | ||||||||||||||||||||||||||||||||||||||||||
| 68 | # | ||||||||||||||||||||||||||||||||||||||||||
| 69 | (?: (\*) | \[ ([0-9]*) \] | ) # pointer $9, array $10 | ||||||||||||||||||||||||||||||||||||||||||
| 70 | | # | ||||||||||||||||||||||||||||||||||||||||||
| 71 | object \s* \( \s* ( (?: [A-Za-z_] [A-Za-z_0-9]* :: )* [A-Za-z_] [A-Za-z_0-9]* ) # object class $11 | ||||||||||||||||||||||||||||||||||||||||||
| 72 | (?: \s*,\s* ( (?: [A-Za-z_] [A-Za-z_0-9]* \s+ )* [A-Za-z_] [A-Za-z_0-9]* ) )? # type $12 | ||||||||||||||||||||||||||||||||||||||||||
| 73 | \s* \) # | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ) # | ||||||||||||||||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||||||||||||||||
| 76 | \s* # trailing white space | ||||||||||||||||||||||||||||||||||||||||||
| 77 | # | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 38 | $/x; # | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | sub parse | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 2758 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=44 SCAR=37.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 2758 | my($self, $name, $opt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 2758 | ▶ | $opt ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt ||= {}
MC/DC100%1/1
$opt ||= {}
$opt
Truth table100%2/2
A
A= $opt
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 2758 | ▶ | return $self->types->{$name} if $self->types->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 2023 | ▶ | $name =~ type_regex or croak "bad type name: $name"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 2014 | ▶ | if(defined (my $at = $1)) # closure | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 54 | my $rt = $2; | |||||||||||||||||||||||||||||||||||||||||
| 93 | return $self->types->{$name} = $self->create_type_closure( | ||||||||||||||||||||||||||||||||||||||||||
| 94 | $self->abi, | ||||||||||||||||||||||||||||||||||||||||||
| 95 | $self->parse($rt, $opt), | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 54 | map { $self->parse($_, $opt) } map { my $t = $_; $t =~ s/^\s+//; $t =~ s/\s+$//; $t } split /,/, $at, | |||||||||||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 1960 | ▶ | if(defined (my $size = $4)) # fixed record / fixed string | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 45 | ▶ | croak "fixed record / fixed string size must be larger than 0" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | unless $size > 0; | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 33 | ▶ | if(my $pointer = $5) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 19 | return $self->types->{$name} = $self->create_type_record( | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | $size, | ||||||||||||||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | ▶ | elsif($opt->{member} || ($3 eq 'string' && $self->_version > 1)) | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$opt->{"member"} or $3 eq "string" and $self->_version > 1
$3 eq "string" and $self->_version > 1
MC/DC100%3/3
$opt->{"member"} or $3 eq "string" and $self->_version > 1
$opt->{"member"}
$3 eq "string"
$self->_version > 1
Truth table100%4/4
A or B and C
A= $opt->{"member"}B= $3 eq "string"C= $self->_version > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 7 | return $self->types->{"$name *"} = $self->create_type_record( | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | $size, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | else | ||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 7 | ▶ | if($self->_version > 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | { | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | croak "classless record not allowed as value type"; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | else | ||||||||||||||||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 6 | croak "fixed string / classless record not allowed as value type"; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 1915 | ▶ | if(defined (my $class = $6)) # class record | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | { | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 15 | ▶ | my $size_method = $class->can('ffi_record_size') || $class->can('_ffi_record_size') || croak "$class has no ffi_record_size or _ffi_record_size method"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$class->can('ffi_record_size') || $class->can('_ffi_record_size') || croak("$class has no ffi_record_size or _ffi_record_size method")
$class->can("ffi_record_size") or $class->can("_ffi_record_size")
MC/DC100%2/2
$class->can('ffi_record_size') || $class->can('_ffi_record_size') || croak("$class has no ffi_record_size or _ffi_record_size method")
$class->can("ffi_record_size")
$class->can("_ffi_record_size")
Truth table100%3/3
A or B
A= $class->can("ffi_record_size")B= $class->can("_ffi_record_size")
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 11 | ▶ | if(my $pointer = $7) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 5 | return $self->types->{$name} = $self->create_type_record( | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | $class->$size_method, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | $class, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | else | ||||||||||||||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 6 | return $self->types->{$name} = $self->create_type_record( | |||||||||||||||||||||||||||||||||||||||||
| 146 | 1, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | $class->$size_method, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | $class, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | $class->_ffi_meta->ptr, | ||||||||||||||||||||||||||||||||||||||||||
| 150 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 1900 | ▶ | if(defined (my $unit_name = $8)) # basic type | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 1874 | ▶ | if($self->global_types->{basic}->{$unit_name}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 1670 | ▶ | if(my $pointer = $9) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 77 | ▶ | croak "void pointer not allowed" if $unit_name eq 'void'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 75 | return $self->types->{$name} = $self->global_types->{ptr}->{$unit_name}; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1593 | ▶ | if(defined (my $size = $10)) # array | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 160 | ▶ | croak "void array not allowed" if $unit_name eq 'void'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 158 | ▶ | if($size ne '') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 63 | ▶ | croak "array size must be larger than 0" if $size < 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | return $self->types->{$name} = $self->create_type_array( | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 61 | $self->global_types->{basic}->{$unit_name}->type_code, | |||||||||||||||||||||||||||||||||||||||||
| 172 | $size, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | else | ||||||||||||||||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | return $self->global_types->{array}->{$unit_name} ||= $self->create_type_array( | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 95 | ▶ | $self->global_types->{basic}->{$unit_name}->type_code, | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->global_types->{"array"}{$unit_name} ||= $self->create_type_array($self->global_types->{"basic"}{$unit_name}->type_code, 0)
MC/DC0%0/2
$self->global_types->{"array"}{$unit_name} ||= $self->create_type_array($self->global_types->{"basic"}{$unit_name}->type_code, 0)
$self->global_types->{"array"}{$unit_name}
$self->create_type_array($self->global_types->{"basic"}{$unit_name}->type_code, 0)
Truth table66%2/3
A ||= B
A= $self->global_types->{"array"}{$unit_name}B= $self->create_type_array($self->global_types->{"basic"}{$unit_name}->type_code, 0)
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0, | ||||||||||||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | # basic type with no decorations | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 1433 | return $self->global_types->{basic}->{$unit_name}; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 204 | ▶ | if(my $map_name = $self->type_map->{$unit_name}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 166 | ▶ | if(my $pointer = $9) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 14 | return $self->types->{$name} = $self->parse("$map_name *", $opt); | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 152 | ▶ | if(defined (my $size = $10)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 19 | ▶ | if($size ne '') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 11 | ▶ | croak "array size must be larger than 0" if $size < 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 9 | return $self->types->{$name} = $self->parse("$map_name [$size]", $opt); | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | else | ||||||||||||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 8 | return $self->types->{$name} = $self->parse("$map_name []", $opt); | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 133 | return $self->types->{$name} = $self->parse("$map_name", $opt); | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 38 | ▶ | if(my $pointer = $9) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 7 | my $unit_type = $self->parse($unit_name, $opt); | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 7 | ▶ | if($unit_type->is_record_value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 3 | my $meta = $unit_type->meta; | |||||||||||||||||||||||||||||||||||||||||
| 217 | return $self->types->{$name} = $self->create_type_record( | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0, | ||||||||||||||||||||||||||||||||||||||||||
| 219 | $meta->{size}, | ||||||||||||||||||||||||||||||||||||||||||
| 220 | $meta->{class}, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 4 | my $basic_name = $self->global_types->{rev}->{$unit_type->type_code}; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 4 | ▶ | if($basic_name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | return $self->types->{$name} = $self->parse("$basic_name *", $opt); | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | else | ||||||||||||||||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | croak "cannot make a pointer to $unit_name"; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 31 | ▶ | if(defined (my $size = $10)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | { | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 18 | my $unit_type = $self->parse($unit_name, $opt); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 18 | my $basic_name = $self->global_types->{rev}->{$unit_type->type_code}; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 18 | ▶ | if($basic_name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 14 | ▶ | if($size ne '') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | croak "array size must be larger than 0" if $size < 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | return $self->types->{$name} = $self->parse("$basic_name [$size]", $opt); | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | else | ||||||||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 12 | return $self->types->{$name} = $self->parse("$basic_name []", $opt); | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | else | ||||||||||||||||||||||||||||||||||||||||||
| 252 | { | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 4 | croak "cannot make an array of $unit_name"; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 13 | ▶ | if($name eq 'string ro') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | { | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 4 | return $self->global_types->{basic}->{string}; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | elsif($name eq 'string rw') | ||||||||||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 7 | ▶ | return $self->global_types->{v2}->{string_rw} ||= $self->create_type_string(1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->global_types->{"v2"}{"string_rw"} ||= $self->create_type_string(1)
MC/DC0%0/2
$self->global_types->{"v2"}{"string_rw"} ||= $self->create_type_string(1)
$self->global_types->{"v2"}{"string_rw"}
$self->create_type_string(1)
Truth table66%2/3
A ||= B
A= $self->global_types->{"v2"}{"string_rw"}B= $self->create_type_string(1)
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | ▶ | return $self->types->{$name} || croak "unknown type: $unit_name"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->types->{$name} || croak("unknown type: $unit_name")
MC/DC0%0/1
$self->types->{$name} || croak("unknown type: $unit_name")
$self->types->{$name}
Truth table50%1/2
A
A= $self->types->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 26 | ▶ | if(defined (my $class = $11)) # object type | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 26 | ▶ | my $basic_name = $12 || 'opaque'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$12 || 'opaque'
MC/DC100%1/1
$12 || 'opaque'
$12
Truth table100%2/2
A
A= $12
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 26 | my $basic_type = $self->parse($basic_name); | |||||||||||||||||||||||||||||||||||||||||
| 273 | 26 | ▶ | if($basic_type->is_object_ok) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 24 | return $self->types->{$name} = $self->create_type_object( | |||||||||||||||||||||||||||||||||||||||||
| 276 | $basic_type->type_code, | ||||||||||||||||||||||||||||||||||||||||||
| 277 | $class, | ||||||||||||||||||||||||||||||||||||||||||
| 278 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | else | ||||||||||||||||||||||||||||||||||||||||||
| 281 | { | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | croak "cannot make an object of $basic_name"; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | croak "internal error parsing: $name"; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 38 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | __END__ | ||||||||||||||||||||||||||||||||||||||||||