/*
 * This file was generated automatically by xsubpp version 1.9508 from the
 * contents of Preprocessor.xs. Do not edit this file, edit Preprocessor.xs instead.
 *
 *	ANY CHANGES MADE HERE WILL BE LOST!
 *
 */

#line 1 "Preprocessor.xs"
/*
 * UUID: 8801bb88-f301-11dc-bf6d-00502c05c241
 * Author: Brian M. Ames, bames@apk.net
 * Copyright: Copyright (C) 2008 by Brian M. Ames
 */

#include <string.h>
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "ppport.h"


static SV * startElementHandler = (SV*) NULL;
static SV * endElementHandler = (SV*) NULL;
static SV * characterDataHandler = (SV*) NULL;
static SV * processingInstructionHandler = (SV*) NULL;
static SV * commentHandler = (SV*) NULL;
static SV * startCdataHandler = (SV*) NULL;
static SV * endCdataHandler = (SV*) NULL;
static SV * xmlDeclHandler = (SV*) NULL;

/*
 * Call the start element handler for Common nodes.
 */
void
call_StartElementHandlerCommon(tag, hasChild)
char * tag;
int hasChild;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(tag, 0)));
    XPUSHs(sv_2mortal(newSViv(hasChild)));
    PUTBACK;

    if(startElementHandler != (SV*) NULL)
        call_sv(startElementHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the start element handler for Common nodes.
 */
void
call_StartElementHandlerIdentifier(tag, hasChild, identifier, replaceable)
char * tag;
int hasChild;
char * identifier;
char * replaceable;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(tag, 0)));
    XPUSHs(sv_2mortal(newSViv(hasChild)));
    XPUSHs(sv_2mortal(newSVpv("identifier", 0)));
    XPUSHs(sv_2mortal(newSVpv(identifier, 0)));
    if(strcmp(replaceable,"yes") != 0) {
      XPUSHs(sv_2mortal(newSVpv("replaceable", 0)));
      XPUSHs(sv_2mortal(newSVpv(replaceable, 0)));
    }
    PUTBACK;

    if(startElementHandler != (SV*) NULL)
        call_sv(startElementHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the start element handler for Macro nodes.
 */
void
call_StartElementHandlerMacro(tag, hasChild, identifier)
char * tag;
int hasChild;
char * identifier;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(tag, 0)));
    XPUSHs(sv_2mortal(newSViv(hasChild)));
    XPUSHs(sv_2mortal(newSVpv("identifier", 0)));
    XPUSHs(sv_2mortal(newSVpv(identifier, 0)));
    PUTBACK;

    if(startElementHandler != (SV*) NULL)
        call_sv(startElementHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the start element handler for Text nodes.
 */
void
call_StartElementHandlerText(tag, hasChild, value)
char * tag;
int hasChild;
char * value;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(tag, 0)));
    XPUSHs(sv_2mortal(newSViv(hasChild)));
    XPUSHs(sv_2mortal(newSVpv("value", 0)));
    XPUSHs(sv_2mortal(newSVpv(value, 0)));
    PUTBACK;

    if(startElementHandler != (SV*) NULL)
        call_sv(startElementHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the start element handler for File nodes.
 */
void
call_StartElementHandlerFile(tag, hasChild, path, lines, guarded, guardId, atime, mtime)
char * tag;
int hasChild;
char * path;
int lines;
int guarded;
char * guardId;
char * atime;
char * mtime;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(tag, 0)));
    XPUSHs(sv_2mortal(newSViv(hasChild)));
    XPUSHs(sv_2mortal(newSVpv("path", 0)));
    XPUSHs(sv_2mortal(newSVpv(path, 0)));
    XPUSHs(sv_2mortal(newSVpv("accessTime", 0)));
    XPUSHs(sv_2mortal(newSVpv(atime, 0)));
    XPUSHs(sv_2mortal(newSVpv("modifyTime", 0)));
    XPUSHs(sv_2mortal(newSVpv(mtime, 0)));
    XPUSHs(sv_2mortal(newSVpv("lines", 0)));
    XPUSHs(sv_2mortal(newSViv(lines)));
    XPUSHs(sv_2mortal(newSVpv("guarded", 0)));
    if(guarded != 0) {
      XPUSHs(sv_2mortal(newSVpv("yes", 0)));
      if(guardId != NULL) {
        XPUSHs(sv_2mortal(newSVpv("guardId", 0)));
        XPUSHs(sv_2mortal(newSVpv(guardId, 0)));
      }
    } else {
      XPUSHs(sv_2mortal(newSVpv("no", 0)));
    }
    PUTBACK;

    if(startElementHandler != (SV*) NULL)
        call_sv(startElementHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the start element handler for IncludePath nodes.
 */
void
call_StartElementHandlerIncludePath(tag, hasChild, path, used)
char * tag;
int hasChild;
char * path;
int used;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(tag, 0)));
    XPUSHs(sv_2mortal(newSViv(hasChild)));
    XPUSHs(sv_2mortal(newSVpv("path", 0)));
    XPUSHs(sv_2mortal(newSVpv(path, 0)));
    XPUSHs(sv_2mortal(newSVpv("used", 0)));
    if(used != 0) {
      XPUSHs(sv_2mortal(newSVpv("yes", 0)));
    } else {
      XPUSHs(sv_2mortal(newSVpv("no", 0)));
    }
    PUTBACK;

    if(startElementHandler != (SV*) NULL)
        call_sv(startElementHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the end Element handler.
 */
void
call_EndElementHandler(tag)
char * tag;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(tag, 0)));
    PUTBACK;

    if(endElementHandler != (SV*) NULL)
        call_sv(endElementHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the Character Data handler.
 */
void
call_CharacterDataHandler(string)
char * string;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(string, 0)));
    PUTBACK;

    if(characterDataHandler != (SV*) NULL)
        call_sv(characterDataHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the Processing Instruction handler.
 */
void
call_ProcessingInstructionHandler(target,data)
char * target;
char * data;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(target, 0)));
    XPUSHs(sv_2mortal(newSVpv(data, 0)));
    PUTBACK;

    if(processingInstructionHandler != (SV*) NULL)
        call_sv(processingInstructionHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the character data handler.
 */
void
call_CommentHandler(string)
char * string;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(string, 0)));
    PUTBACK;

    if(commentHandler != (SV*) NULL)
        call_sv(commentHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

/*
 * Call the start CDATA handler.
 */
void
call_StartCdataHandler()
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    PUTBACK;

    if(startCdataHandler != (SV*) NULL)
        call_sv(startCdataHandler, G_DISCARD|G_NOARGS);

    FREETMPS;
    LEAVE;
}


/*
 * Call the end CDATA handler.
 */
void
call_EndCdataHandler()
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    PUTBACK;

    if(endCdataHandler != (SV*) NULL)
        call_sv(endCdataHandler, G_DISCARD|G_NOARGS);

    FREETMPS;
    LEAVE;
}

/*
 * Call the XML Declaration handler.
 */
void
call_XMLDeclHandler(version, encoding, standalone)
char * version;
char * encoding;
char * standalone;
{
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);
    XPUSHs(sv_2mortal(newSVpv(version, 0)));
    XPUSHs(sv_2mortal(newSVpv(encoding, 0)));
    XPUSHs(sv_2mortal(newSVpv(standalone, 0)));
    PUTBACK;

    if(xmlDeclHandler != (SV*) NULL)
        call_sv(xmlDeclHandler, G_DISCARD);

    FREETMPS;
    LEAVE;
}

#line 396 "Preprocessor.c"

XS(XS_Rinchi__CPlusPlus__Preprocessor_ProcessFileArg); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_ProcessFileArg)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::ProcessFileArg(path, args)");
    {
	const char *	path = (const char *)SvPV_nolen(ST(0));
	SV *	args = ST(1);
#line 393 "Preprocessor.xs"
        I32 argc = -1;
        int n;
        AV * av_args;
        char * arg;
        void malloc_argv(int);
        void parse(const char *);
        void add_argv(char *);

        if (SvROK(args)) {
            av_args = (AV *)SvRV(args);
            if  ((SvTYPE(SvRV(args)) == SVt_PVAV)) {
                argc = av_len(av_args);
                malloc_argv(argc+2);
            }
        }
#line 423 "Preprocessor.c"
#line 409 "Preprocessor.xs"
//* Process the file at the given path with the arguments provided. */
        for (n = 0; n <= argc; n++) {
             STRLEN l;
             arg = SvPV(*av_fetch(av_args, n, 0), l);
             add_argv(arg);
        }
        parse(path);
#line 432 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_Rinchi__CPlusPlus__Preprocessor_ProcessFile); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_ProcessFile)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::ProcessFile(path)");
    {
	const char *	path = (const char *)SvPV_nolen(ST(0));
#line 421 "Preprocessor.xs"
//* Process the file at the given path. */
        {
        void parse(const char *path);
        parse(path);
        }
#line 452 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_Rinchi__CPlusPlus__Preprocessor_SetStartElementHandler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_SetStartElementHandler)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::SetStartElementHandler(name)");
    {
	SV *	name = ST(0);
#line 431 "Preprocessor.xs"
//* Set the startElementHandler callback to the supplied method. */
        /* Take a copy of the callback */
        if (startElementHandler == (SV*)NULL) {
            /* First time, so create a new SV */
            startElementHandler = newSVsv(name);
        } else {
            /* Been here before, so overwrite */
            SvSetSV(startElementHandler, name);
        }
#line 476 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_Rinchi__CPlusPlus__Preprocessor_SetEndElementHandler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_SetEndElementHandler)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::SetEndElementHandler(name)");
    {
	SV *	name = ST(0);
#line 445 "Preprocessor.xs"
//* Set the endElementHandler callback to the supplied method. */
        if (endElementHandler == (SV*)NULL) {
            endElementHandler = newSVsv(name);
        } else {
            SvSetSV(endElementHandler, name);
        }
#line 497 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_Rinchi__CPlusPlus__Preprocessor_SetCharacterDataHandler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_SetCharacterDataHandler)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::SetCharacterDataHandler(name)");
    {
	SV *	name = ST(0);
#line 456 "Preprocessor.xs"
//* Set the characterDataHandler callback to the supplied method. */
        if (characterDataHandler == (SV*)NULL) {
            characterDataHandler = newSVsv(name);
        } else {
            SvSetSV(characterDataHandler, name);
        }
#line 518 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_Rinchi__CPlusPlus__Preprocessor_SetProcessingInstructionHandler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_SetProcessingInstructionHandler)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::SetProcessingInstructionHandler(name)");
    {
	SV *	name = ST(0);
#line 467 "Preprocessor.xs"
//* Set the processingInstructionHandler callback to the supplied method. */
        if (processingInstructionHandler == (SV*)NULL) {
            processingInstructionHandler = newSVsv(name);
        } else {
            SvSetSV(processingInstructionHandler, name);
        }
#line 539 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_Rinchi__CPlusPlus__Preprocessor_SetCommentHandler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_SetCommentHandler)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::SetCommentHandler(name)");
    {
	SV *	name = ST(0);
#line 478 "Preprocessor.xs"
//* Set the commentHandler callback to the supplied method. */
        if (commentHandler == (SV*)NULL) {
            commentHandler = newSVsv(name);
        } else {
            SvSetSV(commentHandler, name);
        }
#line 560 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_Rinchi__CPlusPlus__Preprocessor_SetStartCdataHandler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_SetStartCdataHandler)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::SetStartCdataHandler(name)");
    {
	SV *	name = ST(0);
#line 489 "Preprocessor.xs"
//* Set the startCdataHandler callback to the supplied method. */
        if (startCdataHandler == (SV*)NULL) {
            startCdataHandler = newSVsv(name);
        } else {
            SvSetSV(startCdataHandler, name);
        }
#line 581 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_Rinchi__CPlusPlus__Preprocessor_SetEndCdataHandler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_SetEndCdataHandler)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::SetEndCdataHandler(name)");
    {
	SV *	name = ST(0);
#line 500 "Preprocessor.xs"
//* Set the endCdataHandler callback to the supplied method. */
        if (endCdataHandler == (SV*)NULL) {
            endCdataHandler = newSVsv(name);
        } else {
            SvSetSV(endCdataHandler, name);
        }
#line 602 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_Rinchi__CPlusPlus__Preprocessor_SetXMLDeclHandler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Rinchi__CPlusPlus__Preprocessor_SetXMLDeclHandler)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Rinchi::CPlusPlus::Preprocessor::SetXMLDeclHandler(name)");
    {
	SV *	name = ST(0);
#line 511 "Preprocessor.xs"
//* Set the xmlDeclHandler callback to the supplied method. */
        if (xmlDeclHandler == (SV*)NULL) {
            xmlDeclHandler = newSVsv(name);
        } else {
            SvSetSV(xmlDeclHandler, name);
        }
#line 623 "Preprocessor.c"
    }
    XSRETURN_EMPTY;
}

#ifdef __cplusplus
extern "C"
#endif
XS(boot_Rinchi__CPlusPlus__Preprocessor); /* prototype to pass -Wmissing-prototypes */
XS(boot_Rinchi__CPlusPlus__Preprocessor)
{
    dXSARGS;
    char* file = __FILE__;

    XS_VERSION_BOOTCHECK ;

        newXS("Rinchi::CPlusPlus::Preprocessor::ProcessFileArg", XS_Rinchi__CPlusPlus__Preprocessor_ProcessFileArg, file);
        newXS("Rinchi::CPlusPlus::Preprocessor::ProcessFile", XS_Rinchi__CPlusPlus__Preprocessor_ProcessFile, file);
        newXS("Rinchi::CPlusPlus::Preprocessor::SetStartElementHandler", XS_Rinchi__CPlusPlus__Preprocessor_SetStartElementHandler, file);
        newXS("Rinchi::CPlusPlus::Preprocessor::SetEndElementHandler", XS_Rinchi__CPlusPlus__Preprocessor_SetEndElementHandler, file);
        newXS("Rinchi::CPlusPlus::Preprocessor::SetCharacterDataHandler", XS_Rinchi__CPlusPlus__Preprocessor_SetCharacterDataHandler, file);
        newXS("Rinchi::CPlusPlus::Preprocessor::SetProcessingInstructionHandler", XS_Rinchi__CPlusPlus__Preprocessor_SetProcessingInstructionHandler, file);
        newXS("Rinchi::CPlusPlus::Preprocessor::SetCommentHandler", XS_Rinchi__CPlusPlus__Preprocessor_SetCommentHandler, file);
        newXS("Rinchi::CPlusPlus::Preprocessor::SetStartCdataHandler", XS_Rinchi__CPlusPlus__Preprocessor_SetStartCdataHandler, file);
        newXS("Rinchi::CPlusPlus::Preprocessor::SetEndCdataHandler", XS_Rinchi__CPlusPlus__Preprocessor_SetEndCdataHandler, file);
        newXS("Rinchi::CPlusPlus::Preprocessor::SetXMLDeclHandler", XS_Rinchi__CPlusPlus__Preprocessor_SetXMLDeclHandler, file);
    XSRETURN_YES;
}

