File Coverage

blib/lib/ExtUtils/XSpp/Node/Raw.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 35 37 94.5


line stmt bran cond sub pod time code
1             package ExtUtils::XSpp::Node::Raw;
2 21     21   16293 use strict;
  21         39  
  21         717  
3 21     21   112 use warnings;
  21         39  
  21         672  
4 21     21   103 use base 'ExtUtils::XSpp::Node';
  21         37  
  21         857  
5              
6             =head1 NAME
7              
8             ExtUtils::XSpp::Node::Raw - Node for data that should be included in XS verbatim
9              
10             =head1 DESCRIPTION
11              
12             An L subclass representing code that should be included
13             in the output XS code verbatim.
14              
15             =head1 METHODS
16              
17             =head2 new
18              
19             Creates a new C.
20              
21             Named parameters: C should be a reference to
22             an array of source code lines. A trailing newline
23             is automatically appended.
24              
25             =cut
26              
27             sub init {
28 52     52 1 88 my $this = shift;
29 52         138 my %args = @_;
30              
31 52         185 $this->{ROWS} = $args{rows};
32 52         111 $this->{EMIT_CONDITION} = $args{emit_condition};
33 52         76 push @{$this->{ROWS}}, "\n";
  52         198  
34             }
35              
36             =head1 ACCESSORS
37              
38             =head2 rows
39              
40             Returns an array reference holding the rows to be output in the final file.
41              
42             =cut
43              
44 51     51 1 236 sub rows { $_[0]->{ROWS} }
45              
46             sub print {
47 29     29 1 48 my $this = shift;
48 29         46 my $state = shift;
49 29         46 my $out = '';
50              
51 29 50       127 $out .= '#if ' . $this->emit_condition . "\n" if $this->emit_condition;
52 29         44 $out .= join( "\n", @{$this->rows} ) . "\n";
  29         74  
53 29 50       86 $out .= '#endif // ' . $this->emit_condition . "\n" if $this->emit_condition;
54              
55 29         124 return $out;
56             }
57              
58             1;