line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Emitter for YAML::PP::LibYAML |
2
|
|
|
|
|
|
|
package YAML::PP::LibYAML::Emitter; |
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.004'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use YAML::LibYAML::API::XS; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
9
|
1
|
|
|
1
|
|
6
|
use YAML::PP::Writer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
10
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw/ openhandle /; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
89
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
8
|
use base 'YAML::PP::Emitter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
893
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
2
|
|
|
2
|
1
|
10
|
my ($class, %args) = @_; |
16
|
2
|
|
100
|
|
|
8
|
my $indent = delete $args{indent} || 2; |
17
|
2
|
|
50
|
|
|
9
|
my $width = delete $args{width} || 80; |
18
|
2
|
|
|
|
|
7
|
my $self = bless { |
19
|
|
|
|
|
|
|
indent => $indent, |
20
|
|
|
|
|
|
|
width => $width, |
21
|
|
|
|
|
|
|
}, $class; |
22
|
2
|
50
|
|
|
|
8
|
if (keys %args) { |
23
|
0
|
|
|
|
|
0
|
die "Unexpected arguments: " . join ', ', sort keys %args; |
24
|
|
|
|
|
|
|
} |
25
|
2
|
|
|
|
|
8
|
$self->{events} = []; |
26
|
2
|
|
|
|
|
14
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
41
|
|
|
41
|
0
|
118
|
sub events { return $_[0]->{events} } |
29
|
4
|
|
|
4
|
1
|
11
|
sub indent { return $_[0]->{indent} } |
30
|
4
|
|
|
4
|
0
|
12
|
sub width { return $_[0]->{width} } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub mapping_start_event { |
34
|
5
|
|
|
5
|
1
|
740
|
my ($self, $info) = @_; |
35
|
5
|
|
|
|
|
11
|
$info->{name} = 'mapping_start_event'; |
36
|
5
|
|
|
|
|
7
|
push @{ $self->events }, $info; |
|
5
|
|
|
|
|
11
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub mapping_end_event { |
40
|
5
|
|
|
5
|
1
|
31
|
my ($self, $info) = @_; |
41
|
5
|
|
|
|
|
11
|
$info->{name} = 'mapping_end_event'; |
42
|
5
|
|
|
|
|
6
|
push @{ $self->events }, $info; |
|
5
|
|
|
|
|
11
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub sequence_start_event { |
46
|
0
|
|
|
0
|
1
|
0
|
my ($self, $info) = @_; |
47
|
0
|
|
|
|
|
0
|
$info->{name} = 'sequence_start_event'; |
48
|
0
|
|
|
|
|
0
|
push @{ $self->events }, $info; |
|
0
|
|
|
|
|
0
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub sequence_end_event { |
52
|
0
|
|
|
0
|
1
|
0
|
my ($self, $info) = @_; |
53
|
0
|
|
|
|
|
0
|
$info->{name} = 'sequence_end_event'; |
54
|
0
|
|
|
|
|
0
|
push @{ $self->events }, $info; |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub scalar_event { |
58
|
11
|
|
|
11
|
1
|
971
|
my ($self, $info) = @_; |
59
|
11
|
|
|
|
|
20
|
$info->{name} = 'scalar_event'; |
60
|
11
|
|
|
|
|
15
|
push @{ $self->events }, $info; |
|
11
|
|
|
|
|
19
|
|
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
|
4
|
|
|
4
|
1
|
119
|
my ($self, $info) = @_; |
71
|
4
|
|
|
|
|
7
|
$info->{name} = 'document_start_event'; |
72
|
4
|
|
|
|
|
7
|
push @{ $self->events }, $info; |
|
4
|
|
|
|
|
5
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub document_end_event { |
76
|
4
|
|
|
4
|
1
|
49
|
my ($self, $info) = @_; |
77
|
4
|
|
|
|
|
6
|
$info->{name} = 'document_end_event'; |
78
|
4
|
|
|
|
|
7
|
push @{ $self->events }, $info; |
|
4
|
|
|
|
|
6
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub stream_start_event { |
82
|
4
|
|
|
4
|
1
|
14342
|
my ($self, $info) = @_; |
83
|
4
|
|
|
|
|
9
|
$info->{name} = 'stream_start_event'; |
84
|
4
|
|
|
|
|
8
|
push @{ $self->events }, $info; |
|
4
|
|
|
|
|
8
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub stream_end_event { |
88
|
4
|
|
|
4
|
1
|
23
|
my ($self, $info) = @_; |
89
|
4
|
|
|
|
|
7
|
$info->{name} = 'stream_end_event'; |
90
|
4
|
|
|
|
|
6
|
push @{ $self->events }, $info; |
|
4
|
|
|
|
|
7
|
|
91
|
4
|
|
|
|
|
8
|
my $events = $self->events; |
92
|
4
|
|
|
|
|
21
|
my $writer = $self->writer; |
93
|
4
|
|
|
|
|
21
|
$writer->init(); |
94
|
4
|
|
|
|
|
198
|
my $options = { |
95
|
|
|
|
|
|
|
indent => $self->indent, |
96
|
|
|
|
|
|
|
width => $self->width, |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
4
|
50
|
|
|
|
31
|
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
|
4
|
|
|
|
|
167
|
my $out = YAML::LibYAML::API::XS::emit_string_events($events, $options); |
113
|
4
|
|
|
|
|
22
|
$self->writer->write($out); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
4
|
|
|
|
|
72
|
@$events = (); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |