File Coverage

blib/lib/ExtUtils/XSpp/Node.pm
Criterion Covered Total %
statement 15 21 71.4
branch 0 4 0.0
condition n/a
subroutine 6 9 66.6
pod 3 6 50.0
total 24 40 60.0


line stmt bran cond sub pod time code
1             package ExtUtils::XSpp::Node;
2 21     21   23842 use strict;
  21         38  
  21         3180  
3 21     21   2733 use warnings;
  21         39  
  21         2071  
4 21     21   1379 use Carp ();
  21         1259  
  21         5842  
5              
6             =head1 NAME
7              
8             ExtUtils::XSpp::Node - Base class for elements of the parser output
9              
10             =head1 DESCRIPTION
11              
12             ExtUtils::XSpp::Node is a base class for all elements of the
13             parser's output.
14              
15             =head1 METHODS
16              
17             =head2 new
18              
19             Calls the C<$self->init(@_)> method after construction.
20             Override C in subclasses.
21              
22             =cut
23              
24             sub new {
25 3966     3966 1 5305 my $class = shift;
26 3966         13280 my $this = bless {}, $class;
27              
28 3966         12136 $this->init( @_ );
29              
30 3966         10613 return $this;
31             }
32              
33             =head2 init
34              
35             Called by the constructor. Every sub-class needs to override this.
36              
37             =cut
38              
39             sub init {
40 0     0 1 0 Carp::croak(
41             "Programmer was too lazy to implement init() in her Node sub-class"
42             );
43             }
44              
45             =head2 ExtUtils::XSpp::Node::print
46              
47             Return a string to be output in the final XS file.
48             Every sub-class must override this method.
49              
50             =cut
51              
52             sub print {
53 0     0 1 0 Carp::croak(
54             "Programmer was too lazy to implement print() in her Node sub-class"
55             );
56             }
57              
58 30     30 0 113 sub condition { $_[0]->{CONDITION} }
59              
60             sub condition_expression {
61 0     0 0 0 my $this = shift;
62              
63 0 0       0 return $this->emit_condition if $this->emit_condition;
64 0 0       0 return 'defined( ' . $this->condition . ' )' if $this->condition;
65 0         0 return '1';
66             }
67              
68 394     394 0 1470 sub emit_condition { $_[0]->{EMIT_CONDITION} }
69              
70             1;