| 1 | package Venus::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use 5.018; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # IMPORTS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 20 | ▶ | use Venus::Class 'base', 'with'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # INHERITS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 20 | base 'Venus::Kind::Utility'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # INTEGRATES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 20 | with 'Venus::Role::Buildable'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # STATE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 20 | state $SIMPLE_TYPES = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | any => 'any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | array => 'array', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | arrayref => 'arrayref', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | bool => 'bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | boolean => 'boolean', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | code => 'code', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | coderef => 'coderef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | defined => 'defined', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | dirhandle => 'dirhandle', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | filehandle => 'filehandle', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | float => 'float', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | glob => 'glob', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | hash => 'hash', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | hashref => 'hashref', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | identity => 'identity', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | number => 'number', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | object => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | package => 'package', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | reference => 'reference', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | regexp => 'regexp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | scalar => 'scalar', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | scalarref => 'scalarref', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | string => 'string', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | undef => 'undef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | value => 'value', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | yesno => 'yesno', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 20 | state $COMPLEX_TYPES = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | attributes => 'attributes', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | consumes => 'consumes', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | either => 'either', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | hashkeys => 'hashkeys', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | includes => 'includes', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | inherits => 'inherits', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | integrates => 'integrates', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | maybe => 'maybe', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | routines => 'routines', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | tuple => 'tuple', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | within => 'within', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | sub assert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | require Venus::Assert; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | return Venus::Assert->new->accept($self->offer($expr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 115 | ▶ | sub check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 115 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 115 | require Venus::Check; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 115 | return Venus::Check->new->accept($self->offer($expr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 486 | ▶ | sub clean { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 486 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 486 | ▶ | return '' if !defined $expr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 486 | $expr =~ s/\n//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 486 | $expr =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 486 | return $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | sub coercion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coercion: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | require Venus::Coercion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | return Venus::Coercion->new->accept($self->offer($expr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | ▶ | sub constraint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
constraint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | require Venus::Constraint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | return Venus::Constraint->new->accept($self->offer($expr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 337 | ▶ | sub expression { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expression: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 337 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 337 | ▶ | return ref $data eq 'ARRAY' ? $self->generate_expression($data) : $self->parse_expression($data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 341 | ▶ | sub parse_expression { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_expression: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 341 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 341 | return $self->parser_parse_expression($self->clean($expr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 30 | ▶ | sub parse_signature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_signature: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 30 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 30 | $expr = $self->clean($expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 30 | my $pattern = qr/^(\w+)\s*\((.*?)\)\s*\((.*?)\)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 30 | my ($name, $input_types, $output_types) = ($expr =~ $pattern); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 30 | ▶ | if ($name && $output_types) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name and $output_types
MC/DC50%1/2
$name and $output_types
$name
$output_types
Truth table66%2/3
A and B
A= $nameB= $output_types
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 28 | $name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | [$self->parse_signature_type_expression($input_types)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | [$self->parse_signature_type_expression($output_types)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | return $self->error_on_signature_parse({signature => $expr})->input($self, $expr)->throw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 10 | ▶ | sub parse_signature_input { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_signature_input: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 10 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 10 | my $parsed_signature = $self->parse_signature($expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 10 | my $input = [map $$_[0], @{$parsed_signature->[1]}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | return wantarray ? @{$input} : $input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 10 | ▶ | sub parse_signature_output { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_signature_output: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 10 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 10 | my $parsed_signature = $self->parse_signature($expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 10 | my $output = [map $$_[0], @{$parsed_signature->[2]}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | return wantarray ? @{$output} : $output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 56 | ▶ | sub parse_signature_type_expression { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_signature_type_expression: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 56 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 56 | $expr = $self->clean($expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 56 | my $type_expressions = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 56 | my @parts = map $self->clean($_), split(/\s*,(?![^\[]*\])/, $expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 56 | for my $part (@parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 59 | ▶ | if ($part =~ /^(.+?)\s*([\*\$\@\%]\w+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 31 | push @{$type_expressions}, [$1, $2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 28 | push @{$type_expressions}, [$part]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 56 | ▶ | return wantarray ? @{$type_expressions} : $type_expressions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | sub parser_complex_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser_complex_type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | return $$COMPLEX_TYPES{$expr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub parser_has_complex_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser_has_complex_type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | return $self->parser_complex_type($expr) ? true : false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 534 | ▶ | sub parser_has_simple_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser_has_simple_type: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 534 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 534 | ▶ | return $self->parser_simple_type($expr) ? true : false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub parser_has_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser_has_type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | return $self->parser_has_simple_type($expr) || $self->parser_has_complex_type($expr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->parser_has_simple_type($expr) || $self->parser_has_complex_type($expr)
MC/DC0%0/2
$self->parser_has_simple_type($expr) || $self->parser_has_complex_type($expr)
$self->parser_has_simple_type($expr)
$self->parser_has_complex_type($expr)
Truth table0%0/3
A || B
A= $self->parser_has_simple_type($expr)B= $self->parser_has_complex_type($expr)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 676 | ▶ | sub parser_parse_expression { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser_parse_expression: called CC=14 SCAR=26.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 676 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 676 | $expr =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 676 | ▶ | if ($expr =~ /^(\w+)\[(.+)\]$/ && $expr !~ /^\w+\[.+\]\s*[\|\+]\s*\w+\[.+\]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$expr =~ /^(\w+)\[(.+)\]$/u and not $expr =~ /^\w+\[.+\]\s*[\|\+]\s*\w+\[.+\]$/u
MC/DC100%2/2
$expr =~ /^(\w+)\[(.+)\]$/u and not $expr =~ /^\w+\[.+\]\s*[\|\+]\s*\w+\[.+\]$/u
$expr =~ /^(\w+)\[(.+)\]$/u
not $expr =~ /^\w+\[.+\]\s*[\|\+]\s*\w+\[.+\]$/u
Truth table100%3/3
A and not(B)
A= $expr =~ /^(\w+)\[(.+)\]$/uB= not $expr =~ /^\w+\[.+\]\s*[\|\+]\s*\w+\[.+\]$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 62 | my $type = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 62 | my $inner = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 62 | my @params = $self->parser_parse_parameters($inner); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 62 | return [$type, @params]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 614 | ▶ | if ($expr =~ /\|/ ? $expr =~ /^[^|]*\+[^|]*\|/ : $expr =~ /\+/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | my @parts = $self->parser_split_by_operator($expr, '\+'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | return ['includes', map { $self->parser_parse_expression($_) } @parts]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 612 | ▶ | if ($expr =~ /\+/ ? $expr =~ /^[^+]*\|[^+]*\+/ : $expr =~ /\|/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 78 | my @parts = $self->parser_split_by_operator($expr, '\|'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 78 | return ['either', map { $self->parser_parse_expression($_) } @parts]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 534 | ▶ | if ($expr =~ /^(\w+)\[(.+)\]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $type = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $inner = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my @params = $self->parser_parse_parameters($inner); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return [$type, @params]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 534 | ▶ | if ($self->parser_has_simple_type($expr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 474 | return $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 60 | ▶ | if ($expr =~ /^[A-Z](?:(?:\w|::)*[a-zA-Z0-9])?$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 24 | return $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 36 | my $unquoted = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 36 | ▶ | $expr =~ s/^\"|\"$//g if !$unquoted++ && $expr =~ /^\".*\"$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $unquoted++ and $expr =~ /^\".*\"$/u
MC/DC50%1/2
not $unquoted++ and $expr =~ /^\".*\"$/u
not $unquoted++
$expr =~ /^\".*\"$/u
Truth table66%2/3
not(A) and B
A= not $unquoted++B= $expr =~ /^\".*\"$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 36 | ▶ | $expr =~ s/^\'|\'$//g if !$unquoted++ && $expr =~ /^\'.*\'$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $unquoted++ and $expr =~ /^\'.*\'$/u
MC/DC0%0/2
not $unquoted++ and $expr =~ /^\'.*\'$/u
not $unquoted++
$expr =~ /^\'.*\'$/u
Truth table33%1/3
not(A) and B
A= not $unquoted++B= $expr =~ /^\'.*\'$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 36 | return $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 80 | ▶ | sub parser_split_by_operator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser_split_by_operator: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 80 | my ($self, $expr, $operator) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 80 | my @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 80 | my $depth = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 80 | my $current_part = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 80 | for my $char (split //, $expr) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2324 | ▶ | if ($char eq '[') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 34 | $depth++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | elsif ($char eq ']') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 34 | $depth--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | ▶ | elsif ($char =~ /$operator/ && $depth == 0) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$char =~ /$operator/u and $depth == 0
MC/DC100%2/2
$char =~ /$operator/u and $depth == 0
$char =~ /$operator/u
$depth == 0
Truth table100%3/3
A and B
A= $char =~ /$operator/uB= $depth == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 104 | $current_part =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 104 | push @parts, $current_part; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 104 | $current_part = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 104 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2220 | $current_part .= $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 80 | $current_part =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 80 | ▶ | push @parts, $current_part if $current_part; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 80 | return @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 62 | ▶ | sub parser_parse_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser_parse_parameters: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 62 | my ($self, $param_str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 62 | $param_str =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 62 | my @params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 62 | my $depth = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 62 | my $current_param = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 62 | for my $char (split //, $param_str) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1760 | ▶ | if ($char eq '[') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 20 | $depth++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | elsif ($char eq ']') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 20 | $depth--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ▶ | elsif ($char eq ',' && $depth == 0) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$char eq "," and $depth == 0
MC/DC100%2/2
$char eq "," and $depth == 0
$char eq ","
$depth == 0
Truth table100%3/3
A and B
A= $char eq ","B= $depth == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 89 | $current_param =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 89 | push @params, $self->parser_parse_expression($current_param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 89 | $current_param = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 89 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1671 | $current_param .= $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 62 | $current_param =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 62 | ▶ | push @params, $self->parser_parse_expression($current_param) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | if $current_param; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 62 | return @params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 534 | ▶ | sub parser_simple_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser_simple_type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 534 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 534 | return $$SIMPLE_TYPES{$expr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub parser_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser_type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | return $self->parser_simple_type($expr) || $self->parser_complex_type($expr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->parser_simple_type($expr) || $self->parser_complex_type($expr)
MC/DC0%0/2
$self->parser_simple_type($expr) || $self->parser_complex_type($expr)
$self->parser_simple_type($expr)
$self->parser_complex_type($expr)
Truth table0%0/3
A || B
A= $self->parser_simple_type($expr)B= $self->parser_complex_type($expr)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 39 | ▶ | sub generate_expression { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_expression: called CC=20 SCAR=30.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 39 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 39 | ▶ | if (!defined $data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 38 | ▶ | if (ref $data eq 'HASH' && keys %{$data} == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $data eq "HASH" and keys %{$data;} == 0
MC/DC0%0/2
ref $data eq "HASH" and keys %{$data;} == 0
ref $data eq "HASH"
keys %{$data;} == 0
Truth table66%2/3
A and B
A= ref $data eq "HASH"B= keys %{$data;} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 38 | ▶ | if (ref $data eq 'HASH' && keys %{$data} == 1 && values %{$data} == 1 && ref((values %{$data})[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
ref $data eq "HASH" and keys %{$data;} == 1 and values %{$data;} == 1 and ref((values %{$data;})[0]) eq "HASH"
ref $data eq "HASH" and keys %{$data;} == 1 and values %{$data;} == 1
ref $data eq "HASH" and keys %{$data;} == 1
MC/DC75%3/4
ref $data eq "HASH" and keys %{$data;} == 1 and values %{$data;} == 1 and ref((values %{$data;})[0]) eq "HASH"
ref $data eq "HASH"
keys %{$data;} == 1
values %{$data;} == 1
ref((values %{$data;})[0]) eq "HASH"
Truth table80%4/5
A and B and C and D
A= ref $data eq "HASH"B= keys %{$data;} == 1C= values %{$data;} == 1D= ref((values %{$data;})[0]) eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | return $self->generate_expression([(keys %{$data}), (values %{$data})]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 37 | ▶ | if (ref $data eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 3 | return join ', ', map +($self->generate_expression($_), $self->generate_expression($data->{$_})), sort keys %{$data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 34 | ▶ | if (ref $data eq 'ARRAY' && defined $data->[0] && $data->[0] eq 'either') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
ref $data eq "ARRAY" and defined $data->[0] and $data->[0] eq "either"
ref $data eq "ARRAY" and defined $data->[0]
MC/DC100%3/3
ref $data eq "ARRAY" and defined $data->[0] and $data->[0] eq "either"
ref $data eq "ARRAY"
defined $data->[0]
$data->[0] eq "either"
Truth table100%4/4
A and B and C
A= ref $data eq "ARRAY"B= defined $data->[0]C= $data->[0] eq "either"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 3 | return join ' | ', map $self->generate_expression($_), @{$data}[1..$#$data]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 31 | ▶ | if (ref $data eq 'ARRAY' && defined $data->[0] && $data->[0] eq 'includes') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
ref $data eq "ARRAY" and defined $data->[0] and $data->[0] eq "includes"
ref $data eq "ARRAY" and defined $data->[0]
MC/DC0%0/3
ref $data eq "ARRAY" and defined $data->[0] and $data->[0] eq "includes"
ref $data eq "ARRAY"
defined $data->[0]
$data->[0] eq "includes"
Truth table75%3/4
A and B and C
A= ref $data eq "ARRAY"B= defined $data->[0]C= $data->[0] eq "includes"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | return join ' + ', map $self->generate_expression($_), @{$data}[1..$#$data]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 31 | ▶ | if (ref $data eq 'ARRAY' && scalar(@{$data}) >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $data eq "ARRAY" and scalar @{$data;} >= 2
MC/DC100%2/2
ref $data eq "ARRAY" and scalar @{$data;} >= 2
ref $data eq "ARRAY"
scalar @{$data;} >= 2
Truth table100%3/3
A and B
A= ref $data eq "ARRAY"B= scalar @{$data;} >= 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 6 | return join '', $data->[0], '[', (join ', ', map $self->generate_expression($_), @{$data}[1..$#$data]), ']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 25 | ▶ | if (ref $data eq 'ARRAY' && scalar(@{$data}) <= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $data eq "ARRAY" and scalar @{$data;} <= 1
MC/DC50%1/2
ref $data eq "ARRAY" and scalar @{$data;} <= 1
ref $data eq "ARRAY"
scalar @{$data;} <= 1
Truth table66%2/3
A and B
A= ref $data eq "ARRAY"B= scalar @{$data;} <= 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 3 | return $self->generate_expression($data->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 22 | ▶ | if ($data =~ /\"|\s/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $data =~ s/(?<!\\)\"/\\"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $data = "\"$data\""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 22 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 3 | ▶ | sub generate_signature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_signature: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 3 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 3 | return sprintf '%s(%s) (%s)', $data->[0], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | $self->generate_signature_input($data->[1]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | $self->generate_signature_input($data->[2]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 9 | ▶ | sub generate_signature_input { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_signature_input: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 9 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 9 | return join ', ', map +(join ' ', @{$_}), @{$data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 3 | ▶ | sub generate_signature_output { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_signature_output: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 3 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 3 | return join ', ', map +(join ' ', @{$_}), @{$data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 118 | ▶ | sub offer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offer: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 118 | my ($self, $expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 118 | ▶ | my $data = $self->expression($expr) || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->expression($expr) || []
MC/DC0%0/1
$self->expression($expr) || []
$self->expression($expr)
Truth table50%1/2
A
A= $self->expression($expr)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 118 | ▶ | $data = [$data] if ref $data ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 118 | ▶ | return wantarray ? @{$data} : $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | sub signature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signature: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | return ref $data eq 'ARRAY' ? $self->generate_signature($data) : $self->parse_signature($data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 6 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 6 | my ($self, $args, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 6 | require Venus::Unpack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 6 | ▶ | my $upto = $#$args > $#$data ? $#$args : $#$data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 6 | return Venus::Unpack->new(args => $args)->use(0..$upto)->types(@{$data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 2 | ▶ | sub unpack_signature_input { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_signature_input: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | my ($self, $expr, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 2 | my $data = $self->parse_signature_input($expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | return $self->unpack($args, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | ▶ | sub unpack_signature_output { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_signature_output: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 2 | my ($self, $expr, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | my $data = $self->parse_signature_output($expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 2 | return $self->unpack($args, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # ERRORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 2 | ▶ | sub error_on_signature_parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_signature_parse: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 2 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 2 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 2 | my $message = 'Can\'t parse signature "{{signature}}"'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | $error->name('on.signature.parse'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 2 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 2 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 20 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | Venus::Type - Type Class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | =head1 ABSTRACT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | Type Class for Perl 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | use Venus::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | my $type = Venus::Type->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # bless({}, "Venus::Type") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | This package provides a mechanism for parsing, generating, and validating data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | type expressions and subroutine signatures. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | =head2 Types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | The following types are supported by the parser: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | =head3 Simple Types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | Simple types are basic types supported directly without requiring parameters or nested structures. They include: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | =item C<any> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | Accepts any value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | Example expression: C<any> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | Example parsed output: C<["any"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | =item C<array> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | Accepts array references. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | Example expression: C<array> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | Example parsed output: C<["array"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | =item C<arrayref> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | Accepts array references. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | Example expression: C<arrayref> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | Example parsed output: C<["arrayref"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | =item C<bool> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | Accepts boolean values (true or false). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | Example expression: C<bool> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | Example parsed output: C<["bool"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | =item C<boolean> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | Accepts boolean values (true or false). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | Example expression: C<boolean> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | Example parsed output: C<["boolean"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | =item C<code> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | Accepts code references. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | Example expression: C<code> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | Example parsed output: C<["code"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | =item C<coderef> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | Accepts code references. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | Example expression: C<coderef> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | Example parsed output: C<["coderef"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | =item C<defined> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | Accepts any value that is defined (not undefined). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | Example expression: C<defined> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | Example parsed output: C<["defined"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | =item C<dirhandle> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | Accepts dirhandle values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | Example expression: C<dirhandle> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | Example parsed output: C<["dirhandle"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | =item C<filehandle> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | Accepts filehandle values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | Example expression: C<filehandle> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | Example parsed output: C<["filehandle"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | =item C<float> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | Accepts floating-point values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | Example expression: C<float> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | Example parsed output: C<["float"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | =item C<glob> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | Accepts typeglob values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | Example expression: C<glob> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | Example parsed output: C<["glob"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | =item C<hash> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | Accepts hash references. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | Example expression: C<hash> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | Example parsed output: C<["hash"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | =item C<hashref> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | Accepts hash references. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | Example expression: C<hashref> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | Example parsed output: C<["hashref"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | =item C<identity> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | Accepts objects of the specified type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | Example expression: C<identity[Example]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | Example parsed output: C<["identity", "Example"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | =item C<number> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | Accepts numeric values (integers and floats). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | Example expression: C<number> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | Example parsed output: C<["number"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | =item C<object> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | Accepts package (or class) instances. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | Example expression: C<object> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | Example parsed output: C<["object"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | =item C<package> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | Accepts package names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | Example expression: C<package> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | Example parsed output: C<["package"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | =item C<reference> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | Accepts any reference type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | Example expression: C<reference> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | Example parsed output: C<["reference"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | =item C<regexp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | Accepts regular expression objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | Example expression: C<regexp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | Example parsed output: C<["regexp"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | =item C<scalar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | Accepts scalar references. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | Example expression: C<scalar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | Example parsed output: C<["scalar"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | =item C<scalarref> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | Accepts scalar references. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | Example expression: C<scalarref> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | Example parsed output: C<["scalarref"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | =item C<string> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | Accepts string values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | Example expression: C<string> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | Example parsed output: C<["string"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | =item C<undef> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | Accepts undefined values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | Example expression: C<undef> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | Example parsed output: C<["undef"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | =item C<value> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | Accepts defined, non-reference, scalar values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | Example expression: C<value> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | Example parsed output: C<["value"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | =item C<yesno> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | Accepts a string value, case-insensitive, that is either C<y>, C<yes>, C<1>, C<n>, C<no>, or C<0>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | Example expression: C<yesno> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | Example parsed output: C<["yesno"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | =head3 Complex Types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | Complex types are types that can take one or more type expressions as arguments or involve nesting. These include: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | =item C<attributes> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | Accepts objects with attributes matching the specified names and types. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | Example expression: C<attributes[name, string]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | Example parsed output: C<["attributes", "name", "string"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | =item C<consumes> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | Accepts objects that consume the specified role. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | Example expression: C<consumes[Example::Role]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | Example parsed output: C<["consumes", "Example::Role"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | =item C<either> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | Accepts one of the provided type expressions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | Example expression: C<string | number> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | Example parsed output: C<["either", "string", "number"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | =item C<hashkeys> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | Accepts hashes containing keys whose values match the specified types. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | Example expression: C<hashkeys[name, string]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | Example parsed output: C<["hashkeys", "name", "string"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | =item C<includes> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | Accepts all of the provided type expressions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | Example expression: C<string + number> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | Example parsed output: C<["includes", "string", "number"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | =item C<inherits> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | Accepts objects that inherit from the specified type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | Example expression: C<inherits[Example]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | Example parsed output: C<["inherits", "Example"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | =item C<integrates> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | Accepts objects that support the "does" behavior and consume the specified role. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | Example expression: C<integrates[Example::Role]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | Example parsed output: C<["integrates", "Example::Role"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | =item C<maybe> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | Accepts the provided type or an undefined value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | Example expression: C<maybe[string]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | Example parsed output: C<["maybe", "string"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | =item C<routines> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | Accepts an object having all of the routines specified. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | Example expression: C<routines[new]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | Example parsed output: C<["routines", "new"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | =item C<tuple> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | Accepts array references that conform to a tuple specification. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | Example expression: C<tuple[string, number]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | Example parsed output: C<["tuple", "string", "number"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | =item C<within> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | Accepts array references, hash references, or mappables (i.e. objects derived | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | from classes which consume the "mappable" role, see L<Venus::Role::Mappable>), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | whose values match the specified type expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | Example expression: C<within[arrayref, string]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | Example parsed output: C<["within", "arrayref", "string"]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | =head2 Type Expressions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | A type expression is a combination of one or more simple or complex types, optionally with parameters, that describes a data structure or value expected by the system. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | =head3 Expression Components | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | B<either> - Denoted by a pipe symbol, C<|>, and used to accept one of multiple types. For example: C<string | number>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | B<includes> - Denoted by a plus symbol, C<+>, and used to require all of the specified types. For example: C<string + number>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | B<string-simple> - A simple string is an unquoted string matching the regular expression: C<^\w+$>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | B<string-quoted> - A quoted string is either single-quoted or double-quoted. For example: C<'name'> or C<"name">. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | B<string-package> - A string-package refers to a Perl package name, following the regular expression: C<^[A-Z](?:(?:\w|::)*[a-zA-Z0-9])?$>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | B<parameterized> - A parameterized type includes a type followed by an open square bracket, C<[>, followed by one or more type expressions separated by commas, and a closing square bracket, C<]>. For example, C<within[arrayref, string]> means an array reference where each element is a string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | =head2 Subroutine Signatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | A subroutine signature is a string that defines the name of a subroutine, its input types, and its output types. The parser supports subroutine signatures in the following format: C<name(input_type $variable, ...) (output_type)>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | B<name> - The name of the subroutine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | B<()> - Parentheses enclosing the input type expressions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | B<input_type> - Each input is a type expression followed by a Perl variable (e.g., C<$variable>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | B<,> - If more than one input exists, they are separated by a comma. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | B<()> - Parentheses enclosing the output type expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | B<output_type> - The type expression for the output of the subroutine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | =head3 Signature Examples | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | =item C<chmod(string $mode) (Venus::Path)> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | A subroutine C<chmod> takes a single argument: a string variable C<$mode>, and returns a C<Venus::Path>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | =item C<copy(string | Venus::Path $path) (Venus::Path)> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | A subroutine C<copy> takes an argument C<$path>, which can be either a string or a C<Venus::Path> object, and returns a C<Venus::Path>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | =item C<directories() (within[arrayref, Venus::Path])> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | A subroutine C<directories> takes no arguments and returns a list of C<Venus::Path> objects contained in an array reference. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | =item C<find(string | regexp $expr) (within[arrayref, Venus::Path])> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | A subroutine C<find> takes a string or regular expression as input and returns a list of C<Venus::Path> objects contained in an array reference. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | =item C<mkdir(maybe[string] $mode) (Venus::Path)> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | A subroutine C<mkdir> accepts an optional string argument C<$mode> (or C<undef>) and returns a C<Venus::Path> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | =item C<root(string $spec, string $base) (maybe[Venus::Path])> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | A subroutine C<root> accepts two string arguments and may return a C<Venus::Path> object or C<undef>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | =head2 Usage Examples | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | =item Parsing an "includes" expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | my $parsed = $type->expression('object + within[arrayref, either[string, number]]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # ['includes', 'object', ['within', 'arrayref', ['either', 'string', 'number']]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | =item Generating an "includes" expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | my $generated = $type->expression(['includes', 'object', ['within', 'arrayref', ['either', 'string', 'number']]]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | # object + within[arrayref, either[string, number]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | =item Parsing an "either" expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | my $parsed = $type->expression('string | number | within[arrayref, string | number]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | # ['either', 'string', 'number', ['within', 'arrayref', ['either', 'string', 'number']]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | =item Generating an "either" expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | my $generated = $type->expression(['either', 'string', 'number', ['within', 'arrayref', ['either', 'string', 'number']]]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | # string | number | within[arrayref, string | number] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | =item Parsing a subroutine signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | my $parsed = $type->signature('copy(string | Venus::Path $path) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | # ['copy', [['string | Venus::Path', '$path']], ['Venus::Path']] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | =item Generating a subroutine signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | my $generated = $type->signature(['copy', [['string | Venus::Path', '$path']], ['Venus::Path']]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | # copy(string | Venus::Path $path) (Venus::Path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | =head1 INHERITS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | This package inherits behaviors from: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | L<Venus::Kind::Utility> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | =head1 INTEGRATES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | This package integrates behaviors from: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | L<Venus::Role::Buildable> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | This package provides the following methods: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | =head2 assert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | assert(string $expr) (Venus::Assert) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | Returns a L<Venus::Assert> object based on the type expression provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | =item assert example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | my $assert = $type->assert('string | number'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | # bless(..., "Venus::Assert") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | =head2 check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | check(string $expr) (Venus::Check) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | Returns a L<Venus::Check> object based on the type expression provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | =item check example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | my $check = $type->check('string | number'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | # bless(..., "Venus::Check") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | =head2 coercion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | coercion(string $expr) (Venus::Coercion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | Returns a L<Venus::Coercion> object based on the type expression provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | =item coercion example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | my $coercion = $type->coercion('string | number'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | # bless(..., "Venus::Coercion") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | =head2 constraint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | constraint(string $expr) (Venus::Constraint) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | Returns a L<Venus::Constraint> object based on the type expression provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | =item constraint example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | my $constraint = $type->constraint('string | number'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | # bless(..., "Venus::Constraint") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | =head2 generate_expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | generate_expression(arrayref $expr) (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | Returns the type expression for the data structure (representing a type expression) provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | =item generate_expression example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | my $generate_expression = $type->generate_expression(["string"]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | # "string" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | =item generate_expression example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | my $generate_expression = $type->generate_expression(["either", "string", "number"]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | # "string | number" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | =item generate_expression example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | my $generate_expression = $type->generate_expression([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | "tuple", "number", ["either", ["within", "arrayref", "hashref"], "arrayref"], "coderef", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | # "tuple[number, within[arrayref, hashref] | arrayref, coderef]" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | =head2 generate_signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | generate_signature(arrayref $expr) (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | Returns the subroutine signature for the data structure (representing a subroutine signature) provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | =item generate_signature example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | my $generate_signature = $type->generate_signature(["output", [], []]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | # "output() ()" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | =item generate_signature example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | my $generate_signature = $type->generate_signature(["count", [], [["number"]]]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | # "count() (number)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | =item generate_signature example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | my $generate_signature = $type->generate_signature(["count", [["coderef", "\$filter"]], [["number"]]]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | # "count(coderef $filter) (number)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | =head2 generate_signature_input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | generate_signature_input(arrayref $expr) (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | Returns the subroutine signature input expression for the data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | (representing a subroutine signature input expression) provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | =item generate_signature_input example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | my $generate_signature_input = $type->generate_signature_input([["string", "\$string"]]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | # "string $string" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | =item generate_signature_input example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | my $generate_signature_input = $type->generate_signature_input([["string", "\$string"], ["number", "\$number"]]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | # "string $string, number $number" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | =item generate_signature_input example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | my $generate_signature_input = $type->generate_signature_input([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | ["string", "\$string"], ["coderef", "\$filter"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | # "string $string, coderef $filter" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | =head2 generate_signature_output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | generate_signature_output(arrayref $expr) (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | Returns the subroutine signature output expression for the data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | (representing a subroutine signature output expression) provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | =item generate_signature_output example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | my $generate_signature_output = $type->generate_signature_output([["string", "\$string"]]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | # "string $string" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | =item generate_signature_output example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | my $generate_signature_output = $type->generate_signature_output([["string", "\$string"], ["number", "\$number"]]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | # "string $string, number $number" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | =item generate_signature_output example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | my $generate_signature_output = $type->generate_signature_output([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | ["string", "\$string"], ["coderef", "\$filter"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | # "string $string, coderef $filter" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | new(hashref $data) (Venus::Type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | Constructs a new object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | =item new example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | use Venus::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | my $type = Venus::Type->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | # bless({}, "Venus::Type") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | =head2 parse_expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | parse_expression(string $expr) (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | Returns the parsed data structure based on the type expression provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | =item parse_expression example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | my $parse_expression = $type->parse_expression('string | number | Example'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | # ["either", "string", "number", "Example"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | =item parse_expression example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | my $parse_expression = $type->parse_expression('scalarref | object + string'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | # ["either", "scalarref", ["includes", "object", "string"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | =item parse_expression example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | my $parse_expression = $type->parse_expression('within[arrayref, string | number]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | # ["within", "arrayref", ["either", "string", "number"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | =item parse_expression example 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | my $parse_expression = $type->parse_expression('attributes[name, string, age, number]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | # ["attributes", "name", "string", "age", "number"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | =item parse_expression example 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | my $parse_expression = $type->parse_expression('tuple[string, arrayref, code]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | # ["tuple", "string", "arrayref", "code"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | =item parse_expression example 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | my $parse_expression = $type->parse_expression('inherits[Example] + attributes[value, string]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | # ["includes", ["inherits", "Example"], ["attributes", "value", "string"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | =item parse_expression example 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | my $parse_expression = $type->parse_expression('consumes[Example::Role] | identity[Example]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | # ["either", ["consumes", "Example::Role"], ["identity", "Example"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | =item parse_expression example 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | my $parse_expression = $type->parse_expression('either[tuple[string, number], coderef]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | # ["either", ["tuple", "string", "number"], "coderef"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | =item parse_expression example 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | my $parse_expression = $type->parse_expression('within[hashref, attributes["name", string]]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | # ["within", "hashref", ["attributes", "name", "string"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | =item parse_expression example 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | my $parse_expression = $type->parse_expression('maybe[arrayref] | either[scalar, code]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | # ["either", ["maybe", "arrayref"], ["either", "scalar", "code"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | =head2 parse_signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | parse_signature(string $expr) (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | Returns the parsed data structure based on the subroutine signature provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | =item parse_signature example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | my $parse_signature = $type->parse_signature('print(string @values) (boolean)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | # ["print", [["string", "\@values"]], [["boolean"]]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | =item parse_signature example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | my $parse_signature = $type->parse_signature('chmod(string $mode) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | # ["chmod", [["string", "\$mode"]], [["Venus::Path"]]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | =item parse_signature example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | my $parse_signature = $type->parse_signature('copy(string | Venus::Path $path) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | # ["copy", [["string | Venus::Path", "\$path"]], [["Venus::Path"]]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | =item parse_signature example 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | my $parse_signature = $type->parse_signature('find(string | regexp $expr) (within[arrayref, Venus::Path])'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | # ["find", [["string | regexp", "\$expr"]], [["within[arrayref, Venus::Path]"]]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | =item parse_signature example 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | my $parse_signature = $type->parse_signature('mkdir(maybe[string] $mode) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | # ["mkdir", [["maybe[string]", "\$mode"]], [[ "Venus::Path" ]]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | =item parse_signature example 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | my $parse_signature = $type->parse_signature('open(any @data) (FileHandle)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | # ["open", [["any", "\@data"]], [["FileHandle"]]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | =item parse_signature example 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | my $parse_signature = $type->parse_signature('root(string $spec, string $base) (maybe[Venus::Path])'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | # ["root", [["string", "\$spec"], ["string", "\$base"]], [["maybe[Venus::Path]"]]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | =item parse_signature example 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | my $parse_signature = $type->parse_signature('extension(string $name) (string | Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | # ["extension", [["string", "\$name"]], [["string | Venus::Path"]]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | =item parse_signature example 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | my $parse_signature = $type->parse_signature('count()'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | # Exception! isa Venus::Type::Error (see error_on_signature_parse) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | =item B<may raise> L<Venus::Type::Error> C<on.signature.parse> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | use Venus::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | my $type = Venus::Type->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | $type->parse_signature('count()'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | # Error! (on.signature.parse) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | =head2 parse_signature_input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | parse_signature_input(string $expr) (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | Returns the parsed data structure for the input type expressions in the subroutine signature provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | =item parse_signature_input example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | my $parse_signature_input = $type->parse_signature_input('print(string @values) (boolean)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | # ["string"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | =item parse_signature_input example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | my $parse_signature_input = $type->parse_signature_input('chmod(string $mode) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | # ["string"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | =item parse_signature_input example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | my $parse_signature_input = $type->parse_signature_input('copy(string | Venus::Path $path) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | # ["string | Venus::Path"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | =item parse_signature_input example 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | my $parse_signature_input = $type->parse_signature_input('find(string | regexp $expr) (within[arrayref, Venus::Path])'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | # ["string | regexp"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | =item parse_signature_input example 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | my $parse_signature_input = $type->parse_signature_input('mkdir(maybe[string] $mode) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | # ["maybe[string]"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | =item parse_signature_input example 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | my $parse_signature_input = $type->parse_signature_input('open(any @data) (FileHandle)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | # ["any"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | =item parse_signature_input example 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | my $parse_signature_input = $type->parse_signature_input('root(string $spec, string $base) (maybe[Venus::Path])'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | # ["string", "string"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | =item parse_signature_input example 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | my $parse_signature_input = $type->parse_signature_input('extension(string $name) (string | Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | # ["string"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | =head2 parse_signature_output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | parse_signature_output(string $expr) (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | Returns the parsed data structure for the output type expression in the subroutine signature provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | =item parse_signature_output example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | my $parse_signature_output = $type->parse_signature_output('print(string @values) (boolean)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | # ["boolean"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | =item parse_signature_output example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | my $parse_signature_output = $type->parse_signature_output('chmod(string $mode) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | # ["Venus::Path"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | =item parse_signature_output example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | my $parse_signature_output = $type->parse_signature_output('copy(string | Venus::Path $path) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | # ["Venus::Path"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | =item parse_signature_output example 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | my $parse_signature_output = $type->parse_signature_output('find(string | regexp $expr) (within[arrayref, Venus::Path])'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | # ["within[arrayref, Venus::Path]"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | =item parse_signature_output example 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | my $parse_signature_output = $type->parse_signature_output('mkdir(maybe[string] $mode) (Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | # ["Venus::Path"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | =item parse_signature_output example 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | my $parse_signature_output = $type->parse_signature_output('open(any @data) (FileHandle)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | # ["FileHandle"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | =item parse_signature_output example 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | my $parse_signature_output = $type->parse_signature_output('root(string $spec, string $base) (maybe[Venus::Path])'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | # ["maybe[Venus::Path]"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | =item parse_signature_output example 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | my $parse_signature_output = $type->parse_signature_output('extension(string $name) (string | Venus::Path)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | # ["string | Venus::Path"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | =head2 unpack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | unpack(arrayref $args, arrayref $expr) (Venus::Unpack) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | Returns a L<Venus::Unpack> object based on the values and data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | (representing type expressions) provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | =item unpack example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | my $unpack = $type->unpack(["hello world"], ["string"]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | # bless(..., "Venus::Unpack") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | =item unpack example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | my $unpack = $type->unpack(["hello world"], ["string | number"]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | # bless(..., "Venus::Unpack") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | =head2 unpack_signature_input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | unpack_signature_input(string $signature, arrayref $args) (Venus::Unpack) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | Returns a L<Venus::Unpack> object based on the values and data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | (representing a subroutine signature input expression) provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | =item unpack_signature_input example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | my $unpack_signature_input = $type->unpack_signature_input( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 'output(string $error) (string)', ["hello world"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | # bless(..., "Venus::Unpack") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | =item unpack_signature_input example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | my $unpack_signature_input = $type->unpack_signature_input( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | 'output(string | number $error) (string)', ["hello world"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | # bless(..., "Venus::Unpack") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | =head2 unpack_signature_output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | unpack_signature_output(string $signature, arrayref $args) (Venus::Unpack) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | Returns a L<Venus::Unpack> object based on the values and data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | (representing a subroutine signature output expression) provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | =item unpack_signature_output example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | my $unpack_signature_output = $type->unpack_signature_output( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 'output(string $error) (string)', ["hello world"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | # bless(..., "Venus::Unpack") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | =item unpack_signature_output example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | my $unpack_signature_output = $type->unpack_signature_output( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | 'output(string | number $error) (string)', ["hello world"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | # bless(..., "Venus::Unpack") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | the terms of the Apache license version 2.0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||