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