line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ExtUtils::XSpp::Node::Argument; |
2
|
21
|
|
|
21
|
|
104
|
use strict; |
|
21
|
|
|
|
|
44
|
|
|
21
|
|
|
|
|
647
|
|
3
|
21
|
|
|
21
|
|
123
|
use warnings; |
|
21
|
|
|
|
|
38
|
|
|
21
|
|
|
|
|
572
|
|
4
|
21
|
|
|
21
|
|
102
|
use base 'ExtUtils::XSpp::Node'; |
|
21
|
|
|
|
|
42
|
|
|
21
|
|
|
|
|
1774
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
ExtUtils::XSpp::Node::Argument - Node representing a method/function argument |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
An L subclass representing a single function |
13
|
|
|
|
|
|
|
or method argument such as |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
int foo = 0. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
which would translate to an C which has |
18
|
|
|
|
|
|
|
its C set to C, its C set to C and its C |
19
|
|
|
|
|
|
|
set to C<0.>. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 METHODS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 new |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Creates a new C. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Named parameters: C indicating the C++ argument type, |
28
|
|
|
|
|
|
|
C indicating the variable name, and optionally |
29
|
|
|
|
|
|
|
C indicating the default value of the argument. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 uses_length |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Returns true if the argument uses the XS length feature, false |
34
|
|
|
|
|
|
|
otherwise. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 implementation_name |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Returns the same as the C method unless |
39
|
|
|
|
|
|
|
the argument is of the C<%length(something)> variant. |
40
|
|
|
|
|
|
|
In that case, C returns a |
41
|
|
|
|
|
|
|
munged version of the name that addresses the name mangling |
42
|
|
|
|
|
|
|
done by F: C. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 fix_name_in_code |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Given a code string, replaces any occurrances of |
47
|
|
|
|
|
|
|
the name of this C with its implementation |
48
|
|
|
|
|
|
|
name. If the implementation name is the same as the name, |
49
|
|
|
|
|
|
|
which is the most likely case, the code remains |
50
|
|
|
|
|
|
|
completely untouched. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Returns the potentially modified code. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub init { |
57
|
123
|
|
|
123
|
1
|
197
|
my $this = shift; |
58
|
123
|
|
|
|
|
606
|
my %args = @_; |
59
|
|
|
|
|
|
|
|
60
|
123
|
|
|
|
|
502
|
$this->{TYPE} = $args{type}; |
61
|
123
|
|
|
|
|
323
|
$this->{NAME} = $args{name}; |
62
|
123
|
|
|
|
|
319
|
$this->{DEFAULT} = $args{default}; |
63
|
123
|
|
|
|
|
548
|
$this->{TAGS} = $args{tags}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub print { |
67
|
0
|
|
|
0
|
1
|
0
|
my $this = shift; |
68
|
0
|
|
|
|
|
0
|
my $state = shift; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
0
|
return join( ' ', |
71
|
|
|
|
|
|
|
$this->type->print( $state ), |
72
|
|
|
|
|
|
|
$this->name, |
73
|
|
|
|
|
|
|
( $this->default ? |
74
|
|
|
|
|
|
|
( '=', $this->default ) : () ) ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub uses_length { |
78
|
132
|
|
|
132
|
1
|
469
|
return($_[0]->name =~ /^length\([^\)]+\)/); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub implementation_name { |
82
|
3
|
|
|
3
|
1
|
8
|
my $this = shift; |
83
|
3
|
|
|
|
|
8
|
my $name = $this->name; |
84
|
3
|
50
|
|
|
|
10
|
if ($this->uses_length) { |
85
|
3
|
|
|
|
|
13
|
$name =~ /^length\(([^\)]+)\)/; |
86
|
3
|
|
|
|
|
13
|
return "XSauto_length_of_$1"; |
87
|
|
|
|
|
|
|
} |
88
|
0
|
|
|
|
|
0
|
return $name; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub fix_name_in_code { |
92
|
6
|
|
|
6
|
1
|
11
|
my $this = shift; |
93
|
6
|
|
|
|
|
12
|
my $code = shift; |
94
|
6
|
100
|
|
|
|
15
|
return $code if not $this->uses_length; |
95
|
3
|
|
|
|
|
9
|
my $name = $this->name; |
96
|
3
|
|
|
|
|
11
|
my $impl = $this->implementation_name; |
97
|
3
|
|
|
|
|
71
|
$code =~ s/\b\Q$name\E/$impl/g; |
98
|
3
|
|
|
|
|
20
|
return $code; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 ACCESSORS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 type |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns the type of the argument. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 name |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Returns the variable name of the argument variable. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 default |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Returns the default for the function parameter if any. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 has_default |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Returns whether there is a default for the function parameter. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 function |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns a reference to the containing function/method. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 index |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns the 0-based index of the argument in the argument list. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
114
|
|
|
114
|
1
|
10497
|
sub type { $_[0]->{TYPE} } |
130
|
625
|
|
|
625
|
1
|
3231
|
sub name { $_[0]->{NAME} } |
131
|
114
|
|
|
114
|
0
|
673
|
sub tags { $_[0]->{TAGS} } |
132
|
|
|
|
|
|
|
|
133
|
4
|
|
|
4
|
1
|
16
|
sub default { $_[0]->{DEFAULT} } |
134
|
123
|
|
|
123
|
1
|
566
|
sub has_default { defined $_[0]->{DEFAULT} } |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
1
|
1
|
12
|
sub function { $_[0]->{FUNCTION} } |
137
|
3
|
|
|
3
|
1
|
26
|
sub index { $_[0]->{INDEX} } |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |