/* * This file was generated automatically by ExtUtils::ParseXS version 2.18 from the * contents of Detector.xs. Do not edit this file, edit Detector.xs instead. * * ANY CHANGES MADE HERE WILL BE LOST! * */ #line 1 "lib/Encode/Detect/Detector.xs" // ***** BEGIN LICENSE BLOCK ***** // Version: MPL 1.1/GPL 2.0/LGPL 2.1 // // The contents of this file are subject to the Mozilla Public License Version // 1.1 (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the // License. // // The Original Code is Encode::Detect wrapper // // The Initial Developer of the Original Code is // Proofpoint, Inc. // Portions created by the Initial Developer are Copyright (C) 2005 // the Initial Developer. All Rights Reserved. // // Contributor(s): // // Alternatively, the contents of this file may be used under the terms of // either the GNU General Public License Version 2 or later (the "GPL"), or // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), // in which case the provisions of the GPL or the LGPL are applicable instead // of those above. If you wish to allow use of your version of this file only // under the terms of either the GPL or the LGPL, and not to allow others to // use your version of this file under the terms of the MPL, indicate your // decision by deleting the provisions above and replace them with the notice // and other provisions required by the GPL or the LGPL. If you do not delete // the provisions above, a recipient may use your version of this file under // the terms of any one of the MPL, the GPL or the LGPL. // // ***** END LICENSE BLOCK ***** extern "C" { #define PERL_NO_GET_CONTEXT /* we want efficiency */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" } #include "nscore.h" #include "nsUniversalDetector.h" class Detector: public nsUniversalDetector { public: Detector() {}; virtual ~Detector() {} const char *getresult() { return mDetectedCharset; } virtual void Reset() { this->nsUniversalDetector::Reset(); } protected: virtual void Report(const char* aCharset) { mDetectedCharset = aCharset; } }; #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(var) if (0) var = var #endif #line 72 "lib/Encode/Detect/Detector.c" XS(XS_Encode__Detect__Detector_new); /* prototype to pass -Wmissing-prototypes */ XS(XS_Encode__Detect__Detector_new) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Encode::Detect::Detector::new", "CLASS"); PERL_UNUSED_VAR(cv); /* -W */ { char * CLASS = (char *)SvPV_nolen(ST(0)); Detector * RETVAL; RETVAL = new Detector(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), CLASS, (void*)RETVAL); } XSRETURN(1); } XS(XS_Encode__Detect__Detector_DESTROY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Encode__Detect__Detector_DESTROY) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Encode::Detect::Detector::DESTROY", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ { Detector * THIS; if (sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG)) { THIS = (Detector *)SvIV((SV*)SvRV( ST(0) )); } else { warn("Encode::Detect::Detector::DESTROY() -- THIS is not a blessed SV reference"); XSRETURN_UNDEF; }; delete THIS; } XSRETURN_EMPTY; } XS(XS_Encode__Detect__Detector_handle); /* prototype to pass -Wmissing-prototypes */ XS(XS_Encode__Detect__Detector_handle) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 2) Perl_croak(aTHX_ "Usage: %s(%s)", "Encode::Detect::Detector::handle", "THIS, buf"); PERL_UNUSED_VAR(cv); /* -W */ { Detector * THIS; int RETVAL; dXSTARG; SV * buf = ST(1); if (sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG)) { THIS = (Detector *)SvIV((SV*)SvRV( ST(0) )); } else { warn("Encode::Detect::Detector::handle() -- THIS is not a blessed SV reference"); XSRETURN_UNDEF; }; #line 71 "lib/Encode/Detect/Detector.xs" STRLEN len; char *ptr = SvPV(buf, len); RETVAL = THIS->HandleData(ptr, len); #line 152 "lib/Encode/Detect/Detector.c" XSprePUSH; PUSHi((IV)RETVAL); } XSRETURN(1); } XS(XS_Encode__Detect__Detector_eof); /* prototype to pass -Wmissing-prototypes */ XS(XS_Encode__Detect__Detector_eof) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Encode::Detect::Detector::eof", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ { Detector * THIS; if (sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG)) { THIS = (Detector *)SvIV((SV*)SvRV( ST(0) )); } else { warn("Encode::Detect::Detector::eof() -- THIS is not a blessed SV reference"); XSRETURN_UNDEF; }; #line 80 "lib/Encode/Detect/Detector.xs" THIS->DataEnd(); #line 181 "lib/Encode/Detect/Detector.c" } XSRETURN_EMPTY; } XS(XS_Encode__Detect__Detector_reset); /* prototype to pass -Wmissing-prototypes */ XS(XS_Encode__Detect__Detector_reset) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Encode::Detect::Detector::reset", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ { Detector * THIS; if (sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG)) { THIS = (Detector *)SvIV((SV*)SvRV( ST(0) )); } else { warn("Encode::Detect::Detector::reset() -- THIS is not a blessed SV reference"); XSRETURN_UNDEF; }; #line 85 "lib/Encode/Detect/Detector.xs" THIS->Reset(); #line 209 "lib/Encode/Detect/Detector.c" } XSRETURN_EMPTY; } XS(XS_Encode__Detect__Detector_getresult); /* prototype to pass -Wmissing-prototypes */ XS(XS_Encode__Detect__Detector_getresult) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Encode::Detect::Detector::getresult", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ { Detector * THIS; const char * RETVAL; dXSTARG; if (sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG)) { THIS = (Detector *)SvIV((SV*)SvRV( ST(0) )); } else { warn("Encode::Detect::Detector::getresult() -- THIS is not a blessed SV reference"); XSRETURN_UNDEF; }; #line 90 "lib/Encode/Detect/Detector.xs" RETVAL = THIS->getresult(); #line 239 "lib/Encode/Detect/Detector.c" sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; } XSRETURN(1); } XS(XS_Encode__Detect__Detector_detect); /* prototype to pass -Wmissing-prototypes */ XS(XS_Encode__Detect__Detector_detect) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Encode::Detect::Detector::detect", "buf"); PERL_UNUSED_VAR(cv); /* -W */ { SV * buf = ST(0); const char * RETVAL; dXSTARG; #line 99 "lib/Encode/Detect/Detector.xs" STRLEN len; char *ptr = SvPV(buf, len); Detector *det = new Detector; det->HandleData(ptr, len); det->DataEnd(); RETVAL = det->getresult(); delete det; #line 270 "lib/Encode/Detect/Detector.c" sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; } XSRETURN(1); } #ifdef __cplusplus extern "C" #endif XS(boot_Encode__Detect__Detector); /* prototype to pass -Wmissing-prototypes */ XS(boot_Encode__Detect__Detector) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif char* file = __FILE__; PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ XS_VERSION_BOOTCHECK ; newXSproto("Encode::Detect::Detector::new", XS_Encode__Detect__Detector_new, file, "$"); newXSproto("Encode::Detect::Detector::DESTROY", XS_Encode__Detect__Detector_DESTROY, file, "$"); newXSproto("Encode::Detect::Detector::handle", XS_Encode__Detect__Detector_handle, file, "$$"); newXSproto("Encode::Detect::Detector::eof", XS_Encode__Detect__Detector_eof, file, "$"); newXSproto("Encode::Detect::Detector::reset", XS_Encode__Detect__Detector_reset, file, "$"); newXSproto("Encode::Detect::Detector::getresult", XS_Encode__Detect__Detector_getresult, file, "$"); newXSproto("Encode::Detect::Detector::detect", XS_Encode__Detect__Detector_detect, file, "$"); XSRETURN_YES; }