| 1 | #################################################################### | ||||||||||
| 2 | # | ||||||||||
| 3 | # This file was generated using XDR::Parse version v1.0.1 | ||||||||||
| 4 | # and LibVirt version v12.9.0 | ||||||||||
| 5 | # | ||||||||||
| 6 | # Don't edit this file, use the source template instead | ||||||||||
| 7 | # | ||||||||||
| 8 | # ANY CHANGES HERE WILL BE LOST ! | ||||||||||
| 9 | # | ||||||||||
| 10 | #################################################################### | ||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use v5.14.1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use Syntax::Operator::Elem qw( elem_str ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | package Protocol::Sys::Virt::TypedParams v12.9.0; | ||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | 1 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 1 | ▶ | use Log::Any qw($log); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | # copied from Protocol::Sys::Virt::Remote::XDR, with VIR_ prefix stripped | ||||||||||
| 25 | 1 | ▶ | use constant { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 1 | TYPED_PARAM_INT => 1, | |||||||||
| 27 | TYPED_PARAM_UINT => 2, | ||||||||||
| 28 | TYPED_PARAM_LLONG => 3, | ||||||||||
| 29 | TYPED_PARAM_ULLONG => 4, | ||||||||||
| 30 | TYPED_PARAM_DOUBLE => 5, | ||||||||||
| 31 | TYPED_PARAM_BOOLEAN => 6, | ||||||||||
| 32 | TYPED_PARAM_STRING => 7, | ||||||||||
| 33 | 1 | }; | |||||||||
| 34 | |||||||||||
| 35 | 1 | my %value_field_name = ( | |||||||||
| 36 | 1 => 'i', | ||||||||||
| 37 | 2 => 'ui', | ||||||||||
| 38 | 3 => 'l', | ||||||||||
| 39 | 4 => 'ul', | ||||||||||
| 40 | 5 => 'd', | ||||||||||
| 41 | 6 => 'b', | ||||||||||
| 42 | 7 => 's' | ||||||||||
| 43 | ); | ||||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | 1 | our @EXPORT = qw( | |||||||||
| 47 | typed_params_new | ||||||||||
| 48 | typed_field_new | ||||||||||
| 49 | typed_value_new | ||||||||||
| 50 | |||||||||||
| 51 | typed_params_check_fields_only | ||||||||||
| 52 | typed_params_field | ||||||||||
| 53 | typed_params_fields | ||||||||||
| 54 | |||||||||||
| 55 | typed_params_field_int_value | ||||||||||
| 56 | typed_params_field_uint_value | ||||||||||
| 57 | typed_params_field_long_value | ||||||||||
| 58 | typed_params_field_ulong_value | ||||||||||
| 59 | typed_params_field_double_value | ||||||||||
| 60 | typed_params_field_boolean_value | ||||||||||
| 61 | typed_params_field_string_value | ||||||||||
| 62 | |||||||||||
| 63 | TYPED_PARAM_INT | ||||||||||
| 64 | TYPED_PARAM_UINT | ||||||||||
| 65 | TYPED_PARAM_LLONG | ||||||||||
| 66 | TYPED_PARAM_ULLONG | ||||||||||
| 67 | TYPED_PARAM_DOUBLE | ||||||||||
| 68 | TYPED_PARAM_BOOLEAN | ||||||||||
| 69 | TYPED_PARAM_STRING | ||||||||||
| 70 | |||||||||||
| 71 | ); | ||||||||||
| 72 | |||||||||||
| 73 | |||||||||||
| 74 | 0 | ▶ | sub typed_params_check_fields_only { | ||||||||
|
Subroutine
typed_params_check_fields_only: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 75 | 0 | my ( $params, @fields ) = @_; | |||||||||
| 76 | |||||||||||
| 77 | 0 | for my $param (@{ $params }) { | |||||||||
| 78 | 0 | ▶ | unless (elem_str( $param->{field}, @fields )) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | 0 | croak "Unexpected parameter $param->{field}"; | |||||||||
| 80 | } | ||||||||||
| 81 | } | ||||||||||
| 82 | 0 | return 1; | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 4 | ▶ | sub typed_params_field { | ||||||||
|
Subroutine
typed_params_field: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||
| 86 | 4 | my ( $params, $name, @rest ) = @_; | |||||||||
| 87 | 4 | ▶ | return unless $params; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 88 | |||||||||||
| 89 | 4 | for my $param (@{ $params }) { | |||||||||
| 90 | 4 | ▶ | next unless $param->{field} eq $name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | |||||||||||
| 92 | 2 | ▶ | if (@rest) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | 1 | my $new_entry = shift @rest; | |||||||||
| 94 | 1 | $param = { field => $name, value => $new_entry }; | |||||||||
| 95 | 1 | return $param; | |||||||||
| 96 | } | ||||||||||
| 97 | 1 | return $param; | |||||||||
| 98 | } | ||||||||||
| 99 | 2 | ▶ | if (@rest) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | 1 | my $new_entry = shift @rest; | |||||||||
| 101 | 1 | my $param = { field => $name, value => $new_entry }; | |||||||||
| 102 | 1 | push @{ $params }, $param; | |||||||||
| 103 | 1 | return $param; | |||||||||
| 104 | } | ||||||||||
| 105 | 1 | return undef; | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 2 | ▶ | sub typed_params_fields { | ||||||||
|
Subroutine
typed_params_fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 109 | 2 | my ( $params, $name ) = @_; | |||||||||
| 110 | 2 | return [ grep { $_->{field} eq $name } @{ $params } ]; | |||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | 19 | ▶ | sub typed_value_new { | ||||||||
|
Subroutine
typed_value_new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 114 | 19 | my ( $type, $value ) = @_; | |||||||||
| 115 | 19 | return { type => $type, $value_field_name{$type} => $value }; | |||||||||
| 116 | } | ||||||||||
| 117 | |||||||||||
| 118 | 10 | ▶ | sub typed_field_new { | ||||||||
|
Subroutine
typed_field_new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 119 | 10 | my ( $name, $value ) = @_; | |||||||||
| 120 | 10 | return { field => $name, value => $value }; | |||||||||
| 121 | } | ||||||||||
| 122 | |||||||||||
| 123 | 9 | ▶ | sub typed_params_new { | ||||||||
|
Subroutine
typed_params_new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 124 | 9 | my ( $from ) = @_; | |||||||||
| 125 | 9 | ▶ | $from = [] unless $from; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 126 | |||||||||||
| 127 | 9 | return [ map { { %{ $_ } } } @{ $from } ]; | |||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | 6 | ▶ | sub _typed_params_field_value { | ||||||||
|
Subroutine
_typed_params_field_value: called CC=7 SCAR=19.5
| |||||||||||
| 131 | 6 | my ( $params, $name, $type, @rest ) = @_; | |||||||||
| 132 | 6 | ▶ | return unless $params; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 133 | |||||||||||
| 134 | 6 | for my $param (@{ $params }) { | |||||||||
| 135 | 6 | ▶ | next unless $param->{field} eq $name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 136 | croak "TypedParam type mismatch: expected $type, found $param->{value}->{type}" | ||||||||||
| 137 | 4 | ▶ | if $type != $param->{value}->{type}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 138 | |||||||||||
| 139 | 2 | ▶ | if (@rest) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 140 | 1 | my $new_value = shift @rest; | |||||||||
| 141 | $param = { | ||||||||||
| 142 | field => $name, | ||||||||||
| 143 | value => { | ||||||||||
| 144 | type => $type, | ||||||||||
| 145 | 1 | $value_field_name{$type} => $new_value } | |||||||||
| 146 | }; | ||||||||||
| 147 | 1 | return $new_value; | |||||||||
| 148 | } | ||||||||||
| 149 | |||||||||||
| 150 | 1 | return $param->{value}->{$value_field_name{$type}}; | |||||||||
| 151 | } | ||||||||||
| 152 | |||||||||||
| 153 | 2 | ▶ | if (@rest) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 154 | 1 | my $new_value = shift @rest; | |||||||||
| 155 | 1 | push @{ $params }, { | |||||||||
| 156 | field => $name, | ||||||||||
| 157 | value => { | ||||||||||
| 158 | type => $type, | ||||||||||
| 159 | 1 | $value_field_name{$type} => $new_value } | |||||||||
| 160 | }; | ||||||||||
| 161 | |||||||||||
| 162 | 1 | return $new_value; | |||||||||
| 163 | } | ||||||||||
| 164 | |||||||||||
| 165 | 1 | return undef; | |||||||||
| 166 | } | ||||||||||
| 167 | |||||||||||
| 168 | 4 | ▶ | sub typed_params_field_int_value { | ||||||||
|
Subroutine
typed_params_field_int_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 169 | 4 | my ( $params, $name, @rest ) = @_; | |||||||||
| 170 | 4 | return _typed_params_field_value( $params, $name, TYPED_PARAM_INT, @rest ); | |||||||||
| 171 | } | ||||||||||
| 172 | |||||||||||
| 173 | 0 | ▶ | sub typed_params_field_uint_value { | ||||||||
|
Subroutine
typed_params_field_uint_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 174 | 0 | my ( $params, $name, @rest ) = @_; | |||||||||
| 175 | 0 | return _typed_params_field_value( $params, $name, TYPED_PARAM_UINT, @rest ); | |||||||||
| 176 | } | ||||||||||
| 177 | |||||||||||
| 178 | 0 | ▶ | sub typed_params_field_long_value { | ||||||||
|
Subroutine
typed_params_field_long_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 179 | 0 | my ( $params, $name, @rest ) = @_; | |||||||||
| 180 | 0 | return _typed_params_field_value( $params, $name, TYPED_PARAM_LLONG, @rest ); | |||||||||
| 181 | } | ||||||||||
| 182 | |||||||||||
| 183 | 0 | ▶ | sub typed_params_field_ulong_value { | ||||||||
|
Subroutine
typed_params_field_ulong_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 184 | 0 | my ( $params, $name, @rest ) = @_; | |||||||||
| 185 | 0 | return _typed_params_field_value( $params, $name, TYPED_PARAM_ULLONG, @rest ); | |||||||||
| 186 | } | ||||||||||
| 187 | |||||||||||
| 188 | 0 | ▶ | sub typed_params_field_double_value { | ||||||||
|
Subroutine
typed_params_field_double_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 189 | 0 | my ( $params, $name, @rest ) = @_; | |||||||||
| 190 | 0 | return _typed_params_field_value( $params, $name, TYPED_PARAM_DOUBLE, @rest ); | |||||||||
| 191 | } | ||||||||||
| 192 | |||||||||||
| 193 | 2 | ▶ | sub typed_params_field_boolean_value { | ||||||||
|
Subroutine
typed_params_field_boolean_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 194 | 2 | my ( $params, $name, @rest ) = @_; | |||||||||
| 195 | 2 | return _typed_params_field_value( $params, $name, TYPED_PARAM_BOOLEAN, @rest ); | |||||||||
| 196 | } | ||||||||||
| 197 | |||||||||||
| 198 | 0 | ▶ | sub typed_params_field_string_value { | ||||||||
|
Subroutine
typed_params_field_string_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 199 | 0 | my ( $params, $name, @rest ) = @_; | |||||||||
| 200 | 0 | return _typed_params_field_value( $params, $name, TYPED_PARAM_STRING, @rest ); | |||||||||
| 201 | } | ||||||||||
| 202 | |||||||||||
| 203 | |||||||||||
| 204 | |||||||||||
| 205 | 1 | 1; | |||||||||
| 206 | |||||||||||
| 207 | __END__ | ||||||||||