line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Wrapper around the C libyaml library |
2
|
|
|
|
|
|
|
package YAML::LibYAML::API; |
3
|
6
|
|
|
6
|
|
444989
|
use strict; |
|
6
|
|
|
|
|
70
|
|
|
6
|
|
|
|
|
175
|
|
4
|
6
|
|
|
6
|
|
72
|
use warnings; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
371
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.013_001'; # TRIAL VERSION |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
|
|
4112
|
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
|
|
3097
|
/; |
|
6
|
|
|
|
|
10501
|
|
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
|
8621
|
my ($yaml, $events) = @_; |
55
|
8
|
|
|
|
|
1311
|
YAML::LibYAML::API::XS::parse_string_events($yaml, $events); |
56
|
8
|
|
|
|
|
46
|
_numeric_to_string($events); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub parse_file_events { |
60
|
1
|
|
|
1
|
0
|
35579
|
my ($file, $events) = @_; |
61
|
1
|
|
|
|
|
135
|
YAML::LibYAML::API::XS::parse_file_events($file, $events); |
62
|
1
|
|
|
|
|
6
|
_numeric_to_string($events); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub parse_filehandle_events { |
66
|
1
|
|
|
1
|
0
|
4586
|
my ($fh, $events) = @_; |
67
|
1
|
|
|
|
|
80
|
YAML::LibYAML::API::XS::parse_filehandle_events($fh, $events); |
68
|
1
|
|
|
|
|
6
|
_numeric_to_string($events); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub emit_string_events { |
72
|
10
|
|
|
10
|
0
|
28478
|
my ($events, $options) = @_; |
73
|
10
|
|
100
|
|
|
61
|
$options ||= {}; |
74
|
10
|
|
|
|
|
34
|
_string_to_numeric($events); |
75
|
10
|
|
|
|
|
734
|
return YAML::LibYAML::API::XS::emit_string_events($events, $options); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub emit_file_events { |
79
|
1
|
|
|
1
|
0
|
2390
|
my ($file, $events, $options) = @_; |
80
|
1
|
|
50
|
|
|
8
|
$options ||= {}; |
81
|
1
|
|
|
|
|
5
|
_string_to_numeric($events); |
82
|
1
|
|
|
|
|
217
|
return YAML::LibYAML::API::XS::emit_file_events($file, $events, $options); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub emit_filehandle_events { |
86
|
1
|
|
|
1
|
0
|
759
|
my ($fh, $events, $options) = @_; |
87
|
1
|
|
50
|
|
|
9
|
$options ||= {}; |
88
|
1
|
|
|
|
|
7
|
_string_to_numeric($events); |
89
|
1
|
|
|
|
|
85
|
return YAML::LibYAML::API::XS::emit_filehandle_events($fh, $events, $options); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _numeric_to_string { |
93
|
10
|
|
|
10
|
|
28
|
my ($events) = @_; |
94
|
10
|
|
|
|
|
31
|
for my $event (@$events) { |
95
|
149
|
100
|
|
|
|
475
|
if ($event->{name} eq 'scalar_event') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
96
|
49
|
|
|
|
|
97
|
$event->{style} = $scalar_styles[ $event->{style} ]; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
elsif ($event->{name} eq 'sequence_start_event') { |
99
|
15
|
|
|
|
|
65
|
$event->{style} = $sequence_styles[ $event->{style} ]; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
elsif ($event->{name} eq 'mapping_start_event') { |
102
|
11
|
|
|
|
|
34
|
$event->{style} = $mapping_styles[ $event->{style} ]; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _string_to_numeric { |
108
|
12
|
|
|
12
|
|
36
|
my ($events) = @_; |
109
|
12
|
|
|
|
|
28
|
for my $event (@$events) { |
110
|
165
|
100
|
|
|
|
379
|
if ($event->{name} eq 'scalar_event') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
111
|
53
|
|
|
|
|
92
|
$event->{style} = $scalar_styles{ $event->{style} }; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
elsif ($event->{name} eq 'sequence_start_event') { |
114
|
16
|
|
|
|
|
37
|
$event->{style} = $sequence_styles{ $event->{style} }; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
elsif ($event->{name} eq 'mapping_start_event') { |
117
|
13
|
|
|
|
|
33
|
$event->{style} = $mapping_styles{ $event->{style} }; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |