File: Destructor.pm

package info (click to toggle)
libextutils-xspp-perl 0.1800-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 996 kB
  • ctags: 1,861
  • sloc: perl: 8,324; cpp: 125; makefile: 2
file content (59 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package ExtUtils::XSpp::Node::Destructor;
use strict;
use warnings;
use base 'ExtUtils::XSpp::Node::Method';

=head1 NAME

ExtUtils::XSpp::Node::Destructor - Node representing a destructor method

=head1 DESCRIPTION

An L<ExtUtils::XSpp::Node::Method> subclass representing a 
destructor such as:

  class FooBar {
    ~FooBar(); // <-- this one
  };

=head1 METHODS

=head2 new

Creates a new C<ExtUtils::XSpp::Node::Destructor>.

Most of the functionality of this class is inherited. This
means that all named parameters of L<ExtUtils::XSpp::Node::Method>
and its base class are also valid for this class' destructor.

Additionally, this class requires that no return type has
been specified as destructors do not have return types.

=cut

sub init {
  my $this = shift;
  $this->SUPER::init( @_ );

  die "Can't specify return value in destructor" if $this->{RET_TYPE};
}

=head2 perl_function_name

Returns the name of the class with C<::DESTROY> appended.

=cut

sub perl_function_name {
  my $this = shift;

  if( $this->perl_name ne $this->cpp_name ) {
    return $this->class->cpp_name . '::' . $this->perl_name;
  } else {
    return $this->class->cpp_name . '::' . 'DESTROY';
  }
}

sub ret_type { undef }

1;