From 35e22d48b896e988405a4c4dc696a532cddbc046 Mon Sep 17 00:00:00 2001 From: Jason Edward Stewart <jasons@apache.org> Date: Fri, 13 Oct 2006 21:05:26 +0000 Subject: [PATCH] new interface files git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@463827 13f79535-47bb-0310-9956-ffa450edef68 --- swig/interfaces/Perl/Xerces_IO-extra.pm | 1 + swig/interfaces/Perl/Xerces_SAX-extra.pm | 110 +++++++++++ swig/interfaces/Perl/ignore.i | 3 + swig/interfaces/Perl/sax-callback.i | 24 +++ swig/interfaces/Perl/sax-includes.i | 26 +++ swig/interfaces/Perl/sax-shadow.i | 46 +++++ swig/interfaces/Perl/typemaps-io.i | 19 ++ swig/interfaces/Xerces_IO.i | 113 +++++++++++ swig/interfaces/Xerces_SAX.i | 185 ++++++++++++++++++ swig/interfaces/Xerces_common.i | 70 +++++++ swig/interfaces/domxpath-includes.i | 20 ++ swig/interfaces/framework/XMLAttr.i | 1 + .../interfaces/framework/XMLDocumentHandler.i | 26 +++ swig/interfaces/init.i | 33 ++++ swig/interfaces/io-includes.i | 15 ++ swig/interfaces/make-xml-exception.i | 48 +++++ swig/interfaces/operator.i | 10 + swig/interfaces/output-target.i | 4 + swig/interfaces/platform.i | 12 ++ swig/interfaces/sax-includes.i | 34 ++++ swig/interfaces/transcoder.i | 24 +++ swig/interfaces/typemaps-domnode.i | 55 ++++++ swig/interfaces/typemaps-io.i | 32 +++ swig/interfaces/typemaps-sax.i | 27 +++ swig/interfaces/typemaps.i | 24 +++ swig/interfaces/unicode.i | 11 ++ swig/interfaces/util/PlatformUtils.i | 64 ++++++ swig/interfaces/util/XMLEntityResolver.i | 4 + swig/interfaces/util/XMLResourceIdentifier.i | 1 + 29 files changed, 1042 insertions(+) create mode 100644 swig/interfaces/Perl/Xerces_IO-extra.pm create mode 100644 swig/interfaces/Perl/Xerces_SAX-extra.pm create mode 100644 swig/interfaces/Perl/ignore.i create mode 100644 swig/interfaces/Perl/sax-callback.i create mode 100644 swig/interfaces/Perl/sax-includes.i create mode 100644 swig/interfaces/Perl/sax-shadow.i create mode 100644 swig/interfaces/Perl/typemaps-io.i create mode 100644 swig/interfaces/Xerces_IO.i create mode 100644 swig/interfaces/Xerces_SAX.i create mode 100644 swig/interfaces/Xerces_common.i create mode 100644 swig/interfaces/domxpath-includes.i create mode 100644 swig/interfaces/framework/XMLAttr.i create mode 100644 swig/interfaces/framework/XMLDocumentHandler.i create mode 100644 swig/interfaces/init.i create mode 100644 swig/interfaces/io-includes.i create mode 100644 swig/interfaces/make-xml-exception.i create mode 100644 swig/interfaces/operator.i create mode 100644 swig/interfaces/output-target.i create mode 100644 swig/interfaces/platform.i create mode 100644 swig/interfaces/sax-includes.i create mode 100644 swig/interfaces/transcoder.i create mode 100644 swig/interfaces/typemaps-domnode.i create mode 100644 swig/interfaces/typemaps-io.i create mode 100644 swig/interfaces/typemaps-sax.i create mode 100644 swig/interfaces/typemaps.i create mode 100644 swig/interfaces/unicode.i create mode 100644 swig/interfaces/util/PlatformUtils.i create mode 100644 swig/interfaces/util/XMLEntityResolver.i create mode 100644 swig/interfaces/util/XMLResourceIdentifier.i diff --git a/swig/interfaces/Perl/Xerces_IO-extra.pm b/swig/interfaces/Perl/Xerces_IO-extra.pm new file mode 100644 index 000000000..cdccd3d9b --- /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 000000000..c3ff2d252 --- /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 000000000..263a70086 --- /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 000000000..c3d0b2075 --- /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 000000000..4796bf700 --- /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 000000000..b28db0b55 --- /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 000000000..93a2b3615 --- /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 000000000..2e163a7af --- /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 000000000..e4809877c --- /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 000000000..3a3264332 --- /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 000000000..d29c9aba6 --- /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 000000000..56740f376 --- /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 000000000..5aee3463b --- /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 000000000..ea0b52935 --- /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 000000000..78a2aed77 --- /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 000000000..fee10c901 --- /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 000000000..fbb5f2642 --- /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 000000000..715a38d34 --- /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 000000000..f7d87b575 --- /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 000000000..8dada9e75 --- /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 000000000..7340be0fe --- /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 000000000..a428ecd9a --- /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 000000000..5031053e0 --- /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 000000000..eb8098af8 --- /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 000000000..347aec859 --- /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 000000000..44492d8cf --- /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 000000000..770dcae05 --- /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 000000000..f9cc718cb --- /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 000000000..18d698934 --- /dev/null +++ b/swig/interfaces/util/XMLResourceIdentifier.i @@ -0,0 +1 @@ +%include "xercesc/util/XMLResourceIdentifier.hpp" \ No newline at end of file -- GitLab