| 1 | package ExtUtils::XSpp::Node::Method; | ||||||||||
| 2 | 21 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 21 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 21 | ▶ | use base 'ExtUtils::XSpp::Node::Function'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | =head1 NAME | ||||||||||
| 7 | |||||||||||
| 8 | ExtUtils::XSpp::Node::Method - Node representing a method | ||||||||||
| 9 | |||||||||||
| 10 | =head1 DESCRIPTION | ||||||||||
| 11 | |||||||||||
| 12 | An L<ExtUtils::XSpp::Node::Function> sub-class representing a single method | ||||||||||
| 13 | declaration in a class such as | ||||||||||
| 14 | |||||||||||
| 15 | class FooBar { | ||||||||||
| 16 | int foo(double someArgument); // <-- this one | ||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | =head1 METHODS | ||||||||||
| 21 | |||||||||||
| 22 | =head2 new | ||||||||||
| 23 | |||||||||||
| 24 | Creates a new C<ExtUtils::XSpp::Node::Method>. | ||||||||||
| 25 | |||||||||||
| 26 | Most of the functionality of this class is inherited. This | ||||||||||
| 27 | means that all named parameters of L<ExtUtils::XSpp::Node::Function> | ||||||||||
| 28 | are also valid for this class. | ||||||||||
| 29 | |||||||||||
| 30 | Additional named parameters accepted by the constructor: | ||||||||||
| 31 | C<class>, which can be an L<ExtUtils::XSpp::Node::Class> | ||||||||||
| 32 | object, C<const> and C<virtual> that are true if the method has | ||||||||||
| 33 | been declared C<const> or C<virtual>. | ||||||||||
| 34 | |||||||||||
| 35 | =cut | ||||||||||
| 36 | |||||||||||
| 37 | 69 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 38 | 69 | my $this = shift; | |||||||||
| 39 | 69 | my %args = @_; | |||||||||
| 40 | |||||||||||
| 41 | 69 | $this->SUPER::init( %args ); | |||||||||
| 42 | 69 | $this->{CLASS} = $args{class}; | |||||||||
| 43 | 69 | $this->{CONST} = $args{const}; | |||||||||
| 44 | 69 | $this->{VIRTUAL} = $args{virtual}; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | =head2 perl_function_name | ||||||||||
| 48 | |||||||||||
| 49 | Returns the name of the Perl function (method) that this | ||||||||||
| 50 | method represents. It is constructed from the method's | ||||||||||
| 51 | class's name and the C<perl_name> attribute. | ||||||||||
| 52 | |||||||||||
| 53 | =cut | ||||||||||
| 54 | |||||||||||
| 55 | 60 | ▶ | sub perl_function_name { | ||||||||
|
Subroutine
perl_function_name: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 56 | 60 | my( $self ) = @_; | |||||||||
| 57 | |||||||||||
| 58 | 60 | ▶ | if( $self->package_static ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 1 | return $self->perl_name; | |||||||||
| 60 | } else { | ||||||||||
| 61 | 59 | return $self->class->cpp_name . '::' . $self->perl_name; | |||||||||
| 62 | } | ||||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 64 | ▶ | sub _call_code { | ||||||||
|
Subroutine
_call_code: called CC=1 SCAR=0.0
| |||||||||||
| 66 | 64 | my( $self, $arg_string ) = @_; | |||||||||
| 67 | |||||||||||
| 68 | 64 | return $self->_call_code_aliased($self->cpp_name, $arg_string); | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 65 | ▶ | sub _call_code_aliased { | ||||||||
|
Subroutine
_call_code_aliased: called CC=2 SCAR=6.9
| |||||||||||
| 72 | 65 | my( $self, $alias_name, $arg_string ) = @_; | |||||||||
| 73 | |||||||||||
| 74 | 65 | ▶ | if( $self->package_static ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | 1 | return $self->class->cpp_name . '::' . | |||||||||
| 76 | $alias_name . '(' . $arg_string . ')'; | ||||||||||
| 77 | } else { | ||||||||||
| 78 | 64 | return "THIS->" . | |||||||||
| 79 | $alias_name . '(' . $arg_string . ')'; | ||||||||||
| 80 | } | ||||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | =head2 is_method | ||||||||||
| 84 | |||||||||||
| 85 | Returns true, since all objects of this class are methods. | ||||||||||
| 86 | |||||||||||
| 87 | =cut | ||||||||||
| 88 | |||||||||||
| 89 | 111 | ▶ | sub is_method { 1 } | ||||||||
|
Subroutine
is_method: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 90 | |||||||||||
| 91 | =head2 ACCESSORS | ||||||||||
| 92 | |||||||||||
| 93 | =head2 class | ||||||||||
| 94 | |||||||||||
| 95 | Returns the class (L<ExtUtils::XSpp::Node::Class>) that the | ||||||||||
| 96 | method belongs to. | ||||||||||
| 97 | |||||||||||
| 98 | =head2 virtual | ||||||||||
| 99 | |||||||||||
| 100 | Returns whether the method was declared virtual. | ||||||||||
| 101 | |||||||||||
| 102 | =head2 set_virtual | ||||||||||
| 103 | |||||||||||
| 104 | Set whether the method is to be considered virtual. | ||||||||||
| 105 | |||||||||||
| 106 | =head2 const | ||||||||||
| 107 | |||||||||||
| 108 | Returns whether the method was declared const. | ||||||||||
| 109 | |||||||||||
| 110 | =head2 access | ||||||||||
| 111 | |||||||||||
| 112 | Returns C<'public'>, C<'protected'> or C<'private'> depending on | ||||||||||
| 113 | method access declaration. By default, only public methods are | ||||||||||
| 114 | generated. | ||||||||||
| 115 | |||||||||||
| 116 | =cut | ||||||||||
| 117 | |||||||||||
| 118 | 89 | ▶ | sub class { $_[0]->{CLASS} } | ||||||||
|
Subroutine
class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 119 | 0 | ▶ | sub virtual { $_[0]->{VIRTUAL} } | ||||||||
|
Subroutine
virtual: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 120 | 5 | ▶ | sub set_virtual { $_[0]->{VIRTUAL} = $_[1] } | ||||||||
|
Subroutine
set_virtual: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 121 | 0 | ▶ | sub const { $_[0]->{CONST} } | ||||||||
|
Subroutine
const: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 122 | 49 | ▶ | sub access { $_[0]->{ACCESS} } | ||||||||
|
Subroutine
access: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 123 | 0 | ▶ | sub set_access { $_[0]->{ACCESS} = $_[1] } | ||||||||
|
Subroutine
set_access: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 124 | |||||||||||
| 125 | 21 | 1; | |||||||||