line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Emitter for YAML::PP::LibYAML |
2
|
|
|
|
|
|
|
package YAML::PP::LibYAML::Emitter; |
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
86
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.005'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
12
|
use YAML::LibYAML::API::XS; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
38
|
|
9
|
2
|
|
|
2
|
|
8
|
use YAML::PP::Writer; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
10
|
2
|
|
|
2
|
|
13
|
use Scalar::Util qw/ openhandle /; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
107
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
11
|
use base 'YAML::PP::Emitter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1710
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
4
|
|
|
4
|
1
|
16
|
my ($class, %args) = @_; |
16
|
4
|
|
100
|
|
|
19
|
my $indent = delete $args{indent} || 2; |
17
|
4
|
|
100
|
|
|
18
|
my $width = delete $args{width} || 80; |
18
|
4
|
|
|
|
|
16
|
my $self = bless { |
19
|
|
|
|
|
|
|
indent => $indent, |
20
|
|
|
|
|
|
|
width => $width, |
21
|
|
|
|
|
|
|
}, $class; |
22
|
4
|
50
|
|
|
|
16
|
if (keys %args) { |
23
|
0
|
|
|
|
|
0
|
die "Unexpected arguments: " . join ', ', sort keys %args; |
24
|
|
|
|
|
|
|
} |
25
|
4
|
|
|
|
|
23
|
$self->{events} = []; |
26
|
4
|
|
|
|
|
34
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
63
|
|
|
63
|
0
|
180
|
sub events { return $_[0]->{events} } |
29
|
6
|
|
|
6
|
1
|
19
|
sub indent { return $_[0]->{indent} } |
30
|
6
|
|
|
6
|
0
|
17
|
sub width { return $_[0]->{width} } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub mapping_start_event { |
34
|
5
|
|
|
5
|
1
|
646
|
my ($self, $info) = @_; |
35
|
5
|
|
|
|
|
11
|
$info->{name} = 'mapping_start_event'; |
36
|
5
|
|
|
|
|
6
|
push @{ $self->events }, $info; |
|
5
|
|
|
|
|
11
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub mapping_end_event { |
40
|
5
|
|
|
5
|
1
|
30
|
my ($self, $info) = @_; |
41
|
5
|
|
|
|
|
11
|
$info->{name} = 'mapping_end_event'; |
42
|
5
|
|
|
|
|
8
|
push @{ $self->events }, $info; |
|
5
|
|
|
|
|
10
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub sequence_start_event { |
46
|
4
|
|
|
4
|
1
|
625
|
my ($self, $info) = @_; |
47
|
4
|
|
|
|
|
7
|
$info->{name} = 'sequence_start_event'; |
48
|
4
|
|
|
|
|
6
|
push @{ $self->events }, $info; |
|
4
|
|
|
|
|
10
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub sequence_end_event { |
52
|
4
|
|
|
4
|
1
|
30
|
my ($self, $info) = @_; |
53
|
4
|
|
|
|
|
9
|
$info->{name} = 'sequence_end_event'; |
54
|
4
|
|
|
|
|
7
|
push @{ $self->events }, $info; |
|
4
|
|
|
|
|
13
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub scalar_event { |
58
|
15
|
|
|
15
|
1
|
1352
|
my ($self, $info) = @_; |
59
|
15
|
|
|
|
|
31
|
$info->{name} = 'scalar_event'; |
60
|
15
|
|
|
|
|
21
|
push @{ $self->events }, $info; |
|
15
|
|
|
|
|
30
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub alias_event { |
64
|
0
|
|
|
0
|
1
|
0
|
my ($self, $info) = @_; |
65
|
0
|
|
|
|
|
0
|
$info->{name} = 'alias_event'; |
66
|
0
|
|
|
|
|
0
|
push @{ $self->events }, $info; |
|
0
|
|
|
|
|
0
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub document_start_event { |
70
|
6
|
|
|
6
|
1
|
118
|
my ($self, $info) = @_; |
71
|
6
|
|
|
|
|
12
|
$info->{name} = 'document_start_event'; |
72
|
6
|
|
|
|
|
10
|
push @{ $self->events }, $info; |
|
6
|
|
|
|
|
22
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub document_end_event { |
76
|
6
|
|
|
6
|
1
|
77
|
my ($self, $info) = @_; |
77
|
6
|
|
|
|
|
11
|
$info->{name} = 'document_end_event'; |
78
|
6
|
|
|
|
|
9
|
push @{ $self->events }, $info; |
|
6
|
|
|
|
|
10
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub stream_start_event { |
82
|
6
|
|
|
6
|
1
|
14040
|
my ($self, $info) = @_; |
83
|
6
|
|
|
|
|
15
|
$info->{name} = 'stream_start_event'; |
84
|
6
|
|
|
|
|
11
|
push @{ $self->events }, $info; |
|
6
|
|
|
|
|
18
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub stream_end_event { |
88
|
6
|
|
|
6
|
1
|
37
|
my ($self, $info) = @_; |
89
|
6
|
|
|
|
|
24
|
$info->{name} = 'stream_end_event'; |
90
|
6
|
|
|
|
|
11
|
push @{ $self->events }, $info; |
|
6
|
|
|
|
|
13
|
|
91
|
6
|
|
|
|
|
17
|
my $events = $self->events; |
92
|
6
|
|
|
|
|
19
|
my $writer = $self->writer; |
93
|
6
|
|
|
|
|
29
|
$writer->init(); |
94
|
6
|
|
|
|
|
236
|
my $options = { |
95
|
|
|
|
|
|
|
indent => $self->indent, |
96
|
|
|
|
|
|
|
width => $self->width, |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
6
|
50
|
|
|
|
42
|
if ($writer->can('open_handle')) { |
100
|
0
|
0
|
|
|
|
0
|
if (openhandle($writer->output)) { |
101
|
0
|
|
|
|
|
0
|
YAML::LibYAML::API::XS::emit_filehandle_events( |
102
|
|
|
|
|
|
|
$writer->open_handle, $events, $options |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
else { |
106
|
0
|
|
|
|
|
0
|
YAML::LibYAML::API::XS::emit_file_events( |
107
|
|
|
|
|
|
|
$writer->output, $events, $options |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
else { |
112
|
6
|
|
|
|
|
267
|
my $out = YAML::LibYAML::API::XS::emit_string_events($events, $options); |
113
|
6
|
|
|
|
|
33
|
$self->writer->write($out); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
6
|
|
|
|
|
104
|
@$events = (); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |