#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "MainLayer.h" // The callback routine static bool handle_output(const char *str, SV* sv) { sv_catpv(sv, str); return TRUE; } MODULE = ActiveState::Scineplex PACKAGE = ActiveState::Scineplex SV * AnnotateXS(buf, lang, outputFormat, parsingStartState, DumpSource, DumpEndState, DumpFoldLevels, StopAfterDataSectionLine1) SV* buf; int lang; int outputFormat; int parsingStartState; int DumpSource; int DumpEndState; bool DumpFoldLevels; int StopAfterDataSectionLine1; CODE: char *bufstr = SvPV_nolen(buf); int expected_len; char *p_Explanation = NULL; bool res = FALSE; expected_len = strlen(bufstr); if (DumpSource || outputFormat != CLASSIC_SCINEPLEX) { expected_len *= 2; } RETVAL = newSV(expected_len); sv_setpvn(RETVAL, "", 0); res = doScineplex(bufstr, lang, !!SvUTF8(buf), FALSE, /* not verbose */ handle_output, (void*)RETVAL, outputFormat, parsingStartState, DumpSource, DumpEndState, DumpFoldLevels, StopAfterDataSectionLine1, DumpFoldLevels, NULL, &p_Explanation); if (!res) { sv_free(RETVAL); if (!p_Explanation) p_Explanation = ""; croak("%s", p_Explanation); } OUTPUT: RETVAL BOOT: #ifdef BOOT_CALL_MAIN_ _main(); #endif