ExtUtils::XSpp::Node - Base class for elements of the parser output


ExtUtils-XSpp documentation Contained in the ExtUtils-XSpp distribution.

Index


Code Index:

NAME

Top

ExtUtils::XSpp::Node - Base class for elements of the parser output

DESCRIPTION

Top

ExtUtils::XSpp::Node is a base class for all elements of the parser's output.

METHODS

Top

new

Calls the $self-init(@_)> method after construction. Override init() in subclasses.

init

Called by the constructor. Every sub-class needs to override this.

ExtUtils::XSpp::Node::print

Return a string to be output in the final XS file. Every sub-class must override this method.


ExtUtils-XSpp documentation Contained in the ExtUtils-XSpp distribution.
package ExtUtils::XSpp::Node;
use strict;
use warnings;
use Carp ();

sub new {
  my $class = shift;
  my $this = bless {}, $class;

  $this->init( @_ );

  return $this;
}

sub init {
  Carp::croak(
    "Programmer was too lazy to implement init() in her Node sub-class"
  );
}

sub print {
  Carp::croak(
    "Programmer was too lazy to implement print() in her Node sub-class"
  );
}

sub condition { $_[0]->{CONDITION} }

sub condition_expression {
    my $this = shift;

    return $this->emit_condition if $this->emit_condition;
    return 'defined( ' . $this->condition . ' )' if $this->condition;
    return '1';
}

sub emit_condition { $_[0]->{EMIT_CONDITION} }

1;