line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAML::Old::Dumper::Base; |
2
|
|
|
|
|
|
|
|
3
|
27
|
|
|
27
|
|
147
|
use YAML::Old::Mo; |
|
27
|
|
|
|
|
51
|
|
|
27
|
|
|
|
|
183
|
|
4
|
|
|
|
|
|
|
|
5
|
27
|
|
|
27
|
|
1346
|
use YAML::Old::Node; |
|
27
|
|
|
|
|
62
|
|
|
27
|
|
|
|
|
32864
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# YAML Dumping options |
8
|
|
|
|
|
|
|
has spec_version => default => sub {'1.0'}; |
9
|
|
|
|
|
|
|
has indent_width => default => sub {2}; |
10
|
|
|
|
|
|
|
has use_header => default => sub {1}; |
11
|
|
|
|
|
|
|
has use_version => default => sub {0}; |
12
|
|
|
|
|
|
|
has sort_keys => default => sub {1}; |
13
|
|
|
|
|
|
|
has anchor_prefix => default => sub {''}; |
14
|
|
|
|
|
|
|
has dump_code => default => sub {0}; |
15
|
|
|
|
|
|
|
has use_block => default => sub {0}; |
16
|
|
|
|
|
|
|
has use_fold => default => sub {0}; |
17
|
|
|
|
|
|
|
has compress_series => default => sub {1}; |
18
|
|
|
|
|
|
|
has inline_series => default => sub {0}; |
19
|
|
|
|
|
|
|
has use_aliases => default => sub {1}; |
20
|
|
|
|
|
|
|
has purity => default => sub {0}; |
21
|
|
|
|
|
|
|
has stringify => default => sub {0}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Properties |
24
|
|
|
|
|
|
|
has stream => default => sub {''}; |
25
|
|
|
|
|
|
|
has document => default => sub {0}; |
26
|
|
|
|
|
|
|
has transferred => default => sub {{}}; |
27
|
|
|
|
|
|
|
has id_refcnt => default => sub {{}}; |
28
|
|
|
|
|
|
|
has id_anchor => default => sub {{}}; |
29
|
|
|
|
|
|
|
has anchor => default => sub {1}; |
30
|
|
|
|
|
|
|
has level => default => sub {0}; |
31
|
|
|
|
|
|
|
has offset => default => sub {[]}; |
32
|
|
|
|
|
|
|
has headless => default => sub {0}; |
33
|
|
|
|
|
|
|
has blessed_map => default => sub {{}}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Global Options are an idea taken from Data::Dumper. Really they are just |
36
|
|
|
|
|
|
|
# sugar on top of real OO properties. They make the simple Dump/Load API |
37
|
|
|
|
|
|
|
# easy to configure. |
38
|
|
|
|
|
|
|
sub set_global_options { |
39
|
138
|
|
|
138
|
0
|
255
|
my $self = shift; |
40
|
138
|
50
|
|
|
|
420
|
$self->spec_version($YAML::SpecVersion) |
41
|
|
|
|
|
|
|
if defined $YAML::SpecVersion; |
42
|
138
|
100
|
|
|
|
396
|
$self->indent_width($YAML::Indent) |
43
|
|
|
|
|
|
|
if defined $YAML::Indent; |
44
|
138
|
100
|
|
|
|
401
|
$self->use_header($YAML::UseHeader) |
45
|
|
|
|
|
|
|
if defined $YAML::UseHeader; |
46
|
138
|
50
|
|
|
|
445
|
$self->use_version($YAML::UseVersion) |
47
|
|
|
|
|
|
|
if defined $YAML::UseVersion; |
48
|
138
|
100
|
|
|
|
523
|
$self->sort_keys($YAML::SortKeys) |
49
|
|
|
|
|
|
|
if defined $YAML::SortKeys; |
50
|
138
|
50
|
|
|
|
523
|
$self->anchor_prefix($YAML::AnchorPrefix) |
51
|
|
|
|
|
|
|
if defined $YAML::AnchorPrefix; |
52
|
138
|
100
|
66
|
|
|
965
|
$self->dump_code($YAML::DumpCode || $YAML::UseCode) |
|
|
|
100
|
|
|
|
|
53
|
|
|
|
|
|
|
if defined $YAML::DumpCode or defined $YAML::UseCode; |
54
|
138
|
100
|
|
|
|
362
|
$self->use_block($YAML::UseBlock) |
55
|
|
|
|
|
|
|
if defined $YAML::UseBlock; |
56
|
138
|
50
|
|
|
|
352
|
$self->use_fold($YAML::UseFold) |
57
|
|
|
|
|
|
|
if defined $YAML::UseFold; |
58
|
138
|
100
|
|
|
|
350
|
$self->compress_series($YAML::CompressSeries) |
59
|
|
|
|
|
|
|
if defined $YAML::CompressSeries; |
60
|
138
|
100
|
|
|
|
431
|
$self->inline_series($YAML::InlineSeries) |
61
|
|
|
|
|
|
|
if defined $YAML::InlineSeries; |
62
|
138
|
100
|
|
|
|
490
|
$self->use_aliases($YAML::UseAliases) |
63
|
|
|
|
|
|
|
if defined $YAML::UseAliases; |
64
|
138
|
50
|
|
|
|
334
|
$self->purity($YAML::Purity) |
65
|
|
|
|
|
|
|
if defined $YAML::Purity; |
66
|
138
|
100
|
|
|
|
495
|
$self->stringify($YAML::Stringify) |
67
|
|
|
|
|
|
|
if defined $YAML::Stringify; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub dump { |
71
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
72
|
0
|
|
|
|
|
0
|
$self->die('dump() not implemented in this class.'); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub blessed { |
76
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
77
|
1
|
|
|
|
|
2
|
my ($ref) = @_; |
78
|
1
|
50
|
|
|
|
5
|
$ref = \$_[0] unless ref $ref; |
79
|
1
|
|
|
|
|
4
|
my (undef, undef, $node_id) = YAML::Old::Mo::Object->node_info($ref); |
80
|
1
|
|
|
|
|
27
|
$self->{blessed_map}->{$node_id}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub bless { |
84
|
4
|
|
|
4
|
0
|
7
|
my $self = shift; |
85
|
4
|
|
|
|
|
7
|
my ($ref, $blessing) = @_; |
86
|
4
|
|
|
|
|
5
|
my $ynode; |
87
|
4
|
50
|
|
|
|
13
|
$ref = \$_[0] unless ref $ref; |
88
|
4
|
|
|
|
|
16
|
my (undef, undef, $node_id) = YAML::Old::Mo::Object->node_info($ref); |
89
|
4
|
100
|
|
|
|
16
|
if (not defined $blessing) { |
|
|
100
|
|
|
|
|
|
90
|
2
|
|
|
|
|
9
|
$ynode = YAML::Old::Node->new($ref); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
elsif (ref $blessing) { |
93
|
1
|
50
|
|
|
|
3
|
$self->die() unless ynode($blessing); |
94
|
1
|
|
|
|
|
2
|
$ynode = $blessing; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
else { |
97
|
27
|
|
|
27
|
|
208
|
no strict 'refs'; |
|
27
|
|
|
|
|
68
|
|
|
27
|
|
|
|
|
12940
|
|
98
|
1
|
|
|
|
|
3
|
my $transfer = $blessing . "::yaml_dump"; |
99
|
1
|
50
|
|
|
|
2
|
$self->die() unless defined &{$transfer}; |
|
1
|
|
|
|
|
5
|
|
100
|
1
|
|
|
|
|
2
|
$ynode = &{$transfer}($ref); |
|
1
|
|
|
|
|
27
|
|
101
|
1
|
50
|
|
|
|
6
|
$self->die() unless ynode($ynode); |
102
|
|
|
|
|
|
|
} |
103
|
4
|
|
|
|
|
14
|
$self->{blessed_map}->{$node_id} = $ynode; |
104
|
4
|
50
|
|
|
|
10
|
my $object = ynode($ynode) or $self->die(); |
105
|
4
|
|
|
|
|
66
|
return $object; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |