Modified: xerces/c/trunk/swig/perl/Handler/Makefile.PL URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Handler/Makefile.PL?view=diff&rev=442160&r1=442159&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Handler/Makefile.PL (original) +++ xerces/c/trunk/swig/perl/Handler/Makefile.PL Mon Sep 11 03:08:07 2006 @@ -26,24 +26,3 @@ @LDFLAGS, ); -__END__ -sub MY::static -{ - ' -static :: libhandler$(LIB_EXT) - -dynamic :: static - -libhandler$(LIB_EXT): $(O_FILES) $(MYEXTLIB) - $(AR) cru libhandler$(LIB_EXT) $(O_FILES) - $(RANLIB) libhandler$(LIB_EXT) - -libhandler.$(DLEXT): $(LDFROM) $(MYEXTLIB) - $(LD) -o libhandler.$(DLEXT) $(LDDLFLAGS) --whole-archive $(LDFROM) $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST) - $(CHMOD) 755 libhandler.$(DLEXT) - -'; - -} - -
Modified: xerces/c/trunk/swig/perl/Handler/PerlCallbackHandler.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Handler/PerlCallbackHandler.cpp?view=diff&rev=442160&r1=442159&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Handler/PerlCallbackHandler.cpp (original) +++ xerces/c/trunk/swig/perl/Handler/PerlCallbackHandler.cpp Mon Sep 11 03:08:07 2006 @@ -17,36 +17,24 @@ #include <stdlib.h> #include "PerlCallbackHandler.hpp" -XMLTranscoder* UTF8_TRANSCODER = NULL; - PerlCallbackHandler::PerlCallbackHandler() { - if (UTF8_TRANSCODER == NULL) - { - XMLTransService::Codes failReason; - XMLCh* UTF8_ENCODING = XMLString::transcode("UTF-8"); - UTF8_TRANSCODER = - XMLPlatformUtils::fgTransService->makeNewTranscoderFor(UTF8_ENCODING, - failReason, - 1024, - XMLPlatformUtils::fgMemoryManager); - if (UTF8_TRANSCODER == NULL) { - croak("ERROR: PerlCallbackHandler Could not create UTF-8 transcoder"); - } - } - callbackObj = NULL; -// printf("PerlCallback: constructor"); + // fprintf(stderr,"PerlCallback: constructor\n"); + UTF8_TRANSCODER = Transcoder::getInstance(); + callbackObj = NULL; } PerlCallbackHandler::~PerlCallbackHandler() { - if (callbackObj) { - SvREFCNT_dec(callbackObj); - callbackObj = NULL; - } -// printf("PerlCallback: destructor"); + if (callbackObj) { + SvREFCNT_dec(callbackObj); + callbackObj = NULL; + } + if (UTF8_TRANSCODER) { + UTF8_TRANSCODER = NULL; + } + // fprintf(stderr,"PerlCallback: destructor\n"); } PerlCallbackHandler::PerlCallbackHandler(SV* object) - : callbackObj(NULL) { set_callback_obj(object); } @@ -71,31 +59,4 @@ callbackObj = object; // printf("<new callback object 0x%.4X>\n", callbackObj); return oldRef; -} - -SV* -PerlCallbackHandler::XMLString2Perl(const XMLCh* input) { - SV *output; - unsigned int charsEaten = 0; - int length = XMLString::stringLen(input); // string length - // use +1 to make room for the '\0' at the end of the string - // in the pathological case when each character of the string - // is UTF8_MAXLEN bytes long - XMLByte* res = new XMLByte[(length * UTF8_MAXLEN) + 1]; // output string - - unsigned int total_chars = - UTF8_TRANSCODER->transcodeTo((const XMLCh*) input, - (unsigned int) length, - (XMLByte*) res, - (unsigned int) (length*UTF8_MAXLEN), - charsEaten, - XMLTranscoder::UnRep_Throw - ); - res[total_chars] = '\0'; - - output = sv_newmortal(); - sv_setpv((SV*)output, (char *)res ); - SvUTF8_on((SV*)output); - delete[] res; - return output; } Modified: xerces/c/trunk/swig/perl/Handler/PerlCallbackHandler.hpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Handler/PerlCallbackHandler.hpp?view=diff&rev=442160&r1=442159&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Handler/PerlCallbackHandler.hpp (original) +++ xerces/c/trunk/swig/perl/Handler/PerlCallbackHandler.hpp Mon Sep 11 03:08:07 2006 @@ -17,13 +17,14 @@ #ifndef __PERLCALLBACKHANDLER #define __PERLCALLBACKHANDLER -#ifdef __cplusplus + /* Needed on some windows machines---since MS plays funny games with the header files under C++ */ #include <math.h> #include <stdlib.h> + extern "C" { -#endif + #include "EXTERN.h" #include "perl.h" #include "XSUB.h" @@ -33,9 +34,7 @@ #undef malloc #include <string.h> -#ifdef __cplusplus } -#endif #if !defined(PERL_REVISION) || ((PERL_REVISION >= 5) && ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 50)))) #ifndef PL_sv_yes @@ -56,9 +55,8 @@ #define PERLCALLBACKHANDLER_CONTENT_TYPE 3 #define PERLCALLBACKHANDLER_DOCUMENT_TYPE 4 -#include "xercesc/util/TransService.hpp" -#include "xercesc/util/XMLString.hpp" #include "xercesc/util/PlatformUtils.hpp" +#include "Transcoder.hpp" XERCES_CPP_NAMESPACE_USE @@ -70,7 +68,8 @@ protected: - SV *callbackObj; + SV *callbackObj; + Transcoder* UTF8_TRANSCODER; public: @@ -80,7 +79,6 @@ virtual int type() {return PERLCALLBACKHANDLER_BASE_TYPE;} SV* set_callback_obj(SV*); - SV* XMLString2Perl(const XMLCh*); }; #endif /* __PERLCALLBACKHANDLER */ Modified: xerces/c/trunk/swig/perl/Handler/PerlContentCallbackHandler.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Handler/PerlContentCallbackHandler.cpp?view=diff&rev=442160&r1=442159&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Handler/PerlContentCallbackHandler.cpp (original) +++ xerces/c/trunk/swig/perl/Handler/PerlContentCallbackHandler.cpp Mon Sep 11 03:08:07 2006 @@ -26,22 +26,9 @@ {} PerlContentCallbackHandler::PerlContentCallbackHandler(SV *obj) - : PerlCallbackHandler(obj) -{} - -// SV* -// PerlContentCallbackHandler::set_callback_obj(SV* object) { -// SV *oldRef = &PL_sv_undef; // default to 'undef' -// if (callbackObj != NULL) { -// oldRef = callbackObj; -// #if defined(PERL_VERSION) && PERL_VERSION >= 8 -// // SvREFCNT_dec(oldRef); -// #endif -// } -// SvREFCNT_inc(object); -// callbackObj = object; -// return oldRef; -// } +{ + set_callback_obj(obj); +} void PerlContentCallbackHandler::startElement(const XMLCh* const uri, @@ -61,15 +48,15 @@ XPUSHs(callbackObj); // the next argument is the uri - SV *string1 = XMLString2Perl(uri); + SV *string1 = UTF8_TRANSCODER->XMLString2Perl(uri); XPUSHs(string1); // the next argument is the localname - SV *string2 = XMLString2Perl(localname); + SV *string2 = UTF8_TRANSCODER->XMLString2Perl(localname); XPUSHs(string2); // the next argument is the qname - SV *string3 = XMLString2Perl(qname); + SV *string3 = UTF8_TRANSCODER->XMLString2Perl(qname); XPUSHs(string3); // next is the attributes @@ -102,15 +89,15 @@ XPUSHs(callbackObj); // the next argument is the uri - SV *string1 = XMLString2Perl(uri); + SV *string1 = UTF8_TRANSCODER->XMLString2Perl(uri); XPUSHs(string1); // the next argument is the localname - SV *string2 = XMLString2Perl(localname); + SV *string2 = UTF8_TRANSCODER->XMLString2Perl(localname); XPUSHs(string2); // the next argument is the qname - SV *string3 = XMLString2Perl(qname); + SV *string3 = UTF8_TRANSCODER->XMLString2Perl(qname); XPUSHs(string3); PUTBACK; @@ -137,7 +124,7 @@ XPUSHs(callbackObj); // the next argument is the char data - SV *string = XMLString2Perl(chars); + SV *string = UTF8_TRANSCODER->XMLString2Perl(chars); XPUSHs(string); // next is the length @@ -166,7 +153,7 @@ XPUSHs(callbackObj); // the next argument is the char data - SV *string = XMLString2Perl(chars); + SV *string = UTF8_TRANSCODER->XMLString2Perl(chars); XPUSHs(string); // next is the length @@ -264,11 +251,11 @@ XPUSHs(callbackObj); // the next argument is the target - SV *string1 = XMLString2Perl(target); + SV *string1 = UTF8_TRANSCODER->XMLString2Perl(target); XPUSHs(string1); // the next argument is the data - SV *string2 = XMLString2Perl(data); + SV *string2 = UTF8_TRANSCODER->XMLString2Perl(data); XPUSHs(string2); PUTBACK; @@ -323,11 +310,11 @@ XPUSHs(callbackObj); // the next argument is the prefix - SV *string1 = XMLString2Perl(prefix); + SV *string1 = UTF8_TRANSCODER->XMLString2Perl(prefix); XPUSHs(string1); // the next argument is the uri - SV *string2 = XMLString2Perl(uri); + SV *string2 = UTF8_TRANSCODER->XMLString2Perl(uri); XPUSHs(string2); PUTBACK; @@ -353,7 +340,7 @@ XPUSHs(callbackObj); // the next argument is the prefix - SV *string1 = XMLString2Perl(prefix); + SV *string1 = UTF8_TRANSCODER->XMLString2Perl(prefix); XPUSHs(string1); PUTBACK; @@ -379,7 +366,7 @@ XPUSHs(callbackObj); // the next argument is the name - SV *string1 = XMLString2Perl(name); + SV *string1 = UTF8_TRANSCODER->XMLString2Perl(name); XPUSHs(string1); PUTBACK; Modified: xerces/c/trunk/swig/perl/Handler/PerlDocumentCallbackHandler.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Handler/PerlDocumentCallbackHandler.cpp?view=diff&rev=442160&r1=442159&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Handler/PerlDocumentCallbackHandler.cpp (original) +++ xerces/c/trunk/swig/perl/Handler/PerlDocumentCallbackHandler.cpp Mon Sep 11 03:08:07 2006 @@ -23,12 +23,7 @@ } PerlDocumentCallbackHandler::~PerlDocumentCallbackHandler() -{ - if (callbackObj != NULL) { - SvREFCNT_dec(callbackObj); - callbackObj = NULL; - } -} +{} PerlDocumentCallbackHandler::PerlDocumentCallbackHandler(SV *obj) { @@ -64,7 +59,7 @@ XPUSHs(callbackObj); // the next argument is the element name - SV *string = XMLString2Perl(name); + SV *string = UTF8_TRANSCODER->XMLString2Perl(name); XPUSHs(string); // next is the attribute list @@ -96,7 +91,7 @@ XPUSHs(callbackObj); // the next argument is the element name - SV *string = XMLString2Perl(name); + SV *string = UTF8_TRANSCODER->XMLString2Perl(name); XPUSHs(string); PUTBACK; @@ -123,7 +118,7 @@ XPUSHs(callbackObj); // the next argument is the char data - SV *string = XMLString2Perl(chars); + SV *string = UTF8_TRANSCODER->XMLString2Perl(chars); XPUSHs(string); // next is the length @@ -152,7 +147,7 @@ XPUSHs(callbackObj); // the next argument is the element name - SV *string = XMLString2Perl(chars); + SV *string = UTF8_TRANSCODER->XMLString2Perl(chars); XPUSHs(string); // next is the length @@ -250,11 +245,11 @@ XPUSHs(callbackObj); // the next argument is the target - SV *string1 = XMLString2Perl(target); + SV *string1 = UTF8_TRANSCODER->XMLString2Perl(target); XPUSHs(string1); // the next argument is the data - SV *string2 = XMLString2Perl(data); + SV *string2 = UTF8_TRANSCODER->XMLString2Perl(data); XPUSHs(string2); PUTBACK; Copied: xerces/c/trunk/swig/perl/Handler/PerlEntityResolverHandler.cpp (from r437653, xerces/c/trunk/swig/perl/Handler/PerlEntityResolverHandler.i) URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Handler/PerlEntityResolverHandler.cpp?view=diff&rev=442160&p1=xerces/c/trunk/swig/perl/Handler/PerlEntityResolverHandler.i&r1=437653&p2=xerces/c/trunk/swig/perl/Handler/PerlEntityResolverHandler.cpp&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Handler/PerlEntityResolverHandler.i (original) +++ xerces/c/trunk/swig/perl/Handler/PerlEntityResolverHandler.cpp Mon Sep 11 03:08:07 2006 @@ -16,6 +16,7 @@ #include "xercesc/sax/InputSource.hpp" #include "PerlEntityResolverHandler.hpp" +#include "xerces-swig-perl.hpp" PerlEntityResolverHandler::PerlEntityResolverHandler() { @@ -23,12 +24,7 @@ } PerlEntityResolverHandler::~PerlEntityResolverHandler() -{ - if (callbackObj != NULL) { - SvREFCNT_dec(callbackObj); - callbackObj = NULL; - } -} +{} PerlEntityResolverHandler::PerlEntityResolverHandler(SV *obj) { @@ -41,20 +37,6 @@ set_callback_obj(obj); } -// SV* -// PerlEntityResolverHandler::set_callback_obj(SV* object) { -// SV *oldRef = &PL_sv_undef; // default to 'undef' -// if (callbackObj != NULL) { -// oldRef = callbackObj; -// #if defined(PERL_VERSION) && PERL_VERSION >= 8 -// // SvREFCNT_dec(oldRef); -// #endif -// } -// SvREFCNT_inc(object); -// callbackObj = object; -// return oldRef; -// } - InputSource * PerlEntityResolverHandler::resolveEntity (const XMLCh* const publicId, const XMLCh* const systemId) @@ -66,6 +48,7 @@ dSP; InputSource *source; + char *isName = "XML::Xerces::InputSource"; ENTER; SAVETMPS; @@ -75,11 +58,11 @@ XPUSHs(callbackObj); // the next argument is the publicId - SV *string1 = XMLString2Perl(publicId); + SV *string1 = UTF8_TRANSCODER->XMLString2Perl(publicId); XPUSHs(string1); // the next argument is the systemId - SV *string2 = XMLString2Perl(systemId); + SV *string2 = UTF8_TRANSCODER->XMLString2Perl(systemId); XPUSHs(string2); PUTBACK; @@ -99,13 +82,16 @@ source_sv = POPs; } - if (count == 1 && SvOK(source_sv) && !sv_derived_from(source_sv,"XML::Xerces::InputSource")) { + if (count == 1 + && SvOK(source_sv) + && !sv_derived_from(source_sv, isName)) { croak("EntityResolver did not return an InputSource\n") ; } - if (SWIG_ConvertPtr(source_sv,(void **) &source, SWIGTYPE_p_XERCES_CPP_NAMESPACE__InputSource,0) < 0) { - - croak("EntityResolver did not return an InputSource. Expected %s", SWIGTYPE_p_XERCES_CPP_NAMESPACE__InputSource->name); + // god bless John Lenz's new type system in SWIG 1.3.25!!! + swig_type_info *isType = SWIG_TypeQuery(isName); + if (SWIG_ConvertPtr(source_sv,(void **) &source, isType, 0) < 0) { + croak("EntityResolver did not return an InputSource. Expected %s", isName); } PUTBACK ; FREETMPS; Modified: xerces/c/trunk/swig/perl/Handler/PerlErrorCallbackHandler.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Handler/PerlErrorCallbackHandler.cpp?view=diff&rev=442160&r1=442159&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Handler/PerlErrorCallbackHandler.cpp (original) +++ xerces/c/trunk/swig/perl/Handler/PerlErrorCallbackHandler.cpp Mon Sep 11 03:08:07 2006 @@ -23,31 +23,12 @@ } PerlErrorCallbackHandler::~PerlErrorCallbackHandler() -{ - if (callbackObj != NULL) { - SvREFCNT_dec(callbackObj); - callbackObj = NULL; - } -} +{} PerlErrorCallbackHandler::PerlErrorCallbackHandler(SV *obj) { set_callback_obj(obj); } - -// SV* -// PerlErrorCallbackHandler::set_callback_obj(SV* object) { -// SV *oldRef = &PL_sv_undef; // default to 'undef' -// if (callbackObj != NULL) { -// oldRef = callbackObj; -// #if defined(PERL_VERSION) && PERL_VERSION >= 8 -// // SvREFCNT_dec(oldRef); -// #endif -// } -// SvREFCNT_inc(object); -// callbackObj = object; -// return oldRef; -// } void PerlErrorCallbackHandler::warning(const SAXParseException& exception) { Copied: xerces/c/trunk/swig/perl/Handler/PerlNodeFilterCallbackHandler.cpp (from r437653, xerces/c/trunk/swig/perl/Handler/PerlNodeFilterCallbackHandler.i) URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Handler/PerlNodeFilterCallbackHandler.cpp?view=diff&rev=442160&p1=xerces/c/trunk/swig/perl/Handler/PerlNodeFilterCallbackHandler.i&r1=437653&p2=xerces/c/trunk/swig/perl/Handler/PerlNodeFilterCallbackHandler.cpp&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Handler/PerlNodeFilterCallbackHandler.i (original) +++ xerces/c/trunk/swig/perl/Handler/PerlNodeFilterCallbackHandler.cpp Mon Sep 11 03:08:07 2006 @@ -15,6 +15,7 @@ */ #include "PerlNodeFilterCallbackHandler.hpp" +#include "xerces-swig-perl.hpp" PerlNodeFilterCallbackHandler::PerlNodeFilterCallbackHandler() { @@ -22,32 +23,13 @@ } PerlNodeFilterCallbackHandler::~PerlNodeFilterCallbackHandler() -{ - if (callbackObj != NULL) { - SvREFCNT_dec(callbackObj); - callbackObj = NULL; - } -} +{} PerlNodeFilterCallbackHandler::PerlNodeFilterCallbackHandler(SV *obj) { set_callback_obj(obj); } -// SV* -// PerlNodeFilterCallbackHandler::set_callback_obj(SV* object) { -// SV *oldRef = &PL_sv_undef; // default to 'undef' -// if (callbackObj != NULL) { -// oldRef = callbackObj; -// #if defined(PERL_VERSION) && PERL_VERSION >= 8 -// // SvREFCNT_dec(oldRef); -// #endif -// } -// SvREFCNT_inc(object); -// callbackObj = object; -// return oldRef; -// } - short PerlNodeFilterCallbackHandler::acceptNode (const DOMNode* node) const { @@ -56,6 +38,7 @@ return 0; } short accept = 0; + char *domNodeName = "XML::Xerces::DOMNode"; dSP; @@ -66,8 +49,10 @@ // first put the callback object on the stack XPUSHs(callbackObj); - // the only argument is the node - swig_type_info *ty = SWIG_TypeDynamicCast(SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, (void **) &node); + // the only argument is the node + // god bless John Lenz's new type system in SWIG 1.3.25!!! + swig_type_info *domNodeType = SWIG_TypeQuery(domNodeName); + swig_type_info *ty = SWIG_TypeDynamicCast(domNodeType, (void **) &node); SV* node_sv = sv_newmortal(); SWIG_MakePtr(node_sv, (void *) node, ty,0); XPUSHs(node_sv); Modified: xerces/c/trunk/swig/perl/Makefile.PL URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Makefile.PL?view=diff&rev=442160&r1=442159&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Makefile.PL (original) +++ xerces/c/trunk/swig/perl/Makefile.PL Mon Sep 11 03:08:07 2006 @@ -19,7 +19,11 @@ XERCES_DEVEL SWIG); use strict; -use vars qw($INCLUDES $CXX $CFLAGS @LDFLAGS @OPTIMIZE); +use vars qw($INCLUDES $CXX $CFLAGS @LDFLAGS @OPTIMIZE $LIBS + $TRANSCODER_LIB $HANDLER_LIB + $XERCESCROOT $SWIG_DIR $PERL_DIR $HANDLER_DIR $SCRIPTS_DIR $INTERFACE_DIR + $SWIG_ARGS + ); use File::Basename; use Cwd qw(abs_path); @@ -48,7 +52,7 @@ ERROR } -my $XERCESCROOT = abs_path('../..'); +$XERCESCROOT = abs_path('../..'); my $XERCES_INCLUDE = "$XERCESCROOT/src"; my $XERCES_LIB = "$XERCESCROOT/obj/.libs"; unless (-d $XERCES_LIB) { @@ -57,9 +61,15 @@ die "Error building Xerces-C\n$!" if $?; } -my $LIBS = '-lpthread'; +$SWIG_DIR = "$XERCESCROOT/swig"; +$PERL_DIR = "$SWIG_DIR/perl"; +$HANDLER_DIR = "$PERL_DIR/Handler"; +$INTERFACE_DIR = "$SWIG_DIR/interfaces"; +$SCRIPTS_DIR = "$SWIG_DIR/scripts"; -$INCLUDES = '-I. -IHandler'; +$LIBS = '-lpthread'; + +$INCLUDES = "-I$PERL_DIR -I$PERL_DIR/Handler -I$PERL_DIR/Transcoder"; print STDERR "Using XERCES_LIB = $XERCES_LIB\n"; $LIBS .= " -L$XERCES_LIB "; @@ -198,13 +208,17 @@ print STDERR "Successfully located $libxerces_name!!\n"; -my $HANDLER_LIB = '$(INST_ARCHLIB)/auto/Handler/Handler$(LIB_EXT)'; +$HANDLER_LIB = '$(INST_ARCHLIB)/auto/Handler/Handler$(LIB_EXT)'; +$TRANSCODER_LIB = '$(INST_ARCHLIB)/auto/Transcoder/Transcoder$(LIB_EXT)'; sub MY_postamble { qq[ $HANDLER_LIB: \$(MAKE) -C Handler static + +$TRANSCODER_LIB: + \$(MAKE) -C Transcoder static ]; } @@ -213,9 +227,6 @@ my @MACRO; $CFLAGS .= '-D_REENTRANT'; -my $HANDLER_DIR = 'Handler'; -my $INTERFACE_DIR = '../interfaces'; -my $SCRIPTS_DIR = '../scripts'; # we only consider using SWIG if we are a Xerces Developer if ($XERCES_DEVEL) { # replace this with the path to your Unix compatible find application @@ -230,43 +241,31 @@ chomp(@handler_headers = `$FIND $HANDLER_DIR -name "*.swig.hpp"`); @OPTIMIZE = (OPTIMIZE => '-g'); + $SWIG_ARGS = qq[-Wall -DXERCES_VERSION="$XERCES_PERL_VERSION" \$(INC) -perl5 -c++ -shadow]; + sub Xerces_postamble { chomp(my @import_files = `$FIND $HANDLER_DIR -name "*.i"`); push(@header_files,@handler_headers,@import_files); chomp(my @interface_files = `$FIND $INTERFACE_DIR -name "*.i"`); - @interface_files = grep {$_ !~ /shadow\.i/} @interface_files; - @dom_interface_files = grep {$_ =~ /dom/} @interface_files; - @non_dom_interface_files = grep {$_ !~ /dom/} @interface_files; + @interface_files = grep {$_ !~ /shadow/} @interface_files; + @dom_interface_files = grep {$_ =~ /dom/i} @interface_files; + @non_dom_interface_files = grep {$_ !~ /dom/i} @interface_files; local $" = ' '; - my $OS_DEF; - my $CC_DEF; - if ($^O eq 'linux') { - $OS_DEF = '-DXML_LINUX'; - } elsif($^O eq 'darwin') { - $OS_DEF = '-DXML_MACOSX'; - } else { - die 'unsupported operating system'; - } - if ($CXX =~ /g\+\+/) { - $CC_DEF = '-DXML_GCC'; - } else { - die 'unsupported compiler'; - } - my $SWIG_ARGS = qq[-Wall $OS_DEF $CC_DEF -DXERCES_VERSION="$XERCES_PERL_VERSION" \$(INC) -perl5 -c++ -shadow]; - my $MAKE = ' \$(MAKE) -C Handler static'; + my $MAKE_HANDLER = ' \$(MAKE) -C Handler static'; + my $MAKE_TRANSCODER = ' \$(MAKE) -C Transcoder static'; if ($^O eq 'MSWin32') { # nmake doesn't not honor '-C' - $MAKE = ' cd Handler && \$(MAKE) static'; + $MAKE_HANDLER = ' cd Handler && \$(MAKE) static'; + $MAKE_TRANSCODER = ' cd Transcoder && \$(MAKE) static'; } ### We no longer need to munge the C++ code thanks to SWIG improvements # perl postSource.pl Xerces.cpp my $retval = <<TERMINUS; Xerces-tmp.pm: $SCRIPTS_DIR/postModule.pl $INTERFACE_DIR/Perl/shadow.i - \$(SWIG) $SWIG_ARGS -o Xerces-tmp.cpp $INTERFACE_DIR/Xerces.i - mv Xerces.pm Xerces-tmp.pm + \$(SWIG) $SWIG_ARGS -o Xerces-tmp.cpp -pm Xerces-tmp.pm $INTERFACE_DIR/Xerces.i Xerces.pm: $SCRIPTS_DIR/postModule.pl Xerces-tmp.pm perl -I$SCRIPTS_DIR $SCRIPTS_DIR/postModule.pl --in=Xerces-tmp.pm --out=Xerces.pm @@ -274,19 +273,22 @@ Xerces.cpp: $SCRIPTS_DIR/postSource.pl Xerces-tmp.cpp perl -I$SCRIPTS_DIR $SCRIPTS_DIR/postSource.pl --in=Xerces-tmp.cpp --out=Xerces.cpp -Xerces-tmp.cpp: $INTERFACE_DIR/Xerces.i @interface_files @header_files $INTERFACE_DIR/Perl/Xerces-extra.pm - \$(SWIG) $SWIG_ARGS -o Xerces-tmp.cpp $INTERFACE_DIR/Xerces.i - mv Xerces.pm Xerces-tmp.pm +Xerces-tmp.cpp: $INTERFACE_DIR/Xerces.i @non_dom_interface_files @header_files $INTERFACE_DIR/Perl/Xerces-extra.pm + \$(SWIG) $SWIG_ARGS -o Xerces-tmp.cpp -pm Xerces-tmp.pm $INTERFACE_DIR/Xerces.i perl -I$SCRIPTS_DIR $SCRIPTS_DIR/postModule.pl --in=Xerces-tmp.pm --out=Xerces.pm cp -f Xerces.pm blib/lib/XML/Xerces.pm $HANDLER_LIB: -$MAKE +$MAKE_HANDLER + +$TRANSCODER_LIB: +$MAKE_TRANSCODER TERMINUS return $retval; } print STDERR "Welcome Xerces Developer!\n"; + # if we're to use SWIG, we need to know which version is available my $swig = $SWIG || 'swig'; @MACRO = ('macro' => { @@ -306,15 +308,17 @@ # see the hints/ directory for architecture specific stuff! WriteMakefile( 'NAME' => 'XML::Xerces', - 'AUTHOR' => 'The Xerces-P developers: [email protected]', - 'ABSTRACT' => 'Perl Interface for Xerces XML API', + 'AUTHOR' => q[The Xerces-P developers: p-dev 'at' xerces 'dot' apache 'dot' org], + 'ABSTRACT' => 'Perl Interface for Apache Xerces XML API', 'CC' => $CXX, 'CCFLAGS' => $CFLAGS, 'PM' => { 'Xerces.pm' => '$(INST_LIB)/XML/Xerces.pm', + # 'DOM.pm' => '$(INST_LIB)/XML/Xerces/DOM.pm', }, 'INC' => $INCLUDES, - 'MYEXTLIB' => $HANDLER_LIB, + 'MYEXTLIB' => "$HANDLER_LIB $TRANSCODER_LIB", +# 'SKIP' => [qw( pm_to_blib )], 'LIBS' => [$LIBS], 'OBJECT' => $OBJS, 'VERSION' => "$XERCES_PERL_VERSION", Modified: xerces/c/trunk/swig/perl/TODO URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/TODO?view=diff&rev=442160&r1=442159&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/TODO (original) +++ xerces/c/trunk/swig/perl/TODO Mon Sep 11 03:08:07 2006 @@ -23,6 +23,14 @@ Internals: ========== +Sat Sep 9 2006 +* move other code out of XML::Xerces into new modules: + - Handler + - SAX + - SAX2 +* why are is createXMLReader dispatcher not working - mail swig-dev +* why are we wrapping DefaultHandler?? + Tue Aug 22 23:47:05 IST 2006 * need tests for the new DOM additions: %include "dom/DOMLSException.i" @@ -41,7 +49,6 @@ %include "xercesc/dom/DOMXPathNSResolver.hpp" %include "xercesc/dom/DOMXPathResult.hpp" %include "xercesc/dom/DOMUserDataHandler.hpp" -%include "xercesc/dom/DOMConfiguration.hpp" %include "xercesc/dom/DOMStringList.hpp" %include "xercesc/dom/DOMImplementationList.hpp" %include "xercesc/dom/DOMImplementationSource.hpp" @@ -49,7 +56,6 @@ %include "xercesc/dom/DOMError.hpp" Fri May 13 18:21:45 IST 2005 -* change the string typecheck to only do an SvOK() * does Xerces have any methods were a NULL XMLCh* value is needed? - if so we have to enable a %typemap to support it * Xerces has some methods were a NULL pointer value is needed and some @@ -68,7 +74,6 @@ Sun Jun 2 11:38:11 MDT 2002 * use %newobject and %typemape(newfree) for methods like removeNode() -* look into using SWIG_RegisterMapping() instead of inheritance hack ### *** emacs file mode definition *** ### Local Variables: Propchange: xerces/c/trunk/swig/perl/Transcoder/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Sep 11 03:08:07 2006 @@ -0,0 +1,3 @@ +Makefile.old +Makefile +pm_to_blib Copied: xerces/c/trunk/swig/perl/Transcoder/Makefile.PL (from r437653, xerces/c/trunk/swig/perl/Handler/Makefile.PL) URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Transcoder/Makefile.PL?view=diff&rev=442160&p1=xerces/c/trunk/swig/perl/Handler/Makefile.PL&r1=437653&p2=xerces/c/trunk/swig/perl/Transcoder/Makefile.PL&r2=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Handler/Makefile.PL (original) +++ xerces/c/trunk/swig/perl/Transcoder/Makefile.PL Mon Sep 11 03:08:07 2006 @@ -16,7 +16,7 @@ WriteMakefile( LINKTYPE => 'static', - 'NAME' => 'Handler', + 'NAME' => 'Transcoder', 'INC' => $INCLUDES, 'OBJECT' => '$(O_FILES)', # 'CCFLAGS' => $CFLAGS, @@ -30,17 +30,17 @@ sub MY::static { ' -static :: libhandler$(LIB_EXT) +static :: libtranscode$(LIB_EXT) dynamic :: static -libhandler$(LIB_EXT): $(O_FILES) $(MYEXTLIB) - $(AR) cru libhandler$(LIB_EXT) $(O_FILES) - $(RANLIB) libhandler$(LIB_EXT) +libtranscode$(LIB_EXT): $(O_FILES) $(MYEXTLIB) + $(AR) cru libtranscode$(LIB_EXT) $(O_FILES) + $(RANLIB) libtranscode$(LIB_EXT) -libhandler.$(DLEXT): $(LDFROM) $(MYEXTLIB) - $(LD) -o libhandler.$(DLEXT) $(LDDLFLAGS) --whole-archive $(LDFROM) $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST) - $(CHMOD) 755 libhandler.$(DLEXT) +libtranscode.$(DLEXT): $(LDFROM) $(MYEXTLIB) + $(LD) -o libtranscode.$(DLEXT) $(LDDLFLAGS) --whole-archive $(LDFROM) $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST) + $(CHMOD) 755 libtranscode.$(DLEXT) '; Added: xerces/c/trunk/swig/perl/Transcoder/Transcoder.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Transcoder/Transcoder.cpp?view=auto&rev=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Transcoder/Transcoder.cpp (added) +++ xerces/c/trunk/swig/perl/Transcoder/Transcoder.cpp Mon Sep 11 03:08:07 2006 @@ -0,0 +1,154 @@ +/* + * Copyright 2002,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdlib.h> +#include "Transcoder.hpp" + +Transcoder* Transcoder::_instance = NULL; + +Transcoder* +Transcoder::getInstance() { + // fprintf(stderr, "getInstance: finding instance\n"); + if (_instance == NULL) { + // fprintf(stderr, "getInstance: making new transcoder\n"); + _instance = new Transcoder(); + } + return _instance; +} + +Transcoder::~Transcoder() { + // fprintf(stderr, "Deleting transcoder\n"); +} + +Transcoder::Transcoder() { + XMLTransService::Codes failReason; + + // we assume that the Xerces-C transcoding service is already initialized + // via XMLPlatformUtils::Initialize() + UTF8_TRANSCODER = XMLPlatformUtils::fgTransService->makeNewTranscoderFor( + XMLUni::fgUTF8EncodingString, + failReason, + 1024); + + if (UTF8_TRANSCODER == NULL) { + croak("ERROR: Transcoder Could not create UTF-8 transcoder"); + } else if (failReason == XMLTransService::UnsupportedEncoding) { + croak("ERROR: Transcoder: unsupported encoding"); + } else if (failReason == XMLTransService::InternalFailure) { + croak("ERROR: Transcoder: internal failure"); + } else if (failReason == XMLTransService::SupportFilesNotFound) { + croak("ERROR: Transcoder: support files not found"); + } else if (failReason == XMLTransService::Ok) { + // fprintf(stderr, "Created transcoder ok\n"); + } +} + +SV* +Transcoder::XMLString2Perl(const XMLCh* input) { + SV *output; + unsigned int charsEaten = 0; + int length = XMLString::stringLen(input); // string length + // use +1 to make room for the '\0' at the end of the string + // in the pathological case when each character of the string + // is UTF8_MAXLEN bytes long + XMLByte* res = new XMLByte[(length * UTF8_MAXLEN) + 1]; // output string + + unsigned int total_chars = + UTF8_TRANSCODER->transcodeTo((const XMLCh*) input, + (unsigned int) length, + (XMLByte*) res, + (unsigned int) (length*UTF8_MAXLEN), + charsEaten, + XMLTranscoder::UnRep_Throw + ); + res[total_chars] = '\0'; + +#if (0) + if (DEBUG_UTF8_OUT) { + printf("Xerces out length = %d: ",total_chars); + for (int i=0;i<length;i++){ + printf("<0x%.4X>",res[i]); + } + printf("\n"); + } +#endif + + output = sv_newmortal(); + sv_setpv((SV*)output, (char *)res ); + SvUTF8_on((SV*)output); + delete[] res; + return output; +} + +XMLCh* +Transcoder::Perl2XMLString(SV* input){ + XMLCh* output; + + STRLEN length; + char *ptr = (char *)SvPVutf8(input,length); + +#if (0) + if (DEBUG_UTF8_IN) { + printf("Perl in length = %d: ",length); + for (unsigned int i=0;i<length;i++){ + printf("<0x%.4X>",ptr[i]); + } + printf("\n"); + } +#endif + + if (SvUTF8(input)) { + unsigned int charsEaten = 0; + unsigned char* sizes = new unsigned char[length+1]; + output = new XMLCh[length+1]; + unsigned int chars_stored = + UTF8_TRANSCODER->transcodeFrom((const XMLByte*) ptr, + (unsigned int) length, + (XMLCh*) output, + (unsigned int) length, + charsEaten, + (unsigned char*)sizes + ); + delete [] sizes; + +#if (0) + if (DEBUG_UTF8_IN) { + printf("Xerces in length = %d: ",chars_stored); + for (unsigned int i=0;i<chars_stored;i++){ + printf("<0x%.4X>",output[i]); + } + printf("\n"); + } +#endif + + // indicate the end of the string + output[chars_stored] = '\0'; + } else { + output = XMLString::transcode(ptr); + +#if (0) + if (DEBUG_UTF8_IN) { + printf("Xerces: "); + for (int i=0;output[i];i++){ + printf("<0x%.4X>",output[i]); + } + printf("\n"); + } +#endif + + } + return(output); +} Added: xerces/c/trunk/swig/perl/Transcoder/Transcoder.hpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Transcoder/Transcoder.hpp?view=auto&rev=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Transcoder/Transcoder.hpp (added) +++ xerces/c/trunk/swig/perl/Transcoder/Transcoder.hpp Mon Sep 11 03:08:07 2006 @@ -0,0 +1,60 @@ +/* + * Copyright 2002,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TRANSCODER +#define __TRANSCODER + +/* Needed on some windows machines---since MS plays funny + games with the header files under C++ */ +extern "C" { + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Get rid of free and malloc defined by perl */ +#undef free +#undef malloc + +} + + +#include "xercesc/util/TransService.hpp" +#include "xercesc/util/PlatformUtils.hpp" + +XERCES_CPP_NAMESPACE_USE + +class Transcoder { + +private: + static Transcoder* _instance; + +protected: + + Transcoder(); + XMLTranscoder* UTF8_TRANSCODER; + +public: + + static Transcoder* getInstance(); + + ~Transcoder(); + + SV* XMLString2Perl(const XMLCh*); + XMLCh* Perl2XMLString(SV*); +}; + +#endif /* __TRANSCODER */ Added: xerces/c/trunk/swig/perl/Transcoder/XMLExceptionHandler.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Transcoder/XMLExceptionHandler.cpp?view=auto&rev=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Transcoder/XMLExceptionHandler.cpp (added) +++ xerces/c/trunk/swig/perl/Transcoder/XMLExceptionHandler.cpp Mon Sep 11 03:08:07 2006 @@ -0,0 +1,127 @@ +/* + * Copyright 2002,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdlib.h> +#include "XMLExceptionHandler.hpp" + +XMLExceptionHandler* XMLExceptionHandler::_instance = NULL; + +XMLExceptionHandler* +XMLExceptionHandler::getInstance() { + if (_instance == NULL) { + _instance = new XMLExceptionHandler(); + } + return _instance; +} + +XMLExceptionHandler::XMLExceptionHandler() {} + +XMLException* +XMLExceptionHandler::copyXMLException(const XMLException& e) +{ + if(e.getType() == XMLUni::fgArrayIndexOutOfBoundsException_Name) + { + return (XMLException*)((ArrayIndexOutOfBoundsException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgEmptyStackException_Name) + { + return (XMLException*)((EmptyStackException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgIllegalArgumentException_Name) + { + return (XMLException*)((IllegalArgumentException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgInvalidCastException_Name) + { + return (XMLException*)((InvalidCastException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgIOException_Name) + { + return (XMLException*)((IOException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgNoSuchElementException_Name) + { + return (XMLException*)((NoSuchElementException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgNullPointerException_Name) + { + return (XMLException*)((NullPointerException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgNumberFormatException_Name) + { + return (XMLException*)((NumberFormatException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgParseException_Name) + { + return (XMLException*)((ParseException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgXMLPlatformUtilsException_Name) + { + return (XMLException*)((XMLPlatformUtilsException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgRuntimeException_Name) + { + return (XMLException*)((RuntimeException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgSchemaDateTimeException_Name) + { + return (XMLException*)((SchemaDateTimeException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgTranscodingException_Name) + { + return (XMLException*)((TranscodingException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgUnexpectedEOFException_Name) + { + return (XMLException*)((UnexpectedEOFException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgUnsupportedEncodingException_Name) + { + return (XMLException*)((UnsupportedEncodingException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgUTFDataFormatException_Name) + { + return (XMLException*)((UTFDataFormatException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgNetAccessorException_Name) + { + return (XMLException*)((NetAccessorException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgMalformedURLException_Name) + { + return (XMLException*)((MalformedURLException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgXSerializationException_Name) + { + return (XMLException*)((XSerializationException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgInvalidDatatypeFacetException_Name) + { + return (XMLException*)((InvalidDatatypeFacetException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgInvalidDatatypeValueException_Name) + { + return (XMLException*)((InvalidDatatypeValueException*)&e)->duplicate(); + } + else if(e.getType() == XMLUni::fgXPathException_Name) + { + return (XMLException*)((XPathException*)&e)->duplicate(); + } + else + { + croak("Unknown Exception type: %d", e.getType()); + } +} Added: xerces/c/trunk/swig/perl/Transcoder/XMLExceptionHandler.hpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/Transcoder/XMLExceptionHandler.hpp?view=auto&rev=442160 ============================================================================== --- xerces/c/trunk/swig/perl/Transcoder/XMLExceptionHandler.hpp (added) +++ xerces/c/trunk/swig/perl/Transcoder/XMLExceptionHandler.hpp Mon Sep 11 03:08:07 2006 @@ -0,0 +1,72 @@ +/* + * Copyright 2002,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __XMLEXCEPTIONHANDLER +#define __XMLEXCEPTIONHANDLER + +/* Needed on some windows machines---since MS plays funny + games with the header files under C++ */ +extern "C" { + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Get rid of free and malloc defined by perl */ +#undef free +#undef malloc + +} + +#include "xercesc/util/ArrayIndexOutOfBoundsException.hpp" +#include "xercesc/util/EmptyStackException.hpp" +#include "xercesc/util/IllegalArgumentException.hpp" +#include "xercesc/util/InvalidCastException.hpp" +#include "xercesc/util/IOException.hpp" +#include "xercesc/util/NoSuchElementException.hpp" +#include "xercesc/util/NullPointerException.hpp" +#include "xercesc/util/NumberFormatException.hpp" +#include "xercesc/util/ParseException.hpp" +#include "xercesc/util/RuntimeException.hpp" +#include "xercesc/util/SchemaDateTimeException.hpp" +#include "xercesc/util/TranscodingException.hpp" +#include "xercesc/util/UnexpectedEOFException.hpp" +#include "xercesc/util/UnsupportedEncodingException.hpp" +#include "xercesc/util/UTFDataFormatException.hpp" +#include "xercesc/util/XMLNetAccessor.hpp" +#include "xercesc/internal/XSerializationException.hpp" +#include "xercesc/validators/datatype/InvalidDatatypeFacetException.hpp" +#include "xercesc/validators/datatype/InvalidDatatypeValueException.hpp" +#include "xercesc/validators/schema/identity/XPathException.hpp" + +XERCES_CPP_NAMESPACE_USE + +class XMLExceptionHandler { + +protected: + + XMLExceptionHandler(); + static XMLExceptionHandler* _instance; + +public: + + static XMLExceptionHandler* getInstance(); + + ~XMLExceptionHandler(); + XMLException* copyXMLException(const XMLException& e); +}; + +#endif /* __XMLEXCEPTIONHANDLER */ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
