File Coverage

blib/lib/ExtUtils/XSpp/Node/Destructor.pm
Criterion Covered Total %
statement 17 17 100.0
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 29 30 96.6


line stmt bran cond sub pod time code
1             package ExtUtils::XSpp::Node::Destructor;
2 21     21   133 use strict;
  21         40  
  21         817  
3 21     21   119 use warnings;
  21         37  
  21         718  
4 21     21   107 use base 'ExtUtils::XSpp::Node::Method';
  21         40  
  21         677  
5              
6             =head1 NAME
7              
8             ExtUtils::XSpp::Node::Destructor - Node representing a destructor method
9              
10             =head1 DESCRIPTION
11              
12             An L subclass representing a
13             destructor 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' destructor.
28              
29             Additionally, this class requires that no return type has
30             been specified as destructors do not have return types.
31              
32             =cut
33              
34             sub init {
35 3     3 1 15 my $this = shift;
36 3         30 $this->SUPER::init( @_ );
37              
38 3 50       24 die "Can't specify return value in destructor" if $this->{RET_TYPE};
39             }
40              
41             =head2 perl_function_name
42              
43             Returns the name of the class with C<::DESTROY> appended.
44              
45             =cut
46              
47             sub perl_function_name {
48 3     3 1 8 my $this = shift;
49              
50 3 100       41 if( $this->perl_name ne $this->cpp_name ) {
51 1         9 return $this->class->cpp_name . '::' . $this->perl_name;
52             } else {
53 2         19 return $this->class->cpp_name . '::' . 'DESTROY';
54             }
55             }
56              
57 6     6 1 19 sub ret_type { undef }
58              
59             1;