line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Wrapper around the C libyaml library |
2
|
|
|
|
|
|
|
package YAML::LibYAML::API; |
3
|
6
|
|
|
6
|
|
371177
|
use strict; |
|
6
|
|
|
|
|
60
|
|
|
6
|
|
|
|
|
141
|
|
4
|
6
|
|
|
6
|
|
28
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
276
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.013'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
|
|
3468
|
use YAML::PP::Common qw/ |
9
|
|
|
|
|
|
|
YAML_ANY_SCALAR_STYLE YAML_PLAIN_SCALAR_STYLE |
10
|
|
|
|
|
|
|
YAML_SINGLE_QUOTED_SCALAR_STYLE YAML_DOUBLE_QUOTED_SCALAR_STYLE |
11
|
|
|
|
|
|
|
YAML_LITERAL_SCALAR_STYLE YAML_FOLDED_SCALAR_STYLE |
12
|
|
|
|
|
|
|
YAML_QUOTED_SCALAR_STYLE |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
YAML_ANY_SEQUENCE_STYLE |
15
|
|
|
|
|
|
|
YAML_BLOCK_SEQUENCE_STYLE YAML_FLOW_SEQUENCE_STYLE |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
YAML_ANY_MAPPING_STYLE |
18
|
|
|
|
|
|
|
YAML_BLOCK_MAPPING_STYLE YAML_FLOW_MAPPING_STYLE |
19
|
6
|
|
|
6
|
|
2262
|
/; |
|
6
|
|
|
|
|
8401
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @scalar_styles = ( |
22
|
|
|
|
|
|
|
YAML_ANY_SCALAR_STYLE, |
23
|
|
|
|
|
|
|
YAML_PLAIN_SCALAR_STYLE, |
24
|
|
|
|
|
|
|
YAML_SINGLE_QUOTED_SCALAR_STYLE, |
25
|
|
|
|
|
|
|
YAML_DOUBLE_QUOTED_SCALAR_STYLE, |
26
|
|
|
|
|
|
|
YAML_LITERAL_SCALAR_STYLE, |
27
|
|
|
|
|
|
|
YAML_FOLDED_SCALAR_STYLE, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
my %scalar_styles; |
30
|
|
|
|
|
|
|
@scalar_styles{ @scalar_styles } = 0 .. $#scalar_styles; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my @sequence_styles = ( |
33
|
|
|
|
|
|
|
YAML_ANY_SEQUENCE_STYLE, |
34
|
|
|
|
|
|
|
YAML_BLOCK_SEQUENCE_STYLE, |
35
|
|
|
|
|
|
|
YAML_FLOW_SEQUENCE_STYLE, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
my %sequence_styles; |
38
|
|
|
|
|
|
|
@sequence_styles{ @sequence_styles } = 0 .. $#sequence_styles; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my @mapping_styles = ( |
41
|
|
|
|
|
|
|
YAML_ANY_MAPPING_STYLE, |
42
|
|
|
|
|
|
|
YAML_BLOCK_MAPPING_STYLE, |
43
|
|
|
|
|
|
|
YAML_FLOW_MAPPING_STYLE, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
my %mapping_styles; |
46
|
|
|
|
|
|
|
@mapping_styles{ @mapping_styles } = 0 .. @mapping_styles; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# deprecated |
49
|
|
|
|
|
|
|
sub parse_events { |
50
|
0
|
|
|
0
|
0
|
0
|
parse_string_events(@_); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub parse_string_events { |
54
|
8
|
|
|
8
|
0
|
6929
|
my ($yaml, $events) = @_; |
55
|
8
|
|
|
|
|
1023
|
YAML::LibYAML::API::XS::parse_string_events($yaml, $events); |
56
|
8
|
|
|
|
|
38
|
_numeric_to_string($events); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub parse_file_events { |
60
|
1
|
|
|
1
|
0
|
16169
|
my ($file, $events) = @_; |
61
|
1
|
|
|
|
|
174
|
YAML::LibYAML::API::XS::parse_file_events($file, $events); |
62
|
1
|
|
|
|
|
7
|
_numeric_to_string($events); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub parse_filehandle_events { |
66
|
1
|
|
|
1
|
0
|
3920
|
my ($fh, $events) = @_; |
67
|
1
|
|
|
|
|
103
|
YAML::LibYAML::API::XS::parse_filehandle_events($fh, $events); |
68
|
1
|
|
|
|
|
5
|
_numeric_to_string($events); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub emit_string_events { |
72
|
10
|
|
|
10
|
0
|
14728
|
my ($events, $options) = @_; |
73
|
10
|
|
100
|
|
|
46
|
$options ||= {}; |
74
|
10
|
|
|
|
|
28
|
_string_to_numeric($events); |
75
|
10
|
|
|
|
|
630
|
return YAML::LibYAML::API::XS::emit_string_events($events, $options); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub emit_file_events { |
79
|
1
|
|
|
1
|
0
|
2111
|
my ($file, $events, $options) = @_; |
80
|
1
|
|
50
|
|
|
7
|
$options ||= {}; |
81
|
1
|
|
|
|
|
3
|
_string_to_numeric($events); |
82
|
1
|
|
|
|
|
214
|
return YAML::LibYAML::API::XS::emit_file_events($file, $events, $options); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub emit_filehandle_events { |
86
|
1
|
|
|
1
|
0
|
652
|
my ($fh, $events, $options) = @_; |
87
|
1
|
|
50
|
|
|
7
|
$options ||= {}; |
88
|
1
|
|
|
|
|
3
|
_string_to_numeric($events); |
89
|
1
|
|
|
|
|
42
|
return YAML::LibYAML::API::XS::emit_filehandle_events($fh, $events, $options); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _numeric_to_string { |
93
|
10
|
|
|
10
|
|
23
|
my ($events) = @_; |
94
|
10
|
|
|
|
|
28
|
for my $event (@$events) { |
95
|
149
|
100
|
|
|
|
419
|
if ($event->{name} eq 'scalar_event') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
96
|
49
|
|
|
|
|
78
|
$event->{style} = $scalar_styles[ $event->{style} ]; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
elsif ($event->{name} eq 'sequence_start_event') { |
99
|
15
|
|
|
|
|
34
|
$event->{style} = $sequence_styles[ $event->{style} ]; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
elsif ($event->{name} eq 'mapping_start_event') { |
102
|
11
|
|
|
|
|
25
|
$event->{style} = $mapping_styles[ $event->{style} ]; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _string_to_numeric { |
108
|
12
|
|
|
12
|
|
23
|
my ($events) = @_; |
109
|
12
|
|
|
|
|
28
|
for my $event (@$events) { |
110
|
165
|
100
|
|
|
|
322
|
if ($event->{name} eq 'scalar_event') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
111
|
53
|
|
|
|
|
79
|
$event->{style} = $scalar_styles{ $event->{style} }; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
elsif ($event->{name} eq 'sequence_start_event') { |
114
|
16
|
|
|
|
|
31
|
$event->{style} = $sequence_styles{ $event->{style} }; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
elsif ($event->{name} eq 'mapping_start_event') { |
117
|
13
|
|
|
|
|
27
|
$event->{style} = $mapping_styles{ $event->{style} }; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |