line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ExtUtils::XSpp::Node::Constructor; |
2
|
21
|
|
|
21
|
|
120
|
use strict; |
|
21
|
|
|
|
|
37
|
|
|
21
|
|
|
|
|
965
|
|
3
|
21
|
|
|
21
|
|
113
|
use warnings; |
|
21
|
|
|
|
|
37
|
|
|
21
|
|
|
|
|
620
|
|
4
|
21
|
|
|
21
|
|
104
|
use base 'ExtUtils::XSpp::Node::Method'; |
|
21
|
|
|
|
|
46
|
|
|
21
|
|
|
|
|
1493
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
ExtUtils::XSpp::Node::Constructor - Node representing a constructor method |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
An L subclass representing a |
13
|
|
|
|
|
|
|
constructor such as: |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
class FooBar { |
16
|
|
|
|
|
|
|
FooBar(); // <-- this one |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 METHODS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 new |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Creates a new C. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Most of the functionality of this class is inherited. This |
26
|
|
|
|
|
|
|
means that all named parameters of L |
27
|
|
|
|
|
|
|
and its base class are also valid for this class' constructor. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Additionally, this class requires that no return type has |
30
|
|
|
|
|
|
|
been specified as constructors do not have return types. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub init { |
35
|
4
|
|
|
4
|
1
|
11
|
my $this = shift; |
36
|
4
|
|
|
|
|
41
|
$this->SUPER::init( @_ ); |
37
|
|
|
|
|
|
|
|
38
|
4
|
50
|
|
|
|
24
|
die "Can't specify return value in constructor" if $this->{RET_TYPE}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub print { |
42
|
4
|
|
|
4
|
1
|
8
|
my $this = shift; |
43
|
4
|
|
|
|
|
9
|
my $state = shift; |
44
|
4
|
|
|
|
|
42
|
my $out = $this->SUPER::print( $state ); |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
48
|
return sprintf <
|
47
|
|
|
|
|
|
|
#undef xsp_constructor_class |
48
|
|
|
|
|
|
|
#define xsp_constructor_class(c) (CLASS) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
%s#undef xsp_constructor_class |
51
|
|
|
|
|
|
|
#define xsp_constructor_class(c) (c) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
EOT |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 ret_type |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Unlike the C method of the L class, |
59
|
|
|
|
|
|
|
C will return the type "pointer to object of this class" |
60
|
|
|
|
|
|
|
as return type of the constructor. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub ret_type { |
65
|
12
|
|
|
12
|
1
|
21
|
my $this = shift; |
66
|
|
|
|
|
|
|
|
67
|
12
|
|
|
|
|
58
|
ExtUtils::XSpp::Node::Type->new( base => $this->class->cpp_name, |
68
|
|
|
|
|
|
|
pointer => 1 ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub perl_function_name { |
72
|
4
|
|
|
4
|
1
|
8
|
my $this = shift; |
73
|
4
|
|
|
|
|
38
|
my( $pname, $cname, $pclass, $cclass ) = ( $this->perl_name, |
74
|
|
|
|
|
|
|
$this->cpp_name, |
75
|
|
|
|
|
|
|
$this->class->perl_name, |
76
|
|
|
|
|
|
|
$this->class->cpp_name ); |
77
|
|
|
|
|
|
|
|
78
|
4
|
100
|
|
|
|
17
|
if( $pname ne $cname ) { |
79
|
3
|
|
|
|
|
14
|
return $cclass . '::' . $pname; |
80
|
|
|
|
|
|
|
} else { |
81
|
1
|
|
|
|
|
5
|
return $cclass . '::' . 'new'; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
4
|
|
|
4
|
|
27
|
sub _call_code { return "new " . $_[0]->class->cpp_name . |
86
|
|
|
|
|
|
|
'(' . $_[1] . ')'; } |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |