line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Wrapper around the C libyaml library |
2
|
|
|
|
|
|
|
package YAML::LibYAML::API; |
3
|
6
|
|
|
6
|
|
375588
|
use strict; |
|
6
|
|
|
|
|
55
|
|
|
6
|
|
|
|
|
145
|
|
4
|
6
|
|
|
6
|
|
25
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
261
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.012_001'; # TRIAL VERSION |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
|
|
3397
|
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
|
|
2216
|
/; |
|
6
|
|
|
|
|
8336
|
|
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
|
6537
|
my ($yaml, $events) = @_; |
55
|
8
|
|
|
|
|
1028
|
YAML::LibYAML::API::XS::parse_string_events($yaml, $events); |
56
|
8
|
|
|
|
|
35
|
_numeric_to_string($events); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub parse_file_events { |
60
|
1
|
|
|
1
|
0
|
15505
|
my ($file, $events) = @_; |
61
|
1
|
|
|
|
|
97
|
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
|
3684
|
my ($fh, $events) = @_; |
67
|
1
|
|
|
|
|
71
|
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
|
13883
|
my ($events, $options) = @_; |
73
|
10
|
|
100
|
|
|
40
|
$options ||= {}; |
74
|
10
|
|
|
|
|
29
|
_string_to_numeric($events); |
75
|
10
|
|
|
|
|
633
|
return YAML::LibYAML::API::XS::emit_string_events($events, $options); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub emit_file_events { |
79
|
1
|
|
|
1
|
0
|
1938
|
my ($file, $events, $options) = @_; |
80
|
1
|
|
50
|
|
|
6
|
$options ||= {}; |
81
|
1
|
|
|
|
|
4
|
_string_to_numeric($events); |
82
|
1
|
|
|
|
|
186
|
return YAML::LibYAML::API::XS::emit_file_events($file, $events, $options); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub emit_filehandle_events { |
86
|
1
|
|
|
1
|
0
|
579
|
my ($fh, $events, $options) = @_; |
87
|
1
|
|
50
|
|
|
6
|
$options ||= {}; |
88
|
1
|
|
|
|
|
4
|
_string_to_numeric($events); |
89
|
1
|
|
|
|
|
45
|
return YAML::LibYAML::API::XS::emit_filehandle_events($fh, $events, $options); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _numeric_to_string { |
93
|
10
|
|
|
10
|
|
25
|
my ($events) = @_; |
94
|
10
|
|
|
|
|
25
|
for my $event (@$events) { |
95
|
149
|
100
|
|
|
|
403
|
if ($event->{name} eq 'scalar_event') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
96
|
49
|
|
|
|
|
75
|
$event->{style} = $scalar_styles[ $event->{style} ]; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
elsif ($event->{name} eq 'sequence_start_event') { |
99
|
15
|
|
|
|
|
30
|
$event->{style} = $sequence_styles[ $event->{style} ]; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
elsif ($event->{name} eq 'mapping_start_event') { |
102
|
11
|
|
|
|
|
23
|
$event->{style} = $mapping_styles[ $event->{style} ]; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _string_to_numeric { |
108
|
12
|
|
|
12
|
|
18
|
my ($events) = @_; |
109
|
12
|
|
|
|
|
23
|
for my $event (@$events) { |
110
|
165
|
100
|
|
|
|
347
|
if ($event->{name} eq 'scalar_event') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
111
|
53
|
|
|
|
|
75
|
$event->{style} = $scalar_styles{ $event->{style} }; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
elsif ($event->{name} eq 'sequence_start_event') { |
114
|
16
|
|
|
|
|
29
|
$event->{style} = $sequence_styles{ $event->{style} }; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
elsif ($event->{name} eq 'mapping_start_event') { |
117
|
13
|
|
|
|
|
23
|
$event->{style} = $mapping_styles{ $event->{style} }; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |