diff --git a/swig/interfaces/Perl/Xerces_IO-extra.pm b/swig/interfaces/Perl/Xerces_IO-extra.pm new file mode 100644 index 0000000000000000000000000000000000000000..cdccd3d9b41f2ce1b5631856aa3c2f8e05c72f6f --- /dev/null +++ b/swig/interfaces/Perl/Xerces_IO-extra.pm @@ -0,0 +1 @@ +package XML::Xerces::IO; diff --git a/swig/interfaces/Perl/Xerces_SAX-extra.pm b/swig/interfaces/Perl/Xerces_SAX-extra.pm new file mode 100644 index 0000000000000000000000000000000000000000..c3ff2d252958a8615f49ec731e49d3afa91a8cba --- /dev/null +++ b/swig/interfaces/Perl/Xerces_SAX-extra.pm @@ -0,0 +1,110 @@ +############# Class : XML::Xerces::PerlDefaultHandler ############## +package XML::Xerces::PerlDefaultHandler; +use vars qw(@ISA); +@ISA = qw(XML::Xerces::ContentHandler + XML::Xerces::DocumentHandler); +sub new { + my $class = shift; + + # support copy constructor syntax + $class = ref($class) if ref($class); + + return bless {}, $class; +} + +sub startElement { + my $self = shift; + $self->start_element(@_); +} +sub endElement { + my $self = shift; + $self->end_element(@_); +} +sub startPrefixMapping { + my $self = shift; + $self->start_prefix_mapping(@_); +} +sub endPrefixMapping { + my $self = shift; + $self->end_prefix_mapping(@_); +} +sub skippedEntity { + my $self = shift; + $self->skipped_entity(@_); +} +sub startDocument { + my $self = shift; + $self->start_document(); +} +sub endDocument { + my $self = shift; + $self->end_document(); +} +sub resetDocument { + my $self = shift; + $self->reset_document(); +} +sub characters {} +sub processingInstruction { + my $self = shift; + $self->processing_instruction(@_); +} +sub setDocumentLocator { + my $self = shift; + $self->set_document_locator(@_); +} +sub ignorableWhitespace { + my $self = shift; + $self->ignorable_whitespace(@_); +} + +# +# support alternate Perl-friendly syntax +# +sub start_element {} +sub end_element {} +sub start_prefix_mapping {} +sub end_prefix_mapping {} +sub skipped_entity {} +sub start_document {} +sub end_document {} +sub reset_document {} +sub processing_instruction {} +sub set_document_locator {} +sub ignorable_whitespace {} + + +############# Class : XML::Xerces::PerlContentHandler ############## +package XML::Xerces::PerlContentHandler; +use vars qw(@ISA); +@ISA = qw(XML::Xerces::PerlDefaultHandler); + +############# Class : XML::Xerces::PerlDocumentHandler ############## +package XML::Xerces::PerlDocumentHandler; +use vars qw(@ISA); +@ISA = qw(XML::Xerces::PerlDefaultHandler); + +package XML::Xerces::Attributes; +sub to_hash { + my $self = shift; + my %hash; + for (my $i=0; $i < $self->getLength(); $i++) { + my $qname = $self->getQName($i); + $hash{$qname}->{localName} = $self->getLocalName($i); + $hash{$qname}->{URI} = $self->getURI($i); + $hash{$qname}->{value} = $self->getValue($i); + $hash{$qname}->{type} = $self->getType($i); + } + return %hash; +} + +package XML::Xerces::AttributeList; +sub to_hash { + my $self = shift; + my %hash; + for (my $i=0;$i<$self->getLength();$i++) { + $hash{$self->getName($i)} = $self->getValue($i) + } + return %hash; +} + diff --git a/swig/interfaces/Perl/ignore.i b/swig/interfaces/Perl/ignore.i new file mode 100644 index 0000000000000000000000000000000000000000..263a700867a9063667808f7ef9be189a8a0f685a --- /dev/null +++ b/swig/interfaces/Perl/ignore.i @@ -0,0 +1,3 @@ +%ignore PerlErrorCallbackHandler::warning(const SAXParseException&); +%ignore PerlErrorCallbackHandler::error(const SAXParseException&); +%ignore PerlErrorCallbackHandler::fatalError(const SAXParseException&); diff --git a/swig/interfaces/Perl/sax-callback.i b/swig/interfaces/Perl/sax-callback.i new file mode 100644 index 0000000000000000000000000000000000000000..c3d0b20755d1b31f7db12d6f998bd9fa709465f8 --- /dev/null +++ b/swig/interfaces/Perl/sax-callback.i @@ -0,0 +1,24 @@ +/* + * 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. + */ + +/* + * Perl/sax-callback.i - SAX/SAX2 specific callback handlers + * + */ + +%import "PerlCallbackHandler.hpp" +%include "PerlSAXCallbackHandler.hpp" + diff --git a/swig/interfaces/Perl/sax-includes.i b/swig/interfaces/Perl/sax-includes.i new file mode 100644 index 0000000000000000000000000000000000000000..4796bf700fb58d7743159b03ae6e07138f5272a7 --- /dev/null +++ b/swig/interfaces/Perl/sax-includes.i @@ -0,0 +1,26 @@ +/* + * 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. + */ + +/* + * Perl/includes.i - all Perl #includes needed for Xerces/SAX.cpp + * + */ + +%{ + +#include "PerlSAXCallbackHandler.hpp" + +%} \ No newline at end of file diff --git a/swig/interfaces/Perl/sax-shadow.i b/swig/interfaces/Perl/sax-shadow.i new file mode 100644 index 0000000000000000000000000000000000000000..b28db0b55e0b128872a8786d4d5afc812b9d32b2 --- /dev/null +++ b/swig/interfaces/Perl/sax-shadow.i @@ -0,0 +1,46 @@ +/* + * 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. + */ + +/* + * Perl/sax-shadow.i - modification of Xerces/SAX.pm code + * + */ + +/* + * Handle Callbacks - until directors work in Perl + */ + +%feature("shadow") XERCES_CPP_NAMESPACE::SAXParser::setDocumentHandler %{ +sub setDocumentHandler { + my ($self,$handler) = @_; + my $callback = XML::Xerces::PerlSAXCallbackHandler->new($handler); + $XML::Xerces::REMEMBER{tied(% {$self})}->{__DOCUMENT_HANDLER} = $callback; + + my @args = ($self,$callback); + return XML::Xercesc::SAXParser_setDocumentHandler(@args); +} +%} + +%feature("shadow") XERCES_CPP_NAMESPACE::SAX2XMLReader::setContentHandler %{ +sub setContentHandler { + my ($self,$handler) = @_; + my $callback = XML::Xerces::PerlSAXCallbackHandler->new($handler); + $XML::Xerces::REMEMBER{tied(% {$self})}->{__CONTENT_HANDLER} = $callback; + + my @args = ($self,$callback); + return XML::Xercesc::SAX2XMLReader_setContentHandler(@args); +} +%} diff --git a/swig/interfaces/Perl/typemaps-io.i b/swig/interfaces/Perl/typemaps-io.i new file mode 100644 index 0000000000000000000000000000000000000000..93a2b36155fd7fb4d18d0c3a2f605c9e2dfb9d71 --- /dev/null +++ b/swig/interfaces/Perl/typemaps-io.i @@ -0,0 +1,19 @@ +// XMLByte arrays are just unisgned char*'s +// force loading of FromCharPtr fragment - needed for DOM +%typemap(out, noblock=1, fragment="SWIG_FromCharPtr") const XMLByte* getRawBuffer() { + %set_output(SWIG_FromCharPtr((char*)$1)); +} + +%typemap(in) (const XMLByte* const srcDocBytes, + unsigned int byteCount) { + if (SvPOK($input)||SvIOK($input)||SvNOK($input)) { + STRLEN len; + XMLByte *xmlbytes = (XMLByte *)SvPV($input, len); + $2 = len; + $1 = new XMLByte[len]; + memcpy($1, xmlbytes, len); + } else { + SWIG_croak("Type error in argument 2 of $symname, Expected perl-string."); + } +} + diff --git a/swig/interfaces/Xerces_IO.i b/swig/interfaces/Xerces_IO.i new file mode 100644 index 0000000000000000000000000000000000000000..2e163a7aff4f3412e7b7a1e2f833892dd6ac6e72 --- /dev/null +++ b/swig/interfaces/Xerces_IO.i @@ -0,0 +1,113 @@ +/* + * 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. + */ + +/* + * All DOM classes and their related SWIG alterations go in this interface file + */ + +/* + * Modulename - this *must* be in double quotes to properly handle + * the namespace + */ +#ifdef SWIGPERL +%module(package="XML::Xerces") "XML::Xerces::IO" +#endif +#ifdef SWIGXML +%module(package="XML::Xerces") "XML::Xerces::IO" +#endif + +/* + * All the module-specific includes + * + */ +%include "io-includes.i" + +/* + * After this we will be under the Xerces namespace + * + */ + +%{ + +XERCES_CPP_NAMESPACE_USE + +%} + +/* + * Import the common macros + */ +%include "Xerces_common.i" + +/* + * Import the module-specific typemaps + */ + +%include "typemaps-io.i" + +/* + * Import the language specific macros + */ + +#ifdef SWIGPERL +%include "Perl/typemaps-io.i" +#endif + +/* + * Import the type information from other modules + */ + +%import "Xerces.i" + +/* + * Define exception handlers + * + */ + +%exception { + try + { + $action + } + CATCH_XML_EXCEPTION +} + + +/* + * Module specific classes + * + */ + +/* + * InputSource + */ + +%include "input-source.i" + + +/* + * OutputTarget + */ + +%include "output-target.i" + +#ifdef SWIGPERL + +/* + * Include extra verbatim Perl code + */ +%pragma(perl5) include="../../interfaces/Perl/Xerces_IO-extra.pm" + +#endif diff --git a/swig/interfaces/Xerces_SAX.i b/swig/interfaces/Xerces_SAX.i new file mode 100644 index 0000000000000000000000000000000000000000..e4809877cf42cc2ea16ae6f17525e48a6328b8a6 --- /dev/null +++ b/swig/interfaces/Xerces_SAX.i @@ -0,0 +1,185 @@ +/* + * 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. + */ + +/* + * All SAX/SAX2 classes and their related SWIG alterations go in this interface file + */ + +/* + * Modulename - this *must* be in double quotes to properly handle + * the namespace + */ +#ifdef SWIGPERL +%module(package="XML::Xerces") "XML::Xerces::SAX" +#endif + +/* + * All the module-specific includes + * + */ +%include "io-includes.i" +%include "sax-includes.i" + +/* + * After this we will be under the Xerces namespace + * + */ + +%{ + +XERCES_CPP_NAMESPACE_USE + +void +makeSAXNotRecognizedException(const SAXNotRecognizedException& e){ + SV *error = ERRSV; + SWIG_MakePtr(error, (void *) new SAXNotRecognizedException(e), SWIGTYPE_p_XERCES_CPP_NAMESPACE__SAXNotRecognizedException, SWIG_SHADOW|0); +} + +void +makeSAXNotSupportedException(const SAXNotSupportedException& e){ + SV *error = ERRSV; + SWIG_MakePtr(error, (void *) new SAXNotSupportedException(e), SWIGTYPE_p_XERCES_CPP_NAMESPACE__SAXNotSupportedException, SWIG_SHADOW|0); +} + +%} + +/* + * Import the common macros + */ +%include "Xerces_common.i" + +/* + * Import the language specific macros + */ + +#ifdef SWIGPERL +%include "Perl/shadow.i" +%include "Perl/sax-shadow.i" +%include "Perl/sax-includes.i" +#endif + +/* + * Import the module-specific typemaps + */ + +%include "typemaps-sax.i" + +/* + * Import the type information from other modules + */ + +%import "Xerces.i" +%import "Xerces_IO.i" + +/* + * Have the scripting language manage the memory for objects created + * in factory methods SWIG will automatically handle objects created + * in constructors but it must be told what methods are factory + * methods + */ +%newobject createXMLReader; + +/* + * Define exception handlers + * + */ + +%exception { + try + { + $action + } + CATCH_XML_EXCEPTION +} + +/* + * SAX1 + */ + +%include "SAX.i" + +/* + * SAX2 + */ + +%include "SAX2.i" + +%include "xercesc/sax/Parser.hpp" +%include "xercesc/parsers/SAXParser.hpp" + +/* + * the SAX2XMLReader methods gets a special exception handler + * 'goto fail' must be called - either explicitly, or via SWIG_croak() + * to ensure that any variable cleanup is done - to avoid memory leaks. + * We make this a macro to be similar to the other exception handlers. + */ +%{ +#define CATCH_SAX_EXCEPTION \ + catch (const XMLException& e) \ + { \ + makeXMLException(e); \ + goto fail; \ + } \ + catch (const SAXNotSupportedException& e) \ + { \ + makeSAXNotSupportedException(e); \ + goto fail; \ + } \ + catch (const SAXNotRecognizedException& e) \ + { \ + makeSAXNotRecognizedException(e); \ + goto fail; \ + } \ + catch (...) \ + { \ + SWIG_croak("Handling Unknown exception"); \ + goto fail; \ + } +%} + +%define SAXEXCEPTION(method) +%exception method { + try { + $action + } + CATCH_SAX_EXCEPTION +} +%enddef + +SAXEXCEPTION(XERCES_CPP_NAMESPACE::SAX2XMLReader::getFeature) +SAXEXCEPTION(XERCES_CPP_NAMESPACE::SAX2XMLReader::setFeature) +SAXEXCEPTION(XERCES_CPP_NAMESPACE::SAX2XMLReader::setProperty) +SAXEXCEPTION(XERCES_CPP_NAMESPACE::SAX2XMLReader::getProperty) +SAXEXCEPTION(XERCES_CPP_NAMESPACE::SAX2XMLReader::parse) + +%include "xercesc/sax2/SAX2XMLReader.hpp" +%include "xercesc/sax2/XMLReaderFactory.hpp" + +#ifdef SWIGPERL + +/* + * Callbacks - this needs to be at the very end + * so that SWIG can wrap the superclass methods properly + */ + +%include "Perl/sax-callback.i" + +/* + * Include extra verbatim Perl code + */ +%pragma(perl5) include="../../interfaces/Perl/Xerces_SAX-extra.pm" + +#endif diff --git a/swig/interfaces/Xerces_common.i b/swig/interfaces/Xerces_common.i new file mode 100644 index 0000000000000000000000000000000000000000..3a3264332a02c47f9d47e17563cc91de145d7c91 --- /dev/null +++ b/swig/interfaces/Xerces_common.i @@ -0,0 +1,70 @@ +/* + * 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. + */ + +/* + * The interface files that are common to all the Xerces top-level modules + */ + +%include "includes.i" + +/* + * Platform and compiler specific items + */ + +%include "platform.i" + +/* + * Import the language specific macros - not namespace dependent + * we place these first so that they can define any master + * macros needed by the language-independent interface files + */ + +#ifdef SWIGPERL +%include "Perl/shadow.i" +%include "Perl/ignore.i" +%include "Perl/errors.i" +%include "Perl/defines.i" +%include "Perl/includes.i" +#endif + +/* + * External objects + */ +%include "transcoder.i" +%include "make-xml-exception.i" + +/* + * Common typemaps + */ +%include "typemaps.i" + +/* + * Include extra verbatim C code in the initialization function + */ +%include "init.i" + +/* + * The general %ignore directives + */ + +%include "ignore.i" + +/* + * Operator support + */ + +%include "operator.i" + diff --git a/swig/interfaces/domxpath-includes.i b/swig/interfaces/domxpath-includes.i new file mode 100644 index 0000000000000000000000000000000000000000..d29c9aba621328e54a8b7866d64e11df1c803d09 --- /dev/null +++ b/swig/interfaces/domxpath-includes.i @@ -0,0 +1,20 @@ +/* + * 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 "xercesc/dom/DOM.hpp" +%} + diff --git a/swig/interfaces/framework/XMLAttr.i b/swig/interfaces/framework/XMLAttr.i new file mode 100644 index 0000000000000000000000000000000000000000..56740f37604d17980dc3505e95f80741c01cc828 --- /dev/null +++ b/swig/interfaces/framework/XMLAttr.i @@ -0,0 +1 @@ +%include "xercesc/framework/XMLAttr.hpp" \ No newline at end of file diff --git a/swig/interfaces/framework/XMLDocumentHandler.i b/swig/interfaces/framework/XMLDocumentHandler.i new file mode 100644 index 0000000000000000000000000000000000000000..5aee3463b003cfd7ef9ed97463150431f8d874ca --- /dev/null +++ b/swig/interfaces/framework/XMLDocumentHandler.i @@ -0,0 +1,26 @@ +%import "xercesc/util/BaseRefVectorOf.hpp"; +%import "xercesc/util/RefVectorOf.hpp"; +namespace XERCES_CPP_NAMESPACE { + %template(BaseXMLAttrVector) BaseRefVectorOf<XMLAttr>; + %template(XMLAttrVector) RefVectorOf<XMLAttr>; +} +%include "framework/XMLAttr.i" +// advanced document handler interface +%include "xercesc/framework/XMLDocumentHandler.hpp" + +// Now, we ignore these methods (without class names)!!! +// Many of the parser implement these methods, and they are not +// useful as part of the parser API - i.e. an application will not +// invoke these methods directly on the parser object +%ignore docCharacters; +%ignore docComment; +%ignore docPI; +%ignore endDocument; +%ignore endElement; +%ignore endEntityReference; +%ignore ignorableWhitespace; +%ignore resetDocument; +%ignore startDocument; +%ignore startElement; +%ignore startEntityReference; +%ignore XMLDecl; diff --git a/swig/interfaces/init.i b/swig/interfaces/init.i new file mode 100644 index 0000000000000000000000000000000000000000..ea0b529356bda43b2acf4b79a49bd3a4e53b07fc --- /dev/null +++ b/swig/interfaces/init.i @@ -0,0 +1,33 @@ +/* + * 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 extra verbatim C code in the initialization function + */ +%init %{ + // we create the global transcoder for UTF-8 to UTF-16 + // must initialize the Xerces-C transcoding service + XMLPlatformUtils::Initialize(); + UTF8_TRANSCODER = Transcoder::getInstance(); + if (! UTF8_TRANSCODER) { + croak("ERROR: XML::Xerces: INIT: Could not create UTF-8 transcoder"); + } + + XML_EXCEPTION_HANDLER = XMLExceptionHandler::getInstance(); + if (! XML_EXCEPTION_HANDLER) { + croak("ERROR: XML::Xerces: INIT: Could not create XMLExceptionHandler"); + } +%} diff --git a/swig/interfaces/io-includes.i b/swig/interfaces/io-includes.i new file mode 100644 index 0000000000000000000000000000000000000000..78a2aed779a071ea6a3ad359ce5e64abc4544c07 --- /dev/null +++ b/swig/interfaces/io-includes.i @@ -0,0 +1,15 @@ +%{ + +#include "xercesc/sax/InputSource.hpp" + +#include "xercesc/framework/LocalFileInputSource.hpp" +#include "xercesc/framework/MemBufInputSource.hpp" +#include "xercesc/framework/StdInInputSource.hpp" +#include "xercesc/framework/URLInputSource.hpp" + +#include "xercesc/framework/XMLFormatter.hpp" +#include "xercesc/framework/MemBufFormatTarget.hpp" +#include "xercesc/framework/LocalFileFormatTarget.hpp" +#include "xercesc/framework/StdOutFormatTarget.hpp" + +%} \ No newline at end of file diff --git a/swig/interfaces/make-xml-exception.i b/swig/interfaces/make-xml-exception.i new file mode 100644 index 0000000000000000000000000000000000000000..fee10c90156840177019c7e95bb348cd50502225 --- /dev/null +++ b/swig/interfaces/make-xml-exception.i @@ -0,0 +1,48 @@ +/* + * 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. + */ + +%{ + +static XMLExceptionHandler* XML_EXCEPTION_HANDLER = NULL; + +void +makeXMLException(const XMLException& e){ + SV *error = ERRSV; + SWIG_MakePtr(error, (void *) XML_EXCEPTION_HANDLER->copyXMLException(e), SWIGTYPE_p_XERCES_CPP_NAMESPACE__XMLException, SWIG_SHADOW|0); +} + +/* + * The generic exception handler + * 'goto fail' must be called - either explicitly, or via SWIG_croak() + * to ensure that any variable cleanup is done - to avoid memory leaks. + * By making these macros, it reduces the code *file* size dramatically + * (but doesn't reduce the compiled file size at all...) + */ + +#define CATCH_XML_EXCEPTION \ + catch (const XMLException& e) \ + { \ + makeXMLException(e); \ + goto fail; \ + } \ + catch (...) \ + { \ + SWIG_croak("Handling Unknown exception"); \ + goto fail; \ + } + +%} + diff --git a/swig/interfaces/operator.i b/swig/interfaces/operator.i new file mode 100644 index 0000000000000000000000000000000000000000..fbb5f26420bb9526fb5e01e3877339dfb19e9ae8 --- /dev/null +++ b/swig/interfaces/operator.i @@ -0,0 +1,10 @@ +// Operators we don't want to wrap +%ignore operator =; +%ignore operator new; +%ignore operator delete; +%ignore operator <<; + +// Operators we do want +%rename(operator_equal_to) operator==; +%rename(operator_not_equal_to) operator!=; + diff --git a/swig/interfaces/output-target.i b/swig/interfaces/output-target.i new file mode 100644 index 0000000000000000000000000000000000000000..715a38d34a9ac238cf478be2ef6389b1d5a336a4 --- /dev/null +++ b/swig/interfaces/output-target.i @@ -0,0 +1,4 @@ +%include "framework/XMLFormatter.i" +%include "framework/StdOutFormatTarget.i" +%include "framework/LocalFileFormatTarget.i" +%include "framework/MemBufFormatTarget.i" \ No newline at end of file diff --git a/swig/interfaces/platform.i b/swig/interfaces/platform.i new file mode 100644 index 0000000000000000000000000000000000000000..f7d87b575efb753f2367d22f89286782e996ee50 --- /dev/null +++ b/swig/interfaces/platform.i @@ -0,0 +1,12 @@ +/*****************************/ +/* */ +/* Platforms and Compilers */ +/* */ +/*****************************/ + +// we seem to need these defs loaded before parsing XercesDefs.hpp +// as of Xerces-3.0 +%import "xercesc/util/Xerces_autoconf_config.hpp" // for XMLSize_t and namespaces + +%import "xercesc/util/XercesDefs.hpp" + diff --git a/swig/interfaces/sax-includes.i b/swig/interfaces/sax-includes.i new file mode 100644 index 0000000000000000000000000000000000000000..8dada9e75ba083fd134698db2e9d42f1290c9965 --- /dev/null +++ b/swig/interfaces/sax-includes.i @@ -0,0 +1,34 @@ +/* + * 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. + */ + +/* + * includes.i - all the #includes needed for Xerces/SAX.cpp + */ + +%{ + +#include "xercesc/sax/Locator.hpp" +#include "xercesc/sax/HandlerBase.hpp" +#include "xercesc/parsers/SAXParser.hpp" + +#include "xercesc/sax2/Attributes.hpp" +#include "xercesc/sax2/ContentHandler.hpp" +#include "xercesc/sax2/LexicalHandler.hpp" +#include "xercesc/sax2/DeclHandler.hpp" +#include "xercesc/sax2/SAX2XMLReader.hpp" +#include "xercesc/sax2/XMLReaderFactory.hpp" + +%} \ No newline at end of file diff --git a/swig/interfaces/transcoder.i b/swig/interfaces/transcoder.i new file mode 100644 index 0000000000000000000000000000000000000000..7340be0fe18888d89b81c10a5efe685e67989be6 --- /dev/null +++ b/swig/interfaces/transcoder.i @@ -0,0 +1,24 @@ +/* + * 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. + */ + +%{ + +// we initialize the static UTF-8 transcoding info +// these are used by the typemaps to convert between +// Xerces internal UTF-16 and the scripting language format +static Transcoder* UTF8_TRANSCODER = NULL; + +%} \ No newline at end of file diff --git a/swig/interfaces/typemaps-domnode.i b/swig/interfaces/typemaps-domnode.i new file mode 100644 index 0000000000000000000000000000000000000000..a428ecd9a33ca8e3d296f719374efba5ed927f1d --- /dev/null +++ b/swig/interfaces/typemaps-domnode.i @@ -0,0 +1,55 @@ +/* + * DOM_Node* + */ + +%typemap(out) XERCES_CPP_NAMESPACE::DOMNode * = SWIGTYPE *DYNAMIC; + +DYNAMIC_CAST(SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, DOMNode_dynamic_cast); + +%{ +static swig_type_info * +DOMNode_dynamic_cast(void **ptr) { + DOMNode **nptr = (DOMNode **) ptr; + if (*nptr == NULL) { + return NULL; + } + short int type = (*nptr)->getNodeType(); + if (type == DOMNode::TEXT_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMText; + } + if (type == DOMNode::PROCESSING_INSTRUCTION_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMProcessingInstruction; + } + if (type == DOMNode::DOCUMENT_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMDocument; + } + if (type == DOMNode::ELEMENT_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMElement; + } + if (type == DOMNode::ENTITY_REFERENCE_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMEntityReference; + } + if (type == DOMNode::CDATA_SECTION_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMCDATASection; + } + if (type == DOMNode::CDATA_SECTION_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMCDATASection; + } + if (type == DOMNode::COMMENT_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMComment; + } + if (type == DOMNode::DOCUMENT_TYPE_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMDocumentType; + } + if (type == DOMNode::ENTITY_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMEntity; + } + if (type == DOMNode::ATTRIBUTE_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMAttr; + } + if (type == DOMNode::NOTATION_NODE) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNotation; + } + return NULL; +} +%} diff --git a/swig/interfaces/typemaps-io.i b/swig/interfaces/typemaps-io.i new file mode 100644 index 0000000000000000000000000000000000000000..5031053e022d11d2a1f3c9f2fe5bf874d6458c9b --- /dev/null +++ b/swig/interfaces/typemaps-io.i @@ -0,0 +1,32 @@ +/* + * 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. + */ + +/* + * MemBufInputSource::MemBufInputSource() + * + */ + +// %typemap(in,numinputs=0) (unsigned int byteCount) "$1 = 0;" + +/* + * These arguments are used to indicate that Xerces-C should + * adopt a resource being passed as an argument. We should + * *always* tell Xerces-C to adopt. + */ +%typemap(in,numinputs=0) const bool adoptFlag "$1 = true;" // for Wrapper4InputSource + // and Wrapper4DOMInputSource +%typemap(in,numinputs=0) const bool adoptBuffer "$1 = true;" // for MemBufInputSource + diff --git a/swig/interfaces/typemaps-sax.i b/swig/interfaces/typemaps-sax.i new file mode 100644 index 0000000000000000000000000000000000000000..eb8098af8c87b95cf7d561197e3c12897fff8ce4 --- /dev/null +++ b/swig/interfaces/typemaps-sax.i @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// SAX2XMLReader::setProperty() should refuse the option to set the +// security manager +%extend XERCES_CPP_NAMESPACE::SAX2XMLReader { +%typemap(check) (const XMLCh* const name, void* value) { + if (XMLString::compareIStringASCII($1, XMLUni::fgXercesSecurityManager) == 0) { + makeSAXNotSupportedException(SAXNotSupportedException("Setting security manager not supported")); + goto fail; + } +} +} + diff --git a/swig/interfaces/typemaps.i b/swig/interfaces/typemaps.i new file mode 100644 index 0000000000000000000000000000000000000000..347aec859405b23f5b99bf55d1af2afb19a7aae8 --- /dev/null +++ b/swig/interfaces/typemaps.i @@ -0,0 +1,24 @@ +/* + * 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. + */ + +#ifdef SWIGPERL +%include "Perl/typemaps.i" +%include "Perl/typemaps-xmlch.i" +#endif + +%include "typemaps-xmlch.i" +%include "typemaps-general.i" + diff --git a/swig/interfaces/unicode.i b/swig/interfaces/unicode.i new file mode 100644 index 0000000000000000000000000000000000000000..44492d8cfed7baf8e8c3c4d432bc05aea71ccc5a --- /dev/null +++ b/swig/interfaces/unicode.i @@ -0,0 +1,11 @@ +// not needed - these defined individual characters +// %include "xercesc/util/XMLUniDefs.hpp" + +// general string constants +%include "xercesc/util/XMLUni.hpp" + +// constants for schema support +%include "xercesc/validators/schema/SchemaSymbols.hpp" + +// constants for PSVI +%include "PSVIWriter/PSVIUni.hpp" \ No newline at end of file diff --git a/swig/interfaces/util/PlatformUtils.i b/swig/interfaces/util/PlatformUtils.i new file mode 100644 index 0000000000000000000000000000000000000000..770dcae05af5e382fd56cf85fe3f83ac3d185647 --- /dev/null +++ b/swig/interfaces/util/PlatformUtils.i @@ -0,0 +1,64 @@ +// both of these static variables cause trouble +// the transcoding service is only useful to C++ anyway. +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgTransService; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgNetAccessor; + +// these are other static variables that are useless to Perl +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgUserPanicHandler; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgDefaultPanicHandler; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgMemoryManager; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgDefaulPanicHandler; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgArrayMemoryManager; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgAtomicMutex; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgFileMgr; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgMutexMgr; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgAtomicOpMgr; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgXMLChBigEndian; + +// these are methods that are useless in Perl +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::curFilePos; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::closeFile; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fileSize; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::openFile; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::openFileToWrite; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::openStdInHandle; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::readFileBuffer; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::writeBufferToFile; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::resetFile; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::getFullPath; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::getCurrentDirectory; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::isAnySlash; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::removeDotSlash; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::removeDotDotSlash; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::isRelative; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::weavePaths; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::getCurrentMillis; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::closeMutex; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::lockMutex; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::makeMutex; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::unlockMutex; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::loadMsgSet; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::compareAndSwap; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::atomicIncrement; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::atomicDecrement; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::recognizeNEL; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::isNELRecognized; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::strictIANAEncoding; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::isStrictIANAEncoding; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::alignPointerForNewBlockAllocation; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::makeFileMgr; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::makeMutexMgr; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::makeAtomicOpMgr; +%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::panic; + +// changing the locale and the NLS home is probably useful +// but changing the panic manager and memory manager is not +%ignore Initialize(const char* const + , const char* const + , PanicHandler* const + , MemoryManager* const); +%ignore Initialize(const char* const + , const char* const + , PanicHandler* const); + +%include "xercesc/util/PlatformUtils.hpp" diff --git a/swig/interfaces/util/XMLEntityResolver.i b/swig/interfaces/util/XMLEntityResolver.i new file mode 100644 index 0000000000000000000000000000000000000000..f9cc718cb58fc0f55fe2d21f423ef80c97a37196 --- /dev/null +++ b/swig/interfaces/util/XMLEntityResolver.i @@ -0,0 +1,4 @@ +%import "xercesc/sax/EntityResolver.hpp" + +%include "xercesc/util/XMLResourceIdentifier.hpp" +%include "xercesc/util/XMLEntityResolver.hpp" \ No newline at end of file diff --git a/swig/interfaces/util/XMLResourceIdentifier.i b/swig/interfaces/util/XMLResourceIdentifier.i new file mode 100644 index 0000000000000000000000000000000000000000..18d69893441a3b8dc467a79c98683c2b2d92d463 --- /dev/null +++ b/swig/interfaces/util/XMLResourceIdentifier.i @@ -0,0 +1 @@ +%include "xercesc/util/XMLResourceIdentifier.hpp" \ No newline at end of file